:root {
  --ink: #18201f;
  --muted: #66706e;
  --line: #dce2df;
  --line-strong: #c7d0cc;
  --paper: #ffffff;
  --canvas: #f3f5f4;
  --nav: #202927;
  --nav-muted: #aab6b2;
  --accent: #287565;
  --accent-strong: #1f6255;
  --accent-soft: #e3f0ec;
  --amber: #9c641c;
  --amber-soft: #f8edd9;
  --red: #a43e36;
  --red-soft: #f9e7e5;
  --blue: #315f83;
  --blue-soft: #e5eef5;
  --radius: 6px;
  --shadow: 0 12px 32px rgba(31, 49, 44, 0.08);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100dvh; background: var(--canvas); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .button { letter-spacing: 0; }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--nav); color: #f3f7f5; padding: 18px 14px 14px; }
.brand { display: flex; align-items: center; gap: 11px; min-height: 48px; padding: 0 7px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: 15px; font-weight: 650; }
.brand small, .user-identity small { color: var(--nav-muted); font-size: 11px; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 5px; background: #d7eee8; color: #1f6255; font: 700 17px/1 Consolas, monospace; }
.brand-mark.large { width: 46px; height: 46px; font-size: 22px; }
.nav-list { display: grid; gap: 3px; padding-top: 18px; }
.nav-list a { min-height: 39px; display: flex; align-items: center; padding: 0 12px; border-radius: 5px; color: #d0dad7; font-size: 14px; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav-list a:hover { color: #fff; background: rgba(255,255,255,.075); }
.nav-list a:active { transform: scale(.985); }
.nav-list a.active { color: #fff; background: #33433f; box-shadow: inset 3px 0 0 #63b6a2; }
.nav-divider { height: 1px; background: rgba(255,255,255,.1); margin: 11px 8px; }
.nav-advanced { margin-top: 9px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.1); }
.nav-advanced summary { min-height: 36px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: var(--nav-muted); font-size: 12px; cursor: pointer; list-style: none; }
.nav-advanced summary::-webkit-details-marker { display: none; }
.nav-advanced summary::after { content: "+"; font: 700 16px/1 Consolas, monospace; }
.nav-advanced[open] summary::after { content: "−"; }
.nav-sublist { display: grid; gap: 2px; padding: 2px 0 4px 8px; }
.nav-sublist a { min-height: 34px; font-size: 13px; }
.sidebar-footer { margin-top: auto; padding: 14px 7px 2px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 8px; }
.user-identity { min-width: 0; display: flex; align-items: center; gap: 9px; flex: 1; }
.user-identity span:nth-child(2) { min-width: 0; display: grid; }
.user-identity strong { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.avatar { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #45625b; color: #fff; font-weight: 700; }
.text-button { border: 0; padding: 6px; background: transparent; color: var(--nav-muted); cursor: pointer; }
.text-button:hover { color: #fff; }

.page-column { min-width: 0; }
.topbar { height: 58px; position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; padding: 0 28px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.topbar-title { font-size: 15px; font-weight: 650; }
.quick-search { min-width: 250px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--canvas); color: var(--muted); font-size: 13px; }
.menu-button { display: none; }
.content { width: min(1420px, 100%); margin: 0 auto; padding: 28px; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-heading > div { min-width: 0; }
.page-heading h1 { margin: 0 0 5px; font-size: 24px; line-height: 1.25; letter-spacing: 0; overflow-wrap: anywhere; }
.page-heading p { margin: 0; max-width: 70ch; color: var(--muted); font-size: 14px; line-height: 1.6; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font: 700 11px/1.2 Consolas, monospace; letter-spacing: 0; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--paper); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { background: #f8faf9; border-color: #9faeaa; }
.button:active { transform: scale(.98); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-strong); }
.button.danger { color: var(--red); border-color: #d9aaa6; }
.button.small { min-height: 31px; padding: 5px 10px; font-size: 12px; }
.button.wide { width: 100%; }
.button[disabled] { opacity: .55; cursor: not-allowed; }

.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; margin-bottom: 24px; }
.metric { min-height: 105px; padding: 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 9px; font: 700 28px/1 Consolas, "Microsoft YaHei UI", sans-serif; }
.metric em { display: block; margin-top: 8px; color: var(--accent); font-size: 11px; font-style: normal; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr); gap: 22px; align-items: start; }
.section { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.section-header { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.section-header h2 { margin: 0; font-size: 15px; }
.section-body { padding: 18px; }
.section-body.flush { padding: 0; }
.section-note { color: var(--muted); font-size: 12px; }

.data-table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 10px 12px; background: #f7f9f8; border-bottom: 1px solid var(--line); color: #596461; font-size: 12px; font-weight: 650; text-align: left; white-space: nowrap; }
.data-table td { padding: 11px 12px; border-bottom: 1px solid #e9eeec; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfb; }
.code { font-family: Consolas, "SFMono-Regular", monospace; font-weight: 650; white-space: nowrap; }
.cell-main { display: block; font-weight: 600; }
.cell-sub { display: block; margin-top: 3px; max-width: 64ch; color: var(--muted); font-size: 12px; line-height: 1.45; }

.status { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 99px; background: #e9eeec; color: #4b5754; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status.engineering, .status.exported { background: var(--blue-soft); color: var(--blue); }
.status.master, .status.needs_changes { background: var(--amber-soft); color: var(--amber); }
.status.approved, .status.created, .status.enabled, .status.memory_coded, .status.rule_coded, .status.fallback_coded { background: var(--accent-soft); color: var(--accent-strong); }
.status.completed, .status.confirmed, .status.auto_completed, .status.auto_fallback { background: var(--accent-soft); color: var(--accent-strong); }
.status.existing, .status.ready, .status.requests_created { background: var(--accent-soft); color: var(--accent-strong); }
.status.review, .status.processing, .status.auto_processing, .status.auto_finalizing, .status.researching, .status.awaiting_range { background: var(--amber-soft); color: var(--amber); }
.status.submitted { background: var(--blue-soft); color: var(--blue); }
.status.blocked, .status.failed, .status.error { background: var(--red-soft); color: var(--red); }
.status.cancelled, .status.conflict { background: var(--red-soft); color: var(--red); }
.status.pending, .status.draft, .status.disabled { background: #e9eeec; color: #596461; }

.message-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.message { padding: 11px 13px; border-left: 3px solid var(--accent); border-radius: 3px; background: var(--accent-soft); color: #214f45; font-size: 13px; }
.message.error { border-color: var(--red); background: var(--red-soft); color: #7c2f29; }
.message.warning { border-color: var(--amber); background: var(--amber-soft); color: #774d18; }

.form-shell { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.form-section { padding: 22px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section-heading { margin-bottom: 17px; }
.form-section-heading h2 { margin: 0 0 4px; font-size: 16px; }
.form-section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; align-content: start; gap: 7px; min-width: 0; }
.field[hidden] { display: none !important; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 650; color: #3b4643; }
.field input, .field select, .field textarea { width: 100%; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; color: var(--ink); padding: 8px 10px; outline: none; transition: border-color .16s ease, box-shadow .16s ease; }
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(40,117,101,.12); }
.field input:disabled, .field select:disabled { background: #eef1f0; color: var(--muted); }
.helptext { color: var(--muted); font-size: 11px; line-height: 1.45; }
.field-error, .errorlist { margin: 0; color: var(--red); font-size: 12px; list-style: none; padding: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px; background: #f8faf9; }
.required::after { content: " *"; color: var(--red); }

.search-form { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 8px; margin-bottom: 20px; }
.search-input { width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--paper); font-size: 15px; outline: none; }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(40,117,101,.12); }
.search-groups { display: grid; gap: 20px; }

.empty-state { min-height: 190px; display: grid; place-items: center; padding: 32px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 5px; }
.empty-state p { margin: 0; font-size: 13px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.detail-list { margin: 0; display: grid; grid-template-columns: 160px minmax(0, 1fr); }
.detail-list dt, .detail-list dd { margin: 0; padding: 11px 14px; border-bottom: 1px solid #e9eeec; }
.detail-list dt { color: var(--muted); font-size: 12px; background: #fafbfb; }
.detail-list dd { font-size: 13px; overflow-wrap: anywhere; }
.timeline { position: relative; display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0 0 20px 24px; }
.timeline-item::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline-item::after { content: ""; position: absolute; left: 8px; top: 17px; bottom: 1px; width: 1px; background: var(--line); }
.timeline-item:last-child::after { display: none; }
.timeline-item strong { display: block; font-size: 13px; }
.timeline-item time, .timeline-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.callout { padding: 13px 14px; border-left: 3px solid var(--blue); background: var(--blue-soft); color: #294f6b; font-size: 13px; line-height: 1.5; }
.callout.warning { border-color: var(--amber); background: var(--amber-soft); color: #704916; }
.callout.danger { border-color: var(--red); background: var(--red-soft); color: #762d28; }
.rule-list { display: grid; gap: 8px; }
.rule-item { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rule-item:last-child { border-bottom: 0; }
.rule-item strong { font-size: 13px; }
.rule-item small { display: block; margin-top: 3px; color: var(--muted); }
.bom-result-table { min-width: 1180px; }
.bom-designator { max-width: 230px; max-height: 5.8em; overflow: hidden; }
.issue-line { color: #704916; }
.bom-metrics { grid-template-columns: repeat(5, minmax(130px, 1fr)); }
.bom-metrics.agent { grid-template-columns: repeat(6, minmax(120px, 1fr)); }
.bom-metrics .metric { color: var(--ink); transition: background .16s ease, box-shadow .16s ease; }
.bom-metrics .metric:hover { background: #f8faf9; }
.bom-metrics .metric.selected { background: #f4f8f6; box-shadow: inset 0 -3px 0 var(--accent); }
.bom-metrics .metric.success em, .count-success { color: var(--accent); }
.bom-metrics .metric.info em, .count-info { color: var(--blue); }
.bom-metrics .metric.warning em, .count-warning { color: var(--amber); }
.callout.success { border-color: var(--accent); background: var(--accent-soft); color: #214f45; margin-bottom: 18px; }
.status-row-existing { background: rgba(227, 240, 236, .24); }
.status-row-ready, .status-row-created { background: rgba(229, 238, 245, .23); }
.status-row-review, .status-row-awaiting_range { background: rgba(248, 237, 217, .28); }
.status-row-blocked { background: rgba(249, 231, 229, .3); }
.status.excluded { background: #eef1f0; color: #596461; }
.status-row-excluded { background: rgba(238, 241, 240, .55); }
.bom-heading .page-actions form { margin: 0; }
.bom-batch-table { min-width: 1080px; }
.agent-monitor { margin-bottom: 24px; overflow: hidden; }
.agent-monitor-header { min-height: 64px; }
.agent-monitor-header > div { display: grid; gap: 5px; }
.agent-monitor-header h2 { display: flex; align-items: center; gap: 9px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: agent-live-pulse 1.8s cubic-bezier(.16,1,.3,1) infinite; }
.agent-monitor-total { color: var(--muted); font-size: 12px; white-space: nowrap; }
.agent-monitor-total strong { color: var(--ink); font: 700 20px/1 Consolas, "Microsoft YaHei UI", sans-serif; }
.agent-monitor-body { display: grid; }
.agent-progress-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.45fr); gap: 24px; padding: 22px; border-bottom: 1px solid var(--line); }
.agent-progress-summary { display: grid; align-content: start; gap: 20px; padding-right: 24px; border-right: 1px solid var(--line); }
.agent-progress-item { display: grid; gap: 8px; }
.agent-progress-item > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.agent-progress-item strong { font-size: 13px; }
.agent-progress-item span { color: var(--blue); font: 700 13px/1 Consolas, monospace; }
.agent-progress-item small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.agent-progress-track { height: 8px; overflow: hidden; border-radius: 3px; background: #e8eeec; }
.agent-progress-track > span { display: block; width: var(--progress-value); height: 100%; background: var(--blue); }
.agent-progress-item.resolved span { color: var(--accent); }
.agent-progress-item.resolved .agent-progress-track > span { background: var(--accent); }
.agent-stage-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; align-items: start; margin: 0; padding: 4px 0 0; list-style: none; }
.agent-stage-flow li { position: relative; display: grid; justify-items: start; gap: 10px; min-width: 0; padding-right: 16px; }
.agent-stage-flow li::after { content: ""; position: absolute; top: 14px; left: 34px; right: 6px; height: 2px; background: var(--line); }
.agent-stage-flow li:last-child::after { display: none; }
.agent-stage-index { position: relative; z-index: 1; display: inline-grid; place-items: center; width: 29px; height: 29px; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--paper); color: var(--muted); font: 700 12px/1 Consolas, monospace; }
.agent-stage-flow li.active .agent-stage-index { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }
.agent-stage-flow li.complete .agent-stage-index { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.agent-stage-flow li.active::after { background: #dcc69d; }
.agent-stage-flow li.complete::after { background: #a9cbc2; }
.agent-stage-flow li > div { display: grid; gap: 4px; }
.agent-stage-flow strong { font-size: 12px; }
.agent-stage-flow small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.agent-stage-flow b { color: var(--ink); font: 700 22px/1 Consolas, monospace; }
.agent-family-summary, .agent-task-list { padding: 18px 22px; }
.agent-task-list { border-top: 1px solid var(--line); }
.agent-subheading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.agent-subheading > div { display: grid; gap: 4px; }
.agent-subheading strong { font-size: 13px; }
.agent-subheading span { color: var(--muted); font-size: 11px; }
.agent-subheading a { color: var(--accent); font-size: 12px; font-weight: 650; }
.agent-family-list { border-top: 1px solid var(--line); }
.agent-family-list > div { display: grid; grid-template-columns: 58px minmax(130px, .65fr) minmax(180px, 1.4fr) auto; gap: 12px; align-items: center; min-height: 48px; border-bottom: 1px solid var(--line); }
.agent-family-list strong { font-size: 12px; }
.agent-family-list small { min-width: 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.agent-family-list b { color: var(--amber); font: 700 13px/1 Consolas, monospace; white-space: nowrap; }
.agent-task-table { min-width: 940px; }
.agent-task-reason { max-width: 42ch; color: #704916; }
.status.queued { background: var(--blue-soft); color: var(--blue); }
.status.retrying { background: var(--amber-soft); color: var(--amber); }
@keyframes agent-live-pulse {
  0%, 100% { opacity: .55; transform: scale(.82); }
  50% { opacity: 1; transform: scale(1.18); }
}
.maintenance-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr); gap: 22px; align-items: start; }
.maintenance-warning { margin-bottom: 18px; }
.maintenance-upload-form { display: grid; gap: 18px; }
.maintenance-form-actions { display: flex; justify-content: flex-end; }
.maintenance-status-list { grid-template-columns: 135px minmax(0, 1fr); }
.maintenance-status-note { display: grid; gap: 5px; padding: 13px 14px; border-top: 1px solid var(--line); font-size: 12px; }
.maintenance-status-note strong { font-size: 12px; }
.maintenance-status-note span { color: var(--muted); line-height: 1.5; }
.maintenance-history { margin-top: 22px; }
.maintenance-table { min-width: 1180px; }
.rule-filter { display: flex; align-items: end; gap: 10px; margin-bottom: 18px; }
.rule-filter label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.rule-filter select { min-width: 180px; height: 38px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--paper); }
.rule-memory-metrics { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
.rule-memory-metrics .metric-text { font-family: inherit; font-size: 20px; }
.rule-memory-table { min-width: 1240px; }
.pollution-table { min-width: 1320px; }
.rule-decision-section { margin-top: 22px; }
.evidence-list { margin-top: 7px; }
.evidence-list summary { cursor: pointer; color: var(--accent); font-size: 11px; }
.evidence-list a { display: block; margin-top: 5px; color: var(--accent); overflow-wrap: anywhere; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.sidebar-close, .sidebar-backdrop { display: none; }

.login-body { background: #eef2f0; }
.login-layout { min-height: 100dvh; display: grid; grid-template-columns: minmax(360px, 1.1fr) minmax(380px, .9fr); }
.login-context { display: flex; flex-direction: column; justify-content: center; padding: clamp(40px, 8vw, 120px); background: var(--nav); color: #f4f7f6; }
.login-context h1 { margin: 8px 0 10px; font-size: clamp(34px, 4.5vw, 62px); letter-spacing: 0; }
.login-context > p:not(.eyebrow) { margin: 0; color: #b9c7c3; line-height: 1.7; }
.login-facts { margin: 46px 0 0; display: grid; max-width: 520px; border-top: 1px solid rgba(255,255,255,.15); }
.login-facts div { display: grid; grid-template-columns: 110px 1fr; padding: 13px 0; border-bottom: 1px solid rgba(255,255,255,.1); }
.login-facts dt { color: #91a5a0; font-size: 12px; }
.login-facts dd { margin: 0; font-size: 13px; }
.login-form-wrap { display: grid; place-items: center; padding: 34px; }
.login-form { width: min(390px, 100%); display: grid; gap: 18px; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.form-heading h2 { margin: 0 0 5px; font-size: 22px; }
.form-heading p { margin: 0; color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .bom-metrics { grid-template-columns: repeat(2, 1fr); }
  .bom-metrics.agent { grid-template-columns: repeat(3, 1fr); }
  .bom-metrics .metric:nth-child(2) { border-right: 0; }
  .bom-metrics .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(n+4) { border-top: 1px solid var(--line); }
  .detail-grid, .content-grid { grid-template-columns: 1fr; }
  .agent-progress-grid { grid-template-columns: 1fr; }
  .agent-progress-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-right: 0; padding-bottom: 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .maintenance-grid { grid-template-columns: 1fr; }
  .field-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body.nav-open { overflow: hidden; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 50; width: 236px; transform: translateX(-100%); transition: transform .25s cubic-bezier(.16,1,.3,1); box-shadow: 18px 0 40px rgba(20,30,27,.18); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-grid; place-items: center; position: absolute; z-index: 2; top: 16px; right: 12px; width: 36px; height: 36px; padding: 0; border: 0; background: transparent; color: #d9e4e1; font-size: 26px; line-height: 1; cursor: pointer; }
  .sidebar-backdrop { position: fixed; z-index: 40; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(13,24,21,.42); }
  body.nav-open .sidebar-backdrop { display: block; }
  .topbar { grid-template-columns: auto 1fr; padding: 0 16px; }
  .menu-button { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); }
  .quick-search { display: none; }
  .content { padding: 18px 14px 34px; }
  .page-heading { display: grid; }
  .page-actions { justify-content: flex-start; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric { border-top: 1px solid var(--line); }
  .metric:nth-child(-n+2) { border-top: 0; }
  .metric:nth-child(even) { border-right: 0; }
  .metric:nth-child(3) { border-right: 1px solid var(--line); }
  .metric:last-child { grid-column: 1 / -1; }
  .bom-metrics { grid-template-columns: 1fr; }
  .bom-metrics.agent { grid-template-columns: 1fr; }
  .bom-metrics .metric { border-right: 0; border-top: 1px solid var(--line); }
  .bom-metrics .metric:first-child { border-top: 0; }
  .bom-metrics .metric:last-child { grid-column: auto; }
  .agent-monitor-header { align-items: flex-start; }
  .agent-monitor-total { white-space: normal; }
  .agent-progress-grid { gap: 18px; padding: 18px 14px; }
  .agent-progress-summary { grid-template-columns: 1fr; gap: 18px; padding-bottom: 18px; }
  .agent-stage-flow { grid-template-columns: 1fr; gap: 0; }
  .agent-stage-flow li { grid-template-columns: 29px minmax(0, 1fr) auto; align-items: start; gap: 11px; padding: 0 0 18px; }
  .agent-stage-flow li::after { top: 31px; bottom: 3px; left: 14px; right: auto; width: 2px; height: auto; }
  .agent-stage-flow li > div { padding-top: 2px; }
  .agent-stage-flow li b { padding-top: 3px; font-size: 18px; }
  .agent-family-summary, .agent-task-list { padding: 16px 14px; }
  .agent-subheading { align-items: flex-start; }
  .agent-family-list > div { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 8px; padding: 10px 0; }
  .agent-family-list small { grid-column: 2 / -1; }
  .agent-task-list .data-table-wrap { overflow: visible; }
  .agent-task-table { min-width: 0; }
  .agent-task-table thead { display: none; }
  .agent-task-table, .agent-task-table tbody, .agent-task-table tr, .agent-task-table td { display: block; width: 100%; }
  .agent-task-table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .agent-task-table tr:last-child { border-bottom: 0; }
  .agent-task-table td { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; padding: 5px 0; border: 0; }
  .agent-task-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; }
  .agent-task-table .cell-sub { margin-top: 2px; }
  .agent-task-reason { max-width: none; }
  .field-grid, .field-grid.three { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-section { padding: 18px 14px; }
  .form-actions { position: sticky; bottom: 0; padding: 12px 14px; }
  .detail-list { grid-template-columns: 115px minmax(0, 1fr); }
  .login-layout { grid-template-columns: 1fr; }
  .login-context { min-height: 340px; padding: 42px 24px; }
  .login-context h1 { font-size: 38px; }
  .login-facts { margin-top: 28px; }
  .login-form-wrap { padding: 24px 14px 50px; }
  .search-form { grid-template-columns: 1fr; }
  .rule-filter { display: grid; }
  .rule-filter select { width: 100%; min-width: 0; }
  .rule-memory-metrics { grid-template-columns: 1fr; }
  .rule-memory-metrics .metric { border-right: 0; border-top: 1px solid var(--line); }
  .rule-memory-metrics .metric:first-child { border-top: 0; }
  .rule-memory-metrics .metric:last-child { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .live-dot { animation: none; }
}
