:root {
  --bg: #f3f6fa;
  --card: #ffffff;
  --panel: #ffffff;
  --surface-2: #fbfdff;
  --line: #dfe5ee;
  --line-2: #edf1f6;
  --ink: #111827;
  --ink-2: #607089;
  --ink-3: #8a97ab;
  --slate: #0f172a;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --red: #ef4444;
  --red-bg: #fff1f2;
  --red-border: #fecdd3;
  --green: #10b981;
  --green-ink: #047857;
  --green-bg: #ecfdf5;
  --green-border: #bbf7d0;
  --amber: #f59e0b;
  --amber-ink: #b45309;
  --amber-bg: #fff7ed;
  --amber-border: #fed7aa;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, .04), 0 5px 16px rgba(15, 23, 42, .045);
  --shadow-modal: 0 20px 54px rgba(15, 23, 42, .12);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, .16);
  --state-loading-bg: #f8fbff;
  --state-empty-bg: #ffffff;
  --state-error-bg: #fff1f2;
  --state-error-border: #fecdd3;
  --state-success-bg: #ecfdf5;
  --state-warning-bg: #fff7ed;
  --chart-actual: #2563eb;
  --chart-average: #64748b;
  --chart-yoy: #f59e0b;
  --chart-mom: #0d9488;
  --chart-wow: #7c3aed;
  --chart-positive: #10b981;
  --chart-negative: #fb7185;
  --chart-base: #93c5fd;
  --chart-total: #2563eb;
  --chart-grid: #e5ebf3;
  --chart-axis: #c8d3e2;
  --r-chip: 6px;
  --r-btn: 7px;
  --r-tag: 4px;
  --r-card: 12px;
  --r-nav: 14px;
  --r-modal: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Microsoft YaHei", "Inter", sans-serif;
  --font-num: "SF Pro Text", -apple-system, "Inter", sans-serif;
  --h1-size: 25px;
  --h1-weight: 850;
  --h1-lh: 1.15;
  --h2-size: 16px;
  --h2-weight: 850;
  --h2-lh: 1.25;
  --h3-size: 14px;
  --h3-weight: 800;
  --h3-lh: 1.4;
  --body-size: 13px;
  --body-weight: 500;
  --body-lh: 1.65;
  --small-size: 12px;
  --small-weight: 500;
  --small-lh: 1.6;
  --meta-size: 11px;
  --meta-weight: 700;
  --meta-lh: 1.5;
  --kicker-size: 12px;
  --kicker-weight: 800;
  --kicker-track: 3px;
  --kpi-size: 27px;
  --kpi-weight: 800;
  --hero-size: 64px;
  --hero-weight: 950;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--body-size);
  line-height: var(--body-lh);
  -webkit-font-smoothing: antialiased;
}
button, select, input, textarea { font: inherit; }
button {
  transition: transform .08s ease, box-shadow .12s ease, background-color .12s ease, border-color .12s ease, color .12s ease;
}
button:active { transform: scale(.97); }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
a { color: inherit; }
.hidden { display: none !important; }

.t-kicker {
  font-size: var(--kicker-size);
  font-weight: var(--kicker-weight);
  letter-spacing: var(--kicker-track);
  text-transform: uppercase;
  color: #52637c;
}
.t-h1 { margin: 0; font-size: var(--h1-size); font-weight: var(--h1-weight); line-height: var(--h1-lh); letter-spacing: 0; }
.t-h2 { margin: 0; font-size: var(--h2-size); font-weight: var(--h2-weight); line-height: var(--h2-lh); letter-spacing: 0; }
.t-h3 { font-size: var(--h3-size); font-weight: var(--h3-weight); line-height: var(--h3-lh); }
.t-body { font-size: var(--body-size); font-weight: var(--body-weight); line-height: var(--body-lh); color: var(--ink-2); }
.t-small { font-size: var(--small-size); font-weight: var(--small-weight); line-height: var(--small-lh); color: var(--ink-2); }
.t-meta { font-size: var(--meta-size); font-weight: var(--meta-weight); line-height: var(--meta-lh); color: var(--ink-3); }
.t-num,
.num,
td.num,
th.num {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.t-kpi { font-size: var(--kpi-size); font-weight: var(--kpi-weight); line-height: 1.08; font-feature-settings: "tnum"; white-space: nowrap; }
.t-hero { font-size: var(--hero-size); font-weight: var(--hero-weight); line-height: .95; font-feature-settings: "tnum"; }

.app { min-height: 100vh; }
.page { max-width: 1500px; margin: 0 auto; padding: 26px 30px 56px 200px; }
.app-nav {
  position: fixed; left: 18px; top: 18px; bottom: 18px; width: 150px; z-index: 34;
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: rgba(255,255,255,.96); border: 1px solid var(--line);
  border-radius: var(--r-nav); box-shadow: var(--shadow);
}
.app-nav .nav-brand,
.nav-brand { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-3); font-weight: 900; margin: 2px 4px 8px; }
.app-nav a,
.app-nav button.navlink {
  display: flex; align-items: center; height: 38px; padding: 0 11px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 850;
  border: 1px solid transparent; white-space: nowrap; background: transparent; cursor: pointer;
  width: 100%; text-align: left;
}
.app-nav a:hover,
.app-nav button.navlink:hover { background: #f8fafc; color: var(--ink); }
.app-nav a.active,
.app-nav button.navlink.active { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue); }
.nav-foot { margin-top: auto; font-size: 10.5px; color: var(--ink-3); padding: 6px 5px 2px; line-height: 1.5; }

