:root {
  --bg: #FFFFFF;
  --bg-sub: #FAFAFA;
  --surface: #FFFFFF;
  --surface-2: #F4F4F4;
  --surface-3: #EAEAEA;
  --fg: #0F0F0F;
  --fg-2: #4A4A4A;
  --muted: #6E6E6E;
  --border: #E2E2E2;
  --border-soft: #EFEFEF;
  --accent: #FAFF69;
  --accent-on: #151515;
  --ink: #151515;
  --ink-on: #FFFFFF;
  --ink-solid: #151515;
  --ink-solid-2: #1D1D1D;
  --on-ink: #FFFFFF;
  --on-ink-2: #A0A0A0;
  --on-ink-rule: #2A2A2A;
  --on-ink-3: #A0A0A0;
  --success: #166534;
  --success-bg: #E7F3EB;
  --warn: #8A5A00;
  --warn-bg: #FCF2D8;
  --danger: #B4271D;
  --danger-bg: #FBEBE9;
  --neutral: #4A4A4A;
  --neutral-bg: #F0F0F0;
  --scrim: #000000A6;
  --accent-prod: #F2FF66;
  --accent-quality: #FFF169;
  --accent-env: #E6FF66;
  --accent-flow: #FFEE69;
  --accent-gov: #ECFF69;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-16: 16px;
  --fs-20: 20px;
  --fs-24: 24px;
  --fs-36: 36px;
  --fs-72: 72px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;
  --r-sm: 4px;
  --r-md: 8px;
  --r-pill: 9999px;
  --font-body: Inter, "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-mono: Inconsolata, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-sub: #0A0A0A;
  --surface: #141414;
  --surface-2: #1D1D1D;
  --surface-3: #262626;
  --fg: #FFFFFF;
  --fg-2: #A0A0A0;
  --muted: #A0A0A0;
  --border: #414141;
  --border-soft: #343434;
  --accent: #FAFF69;
  --accent-on: #151515;
  --ink: #FAFF69;
  --ink-on: #151515;
  --success: #2E9E5B;
  --success-bg: #12261A;
  --warn: #EAB308;
  --warn-bg: #2A2210;
  --danger: #EF5A4D;
  --danger-bg: #2A1512;
  --neutral: #A0A0A0;
  --neutral-bg: #1F1F1F;
  --scrim: #000000C4;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-14);
  line-height: 1.5;
}

body {
  min-width: 320px;
}

small {
  font-size: var(--fs-14);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-sm {
  width: 14px;
  height: 14px;
}

.mono,
.batch-id,
.code-value,
.metric-number {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.fg-2 {
  color: var(--fg-2);
}

.danger-text {
  color: var(--danger);
}

.text-right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  color: var(--muted);
}

.brand-mark {
  display: inline-block;
  width: var(--sp-4);
  height: var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--accent);
  flex: 0 0 auto;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-weight: 600;
}

.shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: 236px;
  height: 100vh;
  position: sticky;
  top: 0;
  flex: 0 0 236px;
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg-sub);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-brand {
  padding: var(--sp-1) var(--sp-2) var(--sp-4);
  white-space: nowrap;
}

.sidebar-brand .brand-lockup {
  font-size: var(--fs-15);
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.nav-label {
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
  color: var(--muted);
  font-size: var(--fs-14);
  font-weight: 500;
}

.nav-item {
  position: relative;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--r-sm);
  color: var(--fg-2);
  font-size: var(--fs-14);
  line-height: 1.3;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.nav-item.active {
  background: var(--surface-2);
  color: var(--fg);
}

.nav-item.active::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;
  width: var(--sp-1);
  height: var(--sp-3);
  margin-top: calc(var(--sp-3) / -2);
  border-radius: var(--r-pill);
  background: var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.sidebar-user {
  margin-top: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2);
  border-top: 1px solid var(--border-soft);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-2);
  flex: 0 0 auto;
}

.user-meta {
  min-width: 0;
}

.user-meta strong {
  display: block;
  font-size: var(--fs-14);
  font-weight: 500;
}

.user-meta span {
  display: block;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  width: calc(100vw - 236px);
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  --group-accent: var(--accent);
}

.group-prod { --group-accent: var(--accent-prod); }
.group-quality { --group-accent: var(--accent-quality); }
.group-env { --group-accent: var(--accent-env); }
.group-flow { --group-accent: var(--accent-flow); }
.group-gov { --group-accent: var(--accent-gov); }
.group-overview { --group-accent: var(--accent); }
.group-external { --group-accent: var(--accent); }

.group-chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 var(--sp-2);
  border: 1px solid var(--group-accent);
  border-radius: var(--r-sm);
  color: var(--fg);
  font-size: var(--fs-14);
  white-space: nowrap;
}

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left,
.topbar-right,
.topbar-title-group {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.topbar-left {
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: var(--fs-16);
  font-weight: 600;
  white-space: nowrap;
}

.data-stamp {
  color: var(--muted);
  white-space: nowrap;
}

.chart-legend .legend-item,
.visual-chart .bar,
.visual-chart circle.point {
  cursor: pointer;
}

.chart-legend .legend-item.series-focused {
  color: var(--fg);
  font-weight: 600;
}

.funnel-step.chart-node-selected,
.sankey-step.chart-node-selected,
.relation-node.chart-node-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.scope-select {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  color: var(--fg-2);
  font-size: var(--fs-14);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  white-space: nowrap;
  cursor: pointer;
}

.top-search {
  width: 240px;
  height: 34px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
}

.top-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-14);
}

.top-search input::placeholder {
  color: var(--muted);
}

.date-range {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg-2);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.notification-button {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
}

.notification-button:hover,
.icon-button:hover {
  background: var(--surface-2);
}

.notification-count {
  position: absolute;
  right: -2px;
  top: -2px;
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-1);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-on);
  font-family: var(--font-mono);
  font-size: var(--fs-14);
  line-height: 1;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
}

.page-content {
  width: 100%;
  max-width: 1484px;
  margin: 0 auto;
  padding: var(--sp-6);
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.group-band {
  height: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.group-band-title {
  flex: 0 0 auto;
  font-weight: 600;
}

.group-band-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--fs-14);
  white-space: nowrap;
}

.band-code {
  color: var(--fg-2);
  white-space: nowrap;
}

.band-ticks {
  display: inline-flex;
  align-items: flex-end;
  gap: var(--sp-1);
  height: 18px;
}

.band-ticks i {
  width: 1px;
  height: 12px;
  background: var(--border);
}

.band-ticks i:nth-child(2n) { height: 17px; }
.band-ticks i.lit { background: var(--group-accent); }

.band-scale {
  min-width: 310px;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--muted);
  font-family: var(--font-mono);
}

