:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --head: #b8cdf7;
  --subhead: #dfe8fb;
  --accent: #1769e0;
  --accent-soft: #e8f1ff;
  --danger: #c7352e;
  --warn: #a86600;
  --ok: #137a4d;
  --pink: #f9dada;
  --green: #dff5df;
  --yellow: #fff2c2;
  --purple: #eee2ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef4ff 0, #f4f6fa 220px),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.hidden { display: none !important; }
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-panel {
  width: min(380px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 28px;
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(20, 34, 66, .08);
}
.login-panel h1 { margin: 0 0 24px; font-size: 26px; }
label { display: grid; gap: 8px; color: var(--muted); }
input, select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--text);
  font-size: 14px;
}
.login-panel label { margin-bottom: 16px; }
button {
  height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
button.secondary {
  background: #edf2f7;
  color: var(--text);
}
#loginError { color: var(--danger); min-height: 22px; }

.app {
  min-height: 100vh;
  padding: 18px;
}
.app-shell {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}
.app-shell.sidebar-collapsed {
  grid-template-columns: 68px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  background: #111827;
  color: white;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 16px 40px rgba(17, 24, 39, .16);
}
.sidebar-toggle {
  margin-left: auto;
  width: 30px;
  height: 30px;
  padding: 0;
  background: rgba(255, 255, 255, .1);
}
.sidebar-collapsed .brand-title div,
.sidebar-collapsed .side-link {
  font-size: 0;
}
.sidebar-collapsed .brand-title {
  justify-content: center;
}
.sidebar-collapsed .sidebar-toggle {
  display: grid;
  place-items: center;
  margin: 8px auto 0;
}
.sidebar-collapsed .side-link {
  justify-content: center;
  padding: 0;
}
.sidebar-collapsed .side-link::first-letter {
  font-size: 15px;
}
.sidebar-collapsed .side-link::after {
  content: attr(data-short);
  font-size: 14px;
  font-weight: 800;
}
.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
}
.brand-title small {
  display: block;
  color: #aab3c5;
  margin-top: 2px;
}
.brand-dot {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #2f6fed;
  font-weight: 900;
}
.side-nav {
  display: grid;
  gap: 7px;
}
.side-link {
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: #d8deea;
  border: 1px solid transparent;
  height: 38px;
}
.side-link[data-page="overview"]::before { content: "总"; display: none; }
.side-link.active,
.side-link:hover {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .08);
  color: #fff;
}
.workspace {
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.topbar h1 { margin: 0; font-size: 28px; }
#subtitle { color: var(--muted); margin: 6px 0 0; }
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
#userBadge { color: var(--muted); }
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section h2 { margin: 0; font-size: 18px; }
.section-head span { color: var(--muted); }
.total-section {
  padding: 12px;
}
.metric-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.metric-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
  min-width: 238px;
  max-width: 286px;
  min-height: 118px;
  background: #fff;
  overflow: hidden;
}
.metric-card.primary {
  border-color: #ff8a3d;
  background: #fff0e3;
}
.metric-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 800;
}
.metric-icon::before { content: "数"; }
.icon-money::before { content: "¥"; }
.icon-orders::before { content: "#"; }
.icon-profit::before { content: "利"; }
.icon-traffic::before { content: "曝"; }
.icon-rate::before { content: "%"; }
.icon-avg::before { content: "均"; }
.metric-label {
  color: #344054;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}
.help-dot {
  width: 17px;
  height: 17px;
  border: 1px solid #98a2b3;
  border-radius: 50%;
  color: #667085;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
}
.metric-value {
  font-size: 30px;
  font-weight: 500;
  margin-top: 12px;
  letter-spacing: 0;
}
.metric-sub { color: var(--muted); margin-top: 3px; font-size: 12px; }
.metric-compare {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 4px 8px;
  flex-wrap: wrap;
  color: #98a2b3;
  font-size: 13px;
  line-height: 1.35;
  min-width: 0;
}
.metric-compare b,
.metric-compare i {
  font-style: normal;
  font-weight: 500;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.metric-compare b::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 14px;
  background: #d0d5dd;
  margin-left: 8px;
  vertical-align: -2px;
}
.metric-compare.up b,
.metric-compare.up i { color: #ff3045; }
.metric-compare.down b,
.metric-compare.down i { color: #12b76a; }
.metric-compare.flat b,
.metric-compare.flat i { color: #667085; }

.abnormal-section {
  background: #fbfcff;
}
.abnormal-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.abnormal-card {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(150px, .6fr) minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #98a2b3;
  border-radius: 7px;
  background: #fff;
  padding: 9px 10px;
}
.abnormal-card.high { border-left-color: var(--danger); }
.abnormal-card.medium { border-left-color: var(--warn); }
.abnormal-main {
  display: flex;
  align-items: center;
  gap: 9px;
}
.abnormal-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff1f0;
  color: var(--danger);
  font-weight: 900;
  flex: 0 0 auto;
}
.abnormal-store {
  font-weight: 800;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.abnormal-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.abnormal-stats {
  display: flex;
  gap: 5px 8px;
  align-items: baseline;
  color: var(--muted);
  justify-content: center;
  flex-wrap: wrap;
}
.abnormal-stats b {
  color: var(--text);
  font-size: 16px;
}
.abnormal-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.abnormal-tags span {
  background: #f2f4f7;
  border: 1px solid #e4e7ec;
  color: #475467;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 12px;
}
.anomaly-detail-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.anomaly-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 1.4fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid #98a2b3;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}
.anomaly-row.high { border-left-color: var(--danger); }
.anomaly-row.medium { border-left-color: var(--warn); }
.anomaly-row b { display: block; }
.anomaly-row span {
  color: var(--muted);
  font-size: 12px;
}
.anomaly-row p {
  margin: 0;
  line-height: 1.5;
}
.anomaly-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.anomaly-actions button {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}
.status-pill {
  height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff7e6;
  color: var(--warn);
  font-weight: 700;
}
.status-pill.fixed,
.status-pill.ignored {
  background: #ecfdf3;
  color: var(--ok);
}
.status-pill.processing,
.status-pill.confirmed {
  background: #e8f1ff;
  color: var(--accent);
}
.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  background: #fff;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}
.compact table { min-width: 760px; }
table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}
th { background: #f8fafc; color: var(--muted); font-weight: 700; }
.severity-high { color: var(--danger); font-weight: 700; }
.severity-medium { color: var(--warn); font-weight: 700; }
.severity-low { color: var(--muted); font-weight: 700; }

.detail-section { padding-bottom: 18px; }
.filter-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.filter-line {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #edf1f7;
  border-radius: 8px;
  background: #fbfcff;
}
.filter-line:nth-child(2) { background: #f8fbff; }
.filter-line:nth-child(3) { background: #fbfdfb; }
.filter-line:nth-child(4) { background: #fffdfa; }
.filter-line > :not(.filter-label) {
  min-width: 0;
}
.filter-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  padding-top: 8px;
}
.tab-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.tab, .store-tab {
  background: #eef3fb;
  color: var(--text);
  border: 1px solid var(--line);
}
.tab.active, .store-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.brand-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.brand-tab.active {
  background: var(--brand-color);
  border-color: var(--brand-color);
}
.tab span {
  margin-left: 6px;
  font-size: 12px;
  opacity: .75;
}
.store-switch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  align-items: start;
  gap: 8px;
  min-width: 0;
}
.store-tabs {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.store-tab {
  display: inline-grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  max-width: 210px;
  min-width: 132px;
  height: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--brand-soft);
  border-color: rgba(0, 0, 0, .06);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  font-weight: 700;
  text-align: left;
}
.store-tab.active {
  background: var(--brand-color);
  border-color: var(--brand-color);
  box-shadow: 0 6px 14px rgba(23, 105, 224, .18);
}
.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft, var(--accent-soft));
  color: var(--brand-color, var(--accent));
  font-size: 13px;
  font-weight: 900;
  overflow: hidden;
  flex: 0 0 auto;
}
.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand-logo.large {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 20px;
}
.brand-logo.mini {
  width: 20px;
  height: 20px;
  font-size: 11px;
}
.store-tab.active .brand-logo {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}
.store-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.store-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.store-owner {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.store-tab.active .store-owner { color: rgba(255, 255, 255, .78); }
.store-more {
  width: 190px;
  min-width: 190px;
  position: relative;
  z-index: 2;
  background: #fff;
}
.platform-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin: 0;
}
.platform-tab {
  height: 32px;
  background: #eef3fb;
  color: var(--text);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.platform-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.platform-tab:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.platform-tab span {
  font-size: 11px;
  font-weight: 500;
}
.month-tabs {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin: 0;
}
.month-button-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(48px, 1fr));
  gap: 6px;
  min-width: 0;
}
.year-pill,
.year-select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}
.year-pill {
  display: inline-grid;
  place-items: center;
}
.month-tab {
  background: #eef3fb;
  color: var(--text);
  border: 1px solid var(--line);
  min-width: 0;
  padding: 0 6px;
}
.month-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.month-tab:disabled {
  background: #f6f7f9;
  color: #a0a8b3;
  cursor: not-allowed;
}
.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 8px 0 12px;
}
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9fc;
}
.segmented button {
  height: 30px;
  background: transparent;
  color: var(--muted);
  border-radius: 5px;
  padding: 0 12px;
}
.segmented button.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}
.chart-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chart-controls select {
  min-width: 128px;
}
.line-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.line-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.line-toggles input {
  width: 14px;
  height: 14px;
  padding: 0;
}
.table-legend {
  display: flex;
  align-items: center;
  gap: 8px 10px;
  flex-wrap: wrap;
  margin: 0;
  padding: 6px 9px;
  border: 1px solid #e5eaf2;
  border-radius: 7px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.table-legend .legend-note {
  flex: 0 1 560px;
  color: #536070;
}
.table-legend span:not(.legend-note) {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.legend-chip {
  width: 16px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(16, 24, 40, .08);
}
.legend-chip.warning { background: var(--yellow); }
.legend-chip.up { background: var(--pink); }
.legend-chip.down { background: var(--green); }
.old-table-legend,
.detail-toolbar + .table-legend { display: none; }
.month-table-wrap {
  border: 1px solid #aeb9c7;
  overflow: auto;
  max-height: calc(100vh - 300px);
  background: white;
}
.month-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.month-table th, .month-table td {
  border: 1px solid #cfd6df;
  padding: 6px 7px;
  text-align: center;
  min-width: 62px;
}
.month-table thead th {
  position: sticky;
  top: 0;
  background: #c4d6fb;
  color: #111827;
  z-index: 3;
}
.month-table .group-top {
  min-width: 260px;
  text-align: center;
  font-weight: 800;
}
.group-cell {
  background: #dce9ff;
  font-weight: 800;
  min-width: 62px;
  white-space: normal;
}
.metric-name {
  background: #f7f9fc;
  text-align: left !important;
  min-width: 180px !important;
  position: sticky;
  left: 0;
  z-index: 2;
}
.row-icon {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  margin-right: 6px;
}
.current-total, .current-avg {
  background: var(--purple);
  color: #4f20c8;
  font-weight: 700;
}
.strong { font-weight: 700; }
.day-head {
  min-width: 48px !important;
  padding: 4px 5px !important;
}
.day-head b { display: block; }
.day-head span {
  display: block;
  color: #4b5563;
  font-weight: 500;
}
.day-cell.up { background: var(--pink); color: var(--text); }
.day-cell.down { background: var(--green); color: var(--text); }
.day-cell.warning { background: var(--yellow); color: #5f4300; }
.day-cell.empty { color: #a0a8b3; background: #fbfcfe; }
.spark {
  width: 84px;
  height: 34px;
  display: block;
}
.spark polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}
.trend-panel {
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  padding: 14px;
}
.trend-card {
  min-width: 780px;
}
.trend-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}
.trend-head h3 {
  margin: 0;
  font-size: 20px;
}
.trend-head p {
  margin: 6px 0 0;
  color: var(--muted);
}
.trend-summary {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  text-align: right;
}
.trend-summary span,
.trend-summary i {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}
.trend-summary b {
  display: block;
  margin: 3px 0;
  font-size: 20px;
}
.trend-summary.up i { color: #ff3045; }
.trend-summary.down i { color: #12b76a; }
.trend-svg {
  width: 100%;
  height: 310px;
  display: block;
  overflow: visible;
}
.trend-svg text {
  fill: #667085;
  font-size: 12px;
}
.trend-svg .grid-line {
  stroke: #e4e9f2;
  stroke-width: 1;
}
.trend-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.trend-line.current {
  stroke: #2f6fed;
  filter: drop-shadow(0 5px 8px rgba(47, 111, 237, .18));
}
.trend-line.previous {
  stroke: #9db2d6;
  stroke-width: 2;
  stroke-dasharray: 7 7;
}
.trend-ref {
  stroke-width: 2;
  stroke-dasharray: 8 6;
}
.trend-ref.warning {
  stroke: #d99a00;
}
.trend-ref.baseline {
  stroke: #7c3aed;
}
.trend-svg circle {
  fill: #2f6fed;
  stroke: #fff;
  stroke-width: 2;
}
.trend-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.trend-legend i {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 99px;
  margin-right: 5px;
  vertical-align: 3px;
}
.legend-current { background: #2f6fed; }
.legend-previous { background: #9db2d6; }
.legend-warning { background: #d99a00; }
.legend-baseline { background: #7c3aed; }
.warn-text { color: var(--warn); }
.muted { color: var(--muted); }

.management-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.management-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 14px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h3 {
  margin: 0;
  font-size: 18px;
}
.panel-head span {
  color: var(--muted);
  font-size: 12px;
}
.panel-head-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.management-brand-filter {
  min-width: 0;
}
.management-filter-block {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}
.management-filter-block > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.mini-brand-filter {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}
.mini-brand-chip {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 7px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--brand-soft, #f3f6fb);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  box-shadow: none;
}
.mini-brand-chip.active {
  background: var(--brand-color, var(--accent));
  border-color: var(--brand-color, var(--accent));
  color: #fff;
}
.mini-brand-chip b {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  color: var(--brand-color, var(--accent));
  font-size: 11px;
}
.mini-brand-chip.active b {
  background: rgba(255, 255, 255, .18);
  color: #fff;
}
.mini-brand-chip.active .brand-logo {
  background: rgba(255, 255, 255, .18);
  color: #fff;
}
.brand-manager {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  align-items: stretch;
}
.brand-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, var(--brand-soft), #fff 62%);
  min-height: 210px;
}
.brand-add-card {
  background: #fff;
  border-style: dashed;
}
.brand-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.brand-card h3 {
  margin: 0 0 4px;
}
.brand-card p {
  margin: 0;
  color: var(--muted);
}
.brand-platform-map {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin: 10px 0;
}
.brand-platform-map label,
.store-edit-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}
.brand-platform-map input,
.store-edit-grid input,
.store-edit-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}
.upload-line,
.color-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--text);
}
.upload-line input {
  height: auto;
  max-width: 150px;
  padding: 6px;
}
.color-line input {
  width: 52px;
  padding: 2px;
}
.manage-select {
  min-width: 280px;
}
.store-profile {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.store-profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(90deg, var(--brand-soft), #fff);
  border-bottom: 1px solid var(--line);
}
.store-profile h3,
.operator-hero h3 {
  margin: 0 0 5px;
  font-size: 22px;
}
.store-profile p,
.operator-hero p {
  margin: 0;
  color: var(--muted);
}
.platform-board,
.store-info-grid,
.operator-kpis {
  display: grid;
  gap: 10px;
}
.operator-kpis article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}
.operator-kpis span {
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}
.operator-kpis b {
  font-size: 20px;
}
.platform-board {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  padding: 14px;
}
.platform-card {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}
.platform-card.platform-meituan {
  --platform-color: #ffd000;
  --platform-soft: #fff8d7;
  border-color: #f0c400;
  background: linear-gradient(180deg, #fff8d7, #fffdfa);
}
.platform-card.platform-taobao {
  --platform-color: #ff6a00;
  --platform-soft: #fff0e3;
  border-color: #ffc29a;
  background: linear-gradient(180deg, #fff0e3, #fffaf6);
}
.platform-card.platform-jd {
  --platform-color: #e1251b;
  --platform-soft: #ffe7e6;
  border-color: #ffb7b3;
  background: linear-gradient(180deg, #ffe7e6, #fff8f8);
}
.platform-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.platform-card label {
  display: grid;
  gap: 5px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}
.platform-card input {
  width: 100%;
  height: 34px;
}
.sheet-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.platform-card.online {
  border-style: solid;
}
.platform-card b {
  display: block;
  margin-bottom: 5px;
}
.platform-card span {
  color: var(--platform-color, var(--ok));
  font-weight: 700;
}
.platform-card p {
  margin-top: 6px;
}
.store-info-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  padding: 14px 14px 0;
}
.store-info-strip article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcff;
}
.store-info-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.store-info-strip b {
  font-size: 15px;
}
.lock-btn {
  margin-left: auto;
  white-space: nowrap;
}
.store-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}
.wide-field {
  grid-column: 1 / -1;
}
.store-edit-grid textarea {
  min-height: 76px;
  resize: vertical;
}
.store-save-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 16px;
}
input:disabled,
textarea:disabled,
select:disabled {
  color: #667085;
  background: #f6f8fb;
  cursor: not-allowed;
}
.store-info-grid {
  grid-template-columns: 1.2fr 1fr 1fr;
  padding: 0 14px 14px;
}
.store-info-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.store-info-grid h4,
.operator-detail h4 {
  margin: 0 0 10px;
}
.issue-title {
  color: var(--danger) !important;
  font-weight: 700;
  margin-bottom: 6px !important;
}
.origin-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  margin: 0;
}
.origin-list dt { color: var(--muted); }
.origin-list dd { margin: 0; font-weight: 700; }
.operator-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 260px;
  gap: 14px;
}
.operator-admin-wide {
  border: 1px solid #cfe0ff;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7fbff, #fff);
  padding: 14px;
  margin-bottom: 14px;
}
.operator-profile {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
  align-self: start;
}
.operator-avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #1769e0, #7c3aed);
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 12px;
}
.operator-profile h3 {
  margin: 0 0 5px;
  font-size: 22px;
}
.operator-profile p {
  margin: 0 0 14px;
  color: var(--muted);
}
.operator-profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.operator-profile-stats article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}
.operator-profile-stats b {
  display: block;
  font-size: 20px;
}
.operator-profile-stats span {
  color: var(--muted);
  font-size: 12px;
}
.operator-list {
  display: grid;
  gap: 8px;
  align-content: start;
}
.operator-card {
  height: auto;
  display: grid;
  gap: 4px;
  text-align: left;
  background: #f3f6fb;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 12px;
}
.operator-card.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.operator-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.operator-card.active span { color: rgba(255, 255, 255, .78); }
.operator-detail {
  min-width: 0;
}
.operator-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(90deg, #f6f9ff, #fff);
}
.operator-kpis {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}
.store-mini-grid,
.operator-anomalies {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.store-mini-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.store-mini-grid article,
.operator-anomalies article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}
.store-mini-grid article {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
}
.store-mini-grid span {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}
.operator-anomalies span {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}
.operator-anomalies p {
  margin: 6px 0 0;
  color: var(--text);
}
.operator-timeline {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  align-self: start;
}
.operator-timeline h4 {
  margin: 0 0 12px;
}
.timeline-item {
  position: relative;
  border-left: 3px solid #98a2b3;
  padding: 0 0 14px 12px;
  margin-left: 4px;
}
.timeline-item.high { border-left-color: var(--danger); }
.timeline-item.medium { border-left-color: var(--warn); }
.timeline-item b {
  display: block;
}
.timeline-item span {
  color: var(--muted);
  font-size: 12px;
}
.timeline-item p {
  margin: 5px 0 0;
}
.assignment-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.operator-admin-panel { margin-top: 14px; }
.operator-admin-head h4 {
  margin: 0;
}
.operator-admin-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.operator-people-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
.operator-person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
}
.operator-person b {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.operator-person button {
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
}
.operator-person button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.assignment-toolbar label {
  min-width: 220px;
}
#assignmentStatus {
  color: var(--muted);
}
.assignment-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}
.assignment-table {
  min-width: 920px;
}
.assignment-table td:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}
.assignment-table select {
  min-width: 140px;
}
.platform-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8f1ff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  margin-right: 5px;
}
.muted-pill {
  background: #f2f4f7;
  color: #98a2b3;
}

