/* MOS 演示界面样式 / MOS demo UI styles. Dependency-free. */

/* Legacy variable names are aliases of the M7-A Quiet Precision tokens (design/tokens.css), so every
   existing view adopts the design system without rewriting its markup. */
:root {
  --bg: var(--mos-canvas);
  --surface: var(--mos-surface);
  --surface-2: var(--mos-surface-subtle);
  --border: var(--mos-border);
  --border-strong: var(--mos-border-control);
  --text: var(--mos-text);
  --text-muted: var(--mos-text-secondary);
  --text-faint: var(--mos-text-muted);
  --brand: var(--mos-accent);
  --brand-ink: var(--mos-on-accent);
  --brand-soft: var(--mos-accent-soft);
  --ok: var(--mos-success);
  --ok-soft: var(--mos-success-soft);
  --warning: var(--mos-warning);
  --warning-soft: var(--mos-warning-soft);
  --danger: var(--mos-danger);
  --danger-soft: var(--mos-danger-soft);
  --neutral-soft: var(--mos-surface-hover);
  --shadow: none;
  --radius: var(--mos-radius-panel);
  --radius-sm: var(--mos-radius-control);
  --font: var(--mos-font-ui);
  --mono: var(--mos-font-id);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--mos-type-body);
  font-variant-numeric: tabular-nums lining-nums;
  line-break: strict;
  word-break: normal;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul { padding: 0; list-style: none; }

/* ---------- accessibility helpers ---------- */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--brand); color: var(--brand-ink);
  padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600;
  text-decoration: none; transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