.band-scale i {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.band-scale i:nth-of-type(2) {
  background: var(--group-accent);
}

.threshold-preview {
  position: relative;
  min-width: 320px;
  height: 22px;
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  align-items: center;
  border-radius: var(--r-sm);
  overflow: hidden;
  color: var(--fg-2);
  font-size: var(--fs-14);
}

.threshold-preview i {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  font-style: normal;
}

.threshold-preview b {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--group-accent);
  font-weight: 500;
}

.threshold-preview em {
  position: absolute;
  left: 31%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--fg);
}

.flow-preview {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
}

.flow-preview b {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--muted);
  font-weight: 500;
}

.flow-preview b::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
}

.flow-preview b.done { color: var(--fg); }
.flow-preview b.done::before { background: var(--group-accent); }

.flow-preview i {
  width: 32px;
  height: 1px;
  background: var(--border);
}

.rule-stamp {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--group-accent);
  border-radius: var(--r-sm);
}

.stamp-line {
  width: 84px;
  height: 1px;
  background: var(--border);
}

.overview-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: var(--sp-1);
  height: 23px;
}

.overview-bars i {
  width: 7px;
  height: 12px;
  background: var(--fg);
}

.overview-bars i:nth-child(2) { height: 18px; }
.overview-bars i:nth-child(3) { height: 15px; }
.overview-bars i:nth-child(4) { height: 22px; }
.overview-bars i:nth-child(5) { height: 9px; }
.overview-bars i:nth-child(6) { height: 13px; }
.overview-bars i.peak { background: var(--group-accent); }

.code-frame {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.code-frame i {
  color: var(--fg);
  font-style: normal;
}

.align-ticks {
  display: inline-flex;
  gap: var(--sp-3);
}

.align-ticks i {
  width: 1px;
  height: 14px;
  background: var(--border);
}

.page-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.control {
  height: 36px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: 0;
  background: var(--surface);
  color: var(--fg);
  font-size: var(--fs-14);
}

.control:focus {
  border-color: var(--fg);
}

.control.search-control {
  min-width: 200px;
}

.control.date-control {
  width: 128px;
  font-family: var(--font-mono);
}

textarea.control {
  min-height: 88px;
  padding: var(--sp-2) var(--sp-3);
  resize: vertical;
}

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--fs-14);
  font-weight: 500;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
}

.btn-primary {
  border-color: var(--ink-solid);
  background: var(--ink-solid);
  color: var(--on-ink);
}

.btn-primary:hover {
  background: var(--ink-solid-2);
}

[data-theme="dark"] .btn-primary {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--fg-2);
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

.btn-quiet:hover {
  color: var(--fg);
}

.btn-sm {
  min-height: 32px;
  padding: 0 var(--sp-3);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-4);
}

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

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

.kpi-card {
  min-width: 0;
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.kpi-label {
  color: var(--muted);
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: var(--fs-24);
  font-weight: 600;
  line-height: 1.2;
}

.kpi-unit {
  color: var(--muted);
}

.kpi-delta {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: var(--sp-4);
  min-width: 0;
}

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

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

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

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

.grid.side {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.grid.side-left {
  grid-template-columns: 340px minmax(0, 1fr);
}

.grid.wide-side {
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, .75fr);
}

.grid.harvest-layout {
  grid-template-columns: minmax(0, 1fr) 420px;
}

.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.card-pad {
  padding: var(--sp-4);
}

.card-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}

.card-head.no-border {
  border-bottom: 0;
  padding-bottom: 0;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.card-title {
  margin: 0;
  font-size: var(--fs-16);
  font-weight: 600;
  white-space: nowrap;
}

.card-hint {
  color: var(--muted);
  font-size: var(--fs-14);
}

.card-body {
  padding: var(--sp-4);
}

.card-body.flush {
  padding: 0;
}

.card-action {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--fg-2);
  white-space: nowrap;
}

.card-action:hover {
  color: var(--fg);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-14);
}

.data-table th {
  padding: var(--sp-3);
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.data-table td {
  height: 46px;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
  color: var(--fg-2);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: var(--bg-sub);
}

.data-table .primary-cell {
  color: var(--fg);
  font-weight: 500;
}

.data-table .actions {
  white-space: nowrap;
}

.data-table .actions a,
.data-table .actions button {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.data-table .actions > * + * {
  margin-left: var(--sp-3);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 22px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--neutral-bg);
  color: var(--neutral);
  font-size: var(--fs-14);
  line-height: 1;
  white-space: nowrap;
}

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

.status.warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.status.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.status.neutral {
  color: var(--neutral);
  background: var(--neutral-bg);
}

.status-dot {
  width: var(--sp-1);
  height: var(--sp-1);
  border-radius: var(--r-pill);
  background: currentColor;
}

.badge-accent {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 22px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--fg);
  white-space: nowrap;
}

.badge-accent::before {
  content: "";
  width: var(--sp-1);
  height: var(--sp-1);
  border-radius: var(--r-pill);
  background: var(--group-accent, var(--accent));
}

.pagination {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
}

.page-buttons {
  display: flex;
  gap: var(--sp-1);
  align-items: center;
}

.page-button {
  min-width: 28px;
  height: 28px;
  padding: 0 var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-2);
}

.page-button:hover {
  background: var(--surface-2);
}

.page-button.active {
  border-color: var(--border);
  color: var(--fg);
  background: var(--surface-2);
}

.page-button:disabled {
  opacity: .4;
  cursor: default;
}

.progress-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 54px;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
}

.progress-track {
  height: 5px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--fg);
  border-radius: var(--r-pill);
}

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

.bar-chart {
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  gap: var(--sp-4);
  padding-top: var(--sp-4);
}

.bar-item {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}

.bar-value {
  font-family: var(--font-mono);
  color: var(--fg-2);
}

.bar {
  width: 100%;
  min-height: 16px;
  background: var(--fg);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

.bar.peak {
  background: var(--group-accent, var(--accent));
}

.bar-label {
  color: var(--muted);
  font-family: var(--font-mono);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font-size: var(--fs-14);
}

.legend-swatch {
  width: var(--sp-2);
  height: var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--fg);
}

.legend-swatch.accent {
  background: var(--group-accent, var(--accent));
}

.legend-swatch.line {
  height: 2px;
  background: var(--fg);
}

.legend-swatch.dash {
  height: 2px;
  background: repeating-linear-gradient(to right, var(--fg) 0 4px, transparent 4px 8px);
}

.line-chart {
  width: 100%;
  height: 230px;
  overflow: visible;
}

.line-chart text {
  fill: var(--muted);
  font-size: var(--fs-14);
  font-family: var(--font-mono);
}

.line-chart .grid-line {
  stroke: var(--border-soft);
  stroke-width: 1;
}

.line-chart .axis {
  stroke: var(--border);
  stroke-width: 1;
}

.line-chart .series-primary {
  fill: none;
  stroke: var(--fg);
  stroke-width: 2;
}

.line-chart .series-secondary {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
}

.line-chart .series-accent {
  fill: none;
  stroke: var(--group-accent, var(--accent));
  stroke-width: 3;
}

