/* ════════════════════════════════════════════════════════════════════
   АТС — Тендерийн материал шалгалт
   Цайвар / бараан загвар: <html data-theme="light|dark">
   Дүгнэлтийн өнгө (pass → warn → fail → хянах) — CVD-д шалгасан дараалал.
   ════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  --canvas: #eef1ee;
  --canvas-glow: rgba(12, 122, 85, .07);
  --surface: #ffffff;
  --surface-soft: #f6f8f6;
  --surface-glass: rgba(255, 255, 255, .78);
  --ink: #14181b;
  --ink-2: #3c444b;
  --muted: #66707a;
  --faint: #98a19a;
  --line: #e2e7e3;
  --line-strong: #cdd4ce;
  --on-ink: #ffffff;

  --accent: #0c7a55;
  --accent-hover: #096344;
  --accent-soft: #e7f4ee;
  --accent-line: #c9e2d4;
  --accent-glow: rgba(12, 122, 85, .14);
  --accent-grad: linear-gradient(135deg, #10996b, #0c7a55);

  --pass: #0e9f84;  --pass-soft: #e3f5f0;  --pass-ink: #0a7560;
  --warn: #d18b00;  --warn-soft: #fdf4e0;  --warn-ink: #8a5c00;
  --fail: #d8394a;  --fail-soft: #fdecee;  --fail-ink: #ae2838;
  --comm: #6353cc;  --comm-soft: #efedfc;  --comm-ink: #4f40b3;

  --shadow-sm: 0 1px 2px rgba(18, 24, 20, .05);
  --shadow-md: 0 1px 2px rgba(18, 24, 20, .05), 0 10px 28px rgba(24, 34, 28, .08);
  --shadow-lg: 0 2px 4px rgba(18, 24, 20, .06), 0 18px 44px rgba(24, 34, 28, .14);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0b100e;
  --canvas-glow: rgba(47, 179, 131, .08);
  --surface: #131a17;
  --surface-soft: #19221e;
  --surface-glass: rgba(19, 26, 23, .82);
  --ink: #e7ede9;
  --ink-2: #c2cbc6;
  --muted: #8d9993;
  --faint: #66736c;
  --line: #232d29;
  --line-strong: #34413b;
  --on-ink: #0b100e;

  --accent: #2fb383;
  --accent-hover: #4bc899;
  --accent-soft: rgba(47, 179, 131, .12);
  --accent-line: rgba(47, 179, 131, .32);
  --accent-glow: rgba(47, 179, 131, .2);
  --accent-grad: linear-gradient(135deg, #25a878, #177f5a);

  --pass: #1a9a83;  --pass-soft: rgba(26, 154, 131, .16);  --pass-ink: #5fd2ba;
  --warn: #c98500;  --warn-soft: rgba(201, 133, 0, .17);   --warn-ink: #edb452;
  --fail: #e0485a;  --fail-soft: rgba(224, 72, 90, .16);   --fail-ink: #f58d98;
  --comm: #9085e9;  --comm-soft: rgba(144, 133, 233, .17); --comm-ink: #b8b0f7;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .3);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .35), 0 18px 44px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(1200px 520px at 85% -10%, var(--canvas-glow), transparent 60%), var(--canvas);
  background-attachment: fixed;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 3vw, 30px); line-height: 1.15; letter-spacing: -.035em; font-weight: 800; }
h2 { margin-bottom: 6px; font-size: 20px; line-height: 1.25; letter-spacing: -.02em; font-weight: 750; }
h3 { margin-bottom: 0; font-size: 15px; letter-spacing: -.01em; font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─────────────── Form controls (нэг загвар) ─────────────── */
/* :where() — нэгдсэн загварын specificity 0 тул .search-box input г.м давамгайлна */
:where(input:not([type="checkbox"], [type="file"], [type="radio"]), select, textarea) {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  transition: border-color .16s ease, box-shadow .16s ease;
}
textarea { resize: vertical; line-height: 1.5; }
:where(input, select, textarea):focus { border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-glow); }
select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%238d9993' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > span { display: block; margin-bottom: 6px; color: var(--ink-2); font-size: 12px; font-weight: 650; }
.field small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─────────────── Buttons ─────────────── */
.primary-btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 18px;
  border: 0;
  border-radius: 11px;
  background: var(--accent-grad);
  color: #fff;
  cursor: pointer;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 22px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.primary-btn:hover:not(:disabled) { transform: translateY(-1.5px); filter: brightness(1.06); }
