:root {
  --bg: #f4f6f8;
  --bg-soft: #eef3f8;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --muted-strong: #475569;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #1769aa;
  --primary-hover: #0f4f84;
  --primary-soft: #e8f3fb;
  --sider: #0d1b2a;
  --sider-panel: #12263a;
  --sider-active: #1f7ab8;
  --danger: #cf1322;
  --danger-soft: #fff1f2;
  --success: #237804;
  --success-soft: #edf7ed;
  --warning: #b26a00;
  --warning-soft: #fff7e6;
  --radius: 8px;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.monitoring-stat-grid {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.command-grid,
.report-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.report-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.command-grid article,
.report-grid article {
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 14px;
}

.command-grid span,
.report-grid span,
.map-governance-panel span {
  color: var(--muted);
  font-size: .82rem;
}

.command-grid strong,
.report-grid strong {
  color: var(--text);
  font-size: 1.4rem;
}

.command-grid p,
.report-grid p,
.quality-notes {
  color: var(--muted-strong);
  font-size: .86rem;
  margin: 0;
}

.quality-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.quality-notes span {
  background: var(--primary-soft);
  border: 1px solid #cfe5f6;
  border-radius: 999px;
  color: #155b91;
  padding: 6px 10px;
}

.filter-details summary {
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 800;
}

.filter-details > p {
  color: var(--muted);
  margin: 8px 0 14px;
}

.monitoring-grid .span-6 {
  grid-column: span 6;
}

.monitoring-grid .span-12 {
  grid-column: 1 / -1;
}

.monitoring-chart {
  min-height: 330px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.map-governance-panel {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(180px, 1fr) 2fr;
  margin-bottom: 16px;
  padding: 14px;
}

.map-governance-panel h3,
.map-governance-panel p {
  margin: 0;
}

.map-governance-panel p {
  color: var(--muted);
  font-size: .9rem;
}

.map-governance-panel dl {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  margin: 0;
}

.map-governance-panel dt {
  color: var(--muted);
  font-size: .78rem;
}

.map-governance-panel dd {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
}

.checkbox-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.checkbox-row input {
  min-height: auto;
  width: auto;
}

.muted-text {
  color: var(--muted);
  font-size: .82rem;
}

.trend-timeline-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: baseline;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .84rem;
}

.trend-timeline-summary strong {
  color: var(--text);
  font-size: .98rem;
}

.trend-timeline-chart {
  position: relative;
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 8px;
  color: var(--muted-strong);
  font-size: .82rem;
}

.trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trend-legend i {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  display: inline-block;
}

.legend-daily {
  background: #2f6fdd;
}

.legend-growth {
  background: #d98a05;
}

.trend-line-wrap {
  position: relative;
  overflow-x: auto;
  padding-bottom: 4px;
}

.trend-line-svg {
  display: block;
  min-width: 660px;
  touch-action: pan-y;
}

.trend-grid {
  stroke: #e2e8f0;
  stroke-width: 1;
}

.trend-axis {
  stroke: #94a3b8;
  stroke-width: 1.2;
}

.trend-axis-label,
.trend-date-label {
  fill: var(--muted);
  font-size: 12px;
}

.trend-series {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.trend-series.daily {
  stroke: #2f6fdd;
}

.trend-series.growth {
  stroke: #d98a05;
}

.trend-point {
  fill: #ffffff;
  stroke-width: 2.5;
}

.trend-point.daily,
.trend-focus-dot.daily {
  stroke: #2f6fdd;
}

.trend-point.growth,
.trend-focus-dot.growth {
  stroke: #d98a05;
}

.trend-focus-line {
  stroke: #64748b;
  stroke-dasharray: 4 5;
  stroke-width: 1.2;
}

.trend-focus-dot {
  fill: #ffffff;
  stroke-width: 3;
}

.trend-hit-area {
  cursor: crosshair;
  pointer-events: all;
}

.trend-hover-card {
  position: absolute;
  left: 0;
  top: 0;
  width: 150px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}

.trend-hover-card span,
.trend-hover-card em {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  font-style: normal;
}

.trend-hover-card strong {
  display: block;
  margin: 2px 0;
  color: var(--text);
  font-size: .9rem;
}

.daily-action-panel {
  margin: 0 0 14px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.daily-action-summary span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
}

.daily-action-summary strong {
  display: block;
  margin: 5px 0;
  color: var(--text);
  font-size: 1.25rem;
}

.daily-action-summary p {
  margin: 0;
  color: var(--muted-strong);
  font-size: .84rem;
  line-height: 1.5;
}

.daily-action-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.daily-action-card {
  min-height: 94px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.daily-action-card.priority-high {
  border-left-color: #dc2626;
}

.daily-action-card.priority-medium {
  border-left-color: #d98a05;
}

.daily-action-card.priority-low {
  border-left-color: #64748b;
}

.daily-action-card span,
.daily-action-card small,
.daily-action-card em {
  color: var(--muted);
  font-size: .74rem;
  font-style: normal;
}

.daily-action-card strong {
  display: block;
  margin: 3px 0;
  color: var(--text);
}

.daily-action-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 6px;
  align-content: start;
  color: var(--muted);
  font-size: .74rem;
}

.daily-action-card dd {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.daily-action-card em {
  grid-column: 1 / -1;
  color: var(--muted-strong);
}

.priority-pill {
  display: inline-flex;
  min-width: 30px;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  color: #ffffff;
  font-size: .76rem;
  font-weight: 700;
}

.priority-高 {
  background: #dc2626;
}

.priority-中 {
  background: #d98a05;
}

.priority-低 {
  background: #64748b;
}

.monitoring-chart:empty {
  color: var(--muted);
}

.monitoring-proportions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.monitoring-proportions h3 {
  margin: 0 0 8px;
  font-size: .92rem;
}

.monitoring-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.monitoring-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

.map-section-header {
  align-items: flex-start;
  gap: 12px;
}

.inline-switch-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.inline-switch-form label {
  min-width: 220px;
}

.map-layout-expanded {
  grid-template-columns: 1fr;
}

.monitoring-map-expanded {
  width: 100%;
}

.monitoring-map {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.monitoring-map img {
  display: block;
  width: 100%;
  height: auto;
}

.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 999px;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 26px;
  background: #64748b;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .28);
  cursor: pointer;
}

.risk-severe {
  background: #dc2626;
}

.risk-high {
  background: #f97316;
}

.risk-improving {
  background: #16a34a;
}

.risk-normal {
  background: #64748b;
}

.point-detail-panel,
.calibration-side {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.point-detail-panel span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .78rem;
}

.point-detail-panel strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.point-detail-panel dl {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px;
  margin: 12px 0 0;
}

.point-detail-panel dt {
  color: var(--muted);
}

.point-detail-panel dd {
  margin: 0;
}

.point-detail-strip {
  align-items: center;
  display: grid;
  gap: 8px 16px;
  grid-template-columns: auto minmax(120px, 180px) minmax(0, 1fr) auto;
}

.point-detail-strip span,
.point-detail-strip strong,
.point-detail-strip p,
.point-detail-strip dl {
  margin: 0;
}

.point-detail-strip dl {
  grid-template-columns: repeat(4, auto);
}

.calibration-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.calibration-marker {
  cursor: grab;
}

.calibration-form {
  display: grid;
  gap: 12px;
}

.calibration-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.unpositioned-list {
  margin-top: 18px;
}

.unpositioned-list h3 {
  margin: 0 0 8px;
  font-size: .92rem;
}

.text-row {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  color: var(--text);
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 900px) {
  .command-grid,
  .report-grid,
  .map-governance-panel,
  .map-governance-panel dl {
    grid-template-columns: 1fr 1fr;
  }

  .monitoring-grid .span-6,
  .monitoring-grid .span-12 {
    grid-column: 1 / -1;
  }

  .monitoring-proportions,
  .monitoring-map-layout,
  .calibration-layout {
    grid-template-columns: 1fr;
  }

  .inline-switch-form {
    justify-content: flex-start;
    width: 100%;
  }

  .inline-switch-form label,
  .point-detail-strip {
    width: 100%;
  }

  .point-detail-strip {
    grid-template-columns: 1fr;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

button,
input,
select,
textarea {
  border-radius: 6px;
  font: inherit;
  min-height: 34px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 0 11px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(23, 105, 170, 0.28);
  outline-offset: 2px;
}

textarea {
  line-height: 1.55;
  min-height: 120px;
  padding: 10px 11px;
  resize: vertical;
}

input[type="file"] {
  height: auto;
  padding: 7px 10px;
}

button,
.button-link,
.primary-action,
.button-secondary {
  align-items: center;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 500;
  justify-content: center;
  min-height: 34px;
  padding: 0 15px;
  white-space: nowrap;
}

button:hover,
.button-link:hover,
.primary-action:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.secondary-button,
.button-secondary,
.row-edit summary,
details.row-actions > summary {
  background: #fff;
  border-color: var(--line-strong);
  color: #374151;
}

.secondary-button:hover,
.button-secondary:hover,
.row-edit summary:hover,
details.row-actions > summary:hover {
  background: var(--panel-muted);
  border-color: #bfbfbf;
  color: #111827;
}

.button-secondary {
  color: var(--muted-strong);
}

.danger-button {
  background: var(--danger);
  border-color: var(--danger);
}

.danger-button:hover {
  background: #a8071a;
  border-color: #a8071a;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sider {
  background: var(--sider);
  color: rgba(255, 255, 255, 0.86);
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  gap: 10px;
  height: 64px;
  padding: 0 18px;
}

.brand:hover {
  color: #fff;
}

.brand-mark {
  align-items: center;
  background: #2f8cc9;
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-size: 16px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand small {
  color: rgba(255, 255, 255, 0.48);
  font-size: 11px;
  margin-top: 3px;
}

.side-nav {
  display: grid;
  gap: 12px;
  padding: 14px 10px 18px;
}

.nav-group {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  padding: 8px;
}

.side-nav a {
  align-items: center;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.78);
  display: grid;
  font-size: 14px;
  gap: 2px;
  min-height: 48px;
  padding: 8px 10px;
}

.side-nav a:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.side-nav a.active {
  background: var(--sider-active);
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.62);
  color: #fff;
}

.side-nav a span,
.side-nav a small {
  min-width: 0;
}

.side-nav a small {
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  line-height: 1.25;
}

.side-nav a.active small,
.side-nav a:hover small {
  color: rgba(255, 255, 255, 0.76);
}

.side-nav .nav-section {
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  padding: 2px 10px 5px;
}

.app-main {
  min-width: 0;
}

.app-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: var(--shadow-soft);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 72px;
  padding: 13px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.breadcrumb {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: 0 0 2px;
}

.app-header h1 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}

.header-actions,
.page-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.content-card,
.table-card,
.module-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 18px;
}

.filter-form {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.filter-form label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 6px;
}

.filter-form input,
.filter-form select {
  width: 100%;
}

.filter-form .form-actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.table-card {
  overflow-x: auto;
}

.module-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.module-card {
  display: grid;
  gap: 14px;
}

.module-grid > .content-card {
  display: grid;
  gap: 14px;
  grid-column: span 8;
}

.monitoring-grid > .content-card.span-6 {
  grid-column: span 6;
}

.monitoring-grid > .content-card.span-12 {
  grid-column: 1 / -1;
}

.module-card.span-4 {
  grid-column: span 4;
}

.module-card.span-6 {
  grid-column: span 6;
}

.module-card.span-8 {
  grid-column: span 8;
}

.module-card.span-12 {
  grid-column: 1 / -1;
}

.module-card.compact {
  gap: 10px;
}

.module-card.is-muted {
  background: var(--panel-muted);
  box-shadow: none;
}

.module-heading {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.module-heading h2,
.module-heading h3 {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.3;
  margin: 0;
}

.module-heading p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 4px 0 0;
}

.module-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
}

.quick-links {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.quick-link {
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 14px;
}

.quick-link:hover {
  background: var(--primary-soft);
  border-color: #b7d8ef;
  color: var(--text);
}

.quick-link strong,
.quick-link span {
  display: block;
}

.quick-link strong {
  font-size: 15px;
}

.quick-link span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.page-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 0 16px;
}

.page-header h2,
.section-title h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

.page-header p,
.section-title span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin: 4px 0 0;
}

.stat-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 18px;
  position: relative;
}