.line-chart .point {
  fill: var(--surface);
  stroke: var(--fg);
  stroke-width: 2;
}

.line-chart .accent-point {
  fill: var(--group-accent, var(--accent));
  stroke: var(--fg);
}

.alert-list {
  display: flex;
  flex-direction: column;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}

.alert-item:last-child {
  border-bottom: 0;
}

.alert-item:hover {
  background: var(--bg-sub);
}

.alert-copy {
  min-width: 0;
  flex: 1;
}

.alert-head {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
}

.alert-title {
  font-weight: 600;
}

.alert-time {
  color: var(--muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.alert-desc {
  margin-top: var(--sp-1);
  color: var(--muted);
}

.meta-list {
  display: flex;
  flex-direction: column;
}

.meta-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-soft);
}

.meta-row:last-child {
  border-bottom: 0;
}

.meta-label {
  color: var(--muted);
}

.meta-value {
  text-align: right;
  color: var(--fg);
}

.subtle-box {
  padding: var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
}

.receipt-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.receipt-banner .card-action {
  margin-left: auto;
}

.data-table tr.highlight-row td {
  background: var(--surface-2);
}

.button-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 480px;
}

.map-card {
  overflow: hidden;
}

.map-layout > :first-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.map-layout > :first-child > .map-canvas {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.map-layout .pond-matrix {
  flex: 0 0 auto;
  grid-auto-rows: 66px;
}

.map-layout .pond-cell {
  justify-content: center;
}

.map-layout .map-ring-row {
  flex: 1 1 auto;
  min-height: 150px;
  align-items: center;
  gap: var(--sp-3);
  margin-top: auto;
  padding-top: var(--sp-8);
}

.map-layout .map-ring {
  width: clamp(104px, 10vw, 140px);
  height: 96px;
}

.map-layout > :first-child > .map-footer {
  margin-top: auto;
}

.map-canvas {
  position: relative;
  min-height: 410px;
  margin: 0 var(--sp-4) var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.map-water {
  position: absolute;
  inset: 0;
  opacity: .55;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 48px 48px;
}

.map-label {
  position: relative;
  color: var(--muted);
  margin-bottom: var(--sp-4);
}

.pond-matrix {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: var(--sp-3);
  z-index: 1;
}

.pond-cell {
  min-height: 66px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  text-align: left;
}

.pond-cell:hover {
  border-color: var(--fg-2);
}

.pond-cell strong {
  font-weight: 600;
}

.pond-cell span {
  color: var(--muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pond-cell.risk {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.map-ring-row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-12);
}

.map-ring {
  width: clamp(104px, 10vw, 140px);
  height: 96px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--sp-2);
  border: 1px solid var(--fg-2);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-14);
  text-align: center;
  cursor: pointer;
}

.map-ring.success { border-color: var(--success); }
.map-ring.warn { border-color: var(--warn); }
.map-ring.danger { border-color: var(--danger); }
.map-ring.neutral { border-color: var(--neutral); }

.map-ring:hover,
.map-ring.selected {
  background: var(--surface);
}

.map-ring.selected {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.map-ring-id,
.map-ring-meta,
.map-ring-state {
  font-family: var(--font-mono);
  font-size: var(--fs-14);
  line-height: 1.2;
  white-space: nowrap;
}

.map-ring-id {
  font-family: var(--font-mono);
  font-weight: 600;
}

.map-ring-state {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

.map-ring-meta {
  color: var(--muted);
}

.map-cage-detail {
  position: relative;
  z-index: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg-2);
  font-size: var(--fs-14);
}

.map-cage-detail-label {
  color: var(--muted);
}

.map-footer {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 var(--sp-4) var(--sp-4);
  color: var(--muted);
}

.map-legend {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.map-foot-notes {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-1);
  text-align: right;
}

.legend-dot {
  width: var(--sp-2);
  height: var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--neutral);
}

.legend-dot.success { background: var(--success); }
.legend-dot.warn { background: var(--warn); }
.legend-dot.danger { background: var(--danger); }

.risk-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.risk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-soft);
}

.risk-row:last-child {
  border-bottom: 0;
}

.detail-panel {
  min-width: 0;
}

.detail-panel .card-body {
  padding-top: 0;
}

.tabs {
  display: flex;
  gap: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.tab {
  position: relative;
  min-height: 42px;
  padding: 0 var(--sp-1);
  border: 0;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  color: var(--fg);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--fg);
}

.tab-panel {
  padding-top: var(--sp-4);
}

.ledger-tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
}

.ledger-tabs .tab {
  min-height: 32px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.ledger-tabs .tab.active {
  border-color: var(--fg);
  background: var(--surface-2);
}

.ledger-tabs .tab.active::after {
  display: none;
}

.ledger-stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding-top: var(--sp-4);
}

.ledger-section {
  background: var(--bg-sub);
}

.feeding-task-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--sp-2);
}

.feeding-task-column {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.feeding-task-column strong {
  font-size: var(--fs-14);
}

.feeding-task-column span {
  color: var(--muted);
  font-size: var(--fs-20);
}

.tap-panel {
  min-width: 0;
}

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px 150px minmax(0, 1fr);
  gap: var(--sp-3);
  min-height: 54px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 14px;
  bottom: -6px;
  width: 1px;
  background: var(--border);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  position: relative;
  width: 14px;
  height: 14px;
  border: 2px solid var(--fg);
  border-radius: var(--r-pill);
  background: var(--surface);
  margin-top: 2px;
}

.timeline-item.current .timeline-dot {
  background: var(--group-accent, var(--accent));
}

.timeline-time {
  color: var(--muted);
  font-family: var(--font-mono);
}

.timeline-copy strong {
  display: block;
  font-weight: 600;
}

.timeline-copy span {
  color: var(--muted);
}

.validation-list {
  display: flex;
  flex-direction: column;
}

.validation-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-soft);
}

.validation-item:last-child {
  border-bottom: 0;
}

.validation-copy {
  min-width: 0;
}

.validation-copy strong {
  display: block;
  font-weight: 600;
}

.validation-copy span {
  color: var(--muted);
}

.qr-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--sp-6);
  align-items: start;
}

.qr-frame {
  width: 220px;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.qr-frame img {
  width: 200px;
  height: 200px;
  image-rendering: pixelated;
}

.qr-caption {
  margin-top: var(--sp-2);
  text-align: center;
  color: var(--muted);
}

.harvest-code-card .qr-frame {
  width: 100%;
  min-height: 220px;
  overflow: hidden;
}

.harvest-code-card .qr-frame img {
  width: 200px;
  height: 200px;
}

.code-display {
  font-family: var(--font-mono);
  font-size: var(--fs-20);
  letter-spacing: .04em;
}

.trace-graph-card {
  overflow: hidden;
}

.graph-stage {
  min-width: 1080px;
  min-height: 500px;
  position: relative;
  padding: var(--sp-6);
  background: var(--bg-sub);
  overflow: hidden;
}

.graph-edge {
  position: absolute;
  height: 1px;
  background: var(--border);
  transform-origin: 0 50%;
  z-index: 0;
}

.graph-node {
  position: absolute;
  width: 160px;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  z-index: 1;
}

.graph-node:hover,
.graph-node.selected {
  border-color: var(--fg);
}

.graph-node.selected::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -3px;
  width: var(--sp-2);
  height: var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--group-accent, var(--accent));
}

