/* ==========================================================================
   Ценовой след — 2026 Editorial Enterprise UI System
   Warm-paper precision design, tabular numbers, clear office-worker Russian
   ========================================================================== */

:root {
  --bg: #F6F4EE;
  --surface: #FFFFFF;
  --surface-subtle: #F9F7F2;
  --surface-warm: #EFECE4;
  --border: #E2DDD2;
  --border-subtle: #EDEAE1;
  --border-strong: #C9C3B6;

  --text: #1B1A17;
  --text-secondary: #4D4B45;
  --text-muted: #706D65;

  --primary: #1B1A17;
  --primary-hover: #32302B;
  --primary-text: #FFFFFF;

  --ok: #157F47;
  --ok-bg: #ECF7F0;
  --ok-border: #C4E5D1;
  --warn: #B25E09;
  --warn-bg: #FFF9EE;
  --warn-border: #E8D5AA;
  --err: #B8291E;
  --err-bg: #FDF3F2;
  --err-border: #F1C9C5;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(27, 26, 23, 0.04);
  --shadow-md: 0 6px 20px rgba(27, 26, 23, 0.08);
  --shadow-lg: 0 20px 48px rgba(27, 26, 23, 0.16);

  --rail: 1320px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04";
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

.hidden {
  display: none !important;
}

.ui-icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.money-nowrap {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Global Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(246, 244, 238, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: var(--rail);
  margin: 0 auto;
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.015em;
  color: var(--text);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-divider {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
}

.brand-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-contour-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.nav-back-link,
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 5px 2px;
  transition: color 0.15s ease;
}

.nav-back-link:hover,
.back-link:hover {
  color: var(--text);
}

.page-main {
  min-height: calc(100vh - 61px);
}

.flash-toast {
  max-width: var(--rail);
  margin: 16px auto 0;
  padding: 12px 20px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  border-radius: var(--radius-md);
  color: var(--ok);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}

.flash-toast.is-error {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err);
}

/* --------------------------------------------------------------------------
   Shared Buttons & Inputs
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: translateY(0.5px);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-subtle);
  border-color: var(--text-secondary);
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13.5px;
}

.btn-run {
  height: 42px;
  padding: 0 22px;
  font-size: 14.5px;
}

.btn-quiet-link {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.14s ease, color 0.14s ease, background-color 0.14s ease;
}

.btn-quiet-link:hover {
  background: var(--surface-warm);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-quiet-link.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.icon-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-close-btn:hover {
  background: var(--surface-warm);
  color: var(--text);
}

.text-input,
.textarea-input,
.form-control {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.45;
  padding: 10px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus,
.textarea-input:focus,
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 26, 23, 0.08);
}

.textarea-input {
  resize: vertical;
  min-height: 128px;
}

.form-control-sm {
  padding: 7px 10px;
  font-size: 13.5px;
}

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23706D65' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

select.form-control-sm {
  padding-right: 28px;
  background-position: right 8px center;
}

.field-label,
.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label-xs {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-ok,
.status-dot.is-ok {
  background: var(--ok);
}

.dot-warn,
.status-dot.is-warn {
  background: var(--warn);
}

.dot-err,
.status-dot.is-err {
  background: var(--err);
}

.status-dot.is-muted {
  background: var(--text-muted);
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Screen 1: Home / Intake Layout (Proportional 1440×900 Composition)
   -------------------------------------------------------------------------- */
.home-shell {
  max-width: var(--rail);
  margin: 0 auto;
  padding: 20px 32px 36px;
}

.home-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 18px;
}

.home-hero-copy {
  max-width: 680px;
}

.home-title {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}

.home-subtitle {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.home-hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-fact-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 24px;
  align-items: stretch;
}

/* Left Card: Intake Composer */
.composer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.composer-card form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.composer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.composer-tabs {
  display: flex;
  gap: 20px;
}