.stat-card::before {
  border-radius: 7px 0 0 7px;
  bottom: 0;
  content: "";
  left: 0;
  position: absolute;
  top: 0;
  width: 4px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  font-size: 30px;
  font-weight: 650;
  line-height: 1;
}

.accent-blue::before {
  background: var(--primary);
}

.accent-green::before {
  background: var(--success);
}

.accent-amber::before {
  background: var(--warning);
}

.accent-gray::before {
  background: #8c8c8c;
}

.accent-red::before {
  background: var(--danger);
}

.status-pill {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  min-height: 24px;
  padding: 2px 9px;
  white-space: nowrap;
}

.status-pill.success {
  background: var(--success-soft);
  border-color: #cde7c8;
  color: var(--success);
}

.status-pill.warning {
  background: var(--warning-soft);
  border-color: #ffdca8;
  color: var(--warning);
}

.status-pill.danger {
  background: var(--danger-soft);
  border-color: #ffcdd2;
  color: var(--danger);
}

.status-pill.neutral {
  background: var(--panel-muted);
  color: var(--muted-strong);
}

.meta {
  display: grid;
  gap: 0;
  grid-template-columns: 120px minmax(0, 1fr);
  margin: 14px 0 0;
}

.meta.compact {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.meta dt,
.meta dd {
  border-bottom: 1px solid var(--line);
  margin: 0;
  min-width: 0;
  padding: 10px 12px;
}

.meta dt {
  background: #fafafa;
  color: var(--muted);
  font-weight: 600;
}

.meta dd {
  overflow-wrap: anywhere;
}

.meta dt:nth-last-child(-n + 2),
.meta dd:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.form,
.grid-form,
.import-form,
.stack-form {
  display: grid;
  gap: 12px;
}

.form {
  margin-top: 16px;
}

.grid-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.grid-form + .grid-form {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.grid-form label,
.import-form label,
.form label,
.stack-form label {
  color: #374151;
  display: grid;
  font-size: 13px;
  font-weight: 600;
  gap: 6px;
}

.stack-form {
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 8px;
  padding: 12px;
}

.import-form {
  align-items: end;
  background: var(--panel-muted);
  border: 1px dashed #bfbfbf;
  border-radius: var(--radius);
  grid-template-columns: minmax(220px, 1fr) auto;
  margin: 0 0 16px;
  padding: 12px;
}

.module-card .import-form {
  grid-template-columns: 1fr;
  margin: 0;
}

.module-card .import-form button {
  width: 100%;
}

.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}

.toolbar.between {
  justify-content: space-between;
}

.segmented {
  background: var(--panel-muted);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  display: inline-flex;
  overflow: hidden;
}

.segmented a {
  color: #374151;
  font-size: 13px;
  min-height: 32px;
  padding: 7px 14px;
}

.segmented a + a {
  border-left: 1px solid var(--line-strong);
}

.segmented a.active {
  background: var(--primary);
  color: #fff;
}

.inline-form,
.header-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.checkbox-line,
.checkbox-label {
  align-items: center;
  display: flex !important;
  gap: 8px !important;
}

.checkbox-line input,
.checkbox-label input {
  min-height: 16px;
  width: auto;
}

.inline-form {
  margin-bottom: 8px;
}

.row-actions {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 260px;
}

details.row-actions {
  display: grid;
  min-width: 220px;
}

.row-actions .inline-form {
  margin-bottom: 0;
}

.row-edit {
  min-width: 72px;
}

.row-edit summary,
details.row-actions > summary {
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 500;
  justify-content: center;
  list-style: none;
  min-height: 34px;
  padding: 0 15px;
  user-select: none;
  white-space: nowrap;
}

.row-edit summary::-webkit-details-marker,
details.row-actions > summary::-webkit-details-marker {
  display: none;
}

.table-edit-form {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  margin-top: 8px;
  min-width: 420px;
  padding: 12px;
}

table {
  border-collapse: collapse;
  min-width: 960px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel-muted);
  color: #4b5563;
  font-weight: 600;
}