.graph-node strong {
  font-family: var(--font-mono);
  font-size: var(--fs-14);
}

.graph-node span {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.graph-node .node-kind {
  color: var(--muted);
  font-size: var(--fs-14);
}

.graph-side {
  min-width: 240px;
}

.audit-table td {
  height: 42px;
}

.report-list {
  display: flex;
  flex-direction: column;
}

.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-soft);
}

.report-row:last-child {
  border-bottom: 0;
}

.report-row-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.modal {
  width: min(680px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
}

.modal::backdrop {
  background: var(--scrim);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
}

.modal-title {
  margin: 0;
  font-size: var(--fs-20);
  font-weight: 600;
}

.modal-subtitle {
  margin-top: var(--sp-1);
  color: var(--muted);
}

.modal-body {
  padding: var(--sp-4) var(--sp-5);
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  color: var(--fg-2);
}

.form-field .control {
  width: 100%;
}

.form-error {
  color: var(--danger);
}

.form-error:not(:empty) {
  display: inline-flex;
  width: fit-content;
  min-height: 22px;
  align-items: center;
  padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--danger-bg);
  color: var(--danger);
}

.toast {
  position: fixed;
  right: var(--sp-6);
  bottom: var(--sp-6);
  z-index: 100;
  max-width: min(420px, calc(100vw - 48px));
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  color: var(--muted);
  text-align: center;
}

.public-shell {
  min-height: 100vh;
  background: var(--bg-sub);
}

.public-header {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
}

.public-links {
  display: flex;
  gap: var(--sp-4);
  color: var(--fg-2);
}

.public-main {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  padding: var(--sp-12) 0;
}

.verify-wrap {
  width: min(680px, 100%);
  margin: 0 auto;
}

.verify-heading {
  margin: 0;
  font-size: var(--fs-24);
  font-weight: 600;
}

.verify-subheading {
  margin: var(--sp-2) 0 var(--sp-5);
  color: var(--fg-2);
}

.scan-card {
  padding: var(--sp-6);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.scan-box {
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted);
}

.scan-corners::before,
.scan-corners::after {
  content: "";
  position: absolute;
  width: 36px;
  height: 36px;
  border-color: var(--fg);
}

.scan-corners::before {
  left: 16px;
  top: 16px;
  border-left: 1px solid;
  border-top: 1px solid;
}

.scan-corners::after {
  right: 16px;
  bottom: 16px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.scan-center-icon {
  width: 36px;
  height: 36px;
  color: var(--muted);
}

.scan-divider {
  height: 1px;
  margin-bottom: var(--sp-4);
  background: var(--border-soft);
}

.verify-form {
  display: flex;
  gap: var(--sp-2);
}

.verify-form .control {
  flex: 1;
  height: 40px;
}

.verify-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-5);
  margin-top: var(--sp-5);
}

.verify-fact strong {
  display: block;
  margin-bottom: var(--sp-1);
}

.verify-fact span {
  color: var(--muted);
}

.public-notice {
  margin-top: var(--sp-5);
  text-align: center;
  color: var(--muted);
}

.result-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.result-code {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.result-code h1 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-24);
}

.result-main {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, .85fr);
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

.result-left,
.result-right {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.result-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--sp-2);
}

.result-summary-item {
  min-height: 88px;
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.result-summary-item span {
  display: block;
  margin-bottom: var(--sp-1);
  color: var(--muted);
}

.test-result-list {
  display: flex;
  flex-direction: column;
}

.test-result-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 90px 100px;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-soft);
}

.test-result-row:last-child {
  border-bottom: 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  padding: var(--sp-6);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--scrim), var(--scrim)),
    url("/img/aquaculture-sea-cages.jpg");
  background-size: cover;
  background-position: center;
}

.login-card {
  width: min(440px, 100%);
  padding: var(--sp-6);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.login-brand strong {
  display: block;
  font-size: var(--fs-20);
  font-weight: 600;
}

.login-brand span {
  display: block;
  color: var(--muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.login-field .control {
  height: 40px;
}

.captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: var(--sp-3);
  align-items: center;
}

.captcha-image {
  width: 104px;
  height: 40px;
  padding: 0;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.captcha-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.remember-field {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--fg-2);
}

.remember-field input {
  width: var(--sp-4);
  height: var(--sp-4);
  margin: 0;
  accent-color: var(--fg);
}

.forgot-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.login-secondary {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.login-secondary:hover {
  border-color: var(--fg-2);
}

.login-secondary-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: var(--surface);
}

.login-secondary > span:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.login-secondary strong,
.login-secondary small {
  display: block;
}

.login-secondary strong {
  font-size: var(--fs-14);
  font-weight: 600;
}

.login-secondary small {
  color: var(--muted);
  font-size: var(--fs-14);
}

.login-note {
  color: var(--muted);
  text-align: center;
}

.login-theme {
  position: absolute;
  right: var(--sp-6);
  top: var(--sp-6);
  background: var(--surface);
}

.invalid-card {
  padding: var(--sp-6);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.invalid-card h1 {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-20);
}

.invalid-card p {
  margin: 0 0 var(--sp-4);
  color: var(--muted);
}

.visual-chart {
  min-height: 0;
  overflow: hidden;
}

.chart-body {
  padding: var(--sp-4);
}

.chart-footnote {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-2);
  color: var(--muted);
}

.heat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--sp-2);
}

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

.heat-cell {
  min-height: 66px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  text-align: left;
}

.heat-cell:hover { border-color: var(--fg); }
.heat-cell span, .heat-cell small { color: var(--muted); }
.heat-cell.heat-over { background: var(--group-accent); }
.heat-cell.heat-high { background: var(--surface-3); }
.heat-cell.heat-mid { background: var(--surface-2); }
.heat-cell.heat-low { background: var(--surface); }

.heat-legend {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-top: var(--sp-3);
  color: var(--muted);
}

