:root {
  color-scheme: dark;
  --background: #14151b;
  --rail: #101117;
  --surface: #1a1c25;
  --surface-hover: #202330;
  --control: #161821;
  --text: #eef0f7;
  --muted: #a2a8bc;
  --border: #2d3040;
  --divider: #252836;
  --accent: #a9b6ff;
  --accent-strong: #b5bfff;
  --accent-bg: #282e48;
  --success: #82d7b9;
  --danger: #f3a3b1;
  --warning: #ebc78f;
  --radius: 10px;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font: 13px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
a { color: var(--accent); }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .tablewrap:focus-visible, .chart-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(23px, 2.3vw, 29px); font-weight: 650; letter-spacing: -.035em; line-height: 1.3; }
h2 { font-size: 14px; font-weight: 620; }
small, .subtle { font-size: 12px; color: var(--muted); }
button, .action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.35;
}
button:hover:not(:disabled), .action:hover { background: var(--surface-hover); border-color: #42465c; }
.primary, button.primary {
  color: #151a34;
  background: var(--accent-strong);
  border-color: transparent;
  font-weight: 650;
}
button.primary:hover:not(:disabled) { background: #c7ceff; border-color: transparent; }
.small, .action { font-size: 12px; }
.quiet { color: var(--muted); border-color: transparent; background: transparent; }
.icon { width: 16px; height: 16px; flex: none; vertical-align: middle; }
.iconbutton { width: 34px; padding: 0; }
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 50;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  transform: translateY(calc(-100% - 16px));
}
.skip-link:focus { transform: none; }

.app { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 16px 12px;
  background: var(--rail);
  border-right: 1px solid var(--divider);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 3px 7px 22px; font-weight: 620; }
.brand small { display: block; margin-top: 2px; font-size: 11px; font-weight: 400; }
.brandmark {
  display: grid;
  flex: none;
  place-items: center;
  width: 33px;
  height: 33px;
  border: 1px solid #697bb4;
  border-radius: 9px;
  background: #354061;
  color: #e2e9ff;
  font-size: 17px;
}
.navgroup { margin: 12px 10px 6px; color: var(--muted); font-size: 11px; }
.navgroup:not(:first-child) { margin-top: 21px; }
.nav {
  justify-content: flex-start;
  width: 100%;
  gap: 10px;
  min-height: 34px;
  margin: 2px 0;
  padding: 4px 9px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.nav:hover:not(:disabled) { color: var(--text); border-color: transparent; }
.nav.active, .nav.active:hover:not(:disabled) {
  background: var(--accent-bg);
  color: #e2e6ff;
  border-color: #373e5d;
  font-weight: 620;
}
.nav.active .icon { color: var(--accent); }
.shell { min-width: 0; }
.topbar {
  display: flex;
  min-height: 51px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--divider);
}
.breadcrumb, .profile { display: flex; align-items: center; gap: 9px; }
.breadcrumb-root, .breadcrumb-divider, .profile { color: var(--muted); }
.breadcrumb-divider { color: #747a91; }
.profile { font-size: 12px; }
.avatar {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #2c3b3c;
  color: #a9dec9;
  font-size: 11px;
}
.profile .quiet { min-height: 27px; padding: 3px 6px; }
.demo-badge {
  padding: 2px 6px;
  border: 1px solid #424c6f;
  border-radius: 5px;
  color: #c6d0ff;
  background: var(--accent-bg);
  font-size: 11px;
  white-space: nowrap;
}
.mobilemenu, .sidebar-overlay { display: none; }
main { max-width: 1680px; margin: 0 auto; padding: 27px clamp(16px, 3vw, 36px) 44px; }
main:focus { outline: none; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 13px; margin-bottom: 21px; }
.headtools { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.dashfilters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 9px;
  padding: 12px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.dashfilters label { min-width: 105px; flex: 1 1 105px; margin: 0; }
input:not([type="file"]), select {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--control);
  color: var(--text);
}
input::placeholder { color: var(--muted); opacity: .8; }
.dashfilters label > input, .dashfilters label > select, .search-control { margin-top: 4px; }
.date-fields { display: flex; flex: 0 1 auto; flex-wrap: wrap; gap: 8px; }
.date-fields label { min-width: 124px; }
.filter-actions { display: flex; align-items: center; gap: 5px; }
.filter-apply { background: var(--accent-bg); border-color: #3b4364; color: #e1e6ff; }
.filter-apply:hover:not(:disabled) { background: #333c5d; border-color: #4b567d; }
.logistics-filters label { max-width: 220px; }
.logistics-filters .search-field { max-width: none; flex: 2 1 225px; }
.search-control { position: relative; display: block; }
.search-control .icon { position: absolute; left: 9px; top: 9px; color: var(--muted); pointer-events: none; }
.search-control input { padding-left: 32px; }

.admin-status { margin-bottom: 13px; color: var(--success); }
.admin-status:empty { display: none; }
.admin-status.error { color: var(--danger); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }
.section-head p { color: var(--muted); font-size: 11px; }
.statgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 15px; }
.statcard {
  min-width: 0;
  min-height: 103px;
  padding: 13px 14px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.statcard.key-metric { background: #22273b; border-color: #3c4667; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.stat-label .icon { width: 14px; height: 14px; color: var(--accent); }
.statcard .number {
  margin-top: 6px;
  font-size: clamp(17px, 2vw, 25px);
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.statcard .number.empty-value { color: #8790ad; }
.statcard .delta { margin-top: 5px; font-size: 11px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--muted); }

.stack, .chart-grid { display: grid; gap: 12px; }
.cols, .chart-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 12px; }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panelhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 43px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--divider);
}
.panelhead .panel-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }
.panelbody { padding: 14px; }
.chart-panel .panelhead { border-bottom: 0; padding-bottom: 5px; }
.chart-panel .panelbody { padding: 6px 14px 12px; }
.chart-panel .dashchart { width: 100%; height: auto; max-height: 220px; display: block; overflow: visible; }
.chart-scroll { overflow-x: auto; }
.dashchart .chartaxis { font-size: 11px; fill: var(--muted); }
.dashchart .chartval { font-size: 11px; fill: var(--text); }
.dashchart .donutcenter { font-size: 17px; fill: var(--text); font-weight: 650; }
.chart-guide { stroke: var(--border); stroke-dasharray: 3 4; }
.promo-chart { display: grid; grid-template-columns: 126px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 154px; }
.promo-chart .dashchart { max-width: 126px; }
.dashlegend { display: flex; flex-wrap: wrap; align-content: center; gap: 5px 12px; margin-top: 8px; }
.promo-chart .dashlegend { display: grid; margin: 0; max-height: 154px; overflow: auto; }
.dashlegend span { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 11px; color: var(--muted); }
.promo-chart .dashlegend span { display: grid; grid-template-columns: 7px minmax(0, 1fr); gap: 1px 6px; }
.promo-chart .dashlegend small { grid-column: 2; white-space: normal; }
.dashlegend i { width: 7px; height: 7px; border-radius: 3px; flex: none; }
.dashlegend b { min-width: 0; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.dashlegend small { white-space: nowrap; font-size: 11px; }
.chart-empty {
  min-height: 155px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  background: repeating-linear-gradient(to bottom, transparent, transparent 36px, var(--divider) 37px, transparent 38px);
}
.chart-empty span { padding: 4px 8px; border-radius: 5px; background: var(--surface); }
.empty-ring { width: 90px; height: 90px; margin: auto; border: 12px solid var(--border); border-radius: 50%; }

.data-panel .panelbody { padding: 0; }
.tablewrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; white-space: nowrap; }
th, td { padding: 9px 14px; border-bottom: 1px solid var(--divider); }
th { background: #181a23; color: var(--muted); font-size: 11px; font-weight: 550; }
td { color: var(--text); font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-hover); }
td small { display: block; }
.numeric, .money { font-variant-numeric: tabular-nums; }
.numeric { text-align: right; }
.code { font: 12px/1.5 var(--mono); }
.cell-muted { color: var(--muted); }
.address { min-width: 195px; max-width: 420px; white-space: normal; overflow-wrap: anywhere; }
.store-label {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--control);
  color: var(--muted);
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 13px;
  border-top: 1px solid var(--divider);
}
.pagerinfo { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager-buttons { display: flex; align-items: center; gap: 5px; }
.pager-buttons .iconbutton { width: 28px; min-height: 27px; }
.empty {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 27px 12px;
  text-align: center;
  color: var(--muted);
}
.empty > .icon { width: 21px; height: 21px; color: var(--accent); }
.empty strong { color: var(--text); font-weight: 550; }
.empty p { font-size: 12px; }
.empty .action { margin-top: 3px; }
.admin-gap { margin-top: 15px; }

.tag { display: inline-block; padding: 2px 7px; border-radius: 5px; color: var(--muted); background: var(--control); font-size: 11px; white-space: nowrap; }
.tag.green { color: var(--success); background: #21332e; }
.tag.orange { color: var(--warning); background: #3b2f23; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; margin-left: 5px; padding: 0 0 19px 18px; border-left: 1px solid var(--border); }
.timeline li::before { content: ""; position: absolute; top: 7px; left: -4px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline li:last-child { padding-bottom: 2px; border-left-color: transparent; }
.timeline p { margin-top: 4px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin: 0; }
.kv > div { padding: 8px 0; border-bottom: 1px solid var(--divider); }
.kv dt { font-size: 11px; color: var(--muted); }
.kv dd { margin: 4px 0 0; }
.scenario { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 13px; }
.scenario button.active { background: var(--accent-bg); color: var(--text); border-color: #3d496b; }
.inset { padding: 12px; background: var(--control); border-radius: 6px; color: var(--muted); }
.thumbs { display: flex; gap: 5px; }
.thumb { display: block; width: 37px; height: 37px; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.thumb svg { display: block; width: 100%; height: 100%; }

.login-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 22px;
  background: radial-gradient(ellipse at top, #242940 0, var(--background) 60%);
}
.login-main { width: 100%; max-width: 380px; padding: 0; }
.login-brand { padding: 0 2px 18px; }
.login-panel {
  padding: clamp(17px, 5vw, 25px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.login-panel h1 { font-size: 23px; }
.login-form { display: grid; gap: 14px; margin-top: 20px; }
.login-form label { margin: 0; }
.login-form input { display: block; margin-top: 5px; min-height: 38px; }
.login-form button { margin-top: 3px; min-height: 38px; }
.login-error { padding: 8px 10px; border: 1px solid #653f4a; border-radius: 6px; background: #38242c; color: var(--danger); }

@media (max-width: 1120px) {
  .app { grid-template-columns: 178px minmax(0, 1fr); }
  .dashfilters .date-fields { flex: 1 1 260px; }
}
@media (max-width: 960px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .promo-chart { grid-template-columns: 90px minmax(0, 1fr); gap: 8px; }
}
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar { display: none; position: fixed; z-index: 31; top: 0; bottom: 0; left: 0; width: min(240px, 80vw); }
  .sidebar.open { display: block; }
  .sidebar-overlay:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 30; border: 0; border-radius: 0; background: #080910b5; }
  .sidebar-overlay:hover:not(:disabled) { background: #080910b5; }
  .mobilemenu { display: inline-flex; background: transparent; color: var(--muted); }
  .topbar { min-height: 49px; }
  main { padding-top: 19px; }
  .pagehead { margin-bottom: 14px; }
}
@media (max-width: 560px) {
  .breadcrumb-root, .breadcrumb-divider, .profile > span:last-child { display: none; }
  .pagehead { align-items: flex-start; flex-direction: column; }
  .dashfilters { margin-bottom: 16px; gap: 7px; }
  .dashfilters .date-fields { flex-basis: 100%; }
  .logistics-filters label { max-width: none; }
  .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statcard { min-height: 89px; padding: 10px; }
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
  .promo-chart { grid-template-columns: 100px minmax(0, 1fr); }
}
@media print {
  :root {
    color-scheme: light;
    --background: white;
    --surface: white;
    --text: #171921;
    --muted: #414552;
    --border: #c5c7d0;
    --divider: #dce0e7;
  }
  .sidebar, .topbar, .headtools, .dashfilters, .pagination, .skip-link { display: none !important; }
  .app { display: block; }
  main { padding: 0; }
  .panel { break-inside: avoid; }
  th, .statcard.key-metric { background: #edf0f8; }
  .tablewrap { overflow: visible; }
  th, td { white-space: normal; padding: 5px; }
}
