/* ==========================================================================
   采鉴 / AI 二手采购助手 — Interface System v2.9
   Foundations: warm paper canvas, deep forest ink, copper accent.
   ========================================================================== */
:root {
  --bg: #f2f0ea;
  --bg-deep: #eae7de;
  --surface: #fffefa;
  --surface-2: #f8f6f0;
  --surface-3: #f1eee6;
  --ink: #17211d;
  --ink-2: #34433c;
  --muted: #69756e;
  --faint: #636d67;
  --line: #e0ddd3;
  --line-strong: #cfcbc0;
  --accent: #1f5a4c;
  --accent-strong: #16483d;
  --accent-soft: #e8f1ed;
  --copper: #b6653c;
  --copper-text: #9c5632;
  --copper-strong: #95502e;
  --copper-soft: #f8ece4;
  --teal: #216b57;
  --teal-soft: #e4f1eb;
  --amber: #875c18;
  --amber-soft: #fbf1dc;
  --red: #9f3a3a;
  --red-soft: #f9eaea;
  --shadow-sm: 0 1px 2px rgba(23, 33, 29, .04), 0 8px 24px rgba(23, 33, 29, .045);
  --shadow-md: 0 2px 4px rgba(23, 33, 29, .04), 0 18px 44px rgba(23, 33, 29, .08);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Avenir Next", "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 6% 0%, rgba(182, 101, 60, .075), transparent 34%),
    radial-gradient(ellipse at 96% 4%, rgba(31, 90, 76, .075), transparent 30%),
    var(--bg);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, strong { color: var(--ink); }
::selection { background: var(--accent-soft); color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: fixed; top: 12px; left: 12px; transform: translateY(-150%); padding: 10px 14px; background: var(--ink); color: white; z-index: 99; border-radius: 8px; }
.skip-link:focus { transform: none; }