.heat-legend span {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.heat-legend i {
  width: var(--sp-3);
  height: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.heat-legend .heat-low { background: var(--surface); }
.heat-legend .heat-mid { background: var(--surface-2); }
.heat-legend .heat-high { background: var(--surface-3); }
.heat-legend .heat-over { background: var(--group-accent); }

.bullet-list {
  display: flex;
  flex-direction: column;
}

.bullet-row {
  min-height: 34px;
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr) 46px;
  align-items: center;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
}

.bullet-row:last-child { border-bottom: 0; }

.bullet-track {
  position: relative;
  height: 8px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.bullet-track i {
  display: block;
  height: 100%;
  background: var(--fg);
}

.bullet-track b {
  position: absolute;
  top: -4px;
  width: 1px;
  height: 16px;
  background: var(--fg);
}

.bullet-track em {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  background: var(--group-accent);
  opacity: .7;
}

.radar-chart {
  width: min(300px, 100%);
  height: auto;
  margin: 0 auto;
}

.radar-chart text {
  fill: var(--muted);
  font-size: 14px;
}

.radar-grid,
.radar-axis {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
}

.radar-value {
  fill: var(--group-accent);
  fill-opacity: .5;
  stroke: var(--fg);
  stroke-width: 2;
}

.radar-point {
  fill: var(--surface);
  stroke: var(--fg);
  stroke-width: 2;
}

.radar-score {
  margin-top: calc(-1 * var(--sp-6));
  margin-bottom: var(--sp-4);
  text-align: center;
  color: var(--muted);
  font-family: var(--font-mono);
}

.waterfall-chart,
.stacked-chart,
.dual-axis-chart,
.gantt-chart,
.threshold-chart,
.grouped-bar-chart,
.step-chart,
.scatter-chart {
  width: 100%;
  height: auto;
  min-height: 170px;
}

.waterfall-chart text,
.stacked-chart text,
.dual-axis-chart text,
.gantt-chart text,
.threshold-chart text,
.grouped-bar-chart text,
.step-chart text,
.scatter-chart text {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 14px;
}

.chart-axis,
.gantt-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.wf-bar,
.stack-plan {
  fill: var(--surface-3);
}

.wf-accent,
.stack-residual,
.group-bar-accent {
  fill: var(--group-accent);
}

.stack-actual,
.group-bar-primary {
  fill: var(--fg);
}

.wf-connector {
  stroke: var(--border);
  stroke-dasharray: 3 3;
}

.axis-bar {
  fill: var(--fg);
}

.axis-line {
  fill: none;
  stroke: var(--group-accent);
  stroke-width: 2;
}

.axis-line-point,
.gantt-point,
.threshold-point,
.scatter-point {
  fill: var(--fg);
  stroke: var(--surface);
  stroke-width: 2;
}

.threshold-point.warn,
.scatter-point.alert {
  fill: var(--group-accent);
  stroke: var(--fg);
}

.gantt-track,
.gantt-grid {
  stroke: var(--border-soft);
}

.gantt-use {
  stroke: var(--fg);
  stroke-width: 8;
}

.gantt-withdraw {
  stroke: var(--group-accent);
  stroke-width: 8;
}

.threshold-outside {
  fill: var(--surface-2);
}

.threshold-line {
  stroke: var(--border);
  stroke-dasharray: 5 5;
}

.threshold-series {
  fill: none;
  stroke: var(--fg);
  stroke-width: 2;
}

.funnel-chart {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.funnel-step {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
}

.funnel-step span {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(4% 0, 96% 0, 100% 50%, 96% 100%, 4% 100%, 0 50%);
  background: var(--fg);
  color: var(--on-ink);
}

.funnel-step:nth-child(2n) span { background: var(--surface-3); color: var(--fg); }
.funnel-step:last-child span { background: var(--group-accent); color: var(--fg); }

.funnel-step strong {
  min-width: 34px;
  padding-left: var(--sp-2);
}

.semi-ring {
  position: relative;
  width: min(320px, 100%);
  margin: 0 auto;
}

.semi-ring svg {
  width: 100%;
  height: auto;
}

.semi-track,
.semi-value {
  fill: none;
  stroke-width: 18;
  stroke-linecap: butt;
}

.semi-track { stroke: var(--surface-3); }
.semi-value { stroke: var(--fg); }

.semi-center {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.semi-center strong {
  font-size: var(--fs-24);
}

.semi-center span {
  color: var(--muted);
  white-space: nowrap;
}

.sankey-chart {
  display: flex;
  align-items: stretch;
  gap: var(--sp-2);
}

.sankey-step {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  text-align: left;
}

.sankey-step i {
  display: block;
  height: 4px;
  max-width: 100%;
  background: var(--fg);
}

.sankey-step:last-of-type i { background: var(--group-accent); }

.sankey-arrow {
  align-self: center;
  color: var(--muted);
  font-weight: 400;
}

.relation-mini {
  position: relative;
  min-height: 250px;
  border-radius: var(--r-sm);
  background: var(--bg-sub);
  overflow: hidden;
}

.relation-mini svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.relation-edge {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
}

.relation-node {
  position: absolute;
  width: 154px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  text-align: left;
  transform: translate(-50%, -50%);
}

.relation-node span,
.relation-node small { color: var(--muted); }
.relation-node.accent { border-color: var(--group-accent); }
.relation-node.focus { border-width: 2px; border-color: var(--fg); }

.gauge-chart {
  position: relative;
  width: min(320px, 100%);
  margin: 0 auto;
}

.gauge-chart svg {
  width: 100%;
  height: auto;
}

.gauge-track,
.gauge-value {
  fill: none;
  stroke-width: 16;
  stroke-linecap: butt;
}

.gauge-track { stroke: var(--surface-3); }
.gauge-value { stroke: var(--fg); }
.gauge-needle { stroke: var(--fg); stroke-width: 2; }
.gauge-hub { fill: var(--fg); }
.gauge-threshold { stroke: var(--group-accent); stroke-width: 3; }

.gauge-label {
  margin-top: calc(-1 * var(--sp-5));
  text-align: center;
}

.gauge-label strong {
  display: block;
  font-size: var(--fs-24);
}

.gauge-label span {
  color: var(--muted);
}

.step-added,
.step-closed {
  fill: none;
  stroke-width: 2;
}

.step-added { stroke: var(--fg); }
.step-closed { stroke: var(--group-accent); }

.group-prod .data-table td { height: 44px; }
.group-quality .data-table td { height: 48px; }
.group-flow .data-table td { height: 52px; }
.group-gov .data-table td { height: 40px; }
.group-overview .data-table td { height: 44px; }
.group-external .data-table td { height: 56px; }

.timeline-ledger {
  position: relative;
  padding: var(--sp-2) var(--sp-4) var(--sp-4);
}

.timeline-ledger-row {
  min-height: 44px;
  display: grid;
  grid-template-columns: 120px 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  position: relative;
}

.timeline-ledger-row::before {
  content: "";
  position: absolute;
  left: 130px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-ledger-row:first-child::before { top: 50%; }
.timeline-ledger-row:last-child::before { bottom: 50%; }

.timeline-ledger-row time {
  color: var(--muted);
  text-align: right;
}

.timeline-ledger-node {
  position: relative;
  z-index: 1;
  width: 8px;
  height: 8px;
  margin-left: 7px;
  border: 1px solid var(--fg);
  border-radius: var(--r-pill);
  background: var(--surface);
}

.timeline-ledger-row.current .timeline-ledger-node {
  background: var(--group-accent);
}

.timeline-ledger-copy {
  min-width: 0;
}

.timeline-ledger-copy strong,
.timeline-ledger-copy span {
  display: block;
}

.timeline-ledger-copy span { color: var(--muted); }

.pond-ledger-layout,
.seed-ledger-layout,
.batch-primary-layout,
.feeding-primary-layout,
.quality-primary-layout,
.water-primary-layout,
.harvest-visual-layout,
.governance-ledger-layout,
.alerts-primary-layout,
.recall-primary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--sp-4);
  align-items: stretch;
}

.ledger-side-stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

:is(
  .grid.two,
  .grid.wide-side,
  .grid.side-left,
  .pond-ledger-layout,
  .batch-primary-layout,
  .feeding-primary-layout,
  .quality-primary-layout,
  .water-primary-layout,
  .harvest-visual-layout,
  .governance-ledger-layout,
  .alerts-primary-layout,
  .recall-primary-layout,
  .input-drawer-body,
  .input-lower-grid,
  .input-bottom-grid
) > .card {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

:is(
  .grid.two,
  .grid.wide-side,
  .grid.side-left,
  .pond-ledger-layout,
  .batch-primary-layout,
  .feeding-primary-layout,
  .quality-primary-layout,
  .water-primary-layout,
  .harvest-visual-layout,
  .governance-ledger-layout,
  .alerts-primary-layout,
  .recall-primary-layout,
  .input-drawer-body,
  .input-lower-grid,
  .input-bottom-grid
) > .card > :is(.card-body, .chart-body) {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

:is(
  .grid.two,
  .grid.wide-side,
  .grid.side-left,
  .pond-ledger-layout,
  .batch-primary-layout,
  .feeding-primary-layout,
  .quality-primary-layout,
  .water-primary-layout,
  .harvest-visual-layout,
  .governance-ledger-layout,
  .alerts-primary-layout,
  .recall-primary-layout,
  .input-drawer-body,
  .input-lower-grid,
  .input-bottom-grid
) > .card > :is(.card-body, .chart-body) > :last-child {
  margin-top: auto;
}

.alerts-primary-layout > .ledger-side-stack,
.batch-primary-layout > .ledger-side-stack,
.harvest-visual-layout > .ledger-side-stack,
.quality-primary-layout > .ledger-side-stack,
.governance-ledger-layout > .ledger-side-stack,
.recall-primary-layout > .ledger-side-stack {
  align-self: stretch;
}

.ledger-side-stack > .card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.ledger-side-stack > .card > :is(.card-body, .chart-body) {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

:is(
  .grid.two,
  .grid.wide-side,
  .grid.side-left,
  .pond-ledger-layout,
  .batch-primary-layout,
  .feeding-primary-layout,
  .quality-primary-layout,
  .water-primary-layout,
  .harvest-visual-layout,
  .governance-ledger-layout,
  .alerts-primary-layout,
  .recall-primary-layout,
  .input-drawer-body,
  .input-lower-grid,
  .input-bottom-grid
) .card-body.flush > .table-wrap {
  min-height: 0;
  flex: 1 1 auto;
}

:is(
  .grid.two,
  .grid.wide-side,
  .grid.side-left,
  .pond-ledger-layout,
  .batch-primary-layout,
  .feeding-primary-layout,
  .quality-primary-layout,
  .water-primary-layout,
  .harvest-visual-layout,
  .governance-ledger-layout,
  .alerts-primary-layout,
  .recall-primary-layout,
  .input-drawer-body,
  .input-lower-grid,
  .input-bottom-grid
) .card-body.flush > .table-wrap > .data-table {
  height: 100%;
}

.pond-card-wall {
  flex: 1 1 auto;
  grid-auto-rows: minmax(160px, 1fr);
}

.pond-ledger-card,
.kanban-card,
.split-alert-card {
  display: flex;
  flex-direction: column;
}

.pond-ledger-card .card-link,
.kanban-card .card-link {
  margin-top: auto;
}

.master-detail-body {
  align-items: stretch;
}

.master-list,
.master-detail,
.master-detail-columns > *,
.validation-list {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.master-row,
.validation-item {
  flex: 1 1 auto;
}

.validation-list {
  flex: 1 1 auto;
  justify-content: space-between;
}

.kanban-column {
  display: flex;
  flex-direction: column;
}

.kanban-stack {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kanban-card {
  flex: 1 1 auto;
  justify-content: space-between;
}

.calendar-ledger .calendar-grid,
.matrix-ledger .water-matrix {
  height: 100%;
  grid-auto-rows: minmax(58px, 1fr);
}

.thumbnail-list {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.thumbnail-row {
  flex: 1 1 auto;
}

.step-flow-ledger .step-flow {
  height: 100%;
}

.result-right,
.input-drawer,
.split-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.result-right > .card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.result-right > .card > .card-body {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.result-right .test-result-list,
.result-right .timeline {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.input-drawer {
  justify-content: space-between;
}

.input-drawer .meta-list {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.grid.side-left > .card > :last-child {
  min-height: 0;
  flex: 1 1 auto;
}

.alert-list {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.alert-item {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
}

.alert-item .alert-copy {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.split-list {
  max-height: none;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.split-alert-card,
.split-list > .kanban-empty {
  flex: 1 1 auto;
}

.split-alert-card {
  justify-content: space-between;
}

.pond-card-wall {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.pond-ledger-card {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.pond-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.pond-ledger-card > span {
  color: var(--muted);
}

.pond-card-meta {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: var(--sp-2);
  color: var(--muted);
}

.pond-card-meta b {
  color: var(--fg);
  text-align: right;
}

.card-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  align-self: stretch;
  margin-top: auto;
  padding: var(--sp-2) 0 0;
  border: 0;
  border-top: 1px solid var(--border-soft);
  background: transparent;
  color: var(--fg);
  text-align: left;
}

.master-detail-body {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  min-height: 600px;
}

.master-list {
  border-right: 1px solid var(--border);
}

.master-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}

.master-row:hover,
.master-row.selected {
  background: var(--surface-2);
}

.master-row.selected {
  box-shadow: inset 2px 0 0 var(--group-accent);
}

.master-row-main,
.master-row-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.master-row-main strong,
.master-row-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.master-row-main small,
.master-row-meta {
  color: var(--muted);
}

.master-row-meta {
  align-items: flex-end;
}

.master-detail {
  padding: var(--sp-4);
}

.master-detail-head {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.master-detail-head h2 {
  margin: var(--sp-1) 0;
  font-size: var(--fs-20);
}

.master-detail-head span {
  color: var(--muted);
}

.master-detail-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--sp-5);
  padding-top: var(--sp-4);
}

.master-radar {
  min-width: 0;
}

.master-detail-table {
  margin: 0 var(--sp-4) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.master-detail-table > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  background: var(--surface-2);
  list-style: none;
  cursor: pointer;
}

.master-detail-table > summary::-webkit-details-marker { display: none; }
.master-detail-table > summary svg { margin-left: auto; }
.master-detail-table[open] > summary svg { transform: rotate(90deg); }
.master-detail-table-body { border-top: 1px solid var(--border); }

.business-disclosure {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.business-disclosure > summary {
  min-height: 52px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 18px;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.business-disclosure > summary::-webkit-details-marker { display: none; }
.business-disclosure > summary span { color: var(--muted); font-weight: 400; }
.business-disclosure[open] > summary svg { transform: rotate(90deg); }
.business-disclosure .module-workbench { border: 0; border-top: 1px solid var(--border); border-radius: 0; }

.seed-ledger-layout {
  grid-template-columns: minmax(0, 1fr) 380px;
}

.fold-ledger-group {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.fold-ledger-group + .fold-ledger-group {
  margin-top: var(--sp-2);
}

.fold-ledger-group summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-3);
  cursor: pointer;
  list-style: none;
  background: var(--surface-2);
}

.fold-ledger-group summary::-webkit-details-marker { display: none; }
.fold-ledger-group summary small { margin-left: auto; color: var(--muted); }
.fold-ledger-group[open] summary > svg { transform: rotate(90deg); }

.fold-rows {
  border-top: 1px solid var(--border);
}

.fold-row {
  min-height: 44px;
  display: grid;
  grid-template-columns: 132px minmax(140px, 1fr) 82px minmax(120px, .9fr) 110px 74px;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
}

.fold-row:last-child { border-bottom: 0; }
.fold-row div { min-width: 0; }
.fold-row div > span { display: block; color: var(--muted); }
.fold-row div > strong { display: block; font-weight: 500; }
.fold-row-actions { display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-1); }
.fold-row-actions button { border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }

.batch-primary-layout {
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr);
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 520px;
}

.kanban-column {
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-sub);
}

.kanban-column:last-child { border-right: 0; }

.kanban-column > header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.kanban-column > header span { color: var(--muted); }
.kanban-column.accent > header { box-shadow: inset 0 3px 0 var(--group-accent); }
.kanban-stack { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2); max-height: 620px; overflow-y: auto; }

.kanban-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.kanban-card span,
.kanban-card small { color: var(--muted); }
.kanban-empty { padding: var(--sp-4); color: var(--muted); text-align: center; }

.feeding-primary-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 84px repeat(var(--calendar-columns), minmax(110px, 1fr));
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.calendar-corner,
.calendar-head,
.calendar-date,
.calendar-cell {
  min-height: 44px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.calendar-corner,
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2);
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}

.calendar-date {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--muted);
}

.calendar-cell {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: var(--sp-2);
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  text-align: left;
}

.calendar-cell span { color: var(--muted); }
.calendar-cell.warning { background: var(--warn-bg); }
.calendar-cell.empty { color: var(--muted); cursor: default; }
.calendar-foot { display: flex; gap: var(--sp-4); margin-top: var(--sp-3); color: var(--muted); }

.detail-disclosure {
  overflow: hidden;
}

.detail-disclosure > summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.detail-disclosure > summary::-webkit-details-marker { display: none; }
.detail-disclosure > summary span { margin-left: auto; }
.detail-disclosure[open] > summary span svg { transform: rotate(90deg); }

.input-drawer-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  padding: var(--sp-3);
}

.input-row-list {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.input-ledger-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: 142px minmax(210px, 1fr) 120px 80px 96px 54px;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
}

.input-ledger-row:hover { background: var(--surface-2); }
.input-row-name,
.input-row-name small { display: block; }
.input-row-name small,
.input-row-meta { color: var(--muted); }

.input-drawer {
  min-width: 0;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.input-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}

.input-drawer-head button {
  border: 0;
  background: transparent;
}

.input-drawer .meta-row {
  padding: var(--sp-1) 0;
}

.input-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--sp-4);
}

.storage-row {
  min-height: 46px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--border-soft);
}

.storage-row:last-child { border-bottom: 0; }
.storage-row span { color: var(--muted); }

.input-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(280px, .9fr);
  gap: var(--sp-4);
}

.quality-primary-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.drug-strip-list {
  display: flex;
  flex-direction: column;
}

.drug-strip-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: 190px minmax(240px, 1fr) minmax(250px, .9fr) auto 44px;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}

.drug-strip-row:last-child { border-bottom: 0; }
.drug-strip-id,
.drug-strip-meta { min-width: 0; display: flex; flex-direction: column; }
.drug-strip-id span,
.drug-strip-meta span { color: var(--muted); }

.drug-strip-band {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.drug-strip-band i { height: 100%; background: var(--fg); }
.drug-strip-band b { height: 100%; background: var(--group-accent); }
.drug-strip-band span { position: absolute; left: var(--sp-2); color: var(--on-ink); font-family: var(--font-mono); }

.water-primary-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.water-matrix {
  display: grid;
  grid-template-columns: 100px repeat(7, minmax(58px, 1fr));
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.water-matrix-corner,
.water-matrix-date,
.water-matrix-label,
.water-matrix-cell {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-1);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.water-matrix-corner,
.water-matrix-date,
.water-matrix-label { background: var(--surface-2); color: var(--muted); }
.water-matrix-cell { position: relative; border-top: 0; border-left: 0; background: var(--surface); color: var(--fg); }
.water-matrix-cell i { width: 7px; height: 7px; border-radius: var(--r-pill); background: var(--fg); }
.water-matrix-cell span { position: absolute; bottom: 2px; right: 4px; color: var(--muted); font-size: var(--fs-14); }
.water-matrix-cell.warn { background: var(--warn-bg); }
.water-matrix-cell.warn i { background: var(--group-accent); box-shadow: 0 0 0 1px var(--fg); }
.metric-strip { display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }

.harvest-visual-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.step-flow {
  display: grid;
  grid-template-columns: 1fr 24px 1fr 24px 1fr 24px 1fr 24px 1fr;
  align-items: stretch;
  padding: var(--sp-3);
}

.step-flow-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-sub);
}

.step-flow-column > header {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2);
  border-bottom: 1px solid var(--border);
}

.step-flow-column > header small { margin-left: auto; color: var(--muted); }
.step-flow-column > footer { padding: var(--sp-2); }
.step-flow-list { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2); min-height: 310px; }

.step-flow-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  text-align: left;
}

