/* 智蚕卫士 · app.css
   framed-sheet 风格（draw.mjs --app, seed 1149010267）：
   侧栏与顶栏共享一块绿灰色调框架（产品脸：气候/农业工具的绿灰），工作面为
   右、下各内缩 8px 的白色 sheet（16px 圆角、1px 边、无阴影）。
   网格算术：12 列 grid，gap 24px；8 + 4 = 12，两行成对。 */
:root {
  --ground: #f3f7f4;              /* 框架绿灰：桑园的低饱和步 */
  --surface: #ffffff;             /* 白色工作面与卡片 */
  --raised: #f4f6f5;
  --active: #e7ede8;              /* 导航激活 pill */
  --border: #e6eae7;
  --rule: #f0f2f1;
  --control: #cdd3cf;
  --text: #14181a;
  --muted: #5a615d;
  --faint: #6b716d;
  --accent: #2e6b3e;              /* 桑叶绿：数据主色，4.9:1 on white */
  --primary: #1d2320;
  --primary-ink: #ffffff;
  --positive: #1e7b4f;
  --negative: #c4242a;
  --warning: #92400e;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e;
  --pill-neutral-bg: #ebedee; --pill-neutral-ink: #353736;
  --chart-1: #2e6b3e; --chart-2: #2f70bb; --chart-3: #a86f0c;
  --grid: var(--rule);

  --font: "IBM Plex Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --fs-title: 22px; --fs-section: 16px; --fs-kpi: 28px; --fs-body: 14px; --fs-small: 12px;

  --sidebar-width: 228px;
  --topbar-height: 48px;
  --sheet-inset: 8px;
  --radius-sheet: 16px;
  --pad: 24px;
  --gap: 24px;                    /* 唯一 gutter，横竖一致 */
  --card-pad: 20px;
  --radius-card: 8px;
  --radius-control: 6px;
  --control-height: 32px;
  --row-height: 48px;
  --nav-row: 34px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms; --t-hover: 150ms; --t-ui: 200ms;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: var(--fs-body)/20px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, table, .kpi-value { font-variant-numeric: tabular-nums; }

/* ---------- shell：绿灰 L 框架 + 白色 sheet ---------- */
.frame { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100svh; }

.sidebar { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; gap: 2px; padding: 16px 12px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand-scope { display: block; font-size: var(--fs-small); font-weight: 400; color: var(--muted); margin-top: 2px; }
.group-label { margin: 18px 8px 6px; font-size: var(--fs-small); color: var(--faint); }
.nav-item { display: flex; align-items: center; gap: 10px; height: var(--nav-row); padding: 0 8px; border-radius: 8px; color: var(--muted); transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.nav-item svg { width: 16px; height: 16px; flex: none; stroke-width: 1.5; }
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.sidebar .bottom { margin-top: auto; padding: 8px; font-size: var(--fs-small); color: var(--faint); line-height: 1.6; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 100svh; }
.topbar { height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; }
.topbar .scope { font-weight: 500; }
.topbar .stamp { color: var(--muted); font-size: var(--fs-small); display: inline-flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }

.sheet { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet) 0 0 0; margin: 0 0 var(--sheet-inset) 0; }
/* 框架包住右、下：sheet 右缘贴窗右内缩，底部露出框架色 */
.main { padding-right: var(--sheet-inset); padding-bottom: var(--sheet-inset); }
.sheet { margin-right: 0; border-radius: var(--radius-sheet) 0 0 0; border-right: 0; border-bottom: 0; }
.canvas { padding: var(--pad); }

/* ---------- 标题行 ---------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.title-row h1 { font-size: var(--fs-title); line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
.title-row .sub { margin-top: 4px; color: var(--muted); }
.title-row .sub strong { color: var(--text); font-weight: 500; }
.actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------- 面板与网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.grid.top { align-items: start; }
.col-8 { grid-column: span 8; }
.col-4 { grid-column: span 4; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel h2 { font-size: var(--fs-section); line-height: 1.3; font-weight: 600; }
.panel .meta { color: var(--faint); font-size: var(--fs-small); }

/* ---------- KPI 分割条 ---------- */
.kpis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); margin-bottom: var(--gap); }
.kpi { padding: 16px var(--card-pad); }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { color: var(--muted); }
.kpi-value { margin-top: 6px; font-size: var(--fs-kpi); line-height: 1.15; font-weight: 400; letter-spacing: -0.01em; }
.kpi-value small { font-size: 0.55em; color: var(--muted); font-weight: 400; margin-left: 2px; }

