:root {
  --navy: #192552;
  --navy-2: #24366f;
  --orange: #ff4b18;
  --orange-soft: #fff1ec;
  --ink: #17203a;
  --muted: #667085;
  --line: #e5e9f0;
  --surface: #ffffff;
  --canvas: #f7f8fb;
  --green: #19744b;
  --green-soft: #eaf8f1;
  --red: #b42318;
  --red-soft: #fff0ef;
  --amber: #9a6700;
  --amber-soft: #fff8db;
  --shadow: 0 18px 50px rgba(25, 37, 82, .08);
  --radius: 18px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(255,75,24,.32); outline-offset: 2px; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 100; padding: 10px 14px; background: var(--navy); color: white; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.topbar { position: fixed; inset: 0 0 auto 0; z-index: 30; height: 76px; display: flex; align-items: center; gap: 26px; padding: 0 28px; background: white; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--navy); text-decoration: none; min-width: 196px; }
.brand-type { display: flex; flex-direction: column; line-height: 1; }
.brand-type strong { font-size: 20px; letter-spacing: .4px; }
.brand-type small { margin-top: 5px; font-weight: 800; font-size: 10px; }
.topbar-title { color: #858da1; font-size: 13px; border-left: 1px solid var(--line); padding-left: 24px; }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--navy); color: white; font-weight: 750; }
.user-chip-copy { display: flex; flex-direction: column; font-size: 13px; }
.user-chip-copy small { color: var(--muted); margin-top: 2px; }
.icon-button { border: 0; background: transparent; color: var(--navy); cursor: pointer; }
.menu-button { display: none; width: 40px; height: 40px; padding: 9px; }
.menu-button span { display: block; height: 2px; margin: 5px 0; background: currentColor; border-radius: 2px; }

.app-shell { min-height: 100vh; padding-top: 76px; }
.sidebar { position: fixed; z-index: 25; top: 76px; bottom: 0; left: 0; width: 228px; display: flex; flex-direction: column; justify-content: space-between; padding: 24px 14px 18px; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.nav-label { margin: 4px 14px 10px; color: #98a0b2; font-size: 10px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; }
.admin-label { margin-top: 28px; }
.nav-link { display: flex; width: 100%; align-items: center; gap: 12px; min-height: 45px; padding: 10px 13px; margin: 2px 0; border: 0; border-radius: 10px; color: #535d76; background: transparent; text-decoration: none; font-size: 14px; cursor: pointer; }
.nav-link:hover { background: #f4f6fa; color: var(--navy); }
.nav-link.active { color: var(--navy); background: #f0f3fa; font-weight: 700; box-shadow: inset 3px 0 var(--orange); }
.nav-icon { display: inline-grid; place-items: center; width: 24px; height: 24px; font-size: 18px; color: var(--navy); }
.nav-button { text-align: left; }
.sidebar-footer { padding-top: 14px; border-top: 1px solid var(--line); }
.nav-scrim { display: none; }
.main-content { min-height: calc(100vh - 76px); margin-left: 228px; padding: 42px clamp(24px, 4vw, 64px) 72px; }

.page-heading { margin-bottom: 28px; }
.page-heading h1 { margin: 7px 0 8px; color: var(--navy); font-size: clamp(29px, 3vw, 40px); line-height: 1.13; letter-spacing: -.8px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.split-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.eyebrow { color: var(--orange); font-size: 10px; font-weight: 850; letter-spacing: 1.8px; }
.eyebrow.light { color: #ff9a7b; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: -.2px; }
.separator { margin: 0 8px; color: #b4bac7; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 42px; padding: 9px 17px; border: 1px solid transparent; border-radius: 10px; font-weight: 720; font-size: 13px; text-decoration: none; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--orange); color: white; box-shadow: 0 8px 20px rgba(255,75,24,.22); }
.button.primary:hover { background: #e94314; }
.button.secondary { background: var(--navy); color: white; }
.button.ghost { background: white; color: var(--navy); border-color: var(--line); }
.button.danger { background: var(--red-soft); color: var(--red); border-color: #ffd4d0; }
.button.small { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.button.wide { width: 100%; min-height: 50px; }
.text-link { color: var(--navy-2); font-weight: 730; text-decoration: none; }
.text-link:hover { color: var(--orange); }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--orange); }

.alert { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; padding: 13px 15px; border: 1px solid; border-radius: 12px; font-size: 13px; }
.alert > span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 850; }
.alert p { flex: 1; margin: 0; }
.alert button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 20px; }
.alert.success { background: var(--green-soft); border-color: #b9e8d1; color: var(--green); }
.alert.success > span { background: var(--green); color: white; }
.alert.error { background: var(--red-soft); border-color: #ffd1cd; color: var(--red); }
.alert.error > span { background: var(--red); color: white; }
.alert.compact { margin: 20px 0 0; }
.notice-card { display: flex; gap: 12px; align-items: flex-start; margin: -6px 0 24px; padding: 14px 16px; background: #eef3ff; border: 1px solid #d9e3ff; border-radius: 12px; color: #354571; font-size: 13px; }
.notice-card span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: white; font-weight: 800; }
.notice-card p { margin: 1px 0 0; line-height: 1.6; }

.section-card { margin-bottom: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 16px rgba(25,37,82,.035); overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0 0 4px; color: var(--navy); font-size: 18px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { min-height: 150px; padding: 24px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 16px rgba(25,37,82,.035); }
.metric-card.featured { position: relative; overflow: hidden; background: var(--navy); color: white; border-color: var(--navy); }
.metric-card.featured::after { content: ""; position: absolute; right: -36px; bottom: -52px; width: 140px; height: 140px; border: 23px solid rgba(255,75,24,.9); border-radius: 50%; }
.metric-label { display: block; margin-bottom: 16px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .6px; }
.metric-card.featured .metric-label, .metric-card.featured small { color: #cdd5ee; }
.metric-card strong { position: relative; z-index: 1; display: block; color: var(--navy); font-size: clamp(24px, 2.4vw, 34px); letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-card.featured strong { color: white; }
.metric-card small { position: relative; z-index: 1; display: block; margin-top: 10px; color: var(--muted); font-size: 11px; }
.period-switch { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.period-switch a { min-width: 68px; padding: 9px 13px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 750; text-align: center; text-decoration: none; }
.period-switch a:hover { color: var(--navy); }
.period-switch a.active { background: var(--navy); color: white; }
.overview-metrics { display: grid; grid-template-columns: 1.5fr repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
.overview-metric { min-height: 144px; padding: 24px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 16px rgba(25,37,82,.035); }
.overview-metric > span { display: block; margin-bottom: 18px; color: var(--muted); font-size: 11px; font-weight: 750; }
.overview-metric strong { display: block; color: var(--navy); font-size: clamp(26px, 2.8vw, 38px); letter-spacing: -1px; }
.overview-metric small { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; }
.overview-metric.featured { position: relative; overflow: hidden; background: var(--navy); border-color: var(--navy); }
.overview-metric.featured::after { content: ""; position: absolute; right: -35px; bottom: -65px; width: 160px; height: 160px; border: 26px solid var(--orange); border-radius: 50%; opacity: .85; }
.overview-metric.featured > span, .overview-metric.featured small { position: relative; z-index: 1; color: #cbd3ea; }
.overview-metric.featured strong { position: relative; z-index: 1; color: white; }
.chart-total { color: var(--navy); font-size: 17px; }
.history-chart-wrap { position: relative; padding: 10px 24px 22px; }
.history-chart { display: block; width: 100%; height: auto; min-height: 220px; overflow: visible; }
.chart-grid-line { stroke: #e9edf4; stroke-width: 1; stroke-dasharray: 4 5; }
.chart-axis-line { stroke: #cbd2df; stroke-width: 1; }
.chart-axis-label { fill: var(--muted); font-size: 10px; }
.chart-area { fill: rgba(255,75,24,.08); }
.chart-line { fill: none; stroke: var(--orange); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-point-target { fill: transparent; stroke: transparent; cursor: crosshair; }
.chart-point { fill: white; stroke: var(--orange); stroke-width: 2; pointer-events: none; transition: r .15s ease, fill .15s ease; }
.chart-point-group.is-active .chart-point, .chart-point-group:hover .chart-point, .chart-point-group:focus-within .chart-point { r: 5px; fill: var(--orange); }
.chart-point-target:focus { outline: none; }
.chart-point-target:focus-visible { stroke: rgba(255,75,24,.3); stroke-width: 3; }
.chart-guide { stroke: rgba(25,37,82,.3); stroke-width: 1; pointer-events: none; }
.chart-pointer-surface { fill: transparent; cursor: crosshair; touch-action: pan-y; }
.chart-tooltip { position: absolute; z-index: 5; width: max-content; min-width: 176px; max-width: min(240px, calc(100% - 20px)); padding: 13px 15px; border: 1px solid #cfd4dc; border-radius: 2px; background: rgba(255,255,255,.98); box-shadow: 0 12px 30px rgba(25,37,82,.14); color: var(--ink); pointer-events: none; transform: translate(-50%, calc(-100% - 13px)); }
.chart-tooltip[data-placement="below"] { transform: translate(-50%, 13px); }
.chart-tooltip::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; border-right: 1px solid #cfd4dc; border-bottom: 1px solid #cfd4dc; background: white; transform: translateX(-50%) rotate(45deg); }
.chart-tooltip[data-placement="below"]::after { top: -6px; bottom: auto; border: 0; border-top: 1px solid #cfd4dc; border-left: 1px solid #cfd4dc; }
.chart-tooltip strong, .chart-tooltip span, .chart-tooltip small { display: block; }
.chart-tooltip strong { margin-bottom: 7px; color: var(--ink); font-size: 14px; font-weight: 750; }
.chart-tooltip span { color: var(--orange); font-size: 15px; }
.chart-tooltip span b { font-weight: 800; }
.chart-tooltip small { margin-top: 6px; color: var(--muted); font-size: 11px; }
.chart-tooltip small b { color: var(--navy); }
.chart-period-switch { display: flex; width: calc(100% - 48px); margin: 14px 24px 0; overflow-x: auto; }
.chart-period-switch a { flex: 1 0 auto; }
.chart-period-help { margin: 8px 25px 0; color: var(--muted); font-size: 10px; }
.ranking-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; align-items: start; }
.ranking-card { min-width: 0; }
.ranking-list { margin: 0; padding: 8px 20px 18px; list-style: none; }
.ranking-list li { display: flex; gap: 11px; padding: 13px 3px; border-bottom: 1px solid #edf0f4; }
.ranking-list li:last-child { border-bottom: 0; }
.rank-number { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 7px; background: #f0f2f7; color: var(--muted); font-size: 10px; font-weight: 800; }
.ranking-list li:nth-child(-n+3) .rank-number { background: var(--orange-soft); color: var(--orange); }
.rank-body { min-width: 0; flex: 1; }
.rank-body > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rank-body strong, .rank-body .text-link { min-width: 0; overflow: hidden; color: var(--navy); font-size: 11px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.rank-body > div:first-child > span { flex: none; color: var(--navy); font-size: 10px; font-weight: 800; }
.rank-progress { display: block; width: 100%; height: 4px; margin: 7px 0; overflow: hidden; border: 0; border-radius: 999px; appearance: none; background: #edf0f5; }
.rank-progress::-webkit-progress-bar { border-radius: 999px; background: #edf0f5; }
.rank-progress::-webkit-progress-value { border-radius: 999px; background: var(--orange); }
.rank-progress::-moz-progress-bar { border-radius: 999px; background: var(--orange); }
.rank-body small { display: block; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { padding: 13px 16px; background: #fafbfc; border-bottom: 1px solid var(--line); color: #7a8397; font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.data-table td { padding: 15px 16px; border-bottom: 1px solid #edf0f4; vertical-align: middle; line-height: 1.45; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcff; }
.data-table .numeric { text-align: right; white-space: nowrap; }
.cell-sub { display: block; margin-top: 4px; color: var(--muted); font-size: 10.5px; font-weight: 400; max-width: 280px; }
.currency-tag { display: inline-block; margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 500; }
.date-value { white-space: nowrap; }
.empty-state { padding: 70px 24px; text-align: center; color: var(--muted); }
.empty-state .empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; background: #f1f3f8; color: var(--navy); font-size: 24px; }
.empty-state h3, .empty-state h1 { margin: 0 0 8px; color: var(--navy); }
.empty-state p { margin: 0 0 20px; }
.compact-empty { padding: 32px; }
.page-error { padding-top: 14vh; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; padding: 18px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination > :last-child { justify-self: end; }

.search-bar { display: flex; gap: 10px; margin-bottom: 22px; }
.search-input { position: relative; flex: 1; max-width: 620px; }
.search-input span { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 21px; }
.search-input input { width: 100%; height: 46px; padding: 0 16px 0 44px; border: 1px solid #dfe3eb; border-radius: 11px; background: white; }
.search-input input:focus { border-color: var(--orange); outline: 3px solid var(--orange-soft); }
.customer-avatar { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #eef1f8; color: var(--navy); font-weight: 850; }
.customer-avatar.large { width: 68px; height: 68px; border-radius: 18px; background: var(--navy); color: white; font-size: 25px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #32a06c; box-shadow: 0 0 0 4px #eaf8f1; }
.status-dot.warn { background: #e4a11b; box-shadow: 0 0 0 4px var(--amber-soft); }
.customer-table { min-width: 1240px; }
.customer-table th:first-child, .customer-table td:first-child { padding-left: 24px; }
.customer-table th:last-child, .customer-table td:last-child { padding-right: 24px; }
.customer-name-cell { min-width: 220px; }
.customer-name-link { color: var(--navy); font-weight: 750; text-decoration: none; }
.customer-name-link:hover, .customer-code-link:hover { color: var(--orange); }
.customer-code-link { color: var(--navy-2); font-weight: 750; text-decoration: none; }
.amount-stack { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.amount-stack > span { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
.amount-stack strong { color: var(--navy); font-size: 12px; }
.amount-stack small { min-width: 38px; color: var(--muted); font-size: 9px; text-align: left; }
.row-action { white-space: nowrap; }
.sort-link { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.sort-link span { color: #a5adbc; font-size: 11px; }
.sort-link:hover, .sort-link.active, .sort-link.active span { color: var(--orange); }

.filter-panel { margin-bottom: 22px; background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.filter-panel > summary { display: flex; justify-content: space-between; padding: 17px 22px; color: var(--navy); font-weight: 750; cursor: pointer; }
.filter-panel > summary small { color: var(--muted); font-weight: 400; }
.filter-grid { display: grid; grid-template-columns: repeat(5, minmax(130px,1fr)); gap: 15px; padding: 20px 22px 22px; border-top: 1px solid var(--line); }
label { color: #4d5770; font-size: 12px; font-weight: 700; }
input, select { width: 100%; min-height: 42px; margin-top: 7px; padding: 9px 11px; border: 1px solid #dce1ea; border-radius: 9px; background: white; color: var(--ink); }
input:focus, select:focus { border-color: var(--orange); outline: 3px solid var(--orange-soft); }
.field-help { display: block; min-height: 14px; margin-top: 5px; color: var(--muted); font-size: 9px; font-weight: 500; }
.field-help.error { color: var(--red); }
.customer-picker input[aria-invalid="true"] { border-color: var(--red); }
.filter-actions { display: flex; gap: 8px; align-items: end; }
.result-count { flex: none; padding: 8px 13px; border-radius: 999px; background: var(--orange-soft); color: var(--orange); font-size: 12px; font-weight: 800; }

.customer-hero { display: flex; justify-content: space-between; gap: 30px; margin-bottom: 24px; padding: 28px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 16px rgba(25,37,82,.035); }
.customer-identity { display: flex; align-items: center; gap: 20px; }
.customer-identity h1 { margin: 5px 0 6px; color: var(--navy); font-size: clamp(25px, 3vw, 36px); }
.customer-identity p { margin: 0; color: var(--muted); font-size: 12px; }
.status-stack { display: flex; align-items: flex-start; gap: 7px; }
.badge-row { display: flex; gap: 6px; margin-top: 7px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.badge.success { background: var(--green-soft); color: var(--green); }
.badge.warning { background: var(--amber-soft); color: var(--amber); }
.badge.danger { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: #eff1f5; color: #5e687e; }
.detail-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; }
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; padding: 8px 24px 24px; margin: 0; }
.info-grid.three { grid-template-columns: repeat(3,1fr); padding: 0; }
.info-grid > div { padding: 16px 12px 12px 0; border-bottom: 1px solid #edf0f4; }
.info-grid dt { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.info-grid dd { margin: 0; color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.sales-summary { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; padding: 20px 24px 26px; }
.sales-summary > div { padding: 15px; border-radius: 12px; background: #f7f8fb; }
.sales-summary span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.sales-summary strong { color: var(--navy); font-size: 19px; }
.sales-summary strong.date-metric { font-size: 15px; letter-spacing: -.3px; }
.sales-summary strong small { color: var(--muted); font-size: 10px; font-weight: 600; }
.customer-sales-analysis { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr); gap: 24px; align-items: start; }
.customer-product-ranking .ranking-list { padding-bottom: 12px; }
.detail-expander > summary { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; cursor: pointer; list-style: none; }
.detail-expander > summary::-webkit-details-marker { display: none; }
.detail-expander > summary span:first-child { display: flex; flex-direction: column; gap: 4px; color: var(--navy); }
.detail-expander > summary small { color: var(--muted); font-weight: 400; }
.expand-icon { font-size: 27px; color: var(--orange); transition: transform .2s; }
.detail-expander[open] .expand-icon { transform: rotate(45deg); }
.expanded-content { padding: 6px 24px 28px; border-top: 1px solid var(--line); }
.expanded-content section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.expanded-content section:last-child { border-bottom: 0; }
.expanded-content h3 { margin: 0 0 16px; color: var(--navy); font-size: 15px; }
.profile-copy { color: #4f596f; font-size: 13px; line-height: 1.9; white-space: pre-line; }
.mini-card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mini-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.mini-card strong { color: var(--navy); }
.mini-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.simple-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.simple-table > div { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; padding: 12px 15px; border-bottom: 1px solid var(--line); font-size: 12px; }
.simple-table > div:last-child { border-bottom: 0; }
.simple-table strong { color: var(--ink); }
.simple-table span { color: var(--navy); font-weight: 750; }
.simple-table small { grid-column: 1/-1; color: var(--muted); }
.narrow-card { max-width: 620px; padding: 24px; }
.stack-form { display: grid; gap: 17px; }

.admin-grid { display: grid; grid-template-columns: minmax(280px, .62fr) minmax(520px, 1.38fr); gap: 24px; align-items: start; }
.create-panel { padding-bottom: 24px; }
.create-panel form { padding: 0 24px; }
.account-list { padding: 5px 18px 18px; }
.account-item { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 94px; padding: 16px 5px; border-bottom: 1px solid var(--line); }
.account-item:last-child { border-bottom: 0; }
.account-item.disabled { opacity: .62; }
.account-main { display: flex; align-items: center; gap: 13px; }
.large-avatar { width: 46px; height: 46px; }
.account-main h3 { margin: 0 0 4px; color: var(--navy); font-size: 14px; }
.account-main p { margin: 0; color: var(--muted); font-size: 11px; }
.you-label { margin-left: 5px; color: var(--orange); font-size: 9px; }
.account-actions { position: relative; }
.account-actions > summary { list-style: none; }
.account-actions > summary::-webkit-details-marker { display: none; }
.action-popover { position: absolute; z-index: 6; top: 42px; right: 0; width: 300px; padding: 17px; background: white; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.action-popover form { margin-bottom: 15px; }
.action-popover .action-row form { margin: 0; }
.action-popover label { display: block; margin-bottom: 9px; }
.action-row { display: flex; justify-content: space-between; gap: 8px; padding-top: 13px; border-top: 1px solid var(--line); }

.dataset-stack { display: grid; gap: 24px; }
.dataset-section { overflow: visible; }
.dataset-kicker { color: var(--orange); font-family: ui-monospace, monospace; font-size: 10px; }
.upload-form { display: flex; align-items: center; gap: 8px; }
.file-picker { position: relative; display: inline-flex; align-items: center; min-height: 34px; padding: 6px 11px; overflow: hidden; border: 1px dashed #cfd6e3; border-radius: 8px; color: var(--navy); cursor: pointer; }
.file-picker input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.version-list { padding: 6px 20px 20px; }
.version-item { display: grid; grid-template-columns: minmax(260px,1fr) minmax(220px,.8fr) auto; align-items: center; gap: 22px; padding: 18px 4px; border-bottom: 1px solid var(--line); }
.version-item:last-child { border-bottom: 0; }
.version-status { display: flex; gap: 13px; align-items: flex-start; }
.status-icon { display: grid; flex: none; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #eff1f5; color: var(--muted); font-weight: 850; }
.version-item.active .status-icon { background: var(--green-soft); color: var(--green); }
.version-item.invalid .status-icon { background: var(--red-soft); color: var(--red); }
.version-status h3 { margin: 7px 0 3px; color: var(--navy); font-size: 13px; }
.version-status p, .version-validation p { margin: 4px 0; color: var(--muted); font-size: 10px; }
.version-status code { color: #7a8397; font-size: 9px; }
.version-validation .validation-warning { color: var(--amber); }
.version-validation .validation-error { color: var(--red); }
.version-actions { display: flex; gap: 7px; justify-content: flex-end; }

.login-page { background: white; }
.login-layout { display: grid; grid-template-columns: minmax(460px, 1.08fr) minmax(420px, .92fr); min-height: 100vh; }
.login-brand-panel { position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 50px clamp(42px, 6vw, 90px); background: var(--navy); color: white; }
.login-brand-panel::after { content: ""; position: absolute; right: -160px; bottom: -190px; width: 520px; height: 520px; border: 80px solid var(--orange); border-radius: 50%; opacity: .82; }
.login-brand-panel::before { content: ""; position: absolute; right: 190px; bottom: 80px; width: 190px; height: 190px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 15px; }
.login-brand > div { display: flex; flex-direction: column; }
.login-brand strong { font-size: 30px; letter-spacing: 1px; }
.login-brand span { margin-top: 3px; font-size: 14px; font-weight: 800; }
.brand-message { position: relative; z-index: 1; max-width: 650px; }
.brand-message h1 { margin: 15px 0 24px; font-size: clamp(36px, 3.7vw, 52px); line-height: 1.14; letter-spacing: -1.5px; }
.brand-message p { max-width: 580px; color: #cbd2e8; font-size: 15px; line-height: 1.9; }
.brand-footnote { position: relative; z-index: 1; color: #9aa6c9; font-size: 11px; }
.login-form-panel { display: grid; place-items: center; padding: 40px; background: white; }
.login-card { width: min(100%, 430px); }
.login-card h2 { margin: 9px 0 8px; color: var(--navy); font-size: 36px; letter-spacing: -1px; }
.login-card > p { margin: 0 0 30px; font-size: 13px; }
.login-card .login-help { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: 11px; }
.login-card input { min-height: 49px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .ranking-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid { grid-template-columns: repeat(3,1fr); }
  .admin-grid { grid-template-columns: 1fr; }
  .create-panel form { display: grid; grid-template-columns: repeat(2,1fr); }
  .create-panel form .button { align-self: end; }
}

@media (max-width: 800px) {
  .topbar { height: 64px; padding: 0 14px; gap: 10px; }
  .app-shell { padding-top: 64px; }
  .menu-button { display: block; }
  .brand { min-width: 0; }
  .brand-type strong { font-size: 16px; }
  .brand-type small { font-size: 8px; }
  .topbar-title, .user-chip-copy { display: none; }
  .avatar { width: 34px; height: 34px; }
  .sidebar { top: 64px; width: min(82vw, 290px); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 15px 0 35px rgba(25,37,82,.12); }
  body.menu-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; z-index: 20; inset: 64px 0 0; background: rgba(16,24,50,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.menu-open .nav-scrim { display: block; opacity: 1; pointer-events: auto; }
  .main-content { min-height: calc(100vh - 64px); margin-left: 0; padding: 26px 15px 50px; }
  .page-heading { margin-bottom: 21px; }
  .page-heading h1 { font-size: 29px; }
  .split-heading { align-items: flex-start; }
  .split-heading .button { display: none; }
  .period-switch { flex: none; }
  .overview-metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .overview-metric.featured { grid-column: 1/-1; }
  .ranking-grid { grid-template-columns: 1fr; }
  .history-chart-wrap { padding: 4px 12px 14px; overflow-x: hidden; }
  .history-chart { min-height: 180px; }
  .chart-period-switch { display: grid; width: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 12px 12px 4px; overflow: visible; }
  .chart-period-switch a { min-width: 0; padding-inline: 6px; }
  .chart-period-help { margin: 8px 14px 2px; line-height: 1.5; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .metric-card { min-height: 126px; padding: 18px; }
  .metric-card strong { font-size: 22px; }
  .section-heading { padding: 18px; align-items: flex-start; }
  .section-heading .text-link { font-size: 11px; text-align: right; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table tbody { display: grid; gap: 10px; padding: 12px; background: #f7f8fb; }
  .data-table tr { padding: 10px 14px; background: white; border: 1px solid var(--line); border-radius: 12px; }
  .data-table td { display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 9px; padding: 8px 0; border-bottom: 1px solid #edf0f4; text-align: left !important; overflow-wrap: anywhere; }
  .data-table td:last-child { border-bottom: 0; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: 10px; font-weight: 650; }
  .data-table td > * { min-width: 0; }
  .cell-sub { max-width: none; }
  .pagination { padding: 14px; gap: 8px; }
  .customer-table { min-width: 0; }
  .customer-table th:first-child, .customer-table td:first-child { padding-left: 0; }
  .customer-table th:last-child, .customer-table td:last-child { padding-right: 0; }
  .customer-table .amount-stack { align-items: flex-start; }
  .customer-table .amount-stack > span { justify-content: flex-start; }
  .search-bar { display: grid; grid-template-columns: 1fr auto; }
  .search-input { grid-column: 1/-1; max-width: none; }
  .filter-panel > summary small { display: none; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0,1fr)); padding: 16px; }
  .filter-actions { grid-column: 1/-1; }
  .customer-hero { align-items: flex-start; padding: 20px; }
  .customer-identity { align-items: flex-start; }
  .customer-avatar.large { width: 54px; height: 54px; border-radius: 14px; }
  .status-stack { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; gap: 0; }
  .customer-sales-analysis { grid-template-columns: 1fr; gap: 0; }
  .info-grid.three { grid-template-columns: repeat(2,1fr); }
  .expanded-content { padding-inline: 18px; }
  .upload-form { width: 100%; margin-top: 14px; }
  .dataset-section > .section-heading { display: block; }
  .version-item { grid-template-columns: 1fr; gap: 12px; padding: 18px 0; }
  .version-actions { justify-content: flex-start; }
  .action-popover { position: fixed; z-index: 50; top: auto; right: 14px; bottom: 14px; left: 14px; width: auto; }
  .login-layout { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 260px; padding: 30px 24px; }
  .login-brand-panel::after { width: 300px; height: 300px; right: -150px; bottom: -170px; border-width: 48px; }
  .login-brand { align-items: center; }
  .login-brand strong { font-size: 22px; }
  .brand-message h1 { margin: 18px 0 0; font-size: 30px; letter-spacing: -1px; }
  .brand-message p, .brand-footnote { display: none; }
  .login-form-panel { place-items: start center; padding: 38px 22px; }
  .login-card h2 { font-size: 30px; }
}

@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 116px; padding: 15px; }
  .metric-card strong { font-size: 19px; }
  .metric-card small { font-size: 9px; }
  .filter-grid, .create-panel form { grid-template-columns: 1fr; }
  .filter-actions { grid-column: auto; }
  .search-bar { grid-template-columns: 1fr 1fr; }
  .search-bar .button { width: 100%; }
  .overview-heading { display: block; }
  .period-switch { width: 100%; margin-top: 18px; }
  .period-switch a { flex: 1; min-width: 0; }
  .overview-metrics { grid-template-columns: 1fr 1fr; }
  .overview-metric { min-height: 122px; padding: 17px; }
  .overview-metric strong { font-size: 22px; }
  .overview-metric.featured { grid-column: 1/-1; }
  .chart-total { font-size: 13px; }
  .customer-hero { display: block; }
  .customer-identity { display: block; }
  .customer-identity .customer-avatar { margin-bottom: 15px; }
  .status-stack { flex-direction: row; margin-top: 16px; }
  .info-grid, .info-grid.three { grid-template-columns: 1fr; }
  .sales-summary { grid-template-columns: 1fr 1fr; padding: 15px; }
  .mini-card-grid { grid-template-columns: 1fr; }
  .simple-table > div { grid-template-columns: 1fr; }
  .simple-table small { grid-column: auto; }
  .account-item { align-items: flex-start; }
  .account-main .avatar { display: none; }
  .upload-form { align-items: stretch; display: grid; grid-template-columns: 1fr; }
  .file-picker { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