.step-flow-card span,
.step-flow-card small { color: var(--muted); }
.step-arrow { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.step-flow-column:nth-of-type(5) { box-shadow: inset 0 3px 0 var(--group-accent); }

.test-thumb-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.thumbnail-list { display: flex; flex-direction: column; }

.thumbnail-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: 48px minmax(260px, 1fr) 220px auto 44px;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-1) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}

.thumbnail-row:last-child { border-bottom: 0; }
.conclusion-stamp {
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: var(--r-sm);
  font-weight: 600;
  line-height: 1;
}

.conclusion-stamp small { margin-top: 2px; font-size: var(--fs-14); font-weight: 400; }
.conclusion-stamp.success { color: var(--success); }
.conclusion-stamp.warn { color: var(--warn); }
.conclusion-stamp.danger { color: var(--danger); }
.thumbnail-main,
.thumbnail-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thumbnail-main span,
.thumbnail-main small,
.thumbnail-meta span { color: var(--muted); }

.governance-ledger-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.governance-tabs {
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
}

.governance-tabs span {
  padding: 4px var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--muted);
}

.governance-tabs span.active {
  border-color: var(--fg);
  color: var(--fg);
  background: var(--surface-2);
}

.audit-stream {
  max-height: 520px;
  overflow-y: auto;
}