tbody tr:hover {
  background: #f7fbff;
}

td a {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.error,
.scan-error {
  color: var(--danger);
  font-weight: 600;
}

.hint {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.compact-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.compact-row {
  align-items: center;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(120px, 1fr) minmax(180px, 1.2fr) minmax(180px, 1.6fr);
  padding: 10px 12px;
}

@media (min-width: 721px) {
  .table-card th:last-child,
  .table-card td:last-child {
    background: #fff;
    box-shadow: -1px 0 0 var(--line);
    position: sticky;
    right: 0;
    z-index: 1;
  }

  .table-card th:last-child {
    background: var(--panel-muted);
    z-index: 2;
  }
}

.empty-state {
  background: var(--panel-muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted-strong);
  padding: 18px;
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}

.empty-state p {
  line-height: 1.6;
  margin: 0;
}

.notice-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted-strong);
  line-height: 1.6;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.notice-box.warning {
  background: var(--warning-soft);
  border-color: #ffdca8;
  color: #7a4a00;
}

.auth-shell {
  align-items: center;
  background: var(--bg);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 400px;
  padding: 28px;
  width: 100%;
}

.auth-brand {
  margin-bottom: 22px;
  text-align: center;
}

.auth-brand .brand-mark {
  margin: 0 auto 12px;
}

.auth-brand h1 {
  font-size: 24px;
  margin: 0 0 6px;
}

.auth-brand p {
  color: var(--muted);
  margin: 0;
}

.scan-page {
  background: #f0f2f5;
}

.page {
  margin: 0 auto;
  max-width: 760px;
  padding: 22px 16px;
}

.scan-shell {
  max-width: 560px;
  min-height: 100vh;
  padding: 14px;
}

.panel {
  background: #fff;
  border: 1px solid #f0f0f0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.scan-kicker {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 5px;
}

.scan-page h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 16px;
}

