:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #17201c;
  background: #f3f6f4;
  letter-spacing: 0;
  --ink: #17201c;
  --ink-soft: #52615a;
  --muted: #738079;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --line: #dce4df;
  --line-strong: #c7d2cc;
  --primary: #087a55;
  --primary-strong: #075f43;
  --teal: #1689a0;
  --amber: #b86c0f;
  --danger: #b4372d;
  --header: #151d1a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: #f3f6f4; }
body { margin: 0; min-width: 320px; background: #f3f6f4; color: var(--ink); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, .button-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 15px;
  background: var(--primary);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease;
}
button:hover, .button-link:hover { background: var(--primary-strong); }
button.secondary { border-color: var(--line); background: #fff; color: #304039; }
button.secondary:hover { border-color: #aabbb2; background: #f2f6f4; color: #17201c; }
button.danger { border-color: #f0d5d1; background: #fff; color: #a02e25; }
button.danger:hover { border-color: #e7b8b2; background: #fff1ef; }
button:disabled { cursor: not-allowed; opacity: .58; }
input, select, textarea {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 9px 11px;
  color: var(--ink);
  transition: border-color .14s ease, box-shadow .14s ease;
}
textarea { resize: vertical; line-height: 1.65; }
input::placeholder, textarea::placeholder { color: #929d97; }
input:focus, select:focus, textarea:focus, button:focus-visible, .button-link:focus-visible, a:focus-visible {
  outline: 2px solid rgba(8, 122, 85, .24);
  outline-offset: 2px;
  border-color: var(--primary);
}
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 23px; line-height: 1.25; }
h2 { margin-bottom: 5px; font-size: 21px; line-height: 1.3; }
h3 { margin: 0 0 4px; font-size: 16px; line-height: 1.35; }
h4 { margin: 0; font-size: 14px; line-height: 1.4; }
.muted { color: var(--muted); font-size: 13px; }

.topbar { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid #26332d; background: var(--header); color: #f7faf8; box-shadow: 0 5px 18px rgba(19, 30, 25, .12); }
.topbar-inner { display: flex; width: min(1440px, 100%); min-height: 78px; margin: 0 auto; padding: 13px 24px; align-items: center; justify-content: space-between; gap: 24px; }
.brand-block { display: flex; min-width: 230px; align-items: center; gap: 12px; }
.brand-symbol { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border: 1px solid #4b6257; border-radius: 7px; background: #202b26; color: #72d7b1; font-size: 12px; font-weight: 800; }
.eyebrow { margin-bottom: 3px; color: #72d7b1; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.header-actions { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 8px; }
.header-actions form { display: flex; margin: 0; }
.header-actions button { min-height: 38px; }
.header-actions button.secondary { border-color: #3b4b44; background: #202a26; color: #e7eeea; }
.header-actions button.secondary:hover { border-color: #586b62; background: #2a3731; color: #fff; }
.range-control { display: grid; grid-template-columns: auto 124px; align-items: center; gap: 8px; }
.range-control label { color: #9eada6; font-size: 12px; white-space: nowrap; }
.range-control select { min-height: 38px; border-color: #415149; background: #202a26; color: #f4f8f6; }
.action-divider { width: 1px; height: 24px; margin: 0 3px; background: #3a4842; }

.dashboard { width: min(1440px, 100%); margin: 0 auto; padding: 18px 24px 56px; }
.dashboard-toolbar { display: grid; grid-template-columns: auto minmax(280px, 1fr); align-items: center; gap: 24px; margin-bottom: 26px; }
.section-nav { display: flex; min-width: 0; align-items: center; gap: 22px; overflow-x: auto; scrollbar-width: none; }
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a { padding: 9px 0 8px; border-bottom: 2px solid transparent; color: #53645c; font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.section-nav a:hover { border-bottom-color: var(--primary); color: var(--primary); }
.notice { min-width: 0; margin: 0; padding: 9px 12px; border: 1px solid #cfe0d8; border-left: 3px solid var(--primary); border-radius: 5px; background: #f9fcfa; color: #496057; font-size: 12px; line-height: 1.5; }
.page-error, .form-error { margin: 0 0 18px; padding: 10px 12px; border: 1px solid #edcbc6; border-left: 3px solid var(--danger); border-radius: 5px; background: #fff5f3; color: #922b22; font-size: 13px; }
.workspace-section { scroll-margin-top: 98px; }
.workspace-section + .workspace-section { margin-top: 34px; }
.workspace-heading { display: flex; margin-bottom: 14px; align-items: flex-end; justify-content: space-between; gap: 20px; }
.workspace-heading h2 { margin-bottom: 3px; }
.workspace-heading p:not(.section-kicker) { margin-bottom: 0; color: var(--ink-soft); font-size: 13px; }
.section-kicker { margin-bottom: 4px; color: var(--teal); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.updated-at, .section-summary { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.dashboard-panel, .metric-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 3px 12px rgba(30, 49, 40, .045); }
.dashboard-panel { padding: 18px; }
.panel-heading { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { position: relative; min-height: 116px; overflow: hidden; padding: 17px 18px 15px; }
.metric-card::before { position: absolute; inset: 0 0 auto; height: 3px; background: var(--primary); content: ""; }
.metric-card.tone-teal::before { background: var(--teal); }
.metric-card.tone-amber::before { background: var(--amber); }
.metric-card.tone-neutral::before { background: #7a8982; }
.metric-card span { display: block; color: var(--ink-soft); font-size: 12px; font-weight: 650; }
.metric-card strong { display: block; margin-top: 12px; font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1; }
.metric-card small { display: block; margin-top: 10px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.trend-panel { margin-top: 12px; padding-bottom: 10px; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 14px; color: var(--ink-soft); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: #9fd8c3; }
.legend-swatch.connected { background: var(--primary); }
.trend-chart { height: 274px; margin-top: 10px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-inline: contain; scrollbar-color: #bdcbc4 transparent; scrollbar-width: thin; }
.trend-svg { display: block; width: 100%; min-width: 760px; height: 262px; }
.trend-svg .gridline { stroke: #e3eae6; stroke-width: 1; stroke-dasharray: 3 5; }
.trend-svg .axis { stroke: #c5d1cb; stroke-width: 1; }
.trend-svg .bar { fill: #a6d9c6; cursor: pointer; transition: fill .12s ease; }
.trend-svg .bar-connected { fill: var(--primary); pointer-events: none; }
.trend-svg .day-group:hover .bar, .trend-svg .day-group:focus-visible .bar { fill: #84cbb0; }
.trend-svg .day-group:hover .bar-connected, .trend-svg .day-group:focus-visible .bar-connected { fill: #056846; }
.trend-svg .day-group:focus-visible { outline: none; }
.trend-svg .day-group:focus-visible .bar { stroke: #064832; stroke-width: 2; }
.trend-svg text { fill: #69776f; font-size: 10px; font-variant-numeric: tabular-nums; }
.trend-svg .y-axis-label { fill: #86938d; }

.map-panel { padding: 0; overflow: hidden; position: relative; }
.map-toolbar { display: flex; flex-wrap: wrap; min-height: 60px; padding: 10px 14px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.map-toolbar-group { display: flex; align-items: center; gap: 8px; }
.map-toolbar label { color: var(--ink-soft); font-size: 12px; font-weight: 700; white-space: nowrap; }
.map-toolbar select { width: auto; min-width: 135px; min-height: 38px; }
.map-date-picker-wrap { display: flex; align-items: center; gap: 8px; }
.map-date-picker-wrap[hidden] { display: none !important; }
.map-date-box { display: inline-flex; align-items: center; gap: 6px; }
.map-date-box[hidden] { display: none !important; }
.map-date-input { width: 140px; min-height: 38px; padding: 6px 9px; font-size: 12px; font-variant-numeric: tabular-nums; }
.map-date-sep { color: var(--muted); font-size: 12px; }
.map-apply-btn { min-height: 38px; padding: 0 13px; font-size: 12px; font-weight: 700; border-radius: 6px; }
.map-status { min-width: 0; margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }

.map-stage { position: relative; width: 100%; overflow: hidden; }
.distribution-map { width: 100%; height: 530px; background: #e8efeb; }

/* Device Trajectory Overlay Panel */
.map-track-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1001;
  width: min(370px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(18, 46, 35, 0.18);
  overflow: hidden;
  animation: trackPanelFadeIn .18s ease-out;
}
.map-track-panel[hidden] { display: none !important; }
@keyframes trackPanelFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.track-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}
.track-panel-title-block { display: flex; flex-direction: column; gap: 3px; }
.track-badge-row { display: flex; align-items: center; gap: 8px; }
.track-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 1px 6px;
  background: rgba(8, 122, 85, 0.12);
  color: var(--primary);
  font-size: 10px;
  font-weight: 750;
  border-radius: 4px;
  letter-spacing: .2px;
}
.track-range-pills { display: inline-flex; background: #e2ece7; padding: 2px; border-radius: 5px; gap: 2px; }
.track-pill {
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .12s ease;
}
.track-pill:hover { color: var(--ink); background: rgba(255, 255, 255, 0.6); }
.track-pill.active {
  background: #fff;
  color: var(--primary);
  font-weight: 750;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.track-title { margin: 2px 0 0; font-size: 13.5px; font-weight: 750; color: var(--ink); }
.track-range-text { font-size: 11px; color: var(--muted); }
.track-exit-btn {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 650;
  color: #55655e;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  cursor: pointer;
  transition: all .14s ease;
}
.track-exit-btn:hover {
  background: #fff2f0;
  border-color: #eed0cb;
  color: var(--danger);
}
.track-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 12px;
  background: #fbfdfc;
  border-bottom: 1px solid var(--line);
}
.track-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.track-summary-val { font-size: 13px; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; }
.track-summary-lbl { font-size: 10px; color: var(--muted); margin-top: 1px; }

.track-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  overflow-y: auto;
  max-height: 280px;
}
.track-timeline-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  transition: all .14s ease;
}
.track-timeline-item:hover, .track-timeline-item.active {
  border-color: var(--primary);
  background: #f4fbf8;
  box-shadow: 0 2px 8px rgba(8, 122, 85, 0.08);
}
.track-item-row { display: flex; align-items: center; justify-content: space-between; }
.track-item-day { display: flex; align-items: center; gap: 6px; }
.track-dot-seq {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
}
.track-dot-seq.is-latest { background: var(--amber); }
.track-item-date { font-size: 12px; font-weight: 750; color: var(--ink); }
.track-item-time { font-size: 11px; color: var(--muted); }
.track-item-metrics { font-size: 11px; color: var(--ink-soft); display: flex; gap: 8px; padding-left: 26px; }

/* Track marker on map */
.map-track-marker {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #087a55;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.32);
}
.map-track-marker.is-latest {
  background: #b86c0f;
  box-shadow: 0 0 0 3px rgba(184, 108, 15, 0.28), 0 4px 12px rgba(0, 0, 0, 0.38);
}
.track-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 32px;
  margin-top: 10px;
  padding: 0 10px;
  background: var(--primary);
  color: #fff;
  font-size: 11.5px;
  font-weight: 650;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color .14s ease;
}
.track-action-btn:hover { background: var(--primary-strong); }

.map-note { margin: 0; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.5; }
.map-error { margin: 0; padding: 10px 14px; border-top: 1px solid #edcbc6; background: #fff5f3; color: #922b22; font-size: 12px; }
.map-error[hidden] { display: none; }
.map-value-icon { background: transparent; border: 0; }
.map-value-marker { display: grid; width: 100%; height: 100%; place-items: center; border: 2px solid rgba(255, 255, 255, .9); border-radius: 50%; background: rgba(8, 122, 85, .9); color: #fff; font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums; box-shadow: 0 4px 13px rgba(18, 46, 35, .28); }
.map-value-marker.device-group { background: rgba(22, 137, 160, .92); }
.map-popup { min-width: 220px; color: var(--ink); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
.map-popup h4 { margin: 0 0 8px; }
.map-popup dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 10px; margin: 0; font-size: 12px; }
.map-popup dt { color: var(--muted); }
.map-popup dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.map-device-list { max-height: 190px; margin: 10px 0 0; padding: 8px 0 0; overflow-y: auto; border-top: 1px solid var(--line); list-style: none; }
.map-device-list li { padding: 5px 0; color: var(--ink-soft); font-size: 11px; line-height: 1.45; }
.map-device-list li + li { border-top: 1px solid #edf1ef; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; }

.split-grid { display: grid; grid-template-columns: 1.1fr .8fr 1.1fr; gap: 12px; }
.dimension-panel { min-width: 0; }
.dimension-group { margin-top: 18px; }
.dimension-group + .dimension-group { padding-top: 16px; border-top: 1px solid #e7ece9; }
.dimension-label { display: block; margin-bottom: 9px; color: #849089; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.bar-list { display: grid; gap: 5px; min-height: 24px; }
.bar-list > .muted { margin: 4px 0 0; }
.bar-row { display: grid; min-width: 0; grid-template-columns: minmax(82px, 1fr) minmax(72px, 1.7fr) auto; align-items: center; gap: 9px; padding: 7px 6px; border-radius: 5px; font-size: 12px; cursor: default; transition: background-color .12s ease; }
.bar-row > span:first-child { min-width: 0; overflow: hidden; color: #44534c; text-overflow: ellipsis; white-space: nowrap; }
.bar-row > strong { min-width: 24px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.bar-row:hover, .bar-row:focus-visible { background: #f0f6f3; }
.bar-row:focus-visible { outline: 2px solid rgba(8, 122, 85, .45); outline-offset: 0; }
.bar-track { width: 100%; height: 8px; overflow: hidden; border-radius: 4px; background: #e8efeb; }
.bar-fill { display: block; height: 100%; min-width: 2px; border-radius: 4px; background: var(--teal); transition: width .18s ease, background-color .12s ease; }
.bar-row:hover .bar-fill, .bar-row:focus-visible .bar-fill { background: #0c6d80; }

.announcement-layout { display: grid; grid-template-columns: minmax(320px, .86fr) minmax(0, 1.4fr); align-items: start; gap: 12px; }
.announcement-composer, .announcement-history { min-width: 0; }
.delivery-badge { flex: 0 0 auto; padding: 4px 7px; border: 1px solid #d7e4de; border-radius: 4px; background: #f4f8f6; color: #53665d; font-size: 10px; font-weight: 700; white-space: nowrap; }
.announcement-form { display: grid; gap: 7px; margin-top: 18px; }
.announcement-form label, .announcement-edit-form label, .password-form label { margin-top: 6px; color: #3d4d45; font-size: 12px; font-weight: 700; }
.announcement-form textarea { min-height: 148px; }
.form-footer { display: flex; margin-top: 7px; align-items: center; justify-content: space-between; gap: 12px; }
.character-count { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.form-status { margin: 5px 0 0; padding: 9px 10px; border: 1px solid #cde1d7; border-left: 3px solid var(--primary); border-radius: 5px; background: #f4faf7; color: #28543f; font-size: 12px; }
.announcement-history { padding-bottom: 8px; }
.announcement-list { max-height: 520px; margin: 10px -8px 0; padding: 0 8px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #bdcbc4 transparent; scrollbar-width: thin; }
.announcement-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 14px 8px; border-top: 1px solid #e5ebe8; }
.announcement-item:first-child { border-top: 0; }
.announcement-item.current { border-radius: 6px; background: #f1f8f5; box-shadow: inset 3px 0 0 var(--primary); }
.announcement-item-body { min-width: 0; }
.announcement-item-header { display: flex; min-width: 0; margin-bottom: 7px; align-items: center; flex-wrap: wrap; gap: 7px; }
.announcement-item-meta { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.announcement-status-tag { display: inline-flex; min-height: 22px; align-items: center; border: 1px solid #d5dfda; border-radius: 4px; padding: 0 7px; background: #f4f7f5; color: #65736c; font-size: 10px; font-weight: 700; }
.announcement-status-tag.active { border-color: #bbdccc; background: #eaf6f0; color: #096443; }
.announcement-item h4 { margin-bottom: 5px; color: #22302a; }
.announcement-content { display: -webkit-box; margin: 0; overflow: hidden; color: #53615a; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.announcement-actions { display: flex; align-items: flex-start; gap: 6px; }
.announcement-actions button { min-height: 32px; padding: 0 10px; font-size: 11px; }
.empty-state { display: grid; min-height: 150px; place-items: center; margin: 0; color: var(--muted); font-size: 12px; text-align: center; }

.table-panel { padding: 0; overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-color: #bdcbc4 transparent; scrollbar-width: thin; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12px; }
.recent-table { min-width: 960px; }
.data-table th, .data-table td { height: 46px; padding: 10px 13px; border-bottom: 1px solid #e6ece8; text-align: left; vertical-align: middle; }
.data-table th { background: #f4f7f5; color: #68766f; font-size: 10px; font-weight: 750; text-transform: uppercase; white-space: nowrap; }
.data-table td { overflow: hidden; color: #34433c; text-overflow: ellipsis; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #f8fbf9; }
.recent-table th:nth-child(1) { width: 155px; }
.recent-table th:nth-child(2) { width: 125px; }
.recent-table th:nth-child(3) { width: 78px; }
.recent-table th:nth-child(4) { width: 88px; }
.recent-table th:nth-child(5) { width: 96px; }
.recent-table th:nth-child(6) { width: 240px; }
.recent-table th:nth-child(7) { width: 140px; }
.cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.mode-tag { display: inline-flex; min-height: 24px; align-items: center; border: 1px solid #c8ddd3; border-radius: 4px; padding: 0 7px; background: #edf7f2; color: #0b6243; font-size: 10px; font-weight: 750; }

dialog { max-width: none; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); box-shadow: 0 20px 52px rgba(17, 29, 23, .24); }
dialog::backdrop { background: rgba(19, 28, 24, .58); }
.password-form, .announcement-edit-form { display: grid; width: min(430px, calc(100vw - 32px)); gap: 7px; padding: 24px; }
.announcement-edit-form { width: min(620px, calc(100vw - 32px)); }
.password-form h2, .announcement-edit-form h2 { margin-bottom: 4px; }
.announcement-edit-form textarea { min-height: 190px; }
.announcement-edit-form .form-footer { justify-content: flex-end; }
.password-form .form-error, .announcement-edit-form .form-error { margin: 8px 0 0; }
.dialog-actions { display: flex; margin-top: 13px; justify-content: flex-end; gap: 8px; }
.apk-dialog-panel { width: min(560px, calc(100vw - 32px)); padding: 24px; }
.apk-dialog-panel h2 { margin-bottom: 0; }
.dialog-loading { display: flex; min-height: 220px; align-items: center; justify-content: center; gap: 12px; color: var(--ink-soft); }
.dialog-loading[hidden], #apk-content[hidden], #apk-error[hidden] { display: none; }
.apk-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); margin-top: 20px; align-items: center; gap: 24px; }
.apk-qr { display: grid; width: 220px; aspect-ratio: 1; place-items: center; padding: 10px; border: 1px solid var(--line); background: #fff; }
.apk-qr svg { display: block; width: 100%; height: 100%; }
.apk-details { display: grid; min-width: 0; grid-template-columns: auto minmax(0, 1fr); gap: 9px 12px; margin: 0; font-size: 12px; }
.apk-details dt { color: var(--muted); }
.apk-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-weight: 700; }
#apk-error .form-error { margin: 20px 0 0; }

.login-page { background: #eef3f0; }
.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-panel { width: min(420px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 14px 38px rgba(25, 40, 33, .1); }
.brand-mark { display: grid; width: 42px; height: 42px; margin-bottom: 20px; place-items: center; border-radius: 7px; background: var(--header); color: #72d7b1; font-weight: 800; }
.login-panel h1 { margin-bottom: 10px; }
.login-form { display: grid; gap: 8px; margin-top: 24px; }
.login-form label { margin-top: 6px; font-size: 12px; font-weight: 700; }
.login-form button { margin-top: 10px; }

.loading-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(243, 246, 244, .86); }
.loading-overlay[hidden] { display: none; }
.loading-box { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: 0 12px 30px rgba(24, 38, 31, .14); }
.spinner { width: 19px; height: 19px; border: 3px solid #d4e4dc; border-top-color: var(--primary); border-radius: 50%; animation: spin .75s linear infinite; }
.chart-tooltip { position: fixed; z-index: 30; max-width: min(300px, calc(100vw - 24px)); padding: 9px 11px; border: 1px solid #3f5249; border-radius: 5px; background: #16201b; color: #fff; font-size: 11px; line-height: 1.6; white-space: pre-line; pointer-events: none; box-shadow: 0 8px 22px rgba(18, 30, 24, .22); }
.chart-tooltip[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  .topbar-inner { align-items: flex-start; }
  .header-actions { flex-wrap: wrap; }
  .dashboard-toolbar { grid-template-columns: 1fr; gap: 10px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid > :last-child { grid-column: 1 / -1; }
  .announcement-layout { grid-template-columns: minmax(300px, .8fr) minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .topbar { position: static; }
  .topbar-inner { flex-direction: column; gap: 13px; padding-top: 14px; padding-bottom: 14px; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .action-divider { display: none; }
  .workspace-section { scroll-margin-top: 16px; }
  .announcement-layout, .split-grid { grid-template-columns: 1fr; }
  .split-grid > :last-child { grid-column: auto; }
  .announcement-list { max-height: 440px; }
}

@media (max-width: 560px) {
  .topbar-inner, .dashboard { padding-right: 14px; padding-left: 14px; }
  .brand-symbol { width: 38px; height: 38px; }
  h1 { font-size: 21px; }
  h2 { font-size: 19px; }
  .header-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-actions .range-control { grid-column: 1 / -1; grid-template-columns: auto minmax(0, 1fr); }
  .header-actions button, .header-actions form, .header-actions form button { width: 100%; }
  .dashboard { padding-top: 12px; padding-bottom: 40px; }
  .dashboard-toolbar { margin-bottom: 22px; }
  .section-nav { gap: 18px; }
  .metrics-grid { grid-template-columns: 1fr; gap: 9px; }
  .metric-card { min-height: 102px; }
  .workspace-section + .workspace-section { margin-top: 28px; }
  .workspace-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .dashboard-panel { padding: 15px; }
  .panel-heading { flex-direction: column; gap: 8px; }
  .chart-legend { justify-content: flex-start; }
  .trend-panel { padding-right: 9px; padding-left: 9px; }
  .trend-chart { height: 260px; }
  .trend-svg { height: 248px; }
  .map-toolbar { align-items: stretch; flex-direction: column; gap: 8px; }
  .map-toolbar select { width: 100%; }
  .map-toolbar-group { width: 100%; justify-content: space-between; }
  .map-date-picker-wrap { width: 100%; }
  .map-date-box { width: 100%; display: flex; align-items: center; gap: 6px; }
  .map-date-input { flex: 1; min-width: 0; }
  .map-status { width: 100%; margin-left: 0; text-align: left; }
  .map-track-panel { width: calc(100% - 20px); top: 10px; right: 10px; max-height: calc(100% - 20px); }
  .distribution-map { height: 430px; }
  .announcement-item { grid-template-columns: 1fr; gap: 10px; }
  .announcement-actions { justify-content: flex-end; }
  .announcement-list { max-height: none; }
  .bar-row { grid-template-columns: minmax(78px, 1fr) minmax(68px, 1.5fr) auto; }
  .apk-dialog-panel, .password-form, .announcement-edit-form { padding: 20px; }
  .apk-layout { grid-template-columns: 1fr; justify-items: center; gap: 18px; }
  .apk-qr { width: min(220px, 100%); }
  .apk-details { width: 100%; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button, .dialog-actions .button-link { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