.composer-tab {
  position: relative;
  background: transparent;
  border: none;
  padding: 10px 2px 13px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.composer-tab:hover {
  color: var(--text);
}

.composer-tab.is-active {
  color: var(--text);
}

.composer-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

.composer-formats {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  padding-bottom: 10px;
}

.composer-pane {
  padding: 18px 22px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.dropzone-area {
  flex: 1 1 auto;
  min-height: 205px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone-area.has-file {
  border-style: solid;
  border-color: var(--ok-border);
  background: #F6FAF7;
}

.dropzone-area:hover,
.dropzone-area:focus-visible,
.dropzone-area.is-dragover {
  outline: none;
  border-color: var(--primary);
  background: #F4F1E8;
}

.dropzone-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.dropzone-heading {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.dropzone-sub {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.45;
}

.selected-file-badge {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--ok-border);
  box-shadow: var(--shadow-sm);
  color: var(--ok);
  font-size: 13.5px;
  font-weight: 600;
  max-width: 100%;
}

.selected-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 340px;
}

.selected-file-hint {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.composer-text-pane {
  gap: 14px;
}

.field-group {
  display: flex;
  flex-direction: column;
}

.presets-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding-top: 2px;
}

.presets-inline-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 2px;
}

.preset-chip {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.preset-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-warm);
  color: var(--text);
}

.preset-chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

/* Integrated Mode Selector inside Composer */
.composer-mode-bar {
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-mode-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-mode-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mode-switcher {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  gap: 2px;
}

.mode-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 13px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.mode-chip input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-chip:hover {
  color: var(--text);
}

.mode-chip.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(27, 26, 23, 0.1);
}

.composer-mode-hint {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

@keyframes modeFlash {
  0% { color: var(--primary); }
  100% { color: var(--text-muted); }
}

.composer-mode-hint.is-flash {
  animation: modeFlash 0.65s ease;
}

.composer-footer {
  border-top: 1px solid var(--border);
  padding: 16px 22px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

/* Right Column: Balanced Aside Cards */
.home-aside {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.aside-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}

.aside-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.aside-caption {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.sample-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
}

.sample-form {
  display: flex;
  height: 100%;
}

.sample-card {
  width: 100%;
  height: 100%;
  min-height: 98px;
  padding: 14px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.sample-card:hover {
  border-color: var(--text-secondary);
  background: #F4F1E8;
  transform: translateY(-1px);
}

.sample-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sample-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sample-card-arrow {
  font-size: 15px;
  color: var(--text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.sample-card:hover .sample-card-arrow {
  color: var(--text);
  transform: translate(1px, -1px);
}

.sample-card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.sample-card-meta {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.recent-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-subtle);
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 6px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.14s ease;
}

.recent-row:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.recent-row:hover {
  background: var(--surface-subtle);
  border-radius: 8px;
}

.composer-reg-note {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.reg-checklist {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.reg-checklist li strong {
  color: var(--text);
}

.reg-checklist code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-subtle);
  padding: 1px 5px;
  border-radius: 4px;
}

.test-sandbox-drawer {
  margin-top: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  padding: 10px 16px;
}

.test-sandbox-summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.test-sandbox-summary:hover {
  color: var(--text-secondary);
}

.test-sandbox-body {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.test-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.test-checkbox-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.test-samples-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.test-samples-label {
  font-size: 12.5px;
  color: var(--text-muted);
}

.inline-test-form {
  display: inline-flex;
}

.test-sample-link {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
}

.test-sample-link:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.recent-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.recent-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.recent-amount {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.recent-badge-warn {
  font-size: 13px;
  font-weight: 600;
  color: var(--err);
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  padding: 3px 9px;
  border-radius: 999px;
}

.recent-arrow {
  font-size: 15px;
  color: var(--text-muted);
}

.recent-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
}

/* --------------------------------------------------------------------------
   Privacy Shield Panel & Pre-Flight Preview (Clean 2-Col KV Table)
   -------------------------------------------------------------------------- */
.preview-page-wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 32px;
}

.preview-page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px 30px;
}

.preview-page-header {
  margin-bottom: 22px;
}

.preview-page-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
}

.preview-page-sub {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-secondary);
}

.preview-actions-bar {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.privacy-drawer-inset {
  margin-bottom: 20px;
}

.privacy-drawer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.privacy-drawer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.privacy-drawer-status,
.preview-guide-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
}

.preview-guide-banner {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  color: var(--text);
}

.privacy-split-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(380px, 1.15fr);
  gap: 28px;
  align-items: start;
}

