:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: #18222d;
  background: #f4f6f5;
  letter-spacing: 0;
  --ink: #18222d;
  --muted: #66727d;
  --faint: #8b959e;
  --line: #dce2df;
  --line-strong: #cbd3cf;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --accent: #157a55;
  --accent-dark: #0e5d40;
  --accent-soft: #eaf5ef;
  --blue: #2f6f9f;
  --blue-soft: #eaf2f8;
  --orange: #a95c13;
  --orange-soft: #fff1df;
  --red: #b43d42;
  --red-soft: #fdebed;
  --violet: #6f4ba5;
  --violet-soft: #f0eafb;
  --shadow: 0 8px 28px rgb(24 34 45 / 10%);
}

* { box-sizing: border-box; letter-spacing: 0; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: #f4f6f5; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

.topbar {
  height: 62px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand-block, .login-brand { min-width: 0; display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--accent);
  font-size: 16px;
  font-weight: 800;
}
.brand-block > div, .login-brand > div { min-width: 0; display: grid; gap: 2px; }
.brand-block strong, .login-brand strong { font-size: 14px; }
.brand-block span, .login-brand span { color: var(--muted); font-size: 11px; }
.brand-block .brand-mark, .login-brand .brand-mark { color: #fff; }

.topbar-actions { min-width: 0; flex: 0 0 auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.topbar-actions > button { flex: 0 0 auto; white-space: nowrap; }
.language-select { width: 118px; min-width: 118px; height: 30px; padding: 0 6px; flex: 0 0 118px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); font-size: 12px; }
.collector-state { margin-right: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.collector-state::before { content: ""; width: 7px; height: 7px; margin-right: 6px; display: inline-block; border-radius: 50%; background: #9aa39e; }
.collector-state.ok::before { background: #1d9567; }
.collector-state.error::before { background: #c0444a; }

.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 17px;
}
.icon-button:hover { border-color: #9dadA5; background: var(--surface-soft); }
.primary-command, .secondary-command, .text-command {
  min-height: 32px;
  padding: 6px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 650;
}
.danger-command { min-height: 32px; padding: 6px 11px; border: 1px solid #d7a7aa; border-radius: 6px; color: #a33137; background: #fff; font-size: 12px; font-weight: 650; }
.danger-command:hover { border-color: var(--red); background: var(--red-soft); }
.primary-command { border: 1px solid var(--accent); color: #fff; background: var(--accent); }
.primary-command:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.secondary-command { border: 1px solid var(--line-strong); color: #35434e; background: var(--surface); }
.secondary-command:hover { border-color: #9eaaa4; background: var(--surface-soft); }
.text-command { padding-inline: 7px; border: 0; color: var(--muted); background: transparent; }
.text-command:hover { color: var(--ink); background: #edf1ef; }

.app-layout { height: calc(100vh - 62px); display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.viewer-mode .app-layout { grid-template-columns: 272px minmax(0, 1fr); }
.viewer-mode .admin-surface,
.viewer-mode .admin-only { display: none !important; }
.viewer-only { display: none; }
.viewer-only.parallel-filters { display: none; }
.viewer-mode .viewer-only.side-drawer { display: grid; }
.viewer-mode .viewer-only.parallel-filters { display: grid; margin-bottom: 10px; }
.viewer-mode .viewer-catalog-note { margin: -7px 4px 12px; display: block; color: var(--muted); font-size: 9px; line-height: 1.5; }
.viewer-mode .health-latency { display: none; }
.catalog-sidebar {
  min-height: 0;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #eef2f0;
}
.sidebar-heading { margin: 0 4px 14px; display: flex; align-items: center; justify-content: space-between; }
.sidebar-heading > div { display: grid; gap: 2px; }
.sidebar-heading strong { font-size: 13px; }
.sidebar-heading span { color: var(--muted); font-size: 10px; }

.parallel-filters { display: grid; grid-template-columns: 1fr; gap: 7px; }
.sidebar-heading,
.viewer-catalog-note,
.parallel-filters,
.status-filter,
.archive-filter,
.archive-actions { flex: 0 0 auto; }
.parallel-filters .event-filter-label { grid-column: 1 / -1; }
.parallel-filters label, .parallel-filters .filter-field, .field-stack { min-width: 0; display: grid; gap: 5px; }
.parallel-filters label > span, .filter-label > span, .field-stack > span { color: #4e5a64; font-size: 10px; font-weight: 700; }
.filter-label { min-height: 15px; display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.filter-edit { padding: 0; border: 0; color: var(--accent-dark); background: transparent; font-size: 9px; }
.filter-edit:hover { text-decoration: underline; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  outline: none;
}
input, select { height: 34px; padding: 0 9px; }
textarea { padding: 8px 9px; line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #5b9a7e; box-shadow: 0 0 0 2px rgb(21 122 85 / 10%); }
.parallel-filters select { height: 32px; padding-inline: 7px; font-size: 11px; }

.status-filter { width: 100%; height: 31px; min-height: 31px; margin: 12px 0 9px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line-strong); border-radius: 6px; }
.status-filter button { width: 100%; min-width: 0; height: 29px; padding: 0 3px; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: #f8faf9; font-size: 10px; line-height: 1; text-overflow: clip; white-space: nowrap; }
.status-filter button:last-child { border-right: 0; }
.status-filter button.active { color: #fff; background: #34434c; font-weight: 700; }
.viewer-mode .status-filter { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.archive-filter { width: 100%; height: 27px; min-height: 27px; margin: 0 0 7px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; overflow: hidden; }
.archive-filter button, .archive-actions button { min-width: 0; min-height: 26px; padding: 0 5px; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted); background: #fff; font-size: 9px; line-height: 1; text-overflow: clip; white-space: nowrap; }
.archive-filter button.active { border-color: #708078; color: #fff; background: #56645d; }
.archive-actions { margin-bottom: 8px; min-height: 27px; display: flex; align-items: center; gap: 5px; }
.archive-actions span { margin-right: auto; color: var(--muted); font-size: 9px; }
.archive-actions .archive-select-all { flex: 0 0 auto; display: flex; align-items: center; gap: 3px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.archive-actions .archive-select-all input { width: 13px; height: 13px; }
.archive-actions .archive-select-all span { margin: 0; }

.event-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; display: grid; align-content: start; gap: 4px; }
.event-list-empty { padding: 28px 12px; color: var(--muted); font-size: 11px; text-align: center; }
.catalog-load-more { margin: 6px 0 2px; padding: 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #fff; font-size: 10px; cursor: pointer; }
.catalog-load-more:hover { border-color: #b7cdc2; color: #25323c; }
.event-list-row { min-width: 0; display: block; }
.event-list-row.has-archive-check { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px; }
.event-list-row > button {
  width: 100%;
  min-height: 58px;
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) 8px;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: inherit;
  background: transparent;
  text-align: left;
}
.event-list-row > button:hover { border-color: #d3dad6; background: rgb(255 255 255 / 65%); }
.event-list-row > button.active { border-color: #b7cdc2; background: #fff; }
.event-archive-check { width: 14px; height: 14px; }
.event-list .status-line { width: 4px; min-height: 38px; border-radius: 3px; background: #9ba49f; }
.event-list .status-line.active { background: #1d9567; }
.event-list .status-line.active.today { background: #df8428; }
.event-list .status-line.abnormal { background: #c0444a; }
.event-list .event-list-copy { min-width: 0; display: grid; gap: 4px; }
.event-list strong { overflow: hidden; color: #25323c; font-size: 11px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.event-list small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.event-unread-dot {
  width: 7px;
  height: 7px;
  align-self: center;
  border-radius: 50%;
  background: #d93c43;
  box-shadow: 0 0 0 2px #fff;
}

.workspace { min-width: 0; min-height: 0; overflow: auto; background: var(--surface); }
.mobile-catalog-bar { display: none; }

.empty-state { min-height: calc(100vh - 62px); display: grid; place-content: center; gap: 6px; color: var(--muted); text-align: center; }
.empty-state strong { color: #39464f; font-size: 15px; }
.empty-state span { font-size: 11px; }
.event-view { padding: 0 20px 28px; }

.event-header { min-height: 104px; padding: 18px 0 8px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.event-title-block { min-width: 0; }
.event-kicker { margin-bottom: 6px; display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 10px; font-weight: 750; }
.event-title-block h1 { max-width: 920px; color: #15212b; font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.event-title-block p { margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.65; white-space: pre-line; }
.event-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.status-badge { padding: 2px 6px; border-radius: 4px; color: #56615c; background: #edf1ef; }
.status-badge.active { color: #0f6846; background: var(--accent-soft); }
.status-badge.abnormal { color: #9f3036; background: var(--red-soft); }
.event-countdown { color: #53645b; font-weight: 600; }
.event-source-link { margin-top: 3px; display: inline-flex; color: var(--accent-dark); font-size: 10px; text-decoration: none; }
.event-source-link:hover { text-decoration: underline; }
.monitor-switch { height: 32px; padding: 0 8px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); font-size: 11px; }
.monitor-switch input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }

.summary-callout { margin-top: 2px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.view-controls { min-height: 40px; margin: 0 10px; padding: 6px 0; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.view-controls > div { min-width: 0; display: flex; align-items: center; gap: 8px; }
.control-label { color: var(--muted); font-size: 9px; font-weight: 700; }
.segmented-control { min-width: 0; display: flex; align-items: center; gap: 3px; overflow-x: auto; }
.segmented-control button { height: 28px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 5px; color: #56626b; background: #fff; font-size: 10px; white-space: nowrap; }
.segmented-control button.active { border-color: #7ead97; color: #fff; background: var(--accent); }
.segmented-control.compact button { padding-inline: 8px; }

.metric-strip { min-height: 0; padding: 5px 2px 7px; display: grid; grid-template-columns: repeat(5, minmax(100px, 1fr)); }
.metric-item { min-width: 0; padding: 5px 10px; border-right: 1px solid var(--line); }
.metric-item:last-child { border-right: 0; }
.metric-item span { display: block; color: var(--muted); font-size: 11px; }
.metric-item strong { margin-top: 3px; display: block; overflow: hidden; color: #1b2a35; font-size: 15px; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.metric-item:first-child strong, .viewer-mode .metric-item:first-child strong { color: var(--accent-dark); }
.metric-item strong.negative { color: var(--red); }

.quota-calculator {
  margin: 8px 0 0;
  padding: 8px 11px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  border: 1px solid #e4e9e6;
  border-radius: 7px;
  background: #f8faf9;
  color: var(--muted);
  font-size: 9px;
}
.quota-heading {
  color: #718078;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 750;
}
.quota-fields { flex: 1 1 230px; }
.quota-fields, .quota-results { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.quota-fields label { display: inline-flex; align-items: center; gap: 5px; }
.quota-calculator input { width: 64px; height: 25px; padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: 5px; color: #26333d; background: #fff; font: inherit; }
.quota-calculator input:focus { outline: 2px solid rgb(21 122 85 / 18%); border-color: var(--accent); }
.quota-result strong { color: #5b6a61; font-weight: 700; }
.quota-results { display: flex; gap: 16px; margin-left: auto; }
.quota-result { min-width: 0; display: flex; align-items: baseline; gap: 1px; }
.quota-result strong { display: inline; margin-top: 0; font-size: 10px; line-height: 1.1; }
.quota-result-label { display: block; color: var(--muted); font-size: 9px; font-weight: 750; }
.quota-result { white-space: nowrap; }
.quota-result-unit { margin-left: 2px; font-size: 9px; font-weight: 500; color: var(--muted); }
.quota-results { justify-content: flex-end; }


.health-section, .records-section { padding-top: 16px; }
.health-section { border-bottom: 1px solid var(--line); }
.section-heading { min-height: 28px; display: flex; align-items: flex-start; justify-content: space-between; }
.section-heading > div { display: flex; align-items: baseline; gap: 8px; }
.section-heading strong, .records-toolbar strong { font-size: 12px; }
.section-heading span, .records-toolbar span { color: var(--muted); font-size: 10px; }
.source-health { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); column-gap: 22px; }
.health-row { min-width: 0; min-height: 50px; padding: 9px 0; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; border-top: 1px solid #edf0ee; }
.health-row:nth-child(-n+3) { border-top-color: transparent; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca5a0; }
.health-dot.ok { background: #1e9568; }
.health-dot.error { background: #c1454a; }
.health-dot.historical { background: #3979a9; }
.health-copy { min-width: 0; display: grid; gap: 2px; }
.health-copy strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.health-copy span { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.health-latency { color: var(--faint); font-size: 9px; white-space: nowrap; }

.records-toolbar { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.records-toolbar > div:first-child { display: flex; align-items: baseline; gap: 7px; }
.records-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.records-actions > * { flex: 0 0 auto; white-space: nowrap; }
.record-control-help, .table-head-help { display: inline-flex; align-items: center; justify-content: center; gap: 3px; }
.record-control-help { flex: 0 0 auto; }
.table-head-help .table-sort { width: auto; }
.help-trigger { width: 15px; height: 15px; padding: 0; flex: 0 0 auto; border: 1px solid #bdd3c5; border-radius: 50%; color: #347455; background: #fff; font-size: 10px; font-weight: 700; line-height: 1; text-align: center; }
.help-trigger:hover, .help-trigger[aria-expanded="true"] { border-color: #7ead97; background: #eef6f0; }
.help-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.help-popover { position: fixed; z-index: 60; width: max-content; max-width: min(230px, calc(100vw - 16px)); padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 5px; color: #35434e; background: #fff; font-size: 11px; font-weight: 400; line-height: 1.45; white-space: normal; }
.record-option { height: 27px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 5px; color: #53615a; background: #f7faf8; font-size: 9px; white-space: nowrap; }
.record-option.active { border-color: #80b29a; color: #0f6846; background: var(--accent-soft); }
.records-scroll { max-height: 1500px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; min-width: 850px; border-collapse: collapse; table-layout: fixed; }
.viewer-mode table { min-width: 850px; }
thead { position: sticky; top: 0; z-index: 3; }
th, td { height: 39px; padding: 6px 8px; border-bottom: 1px solid #e7ebe9; text-align: center; white-space: nowrap; }
th { height: 37px; color: #45525d; background: #f2f5f4; font-size: 10px; font-weight: 750; }
td { color: #26333d; font-size: 10px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f6f9f7; }
tbody tr.selected { background: #edf5fb; }
tbody tr.refund-refund { background: var(--red-soft); }
tbody tr.refund-sale { background: #fff4f4; }
tbody tr.annotation-suspected_water { background: var(--blue-soft); box-shadow: inset 3px 0 #3985b6; }
tbody tr.annotation-suspected_supplement { box-shadow: inset 3px 0 #d78a2d; }
tbody tr.annotation-suspected_duplicate { box-shadow: inset 3px 0 #7c57b2; }
tbody tr.annotation-needs_review { box-shadow: inset 3px 0 #7d878e; }
.check-column { width: 94px; }
.index-column { width: 50px; }
th:nth-child(3) { width: 150px; }
th:nth-child(4) { width: 92px; }
th:nth-child(5) { width: 128px; }
th:nth-child(6) { width: 118px; }
th:nth-child(7) { width: 122px; }
th:nth-child(8) { width: auto; }
.viewer-mode th:nth-child(7) { width: 122px; }
input[type="checkbox"] { width: 14px; height: 14px; padding: 0; accent-color: var(--blue); }
.sort-button { display: inline-flex; align-items: center; gap: 3px; }
.sort-button .sort-indicator { color: #66727d; font-size: 10px; }
.sort-button.active { color: var(--accent-dark); }
.table-sort { width: 100%; height: 100%; padding: 0; display: inline-flex; align-items: center; justify-content: center; gap: 3px; border: 0; color: inherit; background: transparent; font-weight: inherit; }
.delta-positive { color: #14764f; font-weight: 750; background: rgba(20, 118, 79, 0.06); }
.delta-negative { color: var(--red); font-weight: 750; background: rgba(180, 61, 66, 0.06); }
.record-tag { margin-right: 3px; padding: 2px 4px; display: inline-block; border-radius: 3px; font-size: 8px; }
.tag-suspected_water { color: #276c98; background: var(--blue-soft); }
.tag-suspected_supplement { color: #94520f; background: var(--orange-soft); }
.tag-suspected_duplicate { color: #644094; background: var(--violet-soft); }
.tag-needs_review { color: #59646c; background: #e9edeb; }
.tag-refund { color: #9c3036; background: var(--red-soft); }
tbody tr.annotation-local_water { background: #fffaf0; box-shadow: inset 3px 0 #c8841f; }
.records-load-state { min-height: 35px; padding: 11px; color: var(--muted); background: #fafbfb; font-size: 9px; text-align: center; }

.drawer-shade { position: fixed; inset: 0; z-index: 20; background: rgb(21 29 34 / 20%); }
.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(390px, 100vw);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-left: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 180ms ease;
}
.side-drawer.wide { width: min(620px, 100vw); }
.side-drawer.open { transform: translateX(0); }
.side-drawer > header { min-height: 62px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.side-drawer > header > div { min-width: 0; display: grid; gap: 3px; }
.side-drawer > header strong { font-size: 14px; }
.side-drawer > header span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { min-height: 0; padding: 16px; overflow-y: auto; }
.side-drawer > footer { min-height: 58px; padding: 10px 14px; display: flex; align-items: center; justify-content: flex-end; gap: 7px; border-top: 1px solid var(--line); }
.quick-tags { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 16px; }
.quick-tags button { height: 38px; border: 1px solid var(--line-strong); border-radius: 5px; color: #4e5b65; background: var(--surface); font-size: 11px; }
.quick-tags button.active { border-color: #8061ab; color: #573582; background: var(--violet-soft); font-weight: 700; }

.event-form { display: grid; align-content: start; gap: 12px; }
.choice-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-buttons button { min-width: 78px; height: 34px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 6px; color: #45535e; background: #fff; font-size: 11px; }
.choice-buttons button.active { border-color: var(--accent); color: #fff; background: var(--accent); font-weight: 700; }
.platform-buttons button { min-width: 100px; }
.link-groups { display: grid; gap: 9px; }
.link-group-card { padding: 10px; display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.link-group-card > header { min-height: 28px; display: flex; align-items: center; justify-content: space-between; }
.link-group-card > header strong { font-size: 11px; }
.album-version-card { padding: 9px; display: grid; gap: 7px; border: 1px solid #cbd8d1; border-radius: 6px; background: #fff; }
.album-version-card > header { min-height: 24px; display: flex; align-items: center; justify-content: space-between; }
.album-version-card > header strong { color: #42524a; font-size: 10px; }
.add-album-version { justify-self: start; }
.paste-input { display: grid; grid-template-columns: minmax(0, 1fr) 52px; }
.paste-input input { border-radius: 5px 0 0 5px; }
.paste-input button { border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 5px 5px 0; color: var(--accent-dark); background: #edf5f1; font-size: 10px; }
.add-link-group { justify-self: start; }
.form-grid { display: grid; gap: 9px; }
.form-grid.two-column { grid-template-columns: 1fr 1fr; }
.form-grid.three-column { grid-template-columns: 1fr 1fr 1fr; }
.preview-action { padding-top: 15px; display: flex; justify-content: flex-end; }
.form-message { min-height: 16px; color: var(--muted); font-size: 10px; }
.form-message.error { color: var(--red); }
.sources-heading { margin-top: 5px; display: flex; align-items: center; justify-content: space-between; }
.sources-heading strong { font-size: 12px; }
.source-editor { display: grid; gap: 8px; }
.source-edit-row { padding: 10px; display: grid; grid-template-columns: 1fr 1fr 34px; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.source-edit-row .source-url { grid-column: 1 / 3; }
.source-edit-row .source-product { grid-column: 1 / 2; }
.source-edit-row .remove-source { grid-column: 3; grid-row: 1; }
.source-edit-row label span { font-size: 9px; }
.batch-event-editor { display: grid; gap: 8px; }
.batch-event-card { padding: 11px; display: grid; gap: 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.batch-event-card > header { min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.batch-event-card > header div { min-width: 0; display: grid; gap: 3px; }
.batch-event-card > header strong, .batch-event-card > header span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-event-card > header strong { font-size: 11px; }
.batch-event-card > header span { color: var(--muted); font-size: 9px; }
.batch-event-fields { display: grid; grid-template-columns: minmax(140px, 1.4fr) 90px 100px 92px; gap: 8px; }
.batch-event-sources { color: var(--muted); font-size: 9px; }
.parse-time-action { display: flex; justify-content: flex-end; }

.account-management { display: grid; align-content: start; gap: 20px; }
.account-management section { display: grid; gap: 8px; }
.account-management h3 { font-size: 12px; }
.account-package { padding: 12px; border: 1px solid #bdd2c7; border-radius: 7px; background: #f3f9f6; }
.package-copy-result { padding: 9px; display: grid; gap: 7px; border: 1px solid #d2b16d; border-radius: 6px; background: #fff9ec; }
.package-copy-result[hidden] { display: none; }
.package-copy-result > span { color: #745820; font-size: 10px; line-height: 1.5; }
.package-copy-result textarea { min-height: 108px; font-size: 12px; }
.package-event-list { max-height: 210px; overflow-y: auto; display: grid; gap: 4px; }
.package-event-list label { min-width: 0; padding: 6px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.package-event-list label input { flex: 0 0 14px; }
.package-event-list label span { min-width: 0; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.account-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.account-toolbar span { color: var(--muted); font-size: 10px; }
.management-list { display: grid; border-top: 1px solid var(--line); }
.management-row { min-height: 54px; padding: 8px 0; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.management-row > div { min-width: 0; flex: 1; display: grid; gap: 3px; }
.management-row strong, .management-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.management-row strong { font-size: 10px; }
.management-row span { color: var(--muted); font-size: 9px; }
.management-row select { width: 88px; min-width: 88px; }
.account-picker #account-selected { display: grid; gap: 9px; }
.account-picker #account-selected[hidden] { display: none; }
.account-picker #account-list .management-row { flex-wrap: wrap; }
.account-active-events { color: var(--muted); font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 15;
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-dark);
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
  font-size: 21px;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
}
.back-to-top:hover { background: var(--accent-dark); }
.back-to-top:focus-visible { outline: 3px solid rgb(21 122 85 / 28%); outline-offset: 3px; }
.back-to-top.is-visible { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: min(460px, calc(100vw - 28px));
  padding: 9px 12px;
  border: 1px solid #38464e;
  border-radius: 6px;
  color: #fff;
  background: #25323a;
  box-shadow: 0 8px 24px rgb(23 31 36 / 20%);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 150ms ease, transform 150ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: #8f2f34; background: #a4383d; }

.login-page { min-height: 100vh; padding: 24px; display: grid; place-items: center; background: #eef2f0; }
.login-panel { width: min(360px, 100%); padding: 26px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.login-heading { margin-bottom: 25px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.login-heading .login-brand { flex: 1; }
.login-heading .language-select { width: 92px; min-width: 92px; flex-basis: 92px; }
.login-panel form { display: grid; gap: 13px; }
.login-submit { width: 100%; margin-top: 2px; }
.form-error { min-height: 16px; color: var(--red); font-size: 10px; }
.mobile-only { display: none; }

@media (max-width: 1050px) {
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .metric-item:nth-child(3) { border-right: 0; }
  .metric-item:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 820px) {
  html, body { overflow-x: hidden; }
  .topbar { height: 56px; padding: 0 12px; gap: 6px; }
  .brand-block > div { display: none; }
  .collector-state { display: none; }
  .topbar-actions { flex: 1 1 auto; justify-content: flex-end; gap: 4px; }
  .topbar-actions #account-button, .topbar-actions #new-event-button { padding-inline: 6px; font-size: 10px; }
  .language-select { width: 86px; min-width: 86px; flex-basis: 86px; font-size: 10px; }
  .topbar-actions .text-command { display: none; }
  .topbar-actions #logout-button {
    height: 30px;
    padding: 0 7px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: var(--surface);
    font-size: 10px;
  }
  .app-layout { height: calc(100vh - 56px); display: block; }
  .viewer-mode .app-layout { display: block; }
  .catalog-sidebar {
    position: fixed;
    inset: 56px auto 0 0;
    z-index: 25;
    width: min(310px, 92vw);
    border-right: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }
  .catalog-sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .workspace { height: 100%; }
  .mobile-catalog-bar { height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); background: #fff; }
  .mobile-catalog-bar button { height: 27px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; font-size: 10px; }
  .mobile-catalog-bar span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .event-view, .viewer-mode .event-view { padding: 0 8px 16px; }
  .event-header { min-height: 0; padding: 10px 0; display: grid; gap: 8px; }
  .event-title-block h1 { font-size: 15px; }
  .event-title-block p { margin-top: 5px; font-size: 10px; line-height: 1.45; }
  .event-kicker { margin-bottom: 4px; }
  .event-actions { justify-content: flex-start; }
  .event-actions .primary-command, .event-actions .secondary-command, .event-actions .monitor-switch { min-height: 29px; height: 29px; padding: 4px 8px; font-size: 10px; }
  .viewer-mode .event-header { display: flex; flex-direction: row; align-items: flex-start; gap: 7px; }
  .viewer-mode .event-title-block { flex: 1 1 auto; }
  .viewer-mode .event-actions { margin-left: auto; justify-content: flex-end; }
  .viewer-mode #export-link { white-space: nowrap; }
  .summary-callout { margin-top: 2px; }
  .view-controls { min-height: 38px; margin: 0 8px; padding: 5px 0; align-items: flex-start; flex-direction: column; }
  .view-controls > div { width: 100%; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .viewer-mode .metric-item:last-child { grid-column: 1 / -1; }
  .metric-strip { min-height: 0; padding: 3px 2px 5px; }
  .metric-item { padding: 5px 8px; }
  .metric-item span { font-size: 10px; }
  .metric-item strong, .viewer-mode .metric-item strong { margin-top: 2px; font-size: 12px; }
  .metric-item:nth-child(2n) { border-right: 0; }
  .metric-item:nth-child(3) { border-right: 1px solid var(--line); }
  .metric-item:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .quota-calculator { gap: 6px; margin-top: 7px; padding: 7px; font-size: 9px; border-radius: 6px; }
  .quota-fields, .quota-results { justify-content: flex-start; gap: 6px 9px; }
  .quota-results { width: 100%; margin-left: 0; padding-top: 2px; gap: 10px; }
  .quota-calculator input { width: 56px; height: 23px; }
  .quota-result strong { font-size: 10px; }
  .quota-result small { font-size: 8px; }
  .source-health { grid-template-columns: 1fr; }
  .health-row { border-top: 1px solid #edf0ee !important; }
  .health-section, .records-section { padding-top: 11px; }
  .records-toolbar { min-height: 36px; align-items: flex-start; flex-direction: column; padding-bottom: 6px; }
  .section-heading strong, .records-toolbar strong { font-size: 11px; }
  .section-heading span, .records-toolbar span { font-size: 9px; }
  .records-actions { width: 100%; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; }
  .record-option { height: 26px; padding-inline: 7px; font-size: 10px; }
  .records-scroll { max-height: none; overflow-x: auto; overflow-y: visible; }
  table, .viewer-mode table { min-width: 640px; }
  th, td { height: 32px; padding: 4px 3px; font-size: 9px; }
  .index-column { display: table-cell; width: 44px; }
  .check-column { width: 64px; }
  .help-trigger { width: 15px; height: 15px; font-size: 10px; }
  th:nth-child(3) { width: 128px; }
  th:nth-child(4) { width: 78px; }
  th:nth-child(5) { width: 96px; }
  th:nth-child(6) { width: 110px; }
  th:nth-child(7) { width: 96px; }
  th:nth-child(8) { width: 160px; }
  .viewer-mode th:nth-child(7) { width: 96px; }
  .form-grid.two-column, .form-grid.three-column { grid-template-columns: 1fr; }
  .preview-action { padding-top: 0; justify-content: flex-start; }
  .source-edit-row { grid-template-columns: 1fr 34px; }
  .source-edit-row .source-url, .source-edit-row .source-product { grid-column: 1; }
  .source-edit-row .remove-source { grid-column: 2; }
  .batch-event-fields { grid-template-columns: 1fr 1fr; }
  .choice-buttons button, .platform-buttons button { min-width: calc(50% - 3px); }
  .paste-input { grid-template-columns: minmax(0, 1fr) 48px; }
  .back-to-top { right: 13px; bottom: 13px; width: 40px; height: 40px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: none; }
}
.kms-group-choice { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.kms-group-choice input { width: auto; flex: 0 0 auto; }
.kms-group-choice.already-created { opacity: .5; cursor: not-allowed; }

/* ===== 夜间模式（dark theme） ===== */
html[data-theme="dark"] {
  color-scheme: dark;
  background: #10151a;
  color: var(--ink);
  --ink: #dfe6ec;
  --muted: #9aa5b0;
  --faint: #6d7883;
  --line: #2a333b;
  --line-strong: #3a444d;
  --surface: #1b2128;
  --surface-soft: #222a32;
  --accent: #2dbd86;
  --accent-dark: #24986c;
  --accent-soft: #12352a;
  --blue: #63a2d0;
  --blue-soft: #14283a;
  --orange: #d4944a;
  --orange-soft: #2f2113;
  --red: #e06a70;
  --red-soft: #351a1d;
  --violet: #a48ad6;
  --violet-soft: #241a38;
  --shadow: 0 8px 28px rgb(0 0 0 / 45%);
}

html[data-theme="dark"] body { background: #10151a; }
html[data-theme="dark"] .catalog-sidebar { background: #141a1f; }
html[data-theme="dark"] .summary-callout { background: var(--surface); }
html[data-theme="dark"] .mobile-catalog-bar { background: var(--surface); }
html[data-theme="dark"] .mobile-catalog-bar button { color: var(--ink); background: var(--surface); }
html[data-theme="dark"] .quota-calculator { background: var(--surface-soft); border-color: var(--line); }
html[data-theme="dark"] .quota-calculator input { background: var(--surface); color: var(--ink); }
html[data-theme="dark"] .quota-result strong { color: #a9b3ac; }
html[data-theme="dark"] .login-page { background: #10151a; }
html[data-theme="dark"] .login-panel { background: var(--surface); }

/* 标题与正文文字 */
html[data-theme="dark"] .event-title-block h1 { color: var(--ink); }
html[data-theme="dark"] .empty-state strong { color: #c6cfd7; }
html[data-theme="dark"] .event-list strong { color: #c6cfd7; }
html[data-theme="dark"] .metric-item strong { color: var(--ink); }
html[data-theme="dark"] .metric-item:first-child strong,
html[data-theme="dark"] .viewer-mode .metric-item:first-child strong { color: var(--accent); }
html[data-theme="dark"] .secondary-command { color: #c6cfd7; }
html[data-theme="dark"] .danger-command { color: var(--red); background: var(--surface); border-color: #4a2a2e; }
html[data-theme="dark"] .status-badge { color: #b6c0c9; background: #212930; }
html[data-theme="dark"] .event-countdown { color: #a9b3ac; }
html[data-theme="dark"] .parallel-filters label > span,
html[data-theme="dark"] .filter-label > span,
html[data-theme="dark"] .field-stack > span { color: #9aa4ad; }
html[data-theme="dark"] .segmented-control button { color: #b6c0c9; background: var(--surface); }
html[data-theme="dark"] .record-option { color: #aeb8c2; background: #1e252c; }
html[data-theme="dark"] .choice-buttons button { color: #c6cfd7; background: var(--surface); }
html[data-theme="dark"] .help-trigger { color: #3fae80; background: var(--surface); border-color: #2a3a33; }
html[data-theme="dark"] .help-trigger:hover,
html[data-theme="dark"] .help-trigger[aria-expanded="true"] { background: #12352a; }
html[data-theme="dark"] .help-popover { color: #c6cfd7; background: var(--surface); }
html[data-theme="dark"] .quick-tags button { color: #c6cfd7; background: var(--surface); }
html[data-theme="dark"] .album-version-card { background: var(--surface); border-color: #2a333b; }
html[data-theme="dark"] .album-version-card > header strong { color: #a9b3ac; }
html[data-theme="dark"] .paste-input button { color: #3fae80; background: #12352a; }
html[data-theme="dark"] .account-package { background: #16282a; border-color: #2a3a33; }
html[data-theme="dark"] .package-copy-result { background: #2c2617; border-color: #4a3a1e; }
html[data-theme="dark"] .package-copy-result > span { color: #c9a35a; }
html[data-theme="dark"] .package-event-list label { background: var(--surface); }
html[data-theme="dark"] .text-command:hover { background: #262e36; color: var(--ink); }
html[data-theme="dark"] .icon-button:hover { border-color: #4a545d; background: var(--surface-soft); }

/* 输入控件 */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }

/* 筛选按钮 */
html[data-theme="dark"] .status-filter button { color: var(--muted); background: #1c232a; }
html[data-theme="dark"] .status-filter button.active { color: #fff; background: #2f3b44; }
html[data-theme="dark"] .archive-filter button,
html[data-theme="dark"] .archive-actions button { color: var(--muted); background: var(--surface); }
html[data-theme="dark"] .archive-filter button.active { color: #fff; background: #2f3a35; border-color: #4a5a52; }

/* 事件列表 */
html[data-theme="dark"] .event-list-row > button:hover { border-color: #2a333b; background: rgb(255 255 255 / 4%); }
html[data-theme="dark"] .event-list-row > button.active { border-color: var(--accent); background: var(--surface); }
html[data-theme="dark"] .event-unread-dot { box-shadow: 0 0 0 2px var(--surface); }
html[data-theme="dark"] .catalog-load-more { color: #c6cfd7; background: var(--surface); }

/* 表格 */
html[data-theme="dark"] th { color: #aeb8c2; background: #1f262e; }
html[data-theme="dark"] td { color: #c6cfd7; }
html[data-theme="dark"] th, html[data-theme="dark"] td { border-bottom-color: #242c34; }
html[data-theme="dark"] tbody tr:hover { background: #232b33; }
html[data-theme="dark"] tbody tr.selected { background: #16293a; }
html[data-theme="dark"] tbody tr.refund-refund { background: #262d34; }
html[data-theme="dark"] tbody tr.refund-sale { background: #232930; }
html[data-theme="dark"] tbody tr.annotation-local_water { background: #2c2617; box-shadow: inset 3px 0 #d08a3a; }
html[data-theme="dark"] .records-load-state { color: var(--muted); background: #1c232a; }
html[data-theme="dark"] .delta-positive { color: var(--accent); background: rgb(45 189 134 / 12%); }
html[data-theme="dark"] .delta-negative { color: #c4ccd4; background: rgb(180 188 196 / 10%); }
html[data-theme="dark"] .tag-needs_review { color: #a9b3ac; background: #212930; }
html[data-theme="dark"] .tag-refund { color: #c4ccd4; background: #2a3038; }
html[data-theme="dark"] .tag-suspected_water { color: #6fb1e0; }
html[data-theme="dark"] .tag-suspected_supplement { color: #d4944a; }
html[data-theme="dark"] .tag-suspected_duplicate { color: #a48ad6; }
html[data-theme="dark"] .sort-button .sort-indicator { color: #8a949e; }
html[data-theme="dark"] .quota-heading { color: #9aa5b0; }
html[data-theme="dark"] .filter-edit { color: var(--accent); }
html[data-theme="dark"] .event-source-link { color: var(--accent); }
html[data-theme="dark"] .sort-button.active { color: var(--accent); }

/* 健康区 */
html[data-theme="dark"] .health-row { border-top-color: #242c34; }
html[data-theme="dark"] .health-row:nth-child(-n+3) { border-top-color: transparent; }

/* 抽屉遮罩 */
html[data-theme="dark"] .drawer-shade { background: rgb(0 0 0 / 45%); }