/* ---------- Login: split editorial layout ---------- */
.login-view { min-height: 100dvh; padding: 22px; display: grid; place-items: center; }
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, .92fr);
  width: min(1360px, 100%);
  min-height: min(840px, calc(100dvh - 44px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 28px;
  box-shadow: 0 36px 90px rgba(20, 34, 29, .18);
  background: var(--surface);
}
.login-brand {
  position: relative;
  overflow: hidden;
  padding: 44px 48px;
  display: flex;
  flex-direction: column;
  color: #f7f5ed;
  background:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px),
    radial-gradient(circle at 90% 16%, rgba(182, 101, 60, .26), transparent 30%),
    #14221d;
  background-size: 44px 44px, 44px 44px, auto, auto;
}
.login-brand::after { content: ""; position: absolute; width: 240px; height: 240px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; right: -90px; bottom: 120px; }
.login-brand-top { display: flex; align-items: center; gap: 13px; position: relative; z-index: 1; }
.login-brand-name { font-weight: 600; letter-spacing: .01em; }
.login-brand-copy { margin: auto 0; max-width: 640px; position: relative; z-index: 1; }
.login-brand-copy .eyebrow { color: #dfa17f; }
.login-brand-copy h1 { color: #f8f5ec; margin-bottom: 20px; font-size: clamp(34px, 3.4vw, 54px); line-height: 1.15; letter-spacing: -.045em; font-weight: 560; max-width: 12em; }
.login-brand-copy > p:last-child { color: #b9c6c0; font-size: 15px; max-width: 38em; line-height: 1.8; }
.login-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; border-top: 1px solid rgba(255,255,255,.14); padding-top: 22px; position: relative; z-index: 1; }
.login-steps div { display: grid; gap: 5px; }
.login-steps span { color: #d99b76; font: 500 11px var(--mono); }
.login-steps strong { color: #f0eee6; font-size: 13px; }
.login-steps p { color: #96a69e; font-size: 12px; line-height: 1.6; margin: 0; }
.login-foot { color: #72827a; font-size: 11px; margin: 24px 0 0; position: relative; z-index: 1; }
.login-form-side { display: grid; place-items: center; padding: 48px; background: var(--surface); }
.login-card { width: min(390px, 100%); }
.login-mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 30px; font-weight: 600; }
.login-card h2 { font-size: 30px; letter-spacing: -.035em; margin-bottom: 8px; font-weight: 560; }
.login-intro { color: var(--muted); font-size: 13px; line-height: 1.75; margin-bottom: 28px; }
.login-assurance { text-align: center; font-size: 11px; color: var(--faint); margin: 20px 0 0; }
.form-narrow { max-width: 460px; }

/* ---------- Shared brand ---------- */
.brand-mark {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 12px;
  color: #f8f5ec; font-size: 19px; font-weight: 600;
  background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.02));
  box-shadow: inset 0 1px rgba(255,255,255,.1);
}
.brand-mark.large { width: 46px; height: 46px; font-size: 21px; }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 26px 18px 22px;
  color: white;
  background:
    radial-gradient(circle at 0% 0%, rgba(182,101,60,.18), transparent 32%),
    linear-gradient(180deg, #172720, #101b17 74%);
  overflow: hidden;
}
.sidebar::after { content: ""; position: absolute; inset: auto -70px -120px auto; width: 220px; height: 220px; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 5px; }
.brand-copy { display: flex; flex-direction: column; gap: 3px; }
.brand-copy strong { color: #f7f5ed; font-size: 14px; font-weight: 600; letter-spacing: .005em; }
.brand-copy span { color: #91a39b; font-size: 11px; }
.nav { display: grid; gap: 5px; margin-top: 40px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%; min-height: 44px;
  padding: 0 13px;
  border: 1px solid transparent; border-radius: 10px;
  color: #a8b8b0; background: transparent;
  text-align: left; font-size: 13px;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.nav-icon { display: grid; place-items: center; width: 20px; height: 20px; opacity: .8; }
.nav-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { color: white; background: rgba(255,255,255,.055); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.085); border-color: rgba(255,255,255,.08); }
.nav-item.active::before { content: ""; position: absolute; left: -18px; top: 11px; bottom: 11px; width: 3px; border-radius: 0 3px 3px 0; background: var(--copper); }
.sidebar-status { margin-top: auto; display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid rgba(255,255,255,.09); border-radius: 13px; background: rgba(255,255,255,.035); }
.sidebar-status div { display: grid; gap: 2px; }
.sidebar-status strong { color: #e7eae5; font-size: 11px; font-weight: 500; }
.sidebar-status span { color: #7f9289; font-size: 10px; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; background: #6fc2a3; box-shadow: 0 0 0 4px rgba(111,194,163,.11); }
.sidebar-note { margin-top: 16px; padding: 0 5px; color: #74877e; font-size: 10px; line-height: 1.7; display: flex; gap: 7px; }
.note-dot { width: 5px; height: 5px; border-radius: 50%; background: #b6653c; margin-top: 6px; flex: none; }

/* ---------- Main / topbar ---------- */
.main { min-width: 0; padding: 30px 34px 56px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 26px; max-width: 1520px; }
.topbar-heading { min-width: 0; }
.eyebrow { margin: 0 0 6px; color: var(--copper-text); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow.light { color: #dda17d; }
.topbar h1 { margin: 0; font-size: clamp(26px, 2.3vw, 34px); letter-spacing: -.045em; line-height: 1.15; font-weight: 560; }
.topbar-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; flex: none; }
.org-control { display: grid; gap: 5px; }
.org-control label { color: var(--faint); font-size: 10px; }
.org-input-row { display: flex; gap: 7px; }
.org-control input { width: 220px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.58); color: var(--muted); font: 11px var(--mono); }
.org-control input:focus { background: white; }
.session-control { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; padding: 4px 4px 4px 5px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.52); }
.user-avatar { width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 11px; }
.session-control .button { height: 29px; padding: 0 10px; border-radius: 999px; font-size: 11px; }

/* ---------- Layout ---------- */
.workspace { display: grid; grid-template-columns: minmax(350px, 390px) minmax(0, 1fr); gap: 22px; align-items: start; max-width: 1520px; }
.left-column { display: grid; gap: 18px; min-width: 0; }
.panel { background: rgba(255,254,250,.92); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.create-panel, .task-panel, .detail-panel, .settings-panel { padding: 22px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.025em; font-weight: 560; line-height: 1.3; }
.section-desc { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; max-width: 34em; }
.stage-badge { flex: none; padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid #d6e6de; font-size: 10px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; }
.muted-badge { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.create-heading { margin-bottom: 20px; }
.create-heading .section-desc { max-width: 27em; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 7px; margin-bottom: 15px; color: var(--ink-2); font-size: 11px; font-weight: 500; }
.field > span { display: flex; align-items: center; gap: 6px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 44px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font-size: 13px; font-weight: 400;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field input:hover, .field textarea:hover, .field select:hover { border-color: #bcb7ab; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,90,76,.1); }
.field-prompt textarea { min-height: 88px; resize: vertical; line-height: 1.7; background: var(--surface-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 13px; }
.field-wide { grid-column: 1 / -1; }
.form-hint { margin: 0 0 16px; color: var(--faint); font-size: 10px; line-height: 1.65; }
.form-message { min-height: 17px; margin: 9px 0 0; color: var(--red); font-size: 11px; line-height: 1.5; }
.form-message:empty { display: none; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

/* ---------- Buttons ---------- */
.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; font-weight: 600; letter-spacing: .005em; transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.button:active { transform: scale(.985); }
.button-primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 5px 14px rgba(31,90,76,.16); }
.button-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(31,90,76,.22); }
.button-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.button-ghost:hover { background: var(--surface-2); border-color: #b9b4a8; }
.button.small { min-height: 30px; padding: 0 10px; font-size: 10px; border-radius: 8px; }
.button-create { width: 100%; min-height: 47px; display: flex; align-items: center; justify-content: center; gap: 9px; font-size: 13px; margin-top: 2px; }
.button-create svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform .18s ease; }
.button-create:hover svg { transform: translateX(3px); }
.report-button { background: var(--accent-soft); color: var(--accent); border-color: #cfe3d9; }
.report-button:hover { background: #dcece4; }
.delete-button { background: transparent; color: var(--red); border-color: #e7c4c4; }
.delete-button:hover { background: var(--red-soft); }
.retry-button { margin-left: 10px; background: var(--red-soft); color: var(--red); border-color: #e9c2c2; }

/* ---------- Mode / cache ---------- */
.mode-card { display: grid; gap: 10px; padding: 13px 14px; margin-bottom: 16px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; background: var(--surface-2); }
.mode-head { display: flex; align-items: center; gap: 8px; }
.mode-label { color: var(--faint); font-size: 10px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.mode-head strong { font-size: 13px; font-weight: 600; }
.mode-meta { display: grid; gap: 3px; }
.mode-meta p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.freshness { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 600; }
.freshness::before { content: ""; width: 5px; height: 5px; border-radius: 50%; margin-right: 5px; background: currentColor; }
.freshness.fresh { background: var(--teal-soft); color: var(--teal); }
.freshness.current { background: var(--accent-soft); color: var(--accent); }
.freshness.stale, .freshness.expired, .freshness.unknown { background: var(--amber-soft); color: var(--amber); }
.cache-warning { color: var(--amber) !important; }

/* ---------- Task list ---------- */
.task-panel .section-heading { margin-bottom: 8px; }
.task-list { display: grid; max-height: 380px; overflow: auto; scrollbar-width: thin; }
.task-item { position: relative; display: grid; gap: 5px; width: 100%; padding: 11px 10px 11px 13px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; transition: background .16s ease; }
.task-item:last-child { border-bottom: 0; }
.task-item:hover { background: var(--surface-2); }
.task-item.selected { background: var(--accent-soft); border-radius: 8px; }
.task-item.selected::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--accent); }
.task-item-title { display: block; font-size: 12px; font-weight: 500; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-item-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--faint); font-size: 10px; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.completed { color: var(--teal); background: var(--teal-soft); }
.status.failed, .status.partial_failed { color: var(--red); background: var(--red-soft); }
.status.queued, .status.collecting, .status.enriching, .status.deciding { color: var(--amber); background: var(--amber-soft); }
.empty-list { padding: 22px 12px; color: var(--faint); font-size: 11px; text-align: center; }

/* ---------- Detail panel ---------- */
.detail-panel { min-height: 620px; padding: 24px; }
.empty-state { min-height: 570px; display: grid; grid-template-columns: minmax(120px, .56fr) minmax(0, 1fr); gap: 40px; align-items: center; padding: 26px 22px; }
.empty-visual { position: relative; min-height: 300px; display: grid; place-items: center; border-right: 1px solid var(--line); }
.empty-visual span { color: var(--line-strong); font: 400 clamp(82px, 9vw, 140px)/1 var(--mono); letter-spacing: -.1em; }
.empty-visual i { position: absolute; width: 80%; height: 1px; background: var(--copper); transform: rotate(-18deg); opacity: .7; }
.empty-copy { max-width: 470px; }
.empty-copy h2 { margin: 0 0 12px; font-size: clamp(25px, 2.6vw, 36px); line-height: 1.16; letter-spacing: -.045em; font-weight: 540; }
.empty-copy > p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.85; }
.empty-copy ul { list-style: none; padding: 18px 0 0; margin: 22px 0 0; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.empty-copy li { display: flex; align-items: center; gap: 9px; color: var(--ink-2); font-size: 12px; }
.empty-copy li span { width: 6px; height: 6px; border-radius: 50%; background: var(--copper); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.detail-head > div:first-child { min-width: 0; }
.detail-head h2 { margin: 0 0 6px; font-size: clamp(22px, 2vw, 29px); letter-spacing: -.04em; line-height: 1.22; font-weight: 550; overflow-wrap: anywhere; }
.detail-head > .status { flex: none; }
.detail-head > .button { flex: none; margin-left: auto; }
.detail-head .report-button + .delete-button { margin-left: 8px; }
.detail-meta { color: var(--faint); font-size: 10px; }
.progress-track { height: 3px; margin: 0 0 18px; background: var(--surface-3); overflow: hidden; border-radius: 0 0 3px 3px; }
.progress-value { height: 100%; background: linear-gradient(90deg, var(--accent), #4c8f74); transition: width .35s cubic-bezier(.16,1,.3,1); }
.error-box { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #e9c2c2; border-radius: 10px; background: var(--red-soft); color: var(--red); font-size: 11px; line-height: 1.7; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.summary-card { position: relative; min-height: 82px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); overflow: hidden; }
.summary-card:nth-child(1) { background: var(--accent-soft); border-color: #d5e5dc; }
.summary-card:nth-child(2) { background: var(--copper-soft); border-color: #eed8ca; }
.summary-card:nth-child(3) { background: var(--surface-2); }
.summary-card::after { content: ""; position: absolute; right: -18px; bottom: -18px; width: 54px; height: 54px; border: 1px solid rgba(23,33,29,.07); border-radius: 50%; }
.summary-card strong { display: block; font: 500 clamp(22px, 2.3vw, 30px)/1 var(--mono); letter-spacing: -.07em; color: var(--accent-strong); }
.summary-card span { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.ai-status-box { margin: 0 0 16px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 8px; }
.ai-status-box::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.ai-status-box.completed { color: var(--teal); background: var(--teal-soft); border-color: #d1e6dd; }
.ai-status-box.completed::before { background: var(--teal); box-shadow: 0 0 0 4px rgba(33,107,87,.09); }
.ai-status-box.partial { color: var(--amber); background: var(--amber-soft); border-color: #ecd8ae; }
.ai-status-box.partial::before { background: var(--amber); }
.ai-status-box.failed { color: var(--red); background: var(--red-soft); border-color: #e9c2c2; }
.ai-status-box.failed::before { background: var(--red); }
.ai-status-box p { margin: 0; }

/* ---------- AI insights ---------- */
.ai-insights { margin: 0 0 18px; padding: 17px; border: 1px solid #dbe6df; border-radius: 14px; background: linear-gradient(135deg, #f4f8f5, var(--surface)); }
.ai-insights h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ai-insights h3::before { content: ""; width: 15px; height: 15px; border: 1px solid var(--teal); border-radius: 50%; box-shadow: inset 0 0 0 4px var(--teal-soft); }
.ai-insight-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ai-insight-grid .summary-card { min-height: 60px; padding: 11px 12px; background: rgba(255,255,255,.65); border-color: #e2e9e4; }
.ai-insight-grid .summary-card::after { display: none; }
.ai-insight-grid .summary-card strong { font-size: 19px; color: var(--ink); }
.ai-insight-grid .summary-card span { font-size: 10px; }
.insight-signals { list-style: none; margin: 13px 0 0; padding: 0; display: grid; gap: 6px; font-size: 10px; line-height: 1.55; }
.insight-signals li { padding-left: 12px; position: relative; color: var(--ink-2); }
.insight-signals li::before { content: ""; position: absolute; left: 0; top: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.insight-signals li.high { color: var(--red); }
.insight-signals li.high::before { background: var(--red); }
.insight-signals li.conflict { color: var(--amber); }
.insight-signals li.conflict::before { background: var(--amber); }
.insight-missing { margin: 10px 0 0; color: var(--accent); font-size: 10px; line-height: 1.6; }
.ai-insight-details { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e2e9e4; }
.ai-insight-details summary { cursor: pointer; list-style: none; color: var(--accent); font-size: 10px; font-weight: 500; }
.ai-insight-details summary::-webkit-details-marker { display: none; }
.ai-insight-details summary::after { content: "+"; float: right; font-size: 13px; line-height: 1; }
.ai-insight-details[open] summary::after { content: "−"; }

/* ---------- Action box ---------- */
.action-box { margin-bottom: 18px; padding: 17px; border: 1px solid #ecd8ca; border-radius: 14px; background: var(--copper-soft); }
.action-box h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--copper-strong); }
.action-box p { margin: 0 0 10px; color: #614434; font-size: 12px; line-height: 1.7; }
.action-box .button { background: transparent; border-color: #d9b7a2; color: var(--copper-strong); min-height: 33px; padding: 0 11px; font-size: 10px; }
.action-box .button:hover { background: rgba(255,255,255,.5); }
.action-box p:last-child { margin: 11px 0 0; padding-top: 10px; border-top: 1px solid rgba(149,80,46,.14); font-size: 10px; color: #8b6c5b; }

/* ---------- Candidates ---------- */
.filter-bar { display: inline-flex; gap: 3px; padding: 3px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.filter-button { min-height: 29px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 500; }
.filter-button:hover { color: var(--ink); }
.filter-button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(23,33,29,.1); }
.candidate-list { display: grid; gap: 13px; }
.candidate { position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 1px 1px rgba(23,33,29,.02); overflow: hidden; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.candidate:hover { border-color: #c8c3b7; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.candidate::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 2px; border-radius: 0 2px 2px 0; background: var(--line-strong); }
.candidate:has(.lane.recommended)::before { background: var(--teal); }
.candidate:has(.lane.conditional)::before, .candidate:has(.lane.uncertain)::before { background: var(--copper); }
.candidate-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.candidate-identity { display: flex; align-items: center; gap: 8px; }
.candidate-rank { color: var(--faint); font: 500 10px var(--mono); letter-spacing: -.03em; }
.candidate:hover .candidate-rank { color: var(--copper-text); }
.availability { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 500; white-space: nowrap; }
.availability::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.availability.on_sale { background: var(--teal-soft); color: var(--teal); }
.availability.sold, .availability.removed { background: var(--red-soft); color: var(--red); }
.availability.reserved, .availability.unknown { background: var(--amber-soft); color: var(--amber); }
.price-change { color: var(--amber); font-size: 10px; font-weight: 500; white-space: nowrap; }
.lane { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 600; }
.lane::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.lane.recommended { background: var(--teal-soft); color: var(--teal); }
.lane.conditional, .lane.uncertain { background: var(--copper-soft); color: var(--copper-strong); }
.lane.excluded { background: var(--red-soft); color: var(--red); }
.candidate-price { display: flex; align-items: baseline; gap: 8px; font: 500 23px/1 var(--mono); letter-spacing: -.06em; color: var(--ink); }
.candidate-price small { font: 500 10px var(--font); letter-spacing: 0; color: var(--faint); }
.candidate h3 { margin: 0 0 10px; font-size: 14px; line-height: 1.55; font-weight: 550; overflow-wrap: anywhere; }
.reasons { list-style: none; display: grid; gap: 5px; margin: 12px 0 0; padding: 11px 0 0; border-top: 1px solid var(--line); font-size: 10px; line-height: 1.6; color: var(--muted); }
.reasons li { padding-left: 11px; position: relative; }
.reasons li::before { content: ""; position: absolute; left: 0; top: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); }
.candidate-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.feedback-button { min-height: 31px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: transparent; color: var(--muted); font-size: 10px; transition: all .16s ease; }
.feedback-button:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.candidate-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--faint); font-size: 10px; }
.candidate-foot a { font-size: 10px; font-weight: 600; white-space: nowrap; }
.reason-more { color: var(--faint); font-style: italic; }
.ai-evidence { margin-top: 12px; border: 1px solid #e5e9e5; border-radius: 10px; background: var(--surface-2); }
.ai-evidence-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 11px; color: var(--ink-2); font-size: 10px; cursor: pointer; list-style: none; }
.ai-evidence-head::-webkit-details-marker { display: none; }
.ai-evidence-head::after { content: "+"; color: var(--accent); font-size: 15px; line-height: 1; }
.ai-evidence[open] .ai-evidence-head::after { content: "−"; }
.ai-evidence-head span { color: var(--faint); font-size: 10px; margin-left: auto; }
.ai-summary { margin: 0; padding: 0 11px 10px; color: var(--muted); font-size: 10px; line-height: 1.65; }
.ai-claims { list-style: none; margin: 0; padding: 0 11px 10px; display: grid; gap: 4px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.ai-risk { margin: 0 11px 8px; padding: 7px 8px; border-radius: 6px; background: var(--amber-soft); color: var(--amber); font-size: 10px; line-height: 1.5; }
.ai-vision { padding: 9px 11px 11px; border-top: 1px solid var(--line); }
.ai-vision-label { display: inline-block; margin-bottom: 6px; color: var(--faint); font-size: 10px; }
.ai-vision-text { margin: 0 0 5px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.ai-cover { display: block; width: min(230px, 100%); max-height: 140px; object-fit: cover; margin-top: 8px; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- Settings & model panels ---------- */
.settings-view { display: grid; gap: 18px; max-width: 1180px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.effective-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.effective-card { display: grid; gap: 6px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.effective-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.effective-cap { color: var(--faint); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.source-badge { padding: 2px 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; }
.source-badge.tenant { background: var(--teal-soft); color: var(--teal); }
.source-badge.system { background: var(--accent-soft); color: var(--accent); }
.effective-model { font: 500 14px var(--mono); word-break: break-all; }
.ready-flag { color: var(--red); font-size: 10px; }
.ready-flag.on { color: var(--teal); }
.ready-flag::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
.warnings-box { margin-top: 12px; padding: 11px 13px; border: 1px solid #ecd8ae; border-radius: 10px; background: var(--amber-soft); color: var(--amber); font-size: 10px; line-height: 1.65; }
.warning-title { display: block; margin-bottom: 4px; font-size: 10px; }
.warning-list { margin: 0; padding-left: 15px; display: grid; gap: 3px; }
.empty-guide { margin-bottom: 14px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--surface-2); }
.guide-title { display: block; margin-bottom: 4px; font-size: 11px; }
.guide-text { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.check-field { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; color: var(--muted); font-size: 11px; }
.check-field input { width: 15px; height: 15px; accent-color: var(--accent); }
.model-slot { margin-bottom: 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.section-heading + .model-slot { padding-top: 0; border-top: 0; }
.slot-badge { margin-left: 6px; padding: 2px 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-style: normal; }
.slot-badge.passed { background: var(--teal-soft); color: var(--teal); }
.slot-badge.failed { background: var(--red-soft); color: var(--red); }
.slot-note { margin: -7px 0 14px; color: var(--faint); font-size: 10px; }
.hint-inline { margin: 0; color: var(--faint); font-size: 10px; text-align: right; line-height: 1.5; }
.test-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.test-result { margin-top: 15px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.test-result.failed { border-color: #e9c2c2; background: var(--red-soft); }
.test-head { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-bottom: 10px; }
.test-verdict { font-size: 12px; }
.test-verdict.ok { color: var(--teal); }
.test-verdict.fail { color: var(--red); }
.test-cap, .test-model { color: var(--faint); font-size: 10px; }
.test-model { font-family: var(--mono); word-break: break-all; }
.test-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.test-item { display: grid; gap: 3px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.test-label { color: var(--faint); font-size: 10px; }
.test-value { font-size: 11px; }
.test-detail { margin: 10px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; word-break: break-word; }
.run-list { display: grid; gap: 7px; }
.run-row { display: grid; grid-template-columns: minmax(0, 1.15fr) auto auto auto auto; gap: 9px; align-items: center; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 10px; }
.run-model { font-weight: 600; word-break: break-all; }
.run-purpose, .run-time { color: var(--faint); font-size: 10px; }
.run-purpose { max-width: 180px; overflow-wrap: anywhere; }
.run-time { white-space: nowrap; }
.run-status { padding: 2px 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; white-space: nowrap; }
.run-status.ok { background: var(--teal-soft); color: var(--teal); }
.run-status.fail { background: var(--red-soft); color: var(--red); }
.run-latency { color: var(--faint); font-size: 10px; white-space: nowrap; }
.run-error { grid-column: 1 / -1; color: var(--red); font-size: 10px; line-height: 1.55; word-break: break-word; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; max-width: min(440px, calc(100vw - 32px)); padding: 10px 16px; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; background: #172720; color: #f5f3eb; box-shadow: 0 12px 32px rgba(23,39,32,.25); font-size: 11px; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1320px) {
  .main { padding: 26px 26px 44px; }
  .workspace { grid-template-columns: minmax(330px, 360px) minmax(0, 1fr); gap: 18px; }
  .create-panel, .task-panel, .detail-panel, .settings-panel { padding: 19px; }
  .detail-panel { min-height: 580px; }
  .empty-state { min-height: 530px; gap: 24px; padding: 20px 10px; }
  .empty-visual { min-height: 260px; }
}
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .sidebar { padding: 22px 14px 18px; }
  .main { padding: 22px 20px 40px; }
  .workspace { grid-template-columns: 1fr; }
  .left-column { grid-template-columns: minmax(0, 1fr) minmax(0, .82fr); align-items: start; }
  .detail-panel { min-height: 480px; }
  .empty-state { min-height: 420px; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; height: auto; z-index: 20; padding: 12px 16px; flex-direction: row; align-items: center; gap: 14px; overflow: visible; }
  .sidebar::after, .sidebar-status, .sidebar-note { display: none; }
  .brand { padding: 0; flex: none; }
  .brand-copy { display: none; }
  .brand-mark { width: 35px; height: 35px; font-size: 16px; border-radius: 10px; }
  .nav { display: flex; margin: 0; gap: 3px; overflow-x: auto; }
  .nav-item { width: auto; min-height: 36px; padding: 0 10px; white-space: nowrap; font-size: 11px; }
  .nav-item.active::before { display: none; }
  .nav-icon { display: none; }
  .main { padding: 18px 14px 34px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
  .topbar-actions { align-items: stretch; }
  .org-control { flex: 1; }
  .org-control input { width: 100%; }
  .session-control { width: 100%; justify-content: space-between; }
  .workspace { gap: 16px; }
  .left-column { grid-template-columns: 1fr; }
  .detail-panel { min-height: 420px; }
  .empty-state { grid-template-columns: 1fr; gap: 10px; min-height: auto; padding: 20px 6px; }
  .empty-visual { min-height: 150px; border-right: 0; border-bottom: 1px solid var(--line); }
  .empty-visual span { font-size: 72px; }
  .empty-copy h2 { font-size: 26px; }
  .login-view { padding: 0; }
  .login-shell { grid-template-columns: 1fr; min-height: 100dvh; border: 0; border-radius: 0; }
  .login-brand { display: none; }
  .login-form-side { padding: 26px 20px; }
  .login-mobile-brand { display: flex; }
}
@media (max-width: 560px) {
  .topbar h1 { font-size: 26px; }
  .panel, .create-panel, .task-panel, .detail-panel, .settings-panel { border-radius: 14px; padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card:nth-child(3) { grid-column: 1 / -1; }
  .ai-insight-grid { grid-template-columns: 1fr 1fr; }
  .detail-head { flex-wrap: wrap; }
  .detail-head > .button { margin-left: 0; }
  .detail-head h2 { width: 100%; }
  .candidate { padding: 15px; }
  .candidate-price { font-size: 21px; }
  .effective-grid, .test-grid { grid-template-columns: 1fr; }
  .run-row { grid-template-columns: 1fr auto; }
  .run-model, .run-error { grid-column: 1 / -1; }
  .hint-inline { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