:where(a, button, select, input, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--mos-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- environment strip (quiet, persistent) ---------- */

.demo-banner {
  display: flex; gap: var(--mos-space-3); align-items: baseline; flex-wrap: wrap;
  padding: var(--mos-space-2) var(--mos-gutter);
  background: var(--mos-surface-subtle);
  color: var(--mos-text-secondary);
  border-bottom: 1px solid var(--mos-border);
  font: var(--mos-type-caption);
}
.demo-banner p { margin: 0; }
.demo-banner__tag {
  flex: none; font-weight: 600;
  background: var(--mos-warning-soft); color: var(--mos-warning);
  border-radius: var(--mos-radius-badge); padding: 0 var(--mos-space-2);
}

/* ---------- layout: see design/shell.css ---------- */

/* ---------- page header ---------- */

.page-head { margin-bottom: var(--mos-space-6); max-width: 72ch; }
.page-head h1 { font: var(--mos-type-title); letter-spacing: normal; }
.page-head p { color: var(--mos-text-secondary); font: var(--mos-type-body); margin-top: var(--mos-space-2); }
@media (max-width: 767px) { .page-head h1 { font: var(--mos-type-title-narrow); } }

/* ---------- cards & primitives ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Grid items default to min-width:auto, which lets a wide table stretch its
   card and scroll the whole page sideways. Wide content scrolls in its own
   container instead. */
.view, .stack, .grid, .stack > *, .grid > * { min-width: 0; }

.grid { display: grid; gap: var(--mos-space-4); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stack { display: grid; gap: var(--mos-space-5); }

.kpi { padding: var(--mos-space-5); display: grid; gap: var(--mos-space-1); }
.kpi__label { font: var(--mos-type-caption); color: var(--mos-text-secondary); display: flex; align-items: center; gap: 6px; }
.kpi__value { font: 600 24px/32px var(--mos-font-ui); font-variant-numeric: tabular-nums; }
.kpi__note { font: var(--mos-type-caption); color: var(--mos-text-muted); }
.kpi--accent { border: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px var(--mos-space-2); border-radius: var(--mos-radius-badge);
  font: 500 13px/20px var(--mos-font-ui); white-space: nowrap;
  background: var(--neutral-soft); color: var(--text-muted);
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--brand { background: var(--brand-soft); color: var(--brand); }
.badge--demo { background: var(--warning-soft); color: var(--warning); }

.mono { font-family: var(--mono); font-size: 13px; }
.trace {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 7px; color: var(--text-muted);
}

.btn {
  font: 500 15px/22px var(--mos-font-ui);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--mos-control); padding: 8px 16px; border-radius: var(--mos-radius-control);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--mos-accent); color: var(--mos-on-accent);
  transition: background-color var(--mos-dur-hover) var(--mos-ease);
}
.btn:hover { background: var(--mos-accent-hover); }
.btn:active { background: var(--mos-accent-pressed); }
.btn--ghost { background: var(--mos-surface); color: var(--mos-text); border-color: var(--mos-border-control); }
.btn--ghost:hover { background: var(--mos-surface-hover); }
.btn--danger { background: var(--surface-2); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
/* Disabled keeps full text opacity; the reason is stated outside the control. */
.btn:disabled, .btn:disabled:hover { cursor: not-allowed; background: var(--mos-surface-subtle); color: var(--mos-text-muted); border-color: var(--mos-border); }

/* ---------- states ---------- */

.state {
  display: grid; gap: 8px; justify-items: center; text-align: center;
  padding: 40px 20px; color: var(--text-muted);
}
.state__icon { font-size: 26px; opacity: .5; }
.state__title { font-size: 16px; font-weight: 600; color: var(--text); }
.state__hint { font-size: 13.5px; max-width: 46ch; }
.state__code { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.state--error .state__icon { color: var(--danger); opacity: 1; }

.skeleton-list { display: grid; gap: 12px; }
.skeleton {
  height: 78px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  border: 1px solid var(--border);
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- decision cards ---------- */

.decision { padding: 18px; display: grid; gap: 14px; }
.decision__head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.decision__title { font: var(--mos-type-section); }
.decision__meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.fact { display: grid; gap: 2px; }
.fact__label { font-size: 12px; color: var(--text-faint); }
.fact__value { font-size: 15px; font-weight: 560; font-variant-numeric: tabular-nums; }
.fact__value--lg { font-size: 19px; font-weight: 620; }

.decision__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 2px; }

.notice {
  display: grid; gap: 4px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  font: 400 14px/22px var(--mos-font-ui); border: 1px solid transparent;
}
.notice strong { font-weight: 620; }
.notice--warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 28%, transparent); }
.notice--danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.notice--info { background: var(--brand-soft); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.notice--ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-caption { padding: 14px 18px 2px; font-size: 13px; color: var(--text-muted); }
tr.is-selected td { background: var(--brand-soft); }

/* An element's own display rule beats the UA [hidden] rule, so restate it. */
.identity[hidden] { display: none; }

.field-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.field-check input { flex: none; width: 18px; height: 18px; margin-top: 3px; accent-color: var(--brand); }
.field-check input:disabled + label { opacity: .6; }

/* guided import / 引导导入 */
.import-capability { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.import-help { margin-top: 12px; font-size: 13.5px; }
.import-help summary { cursor: pointer; font-weight: 600; }
.import-help ol { margin: 8px 0 0; padding-left: 1.4em; display: grid; gap: 4px; }
.import-purpose { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.import-file {
  display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0;
}
.import-file__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: baseline; }
.import-file__input input[type="file"] { max-width: 100%; font: inherit; }
.import-problems { margin: 8px 0 0; padding-left: 1.2em; display: grid; gap: 4px; color: var(--danger, inherit); }
.import-mapping select { max-width: 100%; min-width: 0; font: inherit; }
th, td { padding: var(--mos-space-3) var(--mos-space-4); text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; font: var(--mos-type-table); }
th { font-weight: 600; color: var(--mos-text-secondary); background: var(--mos-surface-subtle); }
tbody tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.masked { color: var(--text-faint); font-style: normal; }

/* Narrow screens: only tables whose cells carry data-label become stacked rows. Every other table keeps its
   structure and scrolls inside its labelled .table-wrap, so captions stay full width (visual review I-02). */
@media (max-width: 700px) {
  table:has(td[data-label]), table:has(td[data-label]) thead, table:has(td[data-label]) tbody,
  table:has(td[data-label]) th, table:has(td[data-label]) td, table:has(td[data-label]) tr { display: block; }
  table:has(td[data-label]) thead { display: none; }
  table:has(td[data-label]) tbody tr { border-bottom: 1px solid var(--border); padding: 6px 0; }
  table:has(td[data-label]) tbody tr:last-child { border-bottom: 0; }
  table:has(td[data-label]) td { border: 0; display: flex; justify-content: space-between; gap: 16px; white-space: normal; padding: 5px 18px; }
  table:has(td[data-label]) td::before { content: attr(data-label); color: var(--text-faint); font-size: 13px; flex: none; }
}
.table-caption { caption-side: top; text-align: left; }

/* ---------- timeline ---------- */

.timeline { display: grid; gap: 0; padding: 6px 18px 18px; margin: 0; list-style: none; }
.timeline__item { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 14px; }
.timeline__rail { display: grid; justify-items: center; }
.timeline__dot {
  width: 10px; height: 10px; border-radius: 50%; margin-top: 16px;
  background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.timeline__line { width: 2px; flex: 1; background: var(--border); height: 100%; }
.timeline__item:last-child .timeline__line { background: transparent; }
.timeline__body { padding: 12px 0; display: grid; gap: 6px; min-width: 0; }
.timeline__title { font-weight: 600; }
.timeline__meta { display: flex; gap: 8px 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }

/* ---------- filter bar ---------- */

.filter {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 16px 18px;
}
.field { display: grid; gap: 5px; }
.field label { font-size: 12.5px; color: var(--text-muted); }
.field input, .field textarea, .field select {
  font: var(--mos-type-body); color: var(--text); min-height: var(--mos-control);
  background: var(--mos-surface); border: 1px solid var(--mos-border-control);
  border-radius: var(--mos-radius-control); padding: 6px 12px; min-width: min(220px, 100%);
}
.field textarea { min-height: 76px; resize: vertical; width: 100%; }
.field input:disabled, .field textarea:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- drawer (evidence detail) ---------- */

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: var(--mos-scrim);
  display: flex; justify-content: flex-end;
}
.drawer {
  width: min(560px, 100%); height: 100%; overflow-y: auto;
  background: var(--mos-surface-raised); border-left: 1px solid var(--border); box-shadow: var(--mos-shadow-2);
  display: flex; flex-direction: column;
}
.drawer__head {
  position: sticky; top: 0; z-index: 1;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.drawer__title { font-size: 17px; font-weight: 630; }
.drawer__sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.drawer__body { padding: 18px 20px 32px; display: grid; gap: 14px; }
.drawer__close {
  font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
  background: transparent; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text-muted); padding: 4px 10px;
}
.section { padding: 16px 18px; display: grid; gap: 12px; }
.section__title { font: 600 16px/24px var(--mos-font-ui); color: var(--mos-text); letter-spacing: normal; }

.kv { display: grid; grid-template-columns: minmax(88px, auto) minmax(0, 1fr); gap: 8px 16px; font: var(--mos-type-table); }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; word-break: break-word; }

.evidence-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 13.5px;
}

@media (max-width: 560px) {
  .drawer { width: 100%; }
  .drawer-backdrop { align-items: flex-end; }
}

/* inventory / production lite / demo overview / 库存、生产影响与演示总览 */
.ops-toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 20px;
}
.ops-toolbar__badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ops-toolbar__note { font-size: 13px; color: var(--text-muted); }
.ops-toolbar__field { min-width: 0; max-width: 100%; }
.ops-toolbar__field select { max-width: 100%; font: inherit; }
.kpi--danger { border: 0; }
.kpi--danger .kpi__value { color: var(--danger); }
.kpi--ok { border: 0; }
.ops-card-title { padding: 16px 18px 0; }
.ops-note { font-size: 13px; color: var(--text-muted); }
.ops-subtle { font-size: 12.5px; color: var(--text-faint); }
.ops-empty { padding: 12px 18px 18px; color: var(--text-muted); font-size: 14px; }
.ops-evidence { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ops-evidence li {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13.5px;
}
.ops-evidence__ref { font-size: 12px; color: var(--text-faint); }
.ops-details summary { cursor: pointer; font-weight: 600; }
.ops-action { border: 0; }
.ops-story { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.ops-step { display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 18px; align-content: start; }
.ops-step__number {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700;
}
.ops-step__body { display: grid; gap: 8px; min-width: 0; }
.ops-step__title { font-size: 16px; }
.ops-step__lead { font-size: 14.5px; line-height: 1.6; }
.ops-list { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: 14px; list-style: disc; }
.kpi__value--long { font-size: 20px; line-height: 1.35; }
.badge--neutral { background: var(--surface-2); color: var(--text-muted); }

.ops-toolbar__sources { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--text-muted); }
.ops-source { display: inline-flex; align-items: center; gap: 6px; }