.audit-stream-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  gap: var(--sp-2);
  align-items: start;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}

.audit-stream-row time,
.audit-stream-row span { color: var(--muted); }
.audit-stream-row strong,
.audit-stream-row span { display: block; }

.alerts-primary-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

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

.split-column {
  min-width: 0;
  border-right: 1px solid var(--border);
}

.split-column:last-child { border-right: 0; }

.split-column > header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.split-column.handled { background: var(--bg-sub); }
.split-list { max-height: 570px; overflow-y: auto; }

.split-alert-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
}

.split-alert-card p { margin: 0; color: var(--muted); }
.split-alert-foot { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; color: var(--muted); }

.recall-primary-layout {
  grid-template-columns: minmax(0, 1fr) 390px;
}

.indent-tree details {
  margin: 0;
}

.indent-tree summary {
  min-height: 38px;
  display: grid;
  grid-template-columns: 18px minmax(120px, .7fr) minmax(180px, 1fr) auto;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2);
  border-bottom: 1px solid var(--border-soft);
  list-style: none;
  cursor: pointer;
}

.indent-tree summary::-webkit-details-marker { display: none; }
.indent-tree summary span:not(.tree-caret):not(.status) { color: var(--muted); }
.tree-caret { color: var(--muted); text-align: center; }
.tree-children { margin-left: 22px; }
.tree-summary { display: flex; align-items: center; gap: var(--sp-4); margin-top: var(--sp-4); padding: var(--sp-3); background: var(--surface-2); }
.tree-summary .card-link { margin-left: auto; border-top: 0; padding: 0; align-self: auto; }

