:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-subtle: #f7f9fb;
  --ink: #15202b;
  --muted: #657384;
  --soft: #91a0ae;
  --line: #dfe5eb;
  --line-strong: #cfd8e1;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --teal: #078c7a;
  --teal-soft: #e5f5f1;
  --amber: #b7791f;
  --amber-soft: #fff4dd;
  --red: #c2413b;
  --red-soft: #fdebea;
  --sidebar: #111b24;
  --shadow: 0 10px 30px rgba(18, 32, 45, 0.06);
}

body.dark {
  color-scheme: dark;
  --bg: #10161c;
  --surface: #182028;
  --surface-raised: #1b252e;
  --surface-subtle: #202b35;
  --ink: #f2f5f7;
  --muted: #a9b5c0;
  --soft: #7f8c98;
  --line: #2e3a45;
  --line-strong: #3b4854;
  --blue-soft: rgba(37, 99, 235, 0.18);
  --teal-soft: rgba(7, 140, 122, 0.18);
  --amber-soft: rgba(183, 121, 31, 0.2);
  --red-soft: rgba(194, 65, 59, 0.18);
  --sidebar: #0b1117;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}
button, select, input { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 238px;
  padding: 20px 14px 16px;
  overflow-y: auto;
  background: var(--sidebar);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: #0ea58f; color: #fff; font-size: 16px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 3px; color: #93a4b3; font-size: 12px; }
nav { padding-top: 7px; }
.nav-group p { margin: 17px 10px 7px; color: #758797; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; margin: 2px 0; border-radius: 7px; color: #acbac6; text-decoration: none; transition: .16s ease; }
nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
nav a.active { color: #fff; background: #263746; }
.nav-icon { display: grid; place-items: center; width: 22px; height: 22px; color: #7890a2; font-size: 10px; font-weight: 800; }
nav a.active .nav-icon { color: #53d5c1; }
.sidebar-foot { display: flex; align-items: center; gap: 10px; margin: 24px 8px 0; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { color: #dbe4ea; font-size: 11px; }
.sidebar-foot small { margin-top: 3px; color: #748695; font-size: 10px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #25c79f; box-shadow: 0 0 0 4px rgba(37,199,159,.12); }
.mobile-menu { display: none; }

.app-main { margin-left: 238px; min-height: 100vh; padding: 24px 28px 44px; }
.page-container { width: min(1540px, 100%); margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, h4, p { letter-spacing: 0; }
h1 { margin: 0; font-size: 27px; line-height: 1.18; }
h2 { margin: 0; font-size: 22px; line-height: 1.3; }
h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.page-subtitle { display: block; margin-top: 7px; color: var(--muted); line-height: 1.5; }
.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.select, select, .button { min-height: 40px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
select { min-width: 150px; padding: 0 34px 0 12px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; font-weight: 700; text-decoration: none; transition: .16s ease; }
.button:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.button.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.button.icon { width: 40px; padding: 0; font-size: 17px; }
.notification-button { position: relative; }
.notification-button.has-unread { border-color: var(--amber); }
.notification-badge { display: grid; place-items: center; position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px; border: 2px solid var(--bg); border-radius: 10px; background: var(--red); color: #fff; font-size: 10px; font-weight: 800; }
.shipment-panel { position: fixed; z-index: 80; top: 78px; right: 28px; width: min(390px, calc(100vw - 28px)); max-height: calc(100vh - 100px); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); box-shadow: 0 22px 60px rgba(16, 27, 36, .22); }
.shipment-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px; border-bottom: 1px solid var(--line); }
.shipment-panel-head strong, .shipment-panel-head small { display: block; }
.shipment-panel-head small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.shipment-list { max-height: calc(100vh - 174px); overflow-y: auto; }
.shipment-item { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.shipment-item:hover { background: var(--surface-subtle); }
.shipment-item:last-child { border-bottom: 0; }
.shipment-item-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shipment-item-head time { color: var(--teal); font-size: 11px; font-weight: 700; }
.shipment-item p { margin: 7px 0 5px; font-weight: 700; line-height: 1.45; }
.shipment-item small { color: var(--muted); line-height: 1.5; }
.shipment-empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.shipment-summary .kpi-grid { margin-bottom: 16px; }
.shipment-filters { display: grid; grid-template-columns: minmax(260px, 1fr) 180px 180px; gap: 10px; margin-bottom: 14px; }
.shipment-filters input { min-height: 40px; width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
.shipment-table td { vertical-align: middle; }
.shipment-table td:nth-child(6) { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.marketing-shipment-callout { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; margin: -2px 0 16px; border: 1px solid #cfe3df; border-left: 4px solid var(--teal); border-radius: 7px; background: var(--teal-soft); }
.marketing-shipment-callout span, .marketing-shipment-callout strong { display: block; }
.marketing-shipment-callout > div > span { margin-bottom: 5px; color: var(--teal); font-size: 11px; font-weight: 800; }
.marketing-shipment-callout strong { line-height: 1.45; }

.executive-banner { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(280px,.5fr); gap: 20px; padding: 24px; margin-bottom: 16px; border: 1px solid #cfe3df; border-radius: 8px; background: linear-gradient(110deg, #eef8f6 0%, #f7fafc 72%); }
body.dark .executive-banner { border-color: #29443f; background: #172520; }
.executive-banner h2 { max-width: 880px; font-size: 28px; }
.executive-banner p { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.decision-box { align-self: stretch; padding-left: 20px; border-left: 1px solid #cfe3df; }
.decision-box span { color: var(--muted); font-size: 12px; }
.decision-box strong { display: block; margin-top: 9px; font-size: 20px; line-height: 1.4; }
.decision-box small { display: block; margin-top: 8px; color: var(--teal); }

.kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card, .panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.kpi-card { position: relative; min-height: 130px; padding: 17px 18px; overflow: hidden; }
.kpi-card::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--accent,var(--blue)); opacity: .85; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { display: block; margin: 13px 0 8px; font-size: 27px; line-height: 1; font-weight: 780; font-variant-numeric: tabular-nums; }
.kpi-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--soft); font-size: 11px; }
.delta { color: var(--teal); font-weight: 700; }
.delta.warn { color: var(--amber); }

.content-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(310px,.45fr); gap: 16px; margin-bottom: 16px; }
.two-col { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-bottom: 16px; }
.panel { min-width: 0; padding: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; background: var(--surface-subtle); color: var(--muted); font-size: 11px; white-space: nowrap; }
.status.good { background: var(--teal-soft); color: var(--teal); }
.status.warn { background: var(--amber-soft); color: var(--amber); }
.status.bad { background: var(--red-soft); color: var(--red); }

.segment-control { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); }
.segment-control button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 700; }
.segment-control button.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(18,32,45,.08); }

.chart { width: 100%; height: 250px; display: block; }
.chart-legend { display: flex; gap: 18px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.chart-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--dot,var(--blue)); }
.insight-list { display: grid; gap: 2px; }
.insight-item { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.insight-item:last-child { border-bottom: 0; }
.insight-rank { color: var(--soft); font-size: 12px; font-weight: 800; }
.insight-item strong, .insight-item small { display: block; }
.insight-item small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.insight-value { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.callout { padding: 15px; border-left: 3px solid var(--teal); background: var(--teal-soft); color: var(--ink); line-height: 1.6; }

.table-toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.creator-toolbar { align-items: center; padding: 12px 0; }
.creator-toolbar > div:first-child { display: grid; gap: 3px; }
.creator-toolbar small { color: var(--muted); }
.integration-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0; margin-bottom: 14px; }
.integration-summary h2 { margin: 4px 0 6px; }
.integration-summary p { color: var(--muted); }
.integration-store-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.integration-store-card { padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.integration-store-head, .integration-store-head > div, .integration-actions { display: flex; align-items: center; gap: 12px; }
.integration-store-head { justify-content: space-between; align-items: flex-start; }
.integration-store-head h3 { margin: 0 0 4px; font-size: 18px; }
.integration-store-head p, .integration-note { color: var(--muted); }
.integration-status-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 20px 0 14px; }
.integration-status-grid div { padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.integration-status-grid span, .integration-status-grid strong { display: block; }
.integration-status-grid span { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.integration-status-grid strong { font-size: 14px; }
.integration-note { min-height: 42px; margin-bottom: 14px; }
@media (max-width: 1000px) { .integration-store-grid { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .integration-summary { align-items: flex-start; flex-direction: column; } .integration-status-grid { grid-template-columns: 1fr; } }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; white-space: nowrap; }
th { background: var(--surface-subtle); color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
tbody tr:hover { background: var(--surface-subtle); }
tbody tr.selected-row { background: var(--teal-soft); }
tbody tr:last-child td { border-bottom: 0; }
.name-cell strong, .name-cell small { display: block; }
.name-cell small { margin-top: 4px; color: var(--soft); }
.empty-state { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 16px; }

.ads-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.product-filter-bar { display: grid; grid-template-columns: minmax(280px, 1.6fr) repeat(3, minmax(150px, .7fr)); gap: 10px; margin: 16px 0; }
.product-filter-bar input { min-height: 40px; width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
.product-filter-bar input:focus, .product-filter-bar select:focus { border-color: var(--blue); outline: 2px solid color-mix(in srgb, var(--blue) 16%, transparent); }
.platform-title { display: flex; align-items: center; gap: 10px; }
.platform-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; background: #111; color: #fff; font-size: 12px; font-weight: 800; }
.platform-mark.shopee { background: #ee4d2d; }
.progress-track { height: 7px; border-radius: 999px; background: var(--surface-subtle); overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--teal); }

.section-cards { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.section-card { padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.section-card span { color: var(--muted); font-size: 12px; }
.section-card h3 { margin-top: 10px; }
.section-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

@media (max-width: 1180px) {
  .kpi-grid, .section-cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; }
  .nav-open .sidebar { transform: translateX(0); }
  .mobile-menu { display: grid; place-items: center; position: fixed; top: 13px; right: 14px; z-index: 40; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
  .app-main { margin-left: 0; padding: 18px 14px 38px; }
  .page-header { padding-right: 52px; flex-direction: column; }
  .toolbar { justify-content: flex-start; }
  .executive-banner { grid-template-columns: 1fr; padding: 20px; }
  .executive-banner h2 { font-size: 23px; }
  .decision-box { padding: 16px 0 0; border-left: 0; border-top: 1px solid #cfe3df; }
  .two-col { grid-template-columns: 1fr; }
  .ads-filter-row { align-items: flex-start; flex-direction: column; }
  .product-filter-bar { grid-template-columns: 1fr; }
  .shipment-filters { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  h1 { font-size: 23px; }
  .kpi-grid, .section-cards { grid-template-columns: 1fr; }
  .kpi-card { min-height: 116px; }
  .panel { padding: 16px; }
  .segment-control { width: 100%; }
  .segment-control button { flex: 1; padding: 0 8px; }
  select { width: 100%; }
  .shipment-panel { top: 64px; right: 14px; width: calc(100vw - 28px); max-height: calc(100vh - 78px); }
}
