:root {
  color-scheme: light dark;
  --bg: #edf1f4;
  --bg-2: #dfe7ec;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --surface-soft: #eef3f6;
  --line: rgba(24, 37, 49, 0.1);
  --line-strong: rgba(24, 37, 49, 0.18);
  --text: #15212c;
  --muted: #677586;
  --success: #127445;
  --success-soft: #e6f5ec;
  --warning: #b06d00;
  --warning-soft: #fff2db;
  --danger: #be3530;
  --danger-soft: #ffe6e4;
  --accent: #005d86;
  --accent-soft: #dff2fb;
  --neutral-soft: #e9eef2;
  --shadow: 0 18px 44px rgba(21, 33, 44, 0.08);
  --shadow-soft: 0 8px 20px rgba(21, 33, 44, 0.05);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(0, 93, 134, 0.08), transparent 28%),
    linear-gradient(180deg, #f4f7f9 0%, var(--bg) 34%, #e8eef2 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(21, 33, 44, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 33, 44, 0.025) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.45;
}

button,
input {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-weight: 700;
  letter-spacing: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(247, 250, 252, 0.84));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.runtime-meta {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  width: fit-content;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 93, 134, 0.12);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.meta-chip strong {
  color: var(--muted);
  font-size: 12px;
}

.meta-chip em {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-style: normal;
  overflow-wrap: anywhere;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.brand-logo {
  display: block;
  width: min(172px, 52vw);
  height: auto;
  max-height: 44px;
  object-fit: contain;
  object-position: left center;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  font-size: 30px;
  line-height: 1.12;
}

h3 {
  font-size: 22px;
  line-height: 1.2;
}

.icon-btn {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--accent);
  box-shadow: var(--shadow-soft);
  font-size: 18px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.sub {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  margin-top: 4px;
}

.hero-panel,
.panel,
.row-card,
.kpi {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.decision-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 250, 0.9));
  box-shadow: var(--shadow);
}

.decision-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.decision-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-badges {
  align-items: center;
}

.legend-pill-button {
  cursor: pointer;
  border: 1px solid rgba(0, 93, 134, 0.16);
  background: rgba(255, 255, 255, 0.92);
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.family-demand-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.family-demand-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(244, 248, 250, 0.9));
  padding: 16px;
  text-align: left;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.family-demand-row.danger {
  border-color: rgba(190, 53, 48, 0.18);
}

.family-demand-row.success {
  border-color: rgba(18, 116, 69, 0.16);
}

.family-demand-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.family-demand-title {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.family-demand-mark {
  font-size: 18px;
  line-height: 1.2;
}

.family-demand-title strong {
  display: block;
  font-size: 22px;
  line-height: 1.15;
}

.family-demand-title em,
.family-demand-open,
.family-demand-foot,
.demand-board-note,
.demand-board-total {
  color: var(--muted);
  font-style: normal;
}

.family-demand-title em {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.family-demand-open {
  font-size: 26px;
  line-height: 1;
  white-space: nowrap;
}

.family-demand-coverage {
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.family-demand-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.family-demand-numbers span {
  color: var(--text);
  font-size: 15px;
}

.family-demand-progress {
  display: block;
}

.family-demand-track {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(21, 33, 44, 0.08);
}

.family-demand-fill {
  height: 100%;
  border-radius: 999px;
}

.family-demand-fill.danger {
  background: var(--danger);
}

.family-demand-fill.success {
  background: var(--success);
}

.family-demand-fill.neutral {
  background: #9aa7b4;
}

.family-demand-foot {
  font-size: 14px;
  line-height: 1.4;
}

.demand-board-note,
.demand-board-total {
  margin-top: 2px;
}

.demand-board-total {
  font-size: 15px;
}

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

.coating-now-list.compact {
  gap: 6px;
}

.coating-now-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(92px, auto)) minmax(120px, auto);
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 248, 251, 0.92));
  box-shadow: var(--shadow-soft);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
}

.coating-now-row.static-row {
  cursor: default;
}

.coating-now-row.returned-row {
  background: linear-gradient(180deg, rgba(245, 252, 247, 0.96), rgba(239, 247, 241, 0.92));
}

.coating-now-row strong {
  font-size: 18px;
  line-height: 1.2;
}

.coating-now-row span,
.coating-now-row em {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  text-align: right;
}

@media (max-width: 759px) {
  .coating-now-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .coating-now-row span,
  .coating-now-row em {
    text-align: left;
  }
}

.hero-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(0, 93, 134, 0.1), rgba(255, 255, 255, 0.92) 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(243, 247, 250, 0.9));
}

.hero-panel.compact {
  padding: 16px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-copy p {
  max-width: 62ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.actionable-card {
  cursor: pointer;
  text-align: left;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hero-stat {
  min-width: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(0, 93, 134, 0.12);
}

.hero-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.hero-stat strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

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

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

.kpi {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 249, 251, 0.88));
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--line-strong);
}

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

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

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

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

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 12px;
}