.privacy-col {
  min-width: 0;
}

.privacy-col-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.privacy-col-subtitle {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 18px;
  margin-bottom: 8px;
}

.privacy-kv-table {
  width: 100%;
  border-collapse: collapse;
}

.privacy-kv-table tr {
  border-bottom: 1px solid var(--border-subtle);
}

.privacy-kv-table tr:last-child {
  border-bottom: none;
}

.privacy-kv-table td.kv-label {
  width: 175px;
  padding: 8px 14px 8px 0;
  font-size: 13.5px;
  color: var(--text-muted);
  vertical-align: top;
}

.privacy-kv-table td.kv-val {
  padding: 8px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.privacy-empty-note {
  font-size: 14px;
  color: var(--text-muted);
  padding: 12px 14px;
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
}

.sanitized-payload-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 310px;
  overflow-y: auto;
}

/* --------------------------------------------------------------------------
   Screen 3: Workspace Layout & Proportions
   -------------------------------------------------------------------------- */
.workspace-shell {
  max-width: var(--rail);
  margin: 0 auto;
  padding: 20px 32px 64px;
}

.ws-breadcrumb-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.privacy-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.privacy-trigger-btn:hover {
  border-color: var(--primary);
  color: var(--text);
  background: var(--surface-subtle);
}

.privacy-trigger-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.privacy-trigger-btn.is-active .privacy-pill-sep {
  color: rgba(255, 255, 255, 0.35);
}

.privacy-pill-sep {
  color: var(--border-strong);
}

.ws-doc-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px 28px;
  margin-bottom: 20px;
}

.ws-doc-title-wrap {
  flex: 1 1 560px;
  min-width: 0;
}

.ws-title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.ws-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.meta-dot {
  color: var(--border-strong);
}

.meta-total {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meta-err {
  color: var(--err);
  font-weight: 600;
}

.ws-export-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.more-menu {
  position: relative;
}

.more-menu-trigger {
  list-style: none;
  cursor: pointer;
}

.more-menu-trigger::-webkit-details-marker {
  display: none;
}

.menu-caret {
  font-size: 12px;
  color: var(--text-muted);
}

.more-menu-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.more-menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: block;
}

.more-menu-item:hover {
  background: var(--surface-subtle);
}

.more-menu-form {
  margin: 0;
}

.more-menu-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 5px 6px;
}

/* Position Tabs — Adaptive Structured Cards Grid (Fits 3 Paper & 5 Cytokines in 1 Row!) */
.item-overview-section {
  margin-bottom: 18px;
}

.underline-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.underline-tab {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-secondary);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.underline-tab:hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text);
}

.underline-tab.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.underline-tab-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.underline-tab-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.underline-tab.is-active .underline-tab-num {
  color: rgba(255, 255, 255, 0.72);
}

.underline-tab-amount {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
}

.underline-tab.is-active .underline-tab-amount {
  color: #FFFFFF;
}

.underline-tab-amount.is-blocked {
  color: var(--err);
  font-weight: 600;
}

.underline-tab.is-active .underline-tab-amount.is-blocked {
  color: #FCD3CE;
}

.underline-tab-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.underline-tab.is-active .underline-tab-label {
  color: #FFFFFF;
}

.underline-tab-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.underline-tab.is-active .underline-tab-meta {
  color: rgba(255, 255, 255, 0.72);
}

.section-hairline {
  height: 1px;
  background: var(--border);
  margin-bottom: 16px;
}

/* Unified White KPI Bar — Zero Giant Empty Gaps! */
.kpi-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1.35fr 1fr 0.95fr 0.95fr;
  overflow: hidden;
  margin-bottom: 14px;
}