.hdr { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.kicker { font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: #52637c; font-weight: 800; margin-bottom: 8px; }
h1 { margin: 0; font-size: 25px; line-height: 1.15; font-weight: 850; letter-spacing: 0; }
h1 small { display: block; margin-top: 8px; font-size: 13px; color: var(--ink-2); font-weight: 500; line-height: 1.6; max-width: 640px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.action-group,
.action-cluster {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.action-group {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow-soft);
}
.action-cluster { flex-wrap: wrap; }
.text-clip,
.num-clip {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.text-wrap-safe {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.num-clip {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.identity-chip {
  max-width: min(300px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: anywhere;
}

.btn {
  height: 34px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: var(--r-btn); padding: 0 12px; font-weight: 750; font-size: 13px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  justify-content: center; gap: 7px; white-space: nowrap;
}
.btn:hover { background: #fafcff; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1d56d6; }
.btn.danger { color: var(--red); }
.btn.green { color: var(--green-ink); border-color: var(--green-border); background: var(--green-bg); }
.btn.amber { color: var(--amber-ink); border-color: var(--amber-border); background: var(--amber-bg); }
.btn.toggle.active { background: var(--slate); border-color: var(--slate); color: #fff; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 34px; padding: 0; }
.btn:disabled,
.btn.disabled { opacity: .55; cursor: not-allowed; transform: none; }

.chip {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-chip); background: #fff;
  color: var(--ink-2); font-size: 12px; font-weight: 750; white-space: nowrap;
}
.chip.blue { background: var(--blue-bg); border-color: #c7d8ff; color: var(--blue); }
.chip.red { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.chip.green { background: var(--green-bg); border-color: var(--green-border); color: var(--green-ink); }
.chip.amber { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber-ink); }

.pill {
  display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font-size: 12px; font-weight: 900; color: var(--ink-2); white-space: nowrap;
}
.pill.good, .pill.pos { color: var(--green-ink); background: var(--green-bg); border-color: var(--green-border); }
.pill.watch, .pill.amber { color: var(--amber-ink); background: var(--amber-bg); border-color: var(--amber-border); }
.pill.bad, .pill.red, .pill.neg { color: var(--red); background: var(--red-bg); border-color: var(--red-border); }
.pill.blue { color: var(--blue); background: var(--blue-bg); border-color: var(--blue-border); }
.pill.good::before,
.pill.watch::before,
.pill.bad::before,
.pill.dot::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; flex: 0 0 auto;
}
.pill.good::before { background: var(--green); }
.pill.watch::before { background: var(--amber); }
.pill.bad::before { background: var(--red); }

.tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px;
  border-radius: var(--r-tag); font-size: 11.5px; font-weight: 800;
  border: 1px solid transparent; white-space: nowrap;
  background: var(--red); color: #fff;
}
.tag.neg { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.tag.pos { background: var(--green-bg); color: var(--green-ink); border-color: var(--green-border); }
.tag.neu { background: var(--bg); color: var(--ink-2); border-color: var(--line); }
.tag.red { background: var(--red); color: #fff; letter-spacing: .8px; height: 22px; font-weight: 850; }
.tag.amber { background: var(--amber); color: #fff; letter-spacing: .8px; height: 22px; font-weight: 850; }
.tag.green { background: var(--green); color: #fff; letter-spacing: .8px; height: 22px; font-weight: 850; }
.tag.blue { background: var(--blue); color: #fff; letter-spacing: .8px; height: 22px; font-weight: 850; }
.tag.solid { background: var(--slate); color: #fff; letter-spacing: .8px; height: 22px; font-weight: 850; }
.tag.solid.red { background: var(--red); }
.tag.solid.amber { background: var(--amber); }
.tag.solid.green { background: var(--green); }
.tag.solid.blue { background: var(--blue); }

.seg { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-btn); background: #fff; overflow: hidden; }
.seg button { height: 32px; border: 0; border-right: 1px solid var(--line); background: #fff; color: var(--ink-2); padding: 0 12px; font-size: 11.5px; font-weight: 850; cursor: pointer; white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--slate); color: #fff; }
.range { display: inline-flex; gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: #f7f8fb; padding: 3px; }
.range button { height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); padding: 0 13px; font-size: 12px; font-weight: 850; cursor: pointer; }
.range button.active { background: #fff; color: var(--blue); box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.vmode { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 4px; }
.vmode button { height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 950; padding: 0 12px; cursor: pointer; }
.vmode button.active { background: var(--red); color: #fff; box-shadow: 0 8px 16px rgba(239,68,68,.20); }

.panel,
.sec {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow); padding: 18px 20px; min-width: 0;
}
.panel.compact,
.sec.compact { padding: 14px 16px; }
.panel.flat,
.sec.flat { box-shadow: none; }
.panel.soft,
.sec.soft { background: var(--surface-2); box-shadow: var(--shadow-soft); }
.panel.danger,
.sec.danger { border-color: var(--red-border); background: var(--red-bg); }
.panel.success,
.sec.success { border-color: var(--green-border); background: var(--green-bg); }
.panel.warning,
.sec.warning { border-color: var(--amber-border); background: var(--amber-bg); }
.panel h2,
.sec h2 { margin: 0 0 5px; font-size: 16px; font-weight: 850; line-height: 1.25; }
.panel .sub,
.sec .sub { margin: 0 0 13px; color: var(--ink-2); font-size: 12.5px; line-height: 1.65; }
.row { display: grid; gap: 14px; margin-bottom: 16px; }
.row.r2 { grid-template-columns: 1.35fr 1fr; }
.row.r2eq { grid-template-columns: 1fr 1fr; }
.row.r3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tldr {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--red);
  border-radius: 10px; padding: 16px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
  font-size: 14px; line-height: 1.75;
}
.tldr .label { display: inline-block; background: var(--red); color: #fff; font-size: 11px; padding: 3px 10px; border-radius: 4px; margin-right: 10px; letter-spacing: 1px; font-weight: 750; }
.tldr b { color: var(--red); }

.kpi-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 15px 16px; position: relative; box-shadow: var(--shadow); min-width: 0; overflow: hidden;
}
.kpi-card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 2px 2px 0; background: var(--blue); }
.kpi-card.warn::before { background: var(--amber); }
.kpi-card.danger::before { background: var(--red); }
.kpi-card.good::before { background: var(--green); }
.kpi-card .lbl { font-size: 12px; color: var(--ink-2); font-weight: 650; }
.kpi-card .v { font-size: 26px; font-weight: 800; margin-top: 5px; line-height: 1.08; font-feature-settings: "tnum"; white-space: nowrap; }
.kpi-card .v small { font-size: 13px; color: var(--ink-3); font-weight: 450; margin-left: 3px; }
.kpi-card .sub2 { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.45; }
.wow { display: inline-flex; align-items: center; height: 22px; margin-top: 8px; padding: 0 7px; border-radius: 4px; background: var(--red-bg); color: var(--red); font-size: 11px; font-weight: 750; }
.wow.down { background: var(--green-bg); color: var(--green-ink); }
.wow.neutral { background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }

.rb { position: relative; background: var(--bg); height: 18px; border-radius: 3px; overflow: hidden; border: 1px solid var(--line-2); min-width: 110px; }
.rb i { display: block; height: 100%; background: linear-gradient(90deg, #f5b3b6, var(--red)); }
.rb.ok i { background: linear-gradient(90deg, #bfe3cd, var(--green)); }
.rb.amber i { background: linear-gradient(90deg, #f5d99c, var(--amber)); }
.rb span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; font-size: 11px; font-weight: 750; color: var(--ink); }
.track { height: 8px; background: #eef2f7; border-radius: 5px; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 5px; background: var(--blue); }
.track i.neg { background: var(--red); }
.track i.pos { background: var(--green); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap.flush { border-radius: 0; border-left: 0; border-right: 0; }
.table-wrap.tall { max-height: 560px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { background: #f8fafc; color: var(--ink-2); font-size: 11.5px; font-weight: 850; text-align: left; padding: 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 9px; border-bottom: 1px solid var(--line-2); vertical-align: middle; font-feature-settings: "tnum"; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fbfdff; }
th.num, td.num { text-align: right; }
.shopname { font-weight: 800; color: var(--ink); }
.cat,
.cat-label { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.cat-icon { width: 22px; height: 22px; border-radius: 7px; background: #eff6ff; color: #1d4ed8; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 950; line-height: 1; flex: 0 0 auto; }

.screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 28px;
  background: linear-gradient(#e8edf5 1px, transparent 1px), linear-gradient(90deg, #e8edf5 1px, transparent 1px), var(--bg);
  background-size: 40px 40px;
}
.login { width: min(460px, 100%); background: #fff; border: 1px solid var(--line); border-radius: var(--r-modal); box-shadow: var(--shadow-modal); padding: 32px; }
.login .kicker { margin-bottom: 12px; }
.login h2 { margin: 0 0 10px; font-size: 24px; font-weight: 850; }
.login p { margin: 0 0 22px; color: var(--ink-2); line-height: 1.7; font-size: 13px; }
.google-btn { height: 40px; padding: 0 16px; }
.google-mark { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 4px; background: #fff; color: var(--blue); font-weight: 900; font-size: 13px; }
.auth-note { margin-top: 18px; font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid #fecaca; background: rgba(255,255,255,.86); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.notice b { display: block; color: #dc2626; margin-bottom: 5px; font-size: 13px; }
.notice p { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.6; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-left,
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.empty-state,
.error-panel,
.loading-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.65;
}
.empty-state {
  background: var(--state-empty-bg);
  color: var(--ink-2);
}
.empty-state b,
.error-panel b,
.loading-block b {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 850;
}
.error-panel {
  background: var(--state-error-bg);
  border-color: var(--state-error-border);
  color: var(--red);
}
.error-panel b { color: var(--red); }
.loading-block {
  background: var(--state-loading-bg);
  color: var(--ink-2);
  display: grid;
  gap: 10px;
}
.loading-line {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(100deg, #eef3f8 20%, #f8fbff 38%, #eef3f8 56%);
  background-size: 260% 100%;
  animation: wbShimmer 1.15s ease-in-out infinite;
}
.loading-line.short { width: 42%; }
.loading-line.medium { width: 68%; }
.state-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

@keyframes wbShimmer {
  0% { background-position: 130% 0; }
  100% { background-position: -130% 0; }
}

@media (max-width: 1120px) {
  .row.r2,
  .row.r2eq,
  .row.r3 { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .page { padding: 76px 14px 18px; }
  .app-nav {
    left: 10px; right: 10px; top: 10px; bottom: auto; width: auto;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
    padding: 8px; border-radius: 12px;
  }
  .app-nav .nav-brand,
  .nav-brand,
  .nav-foot { display: none; }
  .app-nav a,
  .app-nav button.navlink { height: 32px; justify-content: center; padding: 0 6px; font-size: 12px; }
  .hdr { flex-direction: column; align-items: flex-start; }
  .actions { justify-content: flex-start; }
  .action-group { max-width: 100%; flex-wrap: wrap; }
  .identity-chip { max-width: 100%; }
}

@media (max-width: 620px) {
  .page { padding: 72px 12px 18px; }
  .app-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-nav a,
  .app-nav button.navlink { font-size: 11.5px; padding: 0 4px; }
  .panel,
  .sec { padding: 14px 12px; border-radius: 10px; }
  .toolbar { padding: 10px; }
  .btn { min-height: 32px; }
  .chip,
  .pill,
  .tag { max-width: 100%; }
}