.primary-btn:disabled { background: var(--line-strong); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.primary-btn b { font-size: 16px; font-weight: 400; }
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px; font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: all .15s ease;
}
.ghost-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ghost-btn:disabled { opacity: .5; cursor: not-allowed; }
.ghost-btn.sm { min-height: 32px; padding: 6px 11px; font-size: 11px; }
.ghost-btn.danger { color: var(--fail-ink); border-color: color-mix(in srgb, var(--fail) 35%, var(--line)); }
.ghost-btn.danger:hover { border-color: var(--fail); color: var(--fail-ink); background: var(--fail-soft); }
.danger-btn { min-height: 38px; padding: 8px 16px; border: 0; border-radius: 9px; background: var(--fail); color: #fff; cursor: pointer; font-size: 12px; font-weight: 700; }
.danger-btn:hover { filter: brightness(1.08); }
.stop-btn { min-height: 44px; padding: 10px 15px; border: 1px solid color-mix(in srgb, var(--fail) 40%, var(--line)); border-radius: 11px; background: var(--surface); color: var(--fail-ink); cursor: pointer; font-size: 12px; font-weight: 700; }
.stop-btn:hover:not(:disabled) { border-color: var(--fail); background: var(--fail-soft); }
.stop-btn:disabled { cursor: wait; opacity: .6; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--fail-ink); border-color: var(--fail); background: var(--fail-soft); }

/* ─────────────── App bar ─────────────── */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.brand-mark {
  display: grid;
  width: 36px; height: 36px;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #17a973, #0c7a55);
  color: #fff;
  box-shadow: 0 6px 16px rgba(15, 157, 110, .3);
}
.brand div > strong { display: block; font-size: 15px; letter-spacing: .02em; line-height: 1.2; }
.brand div > span { display: block; color: var(--muted); font-size: 10.5px; }
.appbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12.5px; font-weight: 650;
}
.user-chip:hover { border-color: var(--accent); }
.avatar {
  display: grid;
  width: 30px; height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font-size: 12px; font-weight: 800;
}
.user-chip .role { color: var(--muted); font-size: 10.5px; font-weight: 600; }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px; font-weight: 650;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { background: var(--ink); color: var(--on-ink); box-shadow: 0 5px 14px rgba(0, 0, 0, .18); }