.filter-bar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}
.filter-bar.compact {
  background: transparent;
  border: 0;
  padding: 0;
}
.filter-bar label {
  min-width: 170px;
}
.log-list,
.action-list {
  display: grid;
  gap: 10px;
}
.log-card,
.action-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(16, 24, 40, .04);
}
.log-card {
  border-left: 4px solid #98a2b3;
}
.log-card.ok { border-left-color: var(--ok); }
.log-card.failed { border-left-color: var(--danger); }
.log-card > div:first-child,
.action-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.log-card b,
.action-card b {
  font-size: 15px;
}
.log-card span,
.action-card span,
.action-card small {
  color: var(--muted);
}
.log-card p,
.action-card p {
  margin: 8px 0 0;
  line-height: 1.55;
}
.log-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.log-metrics span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #475467;
  font-size: 12px;
}
.log-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 0;
  color: var(--muted);
}
.log-line b {
  color: var(--text);
}
.action-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.action-form {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.action-form h3 {
  margin: 0 0 4px;
}
.action-form textarea {
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  color: var(--text);
}
#actionStatus {
  min-height: 20px;
  color: var(--muted);
}
.month-table-wrap {
  border-radius: 9px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
}
.month-table th:first-child,
.month-table td.metric-name {
  box-shadow: 6px 0 12px rgba(16, 24, 40, .06);
}
.detail-toolbar,
.platform-tabs,
.month-tabs {
  position: relative;
}
.trend-panel {
  box-shadow: 0 10px 28px rgba(16, 24, 40, .06);
}

