/* 数据交付平台 · 共用样式
   布局：左侧导航 + 内容区（后台）；单列表单（供应商 / 客户）
   绿色 = 供应商/客户录入字段，橙色 = 甲方工作人员字段（与 Excel 模板一致） */
:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #16201c;
  --muted: #5b6a64;
  --line: #dce4e0;
  --accent: #0e6a5a;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ed;
  --green: #138a4a;
  --green-soft: #e6f5ec;
  --orange: #c9620f;
  --orange-soft: #fcefe3;
  --danger: #c23b3b;
  --danger-soft: #fbeaea;
  --warn: #9a6a0b;
  --warn-soft: #fbf3dc;
  --shadow: 0 10px 30px rgba(14, 40, 32, .12);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1412; --surface: #151d1a; --surface-2: #1a2420; --ink: #e4ebe8; --muted: #92a39c; --line: #27342f;
    --accent: #3db39a; --accent-ink: #06201a; --accent-soft: #173029;
    --green: #43c97f; --green-soft: #15291e; --orange: #f0954a; --orange-soft: #33230f;
    --danger: #f07070; --danger-soft: #361a1a; --warn: #e2b44c; --warn-soft: #2f2611;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1412; --surface: #151d1a; --surface-2: #1a2420; --ink: #e4ebe8; --muted: #92a39c; --line: #27342f;
  --accent: #3db39a; --accent-ink: #06201a; --accent-soft: #173029;
  --green: #43c97f; --green-soft: #15291e; --orange: #f0954a; --orange-soft: #33230f;
  --danger: #f07070; --danger-soft: #361a1a; --warn: #e2b44c; --warn-soft: #2f2611;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.3; text-wrap: balance; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--accent); }
.num, td, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* —— 按钮与表单 —— */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label.field { display: grid; gap: 4px; min-width: 0; }
label.field > span { font-size: 13px; color: var(--muted); }
label.field > span b { color: var(--danger); font-weight: 400; margin-left: 2px; }
input, select, textarea { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; }
textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
input[readonly], textarea[readonly] { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* —— 徽章 —— */
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.orange { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.tag-green, .tag-orange { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.tag-green { background: var(--green); } .tag-orange { background: var(--orange); }

/* —— 后台布局 —— */
.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, var(--green) 0 50%, var(--orange) 50% 100%); flex: none; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.main { min-width: 0; padding-block: 22px 40px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 16px; }
.section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.section > *, .card > * { min-width: 0; }

/* —— 筛选条 —— */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; padding: 12px; }
.filters label.field { width: 150px; }
.filters label.field.wide { width: 220px; }
.filters .field > span { font-size: 12px; }
.presets { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.presets button { height: 34px; padding: 0 12px; border: 0; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; border-right: 1px solid var(--line); }
.presets button:last-child { border-right: 0; }
.presets button.on { background: var(--accent); color: var(--accent-ink); }

/* —— 统计卡 —— */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .k { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); }

/* —— 表格 —— */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
table.grid th, table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; z-index: 1; }
table.grid th.g { box-shadow: inset 0 3px 0 var(--green); }
table.grid th.o { box-shadow: inset 0 3px 0 var(--orange); }
table.grid tbody tr { cursor: default; }
table.grid tbody tr.click { cursor: pointer; }
table.grid tbody tr.click:hover td { background: var(--surface-2); }
table.grid td.clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid td.nowrap { white-space: nowrap; }
table.grid td.r, table.grid th.r { text-align: right; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; flex-wrap: wrap; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* —— 抽屉与弹窗 —— */
.scrim { position: fixed; inset: 0; background: rgba(8, 20, 16, .42); z-index: 40; display: flex; justify-content: flex-end; }
.scrim.center { justify-content: center; align-items: center; padding: 16px; }
.drawer { width: min(640px, 100%); height: 100%; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.drawer-body > * { flex-shrink: 0; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); }
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 16px 20px; display: grid; gap: 14px; }
.modal-foot { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; }
.group { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.group-title { padding: 8px 14px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.group.green .group-title { background: var(--green-soft); color: var(--green); }
.group.orange .group-title { background: var(--orange-soft); color: var(--orange); }
.group-body { padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.group-body .full { grid-column: 1 / -1; }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice.bad { background: var(--danger-soft); color: var(--danger); }
.log { display: grid; gap: 8px; }
.log-item { font-size: 13px; padding-left: 12px; border-left: 2px solid var(--line); }
.log-item .when { color: var(--muted); font-size: 12px; }
.linkbox { display: flex; gap: 6px; align-items: center; min-width: 0; }
.linkbox code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12px var(--mono); background: var(--surface-2);
  border: 1px solid var(--line); padding: 5px 8px; border-radius: 6px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; max-height: 220px; overflow-y: auto; padding: 4px 0; }

/* —— 提示条 —— */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; pointer-events: none; }
#toast div { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; max-width: min(90vw, 480px); }
#toast div.err { background: var(--danger); color: #fff; }

/* —— 图表 —— */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding: 8px 0 0; overflow-x: auto; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 30px; height: 100%; }
.chart .stack { width: 100%; max-width: 28px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.chart .stack i { display: block; }
.chart .stack i.a { background: var(--accent); }
.chart .stack i.b { background: var(--line); }
.chart .lab { font-size: 10px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* —— 窄屏 —— */
.mobile-bar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
    padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  .side.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface);
    border-bottom: 1px solid var(--line); padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 31; background: var(--surface); }
  .main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .filters label.field, .filters label.field.wide { width: calc(50% - 4px); }
  .group-body { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