.batch-node-card .progress-row {
  grid-template-columns: 100px minmax(0, 1fr) 46px;
}

.public-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.public-code-band {
  height: 40px;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-sub);
  color: var(--muted);
}

.public-code-band .align-ticks { flex: 1; justify-content: flex-start; }
.public-code-band > :last-child { margin-left: auto; }
.login-group-chip { margin-left: auto; align-self: flex-start; }

@media (max-width: 1240px) {
  .sidebar {
    width: 210px;
    flex-basis: 210px;
  }

  .workspace {
    width: calc(100vw - 210px);
  }

  .top-search {
    width: 180px;
  }

  .date-range {
    display: none;
  }

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

  .grid.wide-side,
  .grid.side,
  .grid.harvest-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

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

@media (max-width: 900px) {
  button,
  .btn,
  .card-action,
  .card-link,
  .legend-item,
  .scope-select,
  input,
  select,
  textarea,
  a[data-link] {
    min-height: 32px;
  }

  button,
  .card-action,
  .card-link,
  .legend-item,
  .public-brand > a {
    display: inline-flex;
    align-items: center;
  }

  .public-links a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
  }

  .data-table .actions button,
  .data-table .actions a {
    min-width: 32px;
    min-height: 32px;
    padding: var(--sp-1) var(--sp-2);
  }

  .fold-rows,
  .drug-strip-list,
  .thumbnail-list,
  .indent-tree-ledger,
  .card-body.flush {
    max-width: 100%;
    overflow-x: auto;
  }

  .tree-summary {
    flex-wrap: wrap;
    min-width: 0;
  }

  .sidebar {
    position: fixed;
    left: -236px;
    width: 236px;
    flex-basis: 236px;
    z-index: 30;
    transition: left .16s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .workspace {
    width: 100%;
  }

  .mobile-menu {
    display: inline-flex !important;
  }

  .data-stamp,
  .scope-select,
  .top-search {
    display: none;
  }

  .page-content {
    padding: var(--sp-4);
  }

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

  .group-band-meta,
  .band-code,
  .band-scale,
  .threshold-preview {
    display: none;
  }

  .pond-ledger-layout,
  .seed-ledger-layout,
  .batch-primary-layout,
  .feeding-primary-layout,
  .quality-primary-layout,
  .water-primary-layout,
  .harvest-visual-layout,
  .governance-ledger-layout,
  .alerts-primary-layout,
  .recall-primary-layout,
  .input-lower-grid,
  .input-bottom-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .master-detail-body,
  .master-detail-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .master-list {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

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

  .kanban-column {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .calendar-grid,
  .water-matrix {
    min-width: 720px;
  }

  .calendar-ledger,
  .matrix-ledger {
    overflow-x: auto;
  }

  .input-drawer-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .input-ledger-row {
    grid-template-columns: 130px minmax(180px, 1fr) 100px 80px;
  }

  .input-ledger-row > :nth-child(n+5) {
    display: none;
  }

  .step-flow {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-2);
  }

  .step-arrow {
    transform: rotate(90deg);
  }

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

  .split-column {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .grid.five,
  .grid.side-left,
  .result-main {
    grid-template-columns: minmax(0, 1fr);
  }

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

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

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

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

@media (max-width: 560px) {
  .topbar {
    padding: 0 var(--sp-4);
  }

  .page-title {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

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

  .topbar-right .date-range {
    display: none;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-group,
  .filter-form {
    width: 100%;
  }

  .filter-form .control,
  .filter-form .btn {
    flex: 1;
  }

  .public-main {
    width: calc(100% - 32px);
    padding: var(--sp-6) 0;
  }

  .public-header {
    padding: 0 var(--sp-4);
  }

  .public-links {
    gap: var(--sp-2);
  }

  .public-links a:first-child {
    display: none;
  }

  .scan-card {
    padding: var(--sp-4);
  }

  .scan-box {
    min-height: 180px;
  }

  .verify-form {
    flex-direction: column;
  }

  .result-hero {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .qr-frame {
    width: 100%;
  }

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

  .map-ring-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
    align-items: stretch;
    padding-top: var(--sp-4);
  }

  .map-ring {
    width: 100%;
    min-width: 0;
    height: 100px;
  }

  .map-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-foot-notes {
    align-items: flex-start;
    text-align: left;
  }

  .timeline-item {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .timeline-time {
    grid-column: 2;
  }

  .timeline-copy {
    grid-column: 2;
  }

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