.kpi-col {
  padding: 18px 22px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.kpi-col:last-child {
  border-right: none;
}

.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-value-hero {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-value {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-value-blocked {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--err);
}

.kpi-muted {
  color: var(--text-muted);
}

.kpi-err {
  color: var(--err);
}

.kpi-sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.insufficient-action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 12px 18px;
  margin-bottom: 14px;
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  border-radius: var(--radius-md);
}

.insufficient-action-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.insufficient-action-btns {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* TZ Remarks Notice — Clean Full Border (No Curved Hook!) */
.tz-remarks-disclosure {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.tz-remarks-summary {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.tz-remarks-summary::-webkit-details-marker {
  display: none;
}

.tz-remarks-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.disclosure-chevron {
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.tz-remarks-disclosure[open] .disclosure-chevron {
  transform: rotate(180deg);
}

.tz-remarks-body {
  border-top: 1px solid var(--warn-border);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tz-remark-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #EFE0BE;
  border-radius: var(--radius-sm);
}

.tz-remark-card.is-regime {
  background: #F5F7FA;
  border-color: #D9E1EC;
}

.tz-remark-badge {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.tz-remark-badge.is-warn {
  background: #FCECD0;
  color: #8F4905;
}

.tz-remark-badge.is-regime {
  background: #E2EAF5;
  color: #264873;
}

.tz-remark-content {
  flex: 1 1 auto;
  min-width: 0;
}

.tz-remark-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.tz-remark-rec {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.tz-remark-rec-label {
  font-weight: 600;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Comparison Matrix Card & Table
   -------------------------------------------------------------------------- */
.matrix-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.matrix-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.matrix-controls-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.matrix-filter-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.matrix-filter-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.matrix-filter-btn:hover {
  color: var(--text);
}

.matrix-filter-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(27, 26, 23, 0.08);
}

.controls-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.matrix-controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-field-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
}

.search-field-wrap .ui-icon {
  position: absolute;
  left: 11px;
  pointer-events: none;
}

.search-field {
  height: 36px;
  width: 220px;
  padding: 6px 12px 6px 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text);
}

.search-field:focus {
  outline: none;
  border-color: var(--primary);
}

/* Schema Editor Panel */
.schema-editor-panel {
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  padding: 18px 20px;
}

.schema-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 12px;
}

.schema-editor-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.schema-editor-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.schema-editor-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.schema-editor-table th,
.schema-editor-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  font-size: 13.5px;
}

.schema-editor-table th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-subtle);
}

.schema-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

/* Main Matrix Table */
.matrix-scroll-wrap {
  width: 100%;
  overflow-x: auto;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.matrix-table thead th {
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  padding: 11px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  vertical-align: bottom;
  text-align: left;
  line-height: 1.3;
}

.matrix-table thead th.text-right {
  text-align: right;
}

.matrix-table th.col-supplier {
  min-width: 230px;
  max-width: 280px;
}

.matrix-table th.col-price {
  min-width: 110px;
  white-space: nowrap;
}

.matrix-table th.col-spec-text {
  min-width: 100px;
  max-width: 165px;
}

.matrix-table th.col-spec-num {
  min-width: 76px;
}

.matrix-table th.col-status {
  min-width: 125px;
  max-width: 160px;
}

.matrix-table th.col-action {
  min-width: 96px;
  white-space: nowrap;
}

.matrix-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.12s ease;
}

.matrix-table tbody tr:last-child {
  border-bottom: none;
}

.matrix-table tbody td {
  padding: 12px 10px;
  font-size: 13.5px;
  line-height: 1.38;
  vertical-align: top;
  color: var(--text);
}

.tz-target-row {
  background: #F4F1E8;
}

.tz-target-row td {
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.tz-row-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}

.tz-row-sub,
.tz-row-unit {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.offer-row:hover {
  background: #FAF8F4;
}

.offer-row.is-excluded {
  background: #FCFBFA;
  color: var(--text-secondary);
}

.supplier-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.supplier-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  overflow: hidden;
}

.supplier-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.supplier-text {
  min-width: 0;
  flex: 1 1 auto;
}

.supplier-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.supplier-meta {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.supplier-domain-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.supplier-source-link {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

.supplier-source-link:hover {
  color: var(--text);
  text-decoration-color: var(--text);
}

.offer-price-main {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.offer-price-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.quote-link-btn,
.spec-cell-btn {
  background: transparent;
  border: none;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 6px;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.quote-link-btn {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.quote-link-btn:hover,
.spec-cell-btn:hover {
  background: var(--surface-warm);
  color: var(--text);
}

.spec-cell-btn.is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.is-mismatch .spec-cell-btn {
  color: var(--err);
  font-weight: 600;
}

/* 2-Line Clamp Prevents Giant Row Bloat without splitting words mid-letter */
.spec-val-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 195px;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

.spec-val-clamp.is-num {
  display: inline-block;
  white-space: nowrap;
  max-width: none;
}

.status-line,
.inline-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
}

.status-line {
  display: flex;
  align-items: flex-start;
}

.status-line .status-dot {
  margin-top: 5px;
}

.status-err {
  color: var(--err);
}

.status-muted {
  color: var(--text-muted);
}

.manual-comment-note {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.row-actions-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.btn-row-action,
.btn-row-reset {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-row-action:hover,
.btn-row-reset:hover {
  background: var(--surface-subtle);
  border-color: var(--primary);
}

.inline-reset-form {
  display: inline;
  margin: 0;
}

.empty-matrix-cell {
  padding: 28px 18px;
  text-align: center;
  font-size: 14.5px;
  color: var(--text-muted);
}

/* Math Steps Accordion */
.math-accordion-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.math-accordion-summary {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.math-accordion-summary::-webkit-details-marker {
  display: none;
}

.math-accordion[open] .disclosure-chevron {
  transform: rotate(180deg);
}

.math-accordion-body {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border-subtle);
}

.math-formula-ribbon {
  display: grid;
  grid-template-columns: 0.9fr 0.95fr 1.1fr 1.45fr;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}

.math-formula-cell {
  padding: 12px 16px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.math-formula-cell:last-child {
  border-right: none;
}

.math-formula-cell.is-result {
  background: #F4F1E8;
}

.math-formula-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.math-formula-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.math-steps-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.math-step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.math-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.math-step-content {
  flex: 1 1 auto;
  min-width: 0;
}

.math-step-main {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.math-substep-list {
  margin: 4px 0 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.math-substep {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.math-warnings {
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.math-warning-line {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--warn);
}

/* --------------------------------------------------------------------------
   Slide-Over Evidence & Snapshot Drawer
   -------------------------------------------------------------------------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 26, 23, 0.35);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 540px;
  max-width: 94vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 70;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer-body > * {
  flex-shrink: 0;
}

.drawer-top-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.drawer-caption {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.drawer-field-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.drawer-reason-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.drawer-reason-text:empty {
  display: none;
}

.ev-page-card {
  flex-shrink: 0;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ev-page-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-warm);
  border-bottom: 1px solid var(--border);
}

.ev-domain-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ev-lock-icon {
  color: var(--ok);
  flex-shrink: 0;
}

.ev-domain-label {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ev-http-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.ev-bar-ext {
  margin-top: 0;
  font-size: 12.5px;
  flex-shrink: 0;
}

.ev-product-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
}

.ev-thumb-wrap {
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  overflow: hidden;
}

.ev-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ev-product-info {
  min-width: 0;
  flex: 1 1 auto;
}

.ev-product-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.38;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ev-product-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.ev-meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.ev-meta-chip.is-stock {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}

.quote-highlight-box {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
}

.drawer-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-meta-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.drawer-muted {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.drawer-ext-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.snapshot-excerpt-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  max-height: 240px;
  overflow-y: auto;
  word-break: break-word;
}

.snapshot-excerpt-box mark {
  background: #FDE9B6;
  color: var(--text);
  padding: 1px 4px;
  border-radius: 4px;
}

.drawer-tech-details {
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.drawer-tech-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.drawer-tech-sha-wrap {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sha-hash-box {
  padding: 9px 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
  word-break: break-all;
}

.drawer-footer-actions {
  padding-top: 4px;
}

/* --------------------------------------------------------------------------
   Modals (Privacy Preview, Override, Manual KP, RFQ Draft)
   -------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(27, 26, 23, 0.42);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-open {
  display: flex;
}

.modal-sheet,
.modal-dialog {
  width: 680px;
  max-width: 96vw;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sheet-lg {
  width: 880px;
}

.modal-dialog-md {
  width: 580px;
}

.modal-dialog-lg {
  width: 780px;
}

.modal-subtitle-note {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-body-compact {
  padding: 13px 22px 14px;
}

.modal-body-compact .form-group {
  margin-bottom: 9px;
}

.modal-body-compact .form-label {
  margin-bottom: 4px;
  font-size: 13px;
}

.modal-body-compact .form-control {
  padding: 7px 11px;
  font-size: 14px;
}

.modal-body-compact .form-control-sm {
  padding: 6px 10px;
  font-size: 13.5px;
}

.modal-body-compact .kp-specs-fieldset {
  padding: 10px 12px;
  margin-bottom: 9px;
}

.modal-body-compact .kp-specs-grid {
  gap: 8px 14px;
}

.form-control-quote {
  min-height: 44px;
  resize: vertical;
}

.modal-sheet > form,
.modal-dialog > form {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-loading-state {
  padding: 40px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14.5px;
  color: var(--text-secondary);
}

.spinner,
.spinner-ring {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner-ring {
  width: 36px;
  height: 36px;
  border-width: 3px;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-error-note {
  padding: 14px 16px;
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  border-radius: var(--radius-md);
  color: var(--err);
  font-size: 14px;
}

.form-group {
  margin-bottom: 14px;
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-row-2col-asym {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 14px;
}

.form-row-5col {
  display: grid;
  grid-template-columns: 1.25fr 0.78fr 0.72fr 0.95fr 1.25fr;
  gap: 10px;
}

.kp-specs-fieldset {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}

/* Balanced 2-Column Aligned Inputs Grid (Fixes 09_manual_kp_modal.png!) */
.kp-specs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  align-items: end;
}

.kp-specs-grid > div {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
}

.modal-supplier-summary {
  padding: 12px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.modal-supplier-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

.modal-supplier-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.modal-supplier-meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.quick-reasons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rfq-textarea {
  font-size: 14px;
  line-height: 1.5;
  min-height: 360px;
}

/* Global Pipeline Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(246, 244, 238, 0.88);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.loading-overlay.is-active {
  display: flex;
}

.loading-dialog {
  width: 460px;
  max-width: 94vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.loading-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.pipeline-steps-list {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-steps-list li {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 13.5px;
  color: var(--text-muted);
}

.pipeline-steps-list li.is-done {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints (1280px, Tablet, Mobile)
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .home-grid {
    grid-template-columns: 1fr;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-col:nth-child(2n) {
    border-right: none;
  }

  .kpi-col:nth-child(-n+2) {
    border-bottom: 1px solid var(--border-subtle);
  }

  .privacy-split-grid,
  .math-formula-ribbon {
    grid-template-columns: 1fr;
  }

  .math-formula-cell {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .math-formula-cell:last-child {
    border-bottom: none;
  }
}

@media (max-width: 720px) {
  .site-header-inner,
  .home-shell,
  .workspace-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand-divider,
  .brand-subtitle {
    display: none;
  }

  .sample-cards-grid,
  .form-row-2col,
  .form-row-2col-asym,
  .form-row-5col,
  .kp-specs-grid,
  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .kpi-col {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .kpi-col:last-child {
    border-bottom: none;
  }
}

/* Background run progress page */
.run-progress-wrap {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}

.run-progress-card {
  width: 620px;
}

.run-progress-stage {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.run-progress-elapsed {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.run-progress-log li {
  font-weight: 400;
}

.run-progress-error {
  width: 100%;
  margin: 14px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err);
  font-size: 14px;
  text-align: left;
}

.composer-keys-warning {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err);
}