.scan-page h2 {
  font-size: 18px;
  margin: 18px 0 0;
}

.scan-page .meta {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  grid-template-columns: 86px minmax(0, 1fr);
  margin-bottom: 18px;
  overflow: hidden;
}

.entry-choices {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.choice-card {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  color: var(--text);
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 16px;
}

.choice-card span {
  color: var(--muted);
  font-size: 13px;
}

.choice-card strong {
  font-size: 20px;
}

.scan-error {
  background: #fff1f0;
  border: 1px solid #ffa39e;
  border-left: 4px solid #ff4d4f;
  border-radius: var(--radius);
  line-height: 1.45;
  margin: 0 0 16px;
  padding: 10px 12px;
}

.scan-paused {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  border-left: 4px solid #faad14;
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding: 14px 16px;
}

.scan-paused h2,
.scan-paused p {
  margin: 0;
}

.scan-paused p {
  color: #7c5b00;
  line-height: 1.45;
}

.scan-page input,
.scan-page button,
.scan-page select {
  font-size: 16px;
  min-height: 48px;
  width: 100%;
}

.scan-count-control {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 52px 1fr 52px;
}

.scan-count-control button {
  background: var(--primary-soft);
  border: 1px solid #bfdbf0;
  border-radius: 8px;
  color: var(--primary);
  font-size: 22px;
  font-weight: 800;
}

.camera-capture {
  display: grid;
  gap: 10px;
}

.camera-capture button {
  min-height: 44px;
}

.camera-file-input {
  height: 1px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.photo-preview {
  align-items: center;
  background: #f8fafc;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
}

.photo-preview img {
  border-radius: 6px;
  max-height: 180px;
  max-width: 100%;
}

.scan-receipt {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0;
}

.scan-receipt div {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.scan-receipt span {
  color: var(--muted);
  display: block;
  font-size: .86rem;
}

.scan-receipt strong {
  color: var(--primary);
  display: block;
  font-size: 1.8rem;
  margin-top: 4px;
}

.scan-page .hint {
  background: #f6ffed;
  border-left: 4px solid #52c41a;
  border-radius: 6px;
  color: #3f6212;
  padding: 10px 12px;
}

.form-switch {
  margin: 16px 0 0;
  text-align: center;
}

.scan-history {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 18px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-row {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(96px, 1.4fr) 48px 56px 54px;
  min-height: 44px;
  padding: 8px 10px;
}

.history-row strong {
  color: var(--primary);
  font-size: 18px;
}

.history-row a {
  color: var(--primary);
  font-weight: 700;
  text-align: right;
}

.record-detail-grid {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr);
}

.record-detail-grid dt {
  color: var(--muted);
}

.record-detail-grid dd {
  font-weight: 700;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.image-review-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}

.image-review-grid figure {
  margin: 0;
}

.image-review-grid figcaption {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.image-review-grid img {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 520px;
  object-fit: contain;
  width: 100%;
}

@media (max-width: 960px) {
  .compact-row {
    grid-template-columns: 1fr;
  }

  .app-shell {
    display: block;
  }

  .app-sider {
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .brand {
    height: 52px;
  }

  .side-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .side-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-group {
    background: transparent;
    border: 0;
    display: contents;
    padding: 0;
  }

  .side-nav .nav-section,
  .side-nav a small {
    display: none;
  }

  .side-nav a {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .app-header {
    position: static;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-card.span-4,
  .module-card.span-6,
  .module-card.span-8,
  .module-grid > .content-card {
    grid-column: span 6;
  }
}

@media (max-width: 720px) {
  body {
    min-width: 0;
  }

  .brand {
    padding: 0 12px;
  }

  .brand strong {
    font-size: 16px;
  }

  .brand small {
    font-size: 10px;
  }

  .brand-mark {
    height: 28px;
    width: 28px;
  }

  .side-nav {
    gap: 6px;
    padding: 8px 10px 10px;
  }

  .side-nav a {
    background: rgba(255, 255, 255, 0.08);
    font-size: 13px;
    min-height: 36px;
    padding: 0 12px;
  }

  .app-header {
    align-items: stretch;
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .app-header h1 {
    font-size: 18px;
  }

  .header-actions,
  .page-actions {
    justify-content: stretch;
  }

  .header-actions > *,
  .page-actions > *,
  .button-link,
  .primary-action {
    flex: 1 1 auto;
  }

  .workspace {
    gap: 12px;
    padding: 10px;
  }

  .content-card,
  .table-card,
  .panel,
  .module-card {
    border-radius: 8px;
    padding: 12px;
  }

  .module-grid {
    gap: 12px;
    grid-template-columns: 1fr;
  }

  .module-card.span-4,
  .module-card.span-6,
  .module-card.span-8,
  .module-card.span-12,
  .module-grid > .content-card {
    grid-column: 1 / -1;
  }

  .module-heading {
    display: grid;
  }

  .quick-links {
    grid-template-columns: 1fr;
  }

  .page-header {
    align-items: stretch;
    display: grid;
    gap: 10px;
  }

  .stat-grid {
    gap: 10px;
  }

  .command-grid,
  .report-grid,
  .map-governance-panel,
  .map-governance-panel dl,
  .scan-receipt {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 88px;
    padding: 14px;
  }

  .stat-card strong {
    font-size: 26px;
  }

  .import-form,
  .grid-form {
    grid-template-columns: 1fr;
  }

  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .row-edit summary,
  details.row-actions > summary {
    width: 100%;
  }

  .table-edit-form {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .inline-form input,
  .inline-form button,
  .inline-form select,
  .header-form,
  .header-form button {
    width: 100%;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .segmented a {
    justify-content: center;
    text-align: center;
  }

  .table-card {
    overflow: visible;
  }

  .table-card .page-header {
    margin-bottom: 12px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
  }

  td {
    align-items: start;
    border-bottom: 1px solid #f0f0f0;
    display: grid;
    gap: 10px;
    grid-template-columns: 92px minmax(0, 1fr);
    min-height: 38px;
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 13px;
    font-weight: 700;
  }

  .auth-shell,
  .scan-shell {
    padding: 10px;
  }

  .auth-card {
    padding: 22px;
  }

  .scan-page h1 {
    font-size: 22px;
  }

  .scan-page .meta {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .choice-card {
    min-height: 82px;
    padding: 14px;
  }

  .choice-card strong {
    font-size: 19px;
  }

  .history-row {
    grid-template-columns: minmax(92px, 1fr) 38px 44px 44px;
  }

  .record-detail-grid,
  .image-review-grid {
    grid-template-columns: 1fr;
  }
}