/* ─────────────── Workspace ─────────────── */
.workspace { max-width: 1180px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 90px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: reveal .25s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-head p { max-width: 680px; margin-bottom: 0; color: var(--muted); font-size: 13px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 10.5px; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.card-pad { padding: 24px; }
.card-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11.5px; }
.card-icon { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border: 1px solid var(--accent-line); border-radius: 11px; background: var(--accent-soft); color: var(--accent); }

/* ─────────────── Stepper ─────────────── */
.stepper { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; counter-reset: step; }
.step-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.step-btn:hover:not(:disabled) { border-color: var(--line-strong); }
.step-btn:disabled { cursor: not-allowed; opacity: .55; }
.step-num {
  display: grid;
  width: 32px; height: 32px; flex: 0 0 auto;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 12px; font-weight: 800;
}
.step-txt { min-width: 0; }
.step-txt strong { display: block; font-size: 13px; }
.step-txt small { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.step-btn.done .step-num { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.step-btn.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.step-btn.active .step-num { border-color: var(--accent); background: var(--accent); color: #fff; }

/* Step 1 */
.start-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.tender-list { display: grid; gap: 8px; max-height: 440px; overflow-y: auto; padding-right: 2px; }
.tender-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.tender-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.tender-item strong { overflow: hidden; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.tender-item small { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.empty-state { padding: 26px 12px; color: var(--muted); font-size: 12.5px; text-align: center; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 750; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--pass-soft); color: var(--pass-ink); }
.pill.draft { background: var(--warn-soft); color: var(--warn-ink); }
.pill.muted { background: var(--surface-soft); color: var(--muted); border: 1px solid var(--line); }

/* Upload zones */
.upload-zone {
  position: relative;
  display: flex;
  min-height: 164px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 22px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 13px;
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.upload-zone:hover, .upload-zone.dragging { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 12px 28px var(--accent-glow); }
.upload-zone.has-files { border-style: solid; border-color: var(--accent-line); background: var(--accent-soft); }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-icon { display: grid; width: 40px; height: 40px; margin-bottom: 11px; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.upload-zone strong { margin-bottom: 3px; font-size: 12.5px; }
.upload-zone small { max-width: 280px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.file-list { display: grid; gap: 7px; margin-top: 11px; max-height: 220px; overflow-y: auto; }
.file-list:empty { display: none; }
.file-item { display: flex; min-width: 0; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); }
.file-type { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--fail-soft); color: var(--fail-ink); font-size: 8.5px; font-weight: 800; letter-spacing: .05em; }
.file-meta { min-width: 0; flex: 1; }
.file-name { display: block; overflow: hidden; font-size: 11.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.file-size { display: block; color: var(--muted); font-size: 10px; }
.file-remove { display: grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 17px; }
.file-remove:hover { background: var(--fail-soft); color: var(--fail-ink); }

.action-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; }
.action-row .hint { color: var(--muted); font-size: 12px; }
.run-actions { display: flex; align-items: center; gap: 9px; }
.toggle-line { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 12px; font-weight: 600; cursor: pointer; }

/* Progress */
.progress-box { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--accent-line); border-radius: 14px; background: var(--accent-soft); }
.progress-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.progress-head strong { color: var(--accent); font-size: 13px; }
.progress-time { margin-left: auto; padding: 3px 9px; border: 1px solid var(--accent-line); border-radius: 999px; background: var(--surface); color: var(--accent); font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; }
.spinner { width: 18px; height: 18px; flex: 0 0 auto; border: 2.5px solid var(--accent-line); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track { height: 6px; margin-top: 12px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--accent) 15%, transparent); }
.progress-fill { position: relative; width: 0%; height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s ease; overflow: hidden; }
.progress-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent); animation: shimmer 1.6s ease infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.progress-log { max-height: 170px; overflow-y: auto; margin-top: 12px; color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.progress-log .warn-line { color: var(--warn-ink); }
.progress-log .err-line { color: var(--fail-ink); font-weight: 650; }
.progress-log .tick-line { opacity: .75; }
.progress-box.is-done .spinner, .progress-box.is-stopped .spinner { display: none; }
.progress-box.is-stopped, .progress-box.is-error { border-color: color-mix(in srgb, var(--fail) 40%, var(--line)); background: var(--fail-soft); }
.progress-box.is-stopped strong, .progress-box.is-error strong { color: var(--fail-ink); }
.progress-box.is-error .spinner { display: none; }

/* ─────────────── Requirement editor (2-р алхам) ─────────────── */
.tender-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.approval-note { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--ink-2); font-size: 12px; }
.approval-note.ok { border-color: color-mix(in srgb, var(--pass) 35%, var(--line)); background: var(--pass-soft); color: var(--pass-ink); }
.approval-note.draft { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); color: var(--warn-ink); }
.req-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 12px; }
.req-list { display: grid; gap: 10px; }
.req-row {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--edge, var(--accent));
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.req-row.comm { --edge: var(--comm); }
.req-row.is-new { animation: flash 1.4s ease; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--accent-glow); } }
.req-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.req-id { min-width: 52px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.req-head select { width: auto; min-height: 32px; padding: 4px 30px 4px 10px; font-size: 11.5px; }
.check-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: var(--ink-2); cursor: pointer; font-size: 11.5px; font-weight: 600; user-select: none; }
.check-pill:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.req-head .icon-btn { margin-left: auto; width: 32px; height: 32px; font-size: 15px; }
.req-text { min-height: 46px; field-sizing: content; font-size: 13px; }
.req-foot { display: grid; grid-template-columns: 3fr 2fr; gap: 8px; margin-top: 8px; }
.req-foot input { min-height: 36px; font-size: 12px; }
.save-bar {
  position: sticky;
  bottom: 14px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
}
.save-bar .dirty { color: var(--muted); font-size: 12px; font-weight: 600; }
.save-bar .dirty.on { color: var(--warn-ink); }
.save-bar .spacer { flex: 1; }

/* Step 3 */
.tender-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.tender-strip .t-main { min-width: 0; flex: 1; }
.tender-strip strong { display: block; font-size: 13.5px; }
.tender-strip small { color: var(--muted); font-size: 11.5px; }