@media (max-width: 960px) {
  .topbar, .section-head { align-items: stretch; flex-direction: column; }
  .filter-line {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .filter-label { text-align: left; padding-top: 0; }
  .store-switch {
    grid-template-columns: 1fr;
  }
  .store-more {
    width: 100%;
    min-width: 0;
  }
  .top-actions { flex-wrap: wrap; }
  .metric-card { min-width: 148px; }
  .abnormal-list { grid-template-columns: 1fr; }
  .abnormal-card {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }
  .abnormal-stats { justify-content: flex-start; }
  .abnormal-tags { justify-content: flex-start; }
  .store-tabs { flex-wrap: wrap; overflow: visible; }
  .month-tabs { grid-template-columns: 1fr; }
  .month-button-grid { grid-template-columns: repeat(6, minmax(48px, 1fr)); }
  .profile-grid, .platform-board, .store-info-grid, .operator-layout, .operator-kpis, .action-layout {
    grid-template-columns: 1fr;
  }
  .log-card > div:first-child,
  .action-card > div:first-child,
  .log-line,
  .anomaly-row {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }
  .log-card > div:first-child,
  .action-card > div:first-child,
  .log-line {
    flex-direction: column;
  }
  .anomaly-actions { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .side-nav { grid-template-columns: repeat(2, 1fr); }
}