/* ---------- 分区状态板（签名元素） ---------- */
.zone-board { display: grid; grid-template-columns: minmax(0, 1fr); }
.zone { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 10px 0; cursor: pointer; border-radius: 6px; transition: background-color var(--t-hover) ease; }
.zone + .zone { border-top: 1px solid var(--rule); }
.zone:hover { background: var(--raised); }
.zone-mark { width: 10px; height: 32px; border-radius: 3px; flex: none; background: var(--pill-neutral-bg); }
.zone[data-level="A"] .zone-mark { background: var(--negative); }
.zone[data-level="C"] .zone-mark { background: #d9a514; }
.zone[data-level="B"] .zone-mark { background: var(--positive); }
.zone-id { font-family: var(--font-mono); /* taste-skill-ignore: mono — 区域编号属 ID 用途 */ font-size: 13px; color: var(--muted); width: 76px; flex: none; }
.zone-name { font-weight: 500; min-width: 0; }
.zone-name .sub { display: block; font-weight: 400; font-size: var(--fs-small); color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-read { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.zone-read b { color: var(--text); font-weight: 500; }
.zone-pill { flex: none; }
.zone-footnote { margin-top: 12px; padding: 10px 14px; font-size: var(--fs-small); color: var(--muted); border-left: 3px solid var(--accent); background: var(--ground); border-radius: 0 6px 6px 0; line-height: 1.6; }

/* ---------- 表单 ---------- */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.field { display: grid; gap: 6px; }
.field > label { font-weight: 500; }
.field .hint { color: var(--muted); font-size: var(--fs-small); }
.input, select.input, textarea.input { width: 100%; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); }
textarea.input { height: auto; min-height: 64px; padding: 8px 12px; resize: vertical; }
.input::placeholder { color: var(--faint); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border: 1px solid var(--control); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 13px; color: var(--muted); transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, color var(--t-hover) ease; }
.chip:hover { background: var(--raised); }
.chip[aria-pressed="true"] { background: var(--active); border-color: var(--accent); color: var(--text); }
.switch-row { display: flex; align-items: center; gap: 10px; }
.switch-row .hint { color: var(--muted); font-size: var(--fs-small); }
.switch { appearance: none; width: 32px; height: 20px; border-radius: 999px; background: var(--control); position: relative; cursor: pointer; transition: background-color var(--t-ui) ease; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t-ui) var(--ease-out); }
.switch:checked { background: var(--positive); }
.switch:checked::after { transform: translateX(12px); }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-height); padding: 0 12px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); font-weight: 500; cursor: pointer; transition: background-color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { background: #333a36; }
.btn.ghost { border-color: transparent; background: transparent; }

/* ---------- 研判结果（四段式） ---------- */
.verdict { display: grid; gap: 0; }
.verdict section + section { border-top: 1px solid var(--rule); }
.verdict h3 { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 500; color: var(--muted); margin: 14px 0 10px; }
.verdict h3 .idx { color: var(--faint); }
.level-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.level-badge { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: 6px; font-size: 15px; font-weight: 600; }
.level-badge[data-level="A"] { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.level-badge[data-level="B"] { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.level-badge[data-level="C"] { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.reasons { margin-top: 10px; display: grid; gap: 6px; }
.reasons li, .orders li, .interventions li, .alert-banner { font-size: 14px; line-height: 22px; }
.reasons li::before, .orders li::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); vertical-align: 3px; margin-right: 8px; }
.alert-banner { margin: 2px 0 10px; padding: 10px 12px; border-radius: 6px; }
.alert-banner.red { background: var(--pill-negative-bg); color: var(--pill-negative-ink); font-weight: 500; }
.alert-banner.yellow { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.orders li::before { background: var(--accent); }
.interventions li { color: var(--text); }
.kb-tag { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 6px; background: var(--active); color: var(--text); font-weight: 500; max-width: 100%; }
.kb-tag small { font-weight: 400; color: var(--muted); white-space: nowrap; }
.kb-note { margin-top: 8px; color: var(--muted); font-size: var(--fs-small); }

/* 检查表：阈值对比 */
.check-table { width: 100%; border-collapse: collapse; }
.check-table th { height: 32px; padding: 0 10px; text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.check-table td { padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: baseline; font-size: 13px; }
.check-table tr:last-child td { border-bottom: 0; }
.check-table th.n, .check-table td.n { text-align: right; }
.check-table .std { color: var(--muted); }

/* ---------- pill ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: var(--fs-small); font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; flex: none; }
.pill.pos { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }

/* ---------- 记录表与知识库 ---------- */
.table-wrap { overflow-x: auto; }
.records-table { width: 100%; border-collapse: collapse; }
.records-table th { height: 36px; padding: 0 12px; text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.records-table td { padding: calc((var(--row-height) - 20px) / 2) 12px; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.records-table tbody tr:last-child td { border-bottom: 0; }
.records-table th.n, .records-table td.n { text-align: right; }
.records-table td .sub { display: block; font-size: var(--fs-small); color: var(--muted); }
.routine-note { margin: 0 0 10px; padding: 12px 14px; border-left: 3px solid var(--positive); background: var(--ground); border-radius: 0 6px 6px 0; font-size: var(--fs-small); color: var(--text); line-height: 1.7; }
.kb-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); padding-bottom: var(--gap); margin-bottom: var(--gap); border-bottom: 1px solid var(--border); }
.kb-tools-label { display: block; font-weight: 500; margin-bottom: 4px; }
.kb-tools .meta { display: block; }
.upload-row { display: flex; gap: 8px; margin-top: 10px; }
.upload-row .file-input { flex: 1; padding: 6px 8px; font-size: 13px; }
.kb-files { margin-bottom: var(--gap); }
.kb-file { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.kb-file .kb-file-name { min-width: 0; font-size: 14px; }
.kb-file .kb-file-name .sub { display: block; font-size: var(--fs-small); color: var(--muted); margin-top: 2px; }
.kb-file-actions { margin-left: auto; display: flex; gap: 6px; flex: none; }
.kb-file-empty { padding: 12px 0; font-size: var(--fs-small); color: var(--faint); border-bottom: 1px solid var(--rule); }
.pill.neutral { background: var(--pill-neutral-bg); color: var(--muted); }
@media (max-width: 860px) {
  .kb-tools { grid-template-columns: minmax(0, 1fr); }
  .kb-file-actions { flex-direction: column; align-items: flex-end; }
}
.mono { font-family: var(--font-mono); /* taste-skill-ignore: mono — 记录编号属 ID 用途 */ font-size: 13px; }
.kb-list { display: grid; }
.kb-item { padding: 12px 0; }
.kb-item + .kb-item { border-top: 1px solid var(--rule); }
.kb-item .kb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kb-item .kb-sum { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 20px; }
.empty { display: grid; place-items: center; min-height: 96px; padding: 16px; border: 1px dashed var(--control); border-radius: var(--radius-control); color: var(--muted); text-align: center; grid-column: 1 / -1; width: 100%; }
.empty.verdict-empty { place-items: start center; text-align: left; padding: 20px; min-height: 0; }
.verdict-empty ol { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: var(--fs-small); }
.verdict-empty b { color: var(--text); font-weight: 500; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); }
.tabs button { position: relative; padding: 10px 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 500; }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); }

/* ---------- 隐藏视图 ---------- */
.view[hidden] { display: none; }

/* ---------- 手机：框架消失，sheet 成为屏幕 ---------- */
@media (max-width: 860px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .main { padding-right: 0; padding-bottom: 0; }
  .sheet { border-radius: 0; border: 0; margin: 0; }
  .topbar { padding: 0 16px; }
  .menu-toggle { display: inline-flex; }
  .sidebar { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 20; background: var(--surface); transform: translateX(-100%); transition: transform var(--t-ui) var(--ease-out); padding: 16px; }
  .sidebar.open { transform: none; }
  .sidebar .close-row { display: flex; justify-content: flex-end; }
  .canvas { padding: 16px; }
  .grid > * { grid-column: 1 / -1 !important; }
  .kpis { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .kpi:nth-child(2n) { border-left: 1px solid var(--border); }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .title-row { flex-wrap: wrap; align-items: flex-start; }
  .zone-read { display: none; }
  .zone-name .sub { white-space: normal; }
  .check-table .std { display: none; }
}
.close-row { display: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; } }

/* ---------------- AI 研判（DeepSeek · GB/T 47302-2026） ---------------- */
.ai-source {
  margin: 10px 0 6px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.ai-summary {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(46, 107, 62, 0.06);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.ai-warn {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px dashed var(--warning);
  background: rgba(146, 64, 14, 0.06);
  color: var(--warning);
  font-size: 13px;
  line-height: 1.7;
}

/* ---------------- 扣子知识库状态 ---------------- */
.coze-on { color: var(--accent); font-weight: 600; }
.coze-off { color: var(--warning); }