.kpi strong {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-weight: 700;
  font-size: 40px;
  line-height: 0.98;
}

.kpi-unit {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.kpi em {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  line-height: 1.32;
}

.panel,
.row-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(244, 248, 250, 0.88));
  border-radius: 14px;
}

.panel {
  padding: 14px;
}

.row-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.family-band,
.lens-strip,
.site-grid {
  display: grid;
  gap: 8px;
}

.coating-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-grid,
.projection-hero-list {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 8px;
}

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

.action-card,
.projection-hero-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.action-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 168px;
}

.action-card span,
.projection-hero-card span {
  color: var(--muted);
  font-size: 13px;
}

.action-card strong,
.projection-hero-card strong {
  font-size: 24px;
  line-height: 1.25;
}

.action-card em,
.projection-hero-card em {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  font-style: normal;
}

.action-meta {
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}

.action-card.danger {
  background: linear-gradient(180deg, rgba(255, 230, 228, 0.95), rgba(255, 246, 246, 0.95));
  border-color: rgba(190, 53, 48, 0.16);
}

.action-card.warning {
  background: linear-gradient(180deg, rgba(255, 242, 219, 0.95), rgba(255, 249, 240, 0.95));
  border-color: rgba(176, 109, 0, 0.16);
}

.action-card.success {
  background: linear-gradient(180deg, rgba(230, 245, 236, 0.95), rgba(247, 252, 249, 0.95));
  border-color: rgba(18, 116, 69, 0.16);
}

.action-card.neutral {
  background: linear-gradient(180deg, rgba(233, 238, 242, 0.95), rgba(248, 250, 252, 0.95));
}

.projection-hero-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.projection-hero-card strong {
  color: var(--accent);
}

.drawer-grid {
  margin-bottom: 12px;
}

.ikang-freshness {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.summary-kpis .kpi {
  min-height: 102px;
}

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

.family-stage-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(244, 248, 250, 0.88));
  box-shadow: var(--shadow-soft);
}

.drawer-family-stage {
  margin-bottom: 12px;
  cursor: default;
}

.family-stage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stage-cell {
  padding: 12px;
  border-radius: 10px;
  background: rgba(237, 243, 247, 0.82);
}

.stage-cell span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.stage-cell strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.stage-cell strong.value-muted {
  color: #94a1ae;
}

