:root {
  --navy: #17324d;
  --teal: #267f88;
  --coral: #df654f;
  --canvas: #f4f6f8;
  --panel: #ffffff;
  --muted: #667784;
  --border: #d9e0e5;
  --focus-inner: #ffffff;
  --focus-outer: #17324d;
  --shadow: 0 1px 2px rgb(23 50 77 / 6%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 0;
  color: var(--navy);
  background: var(--canvas);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 12px max(24px, calc((100% - 1440px) / 2));
  color: #fff;
  background: var(--navy);
}

.brand, .import-tools, .panel-heading, .filter-actions { display: flex; align-items: center; }
.brand { gap: 12px; min-width: 0; }
.brand-mark { display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; border: 1px solid rgb(255 255 255 / 65%); font-size: 18px; font-weight: 700; }
h1, h2, p { margin: 0; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 17px; line-height: 1.35; }
.eyebrow, .section-kicker { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0; }
.topbar .eyebrow { color: rgb(255 255 255 / 72%); }
.import-tools { justify-content: flex-end; gap: 12px; min-width: 0; }
.current-file { max-width: 220px; color: rgb(255 255 255 / 82%); font-size: 13px; overflow-wrap: anywhere; }

.button { min-height: 36px; padding: 7px 12px; border: 1px solid transparent; border-radius: 5px; font-weight: 700; white-space: nowrap; }
.button-primary { color: #fff; background: var(--teal); }
.button-primary:hover { background: #206c74; }
.button-secondary { color: var(--navy); background: #fff; border-color: var(--border); }
.button-quiet { color: var(--teal); background: transparent; border-color: #9fbdc0; }
.button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: 0.55; }
.button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus-inner); outline-offset: 2px; box-shadow: 0 0 0 5px var(--focus-outer); }

.dashboard-shell { width: min(1440px, 100%); margin: 0 auto; padding: 28px 24px 40px; }
.overview { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.overview h2 { margin-top: 3px; font-size: 22px; }
.date-summary { margin-top: 6px; color: var(--muted); font-size: 14px; }
.kpi { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 6px; min-width: 190px; padding: 14px 16px; border-left: 4px solid var(--coral); color: var(--navy); background: var(--panel); box-shadow: var(--shadow); }
.kpi span { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.kpi strong { font-size: 30px; line-height: 1.2; }
.kpi small { color: var(--muted); }

.filter-panel, .panel { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.filter-panel { margin-bottom: 20px; padding: 18px; }
.panel { min-width: 0; padding: 18px; }
.panel-heading { justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel-heading h2 { margin-top: 2px; }
#filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; align-items: end; }
label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
input, select { width: 100%; min-width: 0; height: 37px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; color: var(--navy); background: #fff; }
.filter-actions { height: 37px; }

.trend-mode-control { display: flex; flex: 0 0 auto; padding: 0; margin: 0; border: 0; }
.trend-mode-option { position: relative; display: block; color: var(--navy); cursor: pointer; }
.trend-mode-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.trend-mode-option span { display: grid; width: 38px; height: 32px; place-items: center; border: 1px solid var(--border); border-left-width: 0; background: #fff; font-size: 13px; font-weight: 700; }
.trend-mode-option:first-of-type span { border-left-width: 1px; border-radius: 4px 0 0 4px; }
.trend-mode-option:last-of-type span { border-radius: 0 4px 4px 0; }
.trend-mode-option input:checked + span { position: relative; z-index: 1; border-color: var(--teal); color: #fff; background: var(--teal); }
.trend-mode-option input:focus-visible + span { position: relative; z-index: 2; outline: 3px solid var(--focus-inner); outline-offset: 2px; box-shadow: 0 0 0 5px var(--focus-outer); }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.chart-panel-wide { grid-column: 1 / -1; }
.ranking-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.chart { width: 100%; min-height: 260px; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.sr-only[data-tone="error"] {
  position: fixed;
  z-index: 20;
  top: 88px;
  right: 24px;
  width: min(420px, calc(100vw - 48px));
  height: auto;
  padding: 10px 14px;
  margin: 0;
  overflow: visible;
  clip: auto;
  border: 1px solid var(--coral);
  border-radius: 5px;
  color: #7d2d22;
  background: #fff4f2;
  box-shadow: 0 4px 12px rgb(23 50 77 / 16%);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}

#upload-password-dialog {
  width: min(420px, calc(100vw - 32px));
  max-width: 420px;
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--navy);
  background: var(--panel);
  box-shadow: 0 14px 32px rgb(23 50 77 / 24%);
}

#upload-password-dialog::backdrop {
  background: rgb(23 50 77 / 42%);
}

#upload-password-form { padding: 20px; }
.upload-password-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.upload-password-heading h2 { margin-top: 2px; font-size: 18px; }
.upload-password-description { margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.upload-password-close { display: grid; flex: 0 0 36px; width: 36px; height: 36px; padding: 0; place-items: center; border: 1px solid transparent; border-radius: 4px; color: var(--muted); background: transparent; font-size: 24px; line-height: 1; }
.upload-password-close:hover { color: var(--navy); background: var(--canvas); }
.upload-password-toggle { display: flex; align-items: center; gap: 8px; width: fit-content; min-height: 36px; margin-top: 10px; color: var(--navy); cursor: pointer; }
.upload-password-toggle input { width: 18px; height: 18px; margin: 0; }
.upload-password-error { min-height: 21px; margin-top: 8px; color: #9b3528; font-size: 14px; }
.upload-password-error[hidden] { display: block; visibility: hidden; }
.upload-password-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.upload-password-close:focus-visible,
#upload-password-dialog input:focus-visible,
#upload-password-dialog button:focus-visible {
  outline: 3px solid var(--focus-inner);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-outer);
}

@media (max-width: 960px) {
  #filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-actions { grid-column: span 3; }
  .ranking-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar, .overview { align-items: flex-start; flex-direction: column; }
  .topbar { padding: 14px 16px; gap: 14px; }
  .import-tools { width: 100%; justify-content: space-between; }
  .current-file { flex: 1; max-width: min(58%, 220px); font-size: 13px; line-height: 1.35; text-align: right; }
  .sr-only[data-tone="error"] { top: 112px; right: 16px; width: calc(100vw - 32px); }
  .button, input, select { min-height: 44px; }
  .dashboard-shell { padding: 20px 16px 32px; }
  .overview { gap: 16px; }
  .kpi { width: 100%; }
  #filters, .chart-grid, .ranking-grid { grid-template-columns: 1fr; }
  .filter-actions { grid-column: auto; height: auto; min-height: 44px; }
  .chart-panel-wide { grid-column: auto; }
  .filter-panel, .panel { padding: 15px; }
  .trend-panel-heading { align-items: center; gap: 10px; }
  .trend-mode-option span { width: 44px; height: 44px; }
  #upload-password-dialog { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  #upload-password-form { padding: 16px; }
  .upload-password-close { flex-basis: 44px; width: 44px; min-width: 44px; }
  .upload-password-close,
  .upload-password-actions .button,
  .upload-password-toggle { min-height: 44px; }
  .upload-password-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