/* ─────────────── Filters / chips ─────────────── */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.chip { padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 11.5px; font-weight: 650; }
.chip:hover { color: var(--ink); border-color: var(--ink-2); }
.chip.active { border-color: transparent; background: var(--ink); color: var(--on-ink); }
.chip .cnt { margin-left: 5px; opacity: .65; font-weight: 700; }
.search-box { position: relative; margin-left: auto; width: 260px; }
.search-box input { min-height: 36px; padding-left: 34px; font-size: 12px; }
.search-box svg { position: absolute; left: 11px; top: 50%; color: var(--muted); transform: translateY(-50%); pointer-events: none; }

/* ═══════════════ Results dashboard ═══════════════ */
.results-box { margin-top: 28px; animation: reveal .3s ease both; }
.results-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.results-header h3 { margin-bottom: 2px; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.results-header p { margin: 0; color: var(--muted); font-size: 12px; }
.export-row { display: flex; flex-wrap: wrap; gap: 8px; }

.result-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.score-card { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; padding: 22px; }
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-value { position: absolute; display: grid; place-items: center; text-align: center; }
.ring-value b { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.ring-value small { margin-top: 3px; color: var(--muted); font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.status-badge { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 5px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 750; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.ok { background: var(--pass-soft); color: var(--pass-ink); }
.status-badge.cond { background: var(--warn-soft); color: var(--warn-ink); }
.status-badge.bad { background: var(--fail-soft); color: var(--fail-ink); }
.score-card p { margin: 0 0 12px; color: var(--ink-2); font-size: 12.5px; line-height: 1.6; }

.chart-card { padding: 18px 20px; }
.chart-card h4 { margin: 0 0 4px; font-size: 13px; font-weight: 750; }
.chart-card .sub { margin: 0 0 14px; color: var(--muted); font-size: 11.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-2); font-size: 11px; font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.lg-pass, .seg-pass { background: var(--pass); }
.lg-warn, .seg-warn { background: var(--warn); }
.lg-fail, .seg-fail { background: var(--fail); }
.lg-comm, .seg-comm { background: var(--comm); }

.stack-bar { display: flex; gap: 2px; height: 24px; min-width: 0; }
.stack-bar.thin { height: 14px; }
.seg { display: grid; min-width: 0; place-items: center; border-radius: 4px; color: #fff; font-size: 10.5px; font-weight: 800; transition: width .4s ease; }
.seg span { overflow: hidden; padding: 0 3px; }
.stack-empty { flex: 1; border-radius: 4px; background: var(--surface-soft); border: 1px dashed var(--line-strong); }
.cat-rows { display: grid; gap: 11px; }
.cat-row { display: grid; grid-template-columns: minmax(120px, 170px) 1fr 44px; gap: 10px; align-items: center; }
.cat-row .cat-name { overflow: hidden; color: var(--ink-2); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .cat-pct { color: var(--ink); font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.dist-block { margin-top: 16px; }

.fix-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.fix-col { padding: 16px 18px; }
.fix-col h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; font-weight: 750; }
.fix-col ul { margin: 0; padding: 0; list-style: none; }
.fix-col li { position: relative; padding: 5px 0 5px 18px; color: var(--ink-2); font-size: 12px; line-height: 1.5; border-bottom: 1px dashed var(--line); }
.fix-col li:last-child { border-bottom: 0; }
.fix-col li::before { content: ""; position: absolute; left: 2px; top: 12px; width: 7px; height: 7px; border-radius: 2px; background: var(--line-strong); }
.fix-col li.crit::before { background: var(--fail); }
.fix-col li.risk::before { background: var(--warn); }
.fix-col li.none { color: var(--pass-ink); }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
button.metric { cursor: pointer; }
button.metric:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
button.metric.active { border-color: var(--bar, var(--ink)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bar, var(--ink)) 30%, transparent); }
.metric::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--bar, var(--line-strong)); }
.metric.pass { --bar: var(--pass); }
.metric.fail { --bar: var(--fail); }
.metric.warn { --bar: var(--warn); }
.metric.comm { --bar: var(--comm); }
.metric.accent { --bar: var(--accent); }
.metric .num { font-size: 24px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.metric .label { margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 600; }
.metric .sub { margin-top: 2px; color: var(--faint); font-size: 10.5px; }

/* Result rows */
details.result-row {
  margin-bottom: 8px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--edge, var(--line-strong));
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
details.result-row[open] { box-shadow: var(--shadow-md); }
details.result-row.pass { --edge: var(--pass); }
details.result-row.fail { --edge: var(--fail); }
details.result-row.warn { --edge: var(--warn); }
details.result-row.comm { --edge: var(--comm); }
details.result-row summary { display: flex; align-items: center; gap: 10px; padding: 13px 26px 13px 0; cursor: pointer; font-size: 12.5px; font-weight: 600; list-style: none; position: relative; }
details.result-row summary::-webkit-details-marker { display: none; }
details.result-row summary::after { content: "+"; position: absolute; right: 2px; color: var(--muted); font-size: 17px; font-weight: 400; }
details.result-row[open] summary::after { content: "−"; }
.row-summary-text { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reviewed-mark { flex: 0 0 auto; color: var(--accent); font-size: 11px; font-weight: 700; }
.verdict-badge { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.verdict-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.verdict-badge.pass { background: var(--pass-soft); color: var(--pass-ink); }
.verdict-badge.fail { background: var(--fail-soft); color: var(--fail-ink); }
.verdict-badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.verdict-badge.comm { background: var(--comm-soft); color: var(--comm-ink); }
.cat-tag { flex: 0 0 auto; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 650; white-space: nowrap; }
.mand-tag { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); color: var(--warn-ink); }
.row-body { padding: 2px 0 16px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 12.5px; line-height: 1.7; }
.row-body > div:first-child { margin-top: 12px; }
.row-body b.k { display: inline-block; min-width: 130px; color: var(--muted); font-size: 11px; font-weight: 650; }
.mismatch-line { display: flex; gap: 8px; margin-top: 6px; padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--fail) 25%, var(--line)); border-radius: 9px; background: var(--fail-soft); color: var(--fail-ink); font-size: 12px; line-height: 1.55; }
.mismatch-line::before { content: "!"; flex: 0 0 auto; display: grid; place-items: center; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; background: var(--fail); color: #fff; font-size: 10px; font-weight: 800; }
.quote-block { margin: 9px 0; padding: 10px 14px; border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--accent-soft); color: var(--ink); font-size: 12.5px; font-style: italic; line-height: 1.6; }
.quote-block small { display: block; margin-top: 6px; color: var(--muted); font-size: 10.5px; font-style: normal; }
.conf-dots { display: inline-flex; gap: 3px; margin: 0 6px; vertical-align: middle; }
.conf-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.conf-dot.on-high { background: var(--pass); }
.conf-dot.on-mid { background: var(--warn); }
.conf-dot.on-low { background: var(--fail); }
.consistency-tag { display: inline-block; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 10.5px; font-weight: 650; }
.vtags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.vtag { display: inline-block; padding: 2px 9px; border: 1px solid transparent; border-radius: 999px; font-size: 10.5px; font-weight: 650; line-height: 1.5; }
.vtag.ok { background: var(--pass-soft); color: var(--pass-ink); }
.vtag.warn { background: var(--warn-soft); color: var(--warn-ink); }
.vtag.bad { background: var(--fail-soft); color: var(--fail-ink); }
.vtag.info { background: var(--surface-soft); color: var(--muted); border-color: var(--line); }
.committee-box { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.committee-box > b { display: block; margin-bottom: 8px; font-size: 12px; color: var(--ink); }
.committee-box select, .committee-box textarea { margin: 4px 0; font-size: 12px; }
.committee-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
.save-status { color: var(--accent); font-size: 11px; font-weight: 600; }
.save-status.error { color: var(--fail-ink); }
.row-delete-btn { margin-top: 12px; }
.section-title { margin: 22px 0 6px; font-size: 14px; }
.caption { margin-bottom: 11px; color: var(--muted); font-size: 12px; }
.warning-note { margin-top: 18px; padding: 12px 15px; border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--line)); border-radius: 11px; background: var(--warn-soft); color: var(--warn-ink); font-size: 12px; line-height: 1.55; }

/* History & comparison */
.panel-card { min-height: 140px; padding: 22px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 16px; }
.controls select { width: auto; flex: 1 1 220px; min-width: 200px; font-size: 12.5px; }
.bar-row { display: grid; grid-template-columns: 200px 1fr; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.bar-row:last-child { border-bottom: 0; }
.bar-label b { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.bar-label small { display: block; color: var(--muted); font-size: 10.5px; }
.matrix-details { margin-top: 4px; }
.matrix-details > summary { padding: 10px 4px; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 650; list-style: none; }
.matrix-details > summary::-webkit-details-marker { display: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data-table th, table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: 0; }
table.data-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-soft); color: var(--muted); font-size: 10.5px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
table.data-table tbody tr:hover { background: var(--surface-soft); }
table.data-table td.num, table.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.crit-cell { min-width: 220px; max-width: 400px; line-height: 1.5; }
td.cell-v { min-width: 92px; text-align: center; }
.cmp-id { display: block; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .05em; }
.cell-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.cell-badge.pass { background: var(--pass-soft); color: var(--pass-ink); }
.cell-badge.fail { background: var(--fail-soft); color: var(--fail-ink); }
.cell-badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.cell-badge.comm { background: var(--comm-soft); color: var(--comm-ink); }
.cell-badge.empty { background: var(--surface-soft); color: var(--muted); }
.bidder-score b { font-size: 15px; font-variant-numeric: tabular-nums; }
.bidder-score span { margin-left: 4px; color: var(--muted); font-size: 9.5px; text-transform: none; letter-spacing: 0; }
.heat-cell { position: relative; }
.heat-cell::before { content: ""; position: absolute; inset: 4px; z-index: 0; border-radius: 7px; background: color-mix(in srgb, var(--pass) calc(var(--heat, 0) * 85%), var(--surface-soft)); }
.heat-cell span { position: relative; z-index: 1; color: var(--ink); font-size: 11px; font-weight: 750; }

/* ─────────────── Drawer (профайл) ─────────────── */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 50;
  display: flex;
  width: min(380px, 92vw);
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(104%);
  transition: transform .24s cubic-bezier(.4, 0, .2, 1);
  visibility: hidden;
}
.drawer.open { transform: translateX(0); visibility: visible; }
.scrim { position: fixed; inset: 0; z-index: 45; border: 0; background: rgba(8, 12, 10, .45); backdrop-filter: blur(2px); }
.drawer-head { display: flex; align-items: center; gap: 12px; }
.drawer-head .avatar { width: 44px; height: 44px; font-size: 16px; }
.drawer-head strong { display: block; font-size: 15px; }
.drawer-head small { color: var(--muted); font-size: 11.5px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-section { padding-top: 16px; border-top: 1px solid var(--line); }
.section-label { margin: 0 0 10px; color: var(--muted); font-size: 10.5px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 650; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.drawer .ghost-btn.full, .drawer .primary-btn.full { width: 100%; }
.form-msg { min-height: 16px; margin: 6px 0 0; font-size: 11.5px; font-weight: 600; color: var(--accent); }
.form-msg.error { color: var(--fail-ink); }

/* Confirm dialog */
.dialog-overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(8, 12, 10, .5); backdrop-filter: blur(3px); animation: reveal .18s ease both; }
.dialog { width: min(420px, 100%); padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); }
.dialog strong { display: block; margin-bottom: 7px; font-size: 15px; }
.dialog p { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.dialog .field { margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }

/* Toasts */
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 9px; }
.toast { min-width: 220px; max-width: 340px; padding: 11px 15px; border-radius: 12px; background: var(--ink); color: var(--on-ink); font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in .25s ease both; }
.toast.success { background: #0b7c56; color: #fff; }
.toast.error { background: #c62f39; color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ─────────────── Login ─────────────── */
.login-page { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  overflow: hidden;
  padding: clamp(28px, 5vw, 60px);
  background: radial-gradient(600px 400px at -10% -10%, rgba(23, 169, 115, .45), transparent 60%), linear-gradient(160deg, #0f1a15, #0a110e);
  color: #e8efe9;
}
.login-aside .brand { color: #e8efe9; }
.login-aside .brand div > span { color: #93a39a; }
.login-aside h1 { max-width: 460px; margin: 0 0 12px; font-size: clamp(26px, 3.4vw, 38px); }
.login-aside p { max-width: 440px; margin: 0; color: #a9b8b0; font-size: 14px; }
.login-steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.login-steps li { display: flex; align-items: flex-start; gap: 12px; max-width: 420px; color: #c9d5ce; font-size: 13px; }
.login-steps b { display: grid; width: 26px; height: 26px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; color: #6fe0b0; font-size: 11px; }
.login-foot { color: #74857c; font-size: 11.5px; }
.login-main { display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: min(380px, 100%); }
.login-card h2 { margin-bottom: 4px; font-size: 22px; }
.login-card > p { margin-bottom: 22px; color: var(--muted); font-size: 13px; }
.login-card .primary-btn { width: 100%; margin-top: 6px; }
.login-error { min-height: 18px; margin: 10px 0 0; color: var(--fail-ink); font-size: 12px; font-weight: 600; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px; }
.pw-toggle { position: absolute; top: 50%; right: 6px; padding: 5px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 650; transform: translateY(-50%); }
.pw-toggle:hover { background: var(--surface-soft); color: var(--ink); }

/* ─────────────── Admin ─────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 11.5px; font-weight: 650; }
.kpi .num { margin-top: 4px; font-size: 26px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .sub { margin-top: 4px; color: var(--faint); font-size: 11px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.col-chart { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: 8px; border-bottom: 1px solid var(--line-strong); }
.col-chart .col { flex: 1; min-width: 0; display: flex; align-items: flex-end; height: 100%; }
.col-chart .col i { display: block; width: 100%; min-height: 1px; border-radius: 4px 4px 0 0; background: var(--accent); opacity: .9; }
.col-chart .col:hover i { opacity: 1; background: var(--accent-hover); }
.col-chart .col.zero i { background: var(--line-strong); }
.axis-row { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 10.5px; }
.chart-max { color: var(--muted); font-size: 10.5px; }
.table-toggle { margin-top: 10px; color: var(--muted); font-size: 11.5px; }
.table-toggle summary { cursor: pointer; }
.role-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--comm-soft); color: var(--comm-ink); font-size: 10.5px; font-weight: 750; }
.role-tag.user { background: var(--accent-soft); color: var(--accent); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--pass); vertical-align: middle; }
.status-dot.error { background: var(--fail); }
.status-dot.stopped { background: var(--warn); }
.status-dot.incomplete { background: var(--line-strong); }
.add-user-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.add-user-form .field { margin: 0; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* Chat */
.chat-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; height: min(780px, calc(100dvh - 190px)); min-height: 500px; }
.chat-sidebar { min-width: 0; overflow: hidden; }
.chat-sidebar > summary { padding: 16px; cursor: pointer; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--line); }
.chat-sidebar-body { height: calc(100% - 54px); padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.chat-sidebar-body > input { flex-shrink: 0; min-height: 36px; font-size: 12px; }
.chat-threads { flex: 1; min-height: 0; overflow-y: auto; }
.chat-thread { display: block; width: 100%; border: 1px solid transparent; border-radius: 9px; background: transparent; padding: 11px; text-align: left; cursor: pointer; margin-bottom: 5px; }
.chat-thread:hover { background: var(--surface-soft); }
.chat-thread.active { background: var(--accent-soft); border-color: var(--accent-line); }
.chat-thread strong { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread small { display: block; color: var(--muted); font-size: 10px; margin-top: 5px; }
.chat-card { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-conversation-head { padding: 16px 20px 8px; display: flex; align-items: center; gap: 10px; }
.chat-conversation-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-context-bar { display: flex; align-items: end; gap: 10px; padding: 0 20px 14px; border-bottom: 1px solid var(--line); }
.chat-context-bar .field { flex: 1; min-width: 0; margin: 0; }
.chat-context-bar select { min-height: 36px; font-size: 12px; text-overflow: ellipsis; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px; }
.chat-welcome { max-width: 570px; margin: 24px auto; text-align: center; }
.chat-welcome p { color: var(--muted); }
.chat-suggestions { display: grid; gap: 10px; margin-top: 24px; }
.chat-suggestions button { text-align: left; white-space: normal; height: auto; }
.chat-message { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 16px; background: var(--surface-soft); overflow-wrap: anywhere; }
.chat-message.user { max-width: 90%; width: fit-content; margin-left: auto; background: var(--accent-soft); border-color: var(--accent-line); }
.chat-message h3 { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.chat-text { white-space: pre-wrap; line-height: 1.75; }
.chat-source-label { margin: 16px 0 6px; font-size: 11px; color: var(--muted); }
.chat-sources { margin: 0; padding-left: 20px; font-size: 12px; }
.chat-sources li + li { margin-top: 5px; }
.chat-source-details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 12px; }
.chat-source-details > summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.chat-source-details ol { margin-top: 10px; }
.chat-evidence { margin-top: 12px; padding: 12px; border-radius: 8px; background: var(--surface); }
.chat-evidence h4 { margin: 0 0 8px; font-size: 12px; }
.chat-evidence p, .chat-evidence blockquote { margin: 6px 0; white-space: pre-wrap; }
.chat-evidence blockquote { padding-left: 10px; border-left: 3px solid var(--accent-line); }
.chat-evidence small { color: var(--muted); }
.chat-citation { border: 0; padding: 0 2px; background: transparent; color: var(--accent); font-size: inherit; cursor: pointer; text-decoration: underline; }
.chat-form { padding: 20px; border-top: 1px solid var(--line); }
.chat-form .field { margin-bottom: 10px; }
.chat-form textarea { resize: vertical; min-height: 72px; max-height: 240px; }
.chat-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.chat-actions p { margin: 0 auto 0 0; font-size: 12px; color: var(--muted); }
.chat-error { color: var(--fail-ink); margin: 10px 0 0; font-size: 12px; }
.chat-error:empty { display: none; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .chat-sidebar-body { height: auto; max-height: 240px; }
  .chat-threads { max-height: 170px; flex: auto; }
  .chat-card { height: max(540px, 70dvh); }
  .chat-context-bar { flex-wrap: wrap; }
  .chat-context-bar .field { flex-basis: 100%; }
  .chat-messages { padding: 14px; }
  .chat-form { padding: 14px; }
}

/* Print — хянагчийн протокол */
.print-only-header { display: none; }
@media print {
  :root, [data-theme="dark"] { --canvas: #fff; --surface: #fff; --surface-soft: #f6f8f6; --ink: #111; --ink-2: #333; --muted: #555; --line: #ddd; }
  body { background: #fff; font-size: 11px; }
  .appbar, .stepper, .page-head, .action-row, .filter-bar, .export-row, .committee-box, .toast-host,
  .progress-box, .upload-zone, .file-list, .controls, .dialog-overlay, .drawer, .scrim, .row-delete-btn,
  .tender-strip, .save-bar, .card-pad:has(.upload-zone) { display: none !important; }
  .workspace { padding: 0; }
  .card, .metric, details.result-row, .chart-card { box-shadow: none !important; break-inside: avoid; }
  details.result-row summary::after { display: none; }
  .print-only-header { display: block !important; margin-bottom: 14px; }
}

/* ─────────────── Responsive ─────────────── */
@media (max-width: 1020px) {
  .start-grid, .result-hero, .admin-grid, .fix-list { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-user-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .appbar { flex-wrap: wrap; gap: 10px; }
  .appbar .tabs { order: 3; width: 100%; overflow-x: auto; }
  .user-chip .who { display: none; }
  .user-chip { padding-right: 4px; }
  .login-page { grid-template-columns: 1fr; }
  .login-aside { gap: 20px; }
  .login-steps, .login-foot { display: none; }
  .page-head { display: block; }
  .page-head .export-row { margin-top: 12px; }
  .stepper { grid-template-columns: 1fr; gap: 6px; }
  .step-btn { padding: 10px 12px; }
  .field-grid, .tender-bar, .req-foot { grid-template-columns: 1fr; }
  .card-pad { padding: 18px; }
  .score-card { grid-template-columns: 1fr; justify-items: start; }
  .search-box { width: 100%; margin-left: 0; order: 10; }
  .bar-row, .cat-row { grid-template-columns: 1fr; gap: 4px; }
  .cat-row .cat-pct { text-align: left; }
  .run-actions { width: 100%; flex-direction: column-reverse; }
  .run-actions > * { width: 100%; }
  .save-bar .spacer { display: none; }
  .save-bar > button { flex: 1 1 auto; }
}
@media (max-width: 480px) {
  .metrics, .kpi-grid, .add-user-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-user-form > button { grid-column: 1 / -1; }
  .brand div > span { display: none; }
  .row-body b.k { display: block; min-width: 0; }
  details.result-row summary { flex-wrap: wrap; }
  details.result-row summary .cat-tag:not(.mand-tag) { display: none; }
  .row-summary-text { flex-basis: 100%; white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