.stage-distribution {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-bar {
  display: flex;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(21, 33, 44, 0.08);
}

.stage-segment.success,
.stage-dot.success {
  background: var(--success);
}

.stage-segment.accent,
.stage-dot.accent {
  background: var(--accent);
}

.stage-segment.warning,
.stage-dot.warning {
  background: var(--warning);
}

.stage-dot.danger {
  background: var(--danger);
}

.stage-segment.neutral,
.stage-dot.neutral {
  background: #8a97a3;
}

.stage-segment.process,
.stage-dot.process {
  background: #6f4dd8;
}

.stage-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.stage-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.family-stage-footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.family-stage-footer span {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 13px;
}

.family-stage-footer strong {
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.process-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.process-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  text-align: left;
}

.process-pill span {
  color: var(--muted);
  font-size: 12px;
}

.process-pill strong {
  font-size: 18px;
  line-height: 1.2;
  color: var(--text);
}

.process-pill em {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-style: normal;
}

.source-button {
  cursor: pointer;
}

.card-rail {
  display: grid;
  gap: 8px;
}

.progress-block {
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.progress-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
}

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

.progress-top strong {
  font-size: 20px;
  color: var(--text);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(21, 33, 44, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
}

.progress-fill.success {
  background: var(--success);
}

.progress-fill.warning {
  background: var(--warning);
}

.progress-fill.danger {
  background: var(--danger);
}

.progress-fill.neutral {
  background: var(--accent);
}

.progress-block em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.family-band {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.family-band span {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(237, 243, 247, 0.8);
  color: var(--muted);
  font-size: 12px;
}

.family-band strong {
  color: var(--text);
  font-size: 16px;
}

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

.lens-strip-card,
.site-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(241, 246, 249, 0.92));
  padding: 12px;
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.coating-lens-card {
  min-height: 120px;
  justify-content: space-between;
}

.lens-strip-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lens-strip-card span,
.site-card span {
  color: var(--muted);
  font-size: 12px;
}

.lens-strip-card strong,
.site-card strong {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-weight: 700;
  font-size: 21px;
  color: var(--text);
}

.lens-strip-card em,
.site-card em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.35;
}

.coating-site-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.coating-site-breakdown span {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.coating-site-breakdown strong {
  font-size: 14px;
  color: var(--muted);
  margin-right: 4px;
}

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

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

.decision-callout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.decision-callout span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.decision-callout strong {
  font-size: 15px;
  line-height: 1.45;
}

.decision-callout.success {
  background: linear-gradient(180deg, rgba(230, 245, 236, 0.95), rgba(247, 252, 249, 0.95));
  border-color: rgba(18, 116, 69, 0.16);
}

.decision-callout.warning {
  background: linear-gradient(180deg, rgba(255, 242, 219, 0.95), rgba(255, 249, 240, 0.95));
  border-color: rgba(176, 109, 0, 0.16);
}

.decision-callout.danger {
  background: linear-gradient(180deg, rgba(255, 230, 228, 0.95), rgba(255, 246, 246, 0.95));
  border-color: rgba(190, 53, 48, 0.16);
}

.decision-callout.neutral {
  background: linear-gradient(180deg, rgba(233, 238, 242, 0.95), rgba(248, 250, 252, 0.95));
}

.risk-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-pill,
.trace-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
}

.legend-pill.critical,
.trace-badge.mismatch {
  background: rgba(255, 230, 228, 0.98);
  border-color: rgba(190, 53, 48, 0.16);
  color: var(--danger);
}

.legend-pill.warning,
.trace-badge.warning,
.trace-badge.pending {
  background: rgba(255, 242, 219, 0.98);
  border-color: rgba(176, 109, 0, 0.16);
  color: var(--warning);
}

.trace-badge.ok {
  background: rgba(230, 245, 236, 0.98);
  border-color: rgba(18, 116, 69, 0.16);
  color: var(--success);
}

.legend-pill.ok {
  background: rgba(230, 245, 236, 0.98);
  border-color: rgba(18, 116, 69, 0.16);
  color: var(--success);
}

.metric {
  background: linear-gradient(180deg, rgba(236, 242, 246, 0.95), rgba(247, 250, 252, 0.95));
  border: 1px solid rgba(21, 33, 44, 0.05);
  border-radius: 10px;
  padding: 10px;
  min-width: 0;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: flex-start;
}

.metric span,
.trace-raw span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.metric strong {
  display: block;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.metric-unit {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.metric-actions {
  display: inline-flex;
  gap: 4px;
  flex: 0 0 auto;
}

.trace-btn {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(0, 93, 134, 0.24);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.validation {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-style: normal;
  color: var(--success);
}

.validation.mismatch {
  color: var(--danger);
}

.validation.warning,
.validation.pending {
  color: var(--warning);
}

.trace-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 10px;
}

.trace-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

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

.trace-row strong,
.trace-raw p {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.trace-raw code {
  background: var(--surface-soft);
  border-radius: 4px;
  padding: 1px 4px;
}

.trace-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.projection-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.projection-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(82px, 0.8fr) minmax(74px, 0.7fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(237, 247, 251, 0.95), rgba(248, 251, 252, 0.95));
  padding: 9px;
  color: var(--text);
  text-align: left;
}

.projection-row span,
.projection-row strong,
.projection-row em {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.projection-row em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
}

.status.ok {
  background: var(--success);
}

.status.watch,
.status.process {
  background: var(--warning);
}

.status.risk,
.status.critical {
  background: var(--danger);
}

.status.neutral {
  background: #7a8490;
}

.status.move {
  background: var(--accent);
}

.search {
  width: 100%;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 0 14px;
  color: var(--text);
  box-shadow: var(--shadow-soft);
  font-size: 16px;
}

.detail-drawer {
  position: fixed;
  inset: auto 0 0;
  max-height: 82vh;
  overflow: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 246, 249, 0.96));
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line);
  box-shadow: 0 -20px 40px rgba(22, 32, 42, 0.16);
  padding: 16px 16px calc(22px + env(safe-area-inset-bottom));
  z-index: 5;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 32, 42, 0.35);
  z-index: 4;
}

.drawer-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.link-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--accent);
  box-shadow: var(--shadow-soft);
  font-size: 15px;
}

.more-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  text-align: left;
}

.more-tile strong {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}

.more-tile span {
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
}

.empty,
.error {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  background: rgba(234, 240, 244, 0.88);
  border-top: 1px solid rgba(21, 33, 44, 0.08);
  backdrop-filter: blur(18px);
}

.tab {
  min-width: 0;
  min-height: 54px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.tab.active {
  background: var(--surface-strong);
  color: var(--accent);
  box-shadow: var(--shadow-soft);
}

@media (min-width: 760px) {
  .app-shell {
    max-width: 1080px;
    margin: 0 auto;
  }

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

  .compact-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .decision-head {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
  }

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

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

  .hero-panel {
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.8fr);
    align-items: end;
  }

  .lens-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .coating-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .process-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .family-stage-grid,
  .family-stage-footer {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .action-grid,
  .projection-hero-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .runtime-meta {
    display: flex;
  }
}

@media (min-width: 1120px) {
  .family-stage-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
