/* HS CODE · Enterprise SaaS Workspace UI v7 (Taste) */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --primary: #0F766E;
  --primary-hover: #0D9488;
  --primary-active: #115E59;
  --primary-rgb: 15, 118, 110;
  --primary-soft: rgba(var(--primary-rgb), 0.08);
  --primary-softer: rgba(var(--primary-rgb), 0.04);
  --primary-ring: rgba(var(--primary-rgb), 0.22);

  --bg: #F1F4F7;
  --surface: #FFFFFF;
  --surface-muted: #F8FAFB;
  --surface-hover: #F3F6F8;

  --border: #DDE3EA;
  --border-subtle: #E8EDF2;
  --border-strong: #C5CDD8;

  --text: #0C1222;
  --text-secondary: #3D4A5C;
  --text-muted: #7B8798;
  --text-inverse: #FFFFFF;

  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --warning: #D97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.08);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-pill: 999px;
  --radius-md: 12px;

  --shadow-xs: 0 1px 2px rgba(12, 18, 34, 0.04);
  --shadow-sm: 0 1px 3px rgba(12, 18, 34, 0.05), 0 1px 2px rgba(12, 18, 34, 0.03);
  --shadow-md: 0 4px 16px rgba(12, 18, 34, 0.06), 0 2px 4px rgba(12, 18, 34, 0.03);
  --shadow-lg: 0 12px 32px rgba(12, 18, 34, 0.08), 0 4px 8px rgba(12, 18, 34, 0.04);
  --shadow-card: 0 1px 2px rgba(12, 18, 34, 0.04), 0 6px 20px rgba(12, 18, 34, 0.05);

  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --topbar-h: 56px;
  --workspace-max: min(1520px, calc(100vw - 40px));
  --side-panel-w: 320px;
  --sticky-cta-h: 72px;
}

/* ── Reset & base ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

em {
  font-style: normal;
  color: var(--danger);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--border);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

/* ── App shell ─────────────────────────────────────────────── */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}

.brand-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.status-pill.is-live .pulse-dot {
  background: var(--success);
}

.pulse-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

.pill-text {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Banner ────────────────────────────────────────────────── */
.banner {
  max-width: var(--workspace-max);
  width: calc(100% - 40px);
  margin: 16px auto 0;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.55;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.banner-warn {
  color: #92400E;
  background: var(--warning-soft);
  border-color: rgba(217, 119, 6, 0.2);
}

.banner strong {
  font-weight: 600;
}

/* ── Workspace layout ──────────────────────────────────────── */
.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-panel-w);
  gap: 20px;
  align-items: start;
  flex: 1;
  padding: 20px 24px 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  min-height: calc(100dvh - var(--topbar-h) - 80px);
}

/* ── Main card ─────────────────────────────────────────────── */
.main-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.main-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 28px 0;
}

.page-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--text);
}

.page-desc {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.chip-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chip-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.chip-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.chip-input {
  width: 100px;
  padding: 4px 10px 4px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
}

.chip-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Scope field ───────────────────────────────────────────── */
#orderForm {
  padding: 24px 28px 0;
}

.scope-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.scope-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.scope-label .opt {
  font-weight: 400;
  color: var(--text-muted);
}

.scope-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  resize: vertical;
  min-height: 64px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.scope-input::placeholder {
  color: var(--text-muted);
}

.scope-input:hover {
  border-color: var(--border-strong);
}

.scope-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ── Sheet toolbar ─────────────────────────────────────────── */
.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sheet-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Spreadsheet ───────────────────────────────────────────── */
.spreadsheet-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.spreadsheet {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 13px;
}

.spreadsheet thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.spreadsheet th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.spreadsheet td {
  padding: 0;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  background: var(--surface);
  transition: background var(--transition);
}

.spreadsheet tbody tr:last-child td {
  border-bottom: none;
}

.spreadsheet tbody tr:hover td {
  background: var(--surface-hover);
}

.spreadsheet .col-idx {
  width: 44px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.spreadsheet th.col-idx {
  text-align: center;
}

.spreadsheet .col-name {
  width: 28%;
}

.spreadsheet .col-model {
  width: 18%;
}

.spreadsheet .col-code {
  width: 16%;
}

.spreadsheet .col-hs {
  width: 14%;
}

.spreadsheet .col-suggest {
  width: 14%;
}

.spreadsheet .col-ops {
  width: 72px;
}

.spreadsheet td.col-idx {
  padding: 0 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.spreadsheet .cell-input,
.spreadsheet td input[type="text"],
.spreadsheet td input[type="number"] {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  transition: background var(--transition), box-shadow var(--transition);
}

.spreadsheet .cell-input::placeholder,
.spreadsheet td input::placeholder {
  color: var(--text-muted);
}

.spreadsheet .cell-input:hover,
.spreadsheet td input:hover {
  background: rgba(var(--primary-rgb), 0.03);
}

.spreadsheet .cell-input:focus,
.spreadsheet td input:focus {
  background: var(--primary-softer);
  box-shadow: inset 0 0 0 2px var(--primary-ring);
}

.spreadsheet .cell-input.is-invalid,
.spreadsheet td input.is-invalid,
.input.is-invalid {
  background: var(--danger-soft);
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.35);
}

.spreadsheet .cell-input.is-invalid:focus,
.spreadsheet td input.is-invalid:focus,
.input.is-invalid:focus {
  box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.45);
}

/* AI suggest cell */
.ai-suggest {
  position: relative;
  padding: 0 10px !important;
}

.suggest-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-pill);
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.suggest-badge::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.suggest-badge.is-empty {
  color: var(--text-muted);
  background: #F1F5F9;
}

.suggest-badge.is-empty::before {
  background: var(--text-muted);
}

.suggest-popover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  z-index: 20;
  min-width: 220px;
  max-width: 280px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.suggest-popover::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--surface);
  filter: drop-shadow(0 1px 0 var(--border));
}

.ai-suggest:hover .suggest-popover,
.ai-suggest:focus-within .suggest-popover {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.suggest-popover-title {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.suggest-popover-code {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.suggest-popover-desc {
  margin: 0;
  color: var(--text-secondary);
}

/* Row ops */
.row-ops {
  padding: 0 6px !important;
  text-align: center;
  white-space: nowrap;
}

.row-ops,
.cell-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.btn-row-copy,
.btn-row-delete,
.btn-row-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  opacity: 0;
  transition: opacity var(--transition), background var(--transition), color var(--transition);
}

.spreadsheet tbody tr:hover .btn-row-copy,
.spreadsheet tbody tr:hover .btn-row-delete,
.spreadsheet tbody tr:hover .btn-row-remove,
.line-row:hover .btn-row-remove {
  opacity: 1;
}

.btn-row-copy:hover,
.btn-row-delete:hover,
.btn-row-remove:hover {
  background: #F1F5F9;
  color: var(--text);
}

.btn-row-delete:hover,
.btn-row-remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.sheet-empty {
  margin: 0;
  padding: 32px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

/* Legacy div-based line rows (JS compat) */
.line-row {
  display: table-row;
}

.line-row > .cell-name,
.line-row > .cell-model,
.line-row > .cell-code,
.line-row > .cell-hs,
.line-row > .cell-action {
  display: table-cell;
  padding: 0;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.line-row .input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  background: transparent;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
}

.line-row .input:focus {
  background: var(--primary-softer);
  box-shadow: inset 0 0 0 2px var(--primary-ring);
}

.line-row .field-hint {
  display: none;
}

.field-hint.is-error {
  color: var(--danger);
}

.field-hint.is-ok {
  color: var(--success);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition), box-shadow var(--transition), opacity var(--transition),
    transform 0.12s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-xs);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  color: var(--text-inverse);
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--primary-active);
  transform: translateY(0.5px);
}

.btn-secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border-strong);
}

/* ── Processing block ──────────────────────────────────────── */
.processing-block {
  padding: 24px 28px 28px;
  border-top: 1px solid var(--border-subtle);
}

.processing-bar {
  height: 4px;
  margin-bottom: 16px;
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.processing-bar-fill {
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, var(--primary), #14B8A6);
  border-radius: var(--radius-pill);
  animation: processingFill 1.8s ease-in-out infinite;
}

@keyframes processingFill {
  0% { width: 8%; margin-left: 0; }
  50% { width: 55%; margin-left: 25%; }
  100% { width: 8%; margin-left: 92%; }
}

.processing-label {
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: #EEF2F6;
  border-radius: var(--radius-sm);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.sk-stat {
  height: 56px;
}

.sk-table {
  height: 180px;
  border-radius: var(--radius-sm);
}

/* ── Result block ──────────────────────────────────────────── */
.result-block {
  padding: 0 28px 28px;
  border-top: 1px solid var(--border-subtle);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 0 16px;
}

.result-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.result-meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary .item {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.summary .num {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.review-alert,
.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: #92400E;
  background: var(--warning-soft);
  border: 1px solid rgba(217, 119, 6, 0.2);
  border-radius: var(--radius-sm);
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  margin-bottom: 14px;
  background: #F1F5F9;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.seg-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.seg-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
}

.seg-btn.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.table-shell {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.result-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.result-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
}

.result-table tbody tr:last-child td {
  border-bottom: none;
}

.result-table tbody tr:hover td {
  background: var(--surface-hover);
}

.result-table td:first-child {
  color: var(--text);
  font-weight: 500;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.tag.high {
  color: var(--success);
  background: var(--success-soft);
}

.tag.medium {
  color: var(--warning);
  background: var(--warning-soft);
}

.tag.low {
  color: var(--text-muted);
  background: #F1F5F9;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Sticky CTA (within workspace-main) ────────────────────── */
.sticky-cta {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.cta-status,
.status-inline {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.cta-status.ok,
.status-inline.ok {
  color: var(--success);
}

.cta-status.error,
.status-inline.error {
  color: var(--danger);
}

.btn-cta {
  flex-shrink: 0;
  min-width: 128px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  position: relative;
}

.btn-cta .btn-spinner {
  display: none;
}

.btn-cta.is-loading .btn-label {
  opacity: 0.85;
}

.btn-cta.is-loading .btn-spinner {
  display: inline-block;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Side panel ────────────────────────────────────────────── */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.panel-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel-excel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.panel-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
}

.panel-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.panel-desc {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.panel-excel > .btn-secondary {
  margin-bottom: 16px;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Dropzone ──────────────────────────────────────────────── */
.dropzone {
  display: block;
  cursor: pointer;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
  transition: border-color var(--transition), background var(--transition),
    box-shadow var(--transition), transform 0.15s ease;
}

.dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-softer);
}

.dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-ring);
  transform: scale(1.01);
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--primary);
  background: var(--primary-softer);
}

.dropzone.has-file .dropzone-icon {
  color: var(--primary);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 28px 20px;
  text-align: center;
}

.dropzone-icon {
  color: var(--text-muted);
  margin-bottom: 4px;
  transition: color var(--transition);
}

.dropzone:hover .dropzone-icon,
.dropzone.is-dragover .dropzone-icon {
  color: var(--primary);
}

.dropzone-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

.dropzone-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.dropzone.has-file .dropzone-hint {
  color: var(--primary);
}

/* ── Preview block ─────────────────────────────────────────── */
.preview-block {
  padding: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.preview-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.preview-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
}

.preview-table-wrap {
  overflow-x: auto;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  max-height: 200px;
  overflow-y: auto;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-table th {
  position: sticky;
  top: 0;
  padding: 8px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.preview-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.preview-table tbody tr:last-child td {
  border-bottom: none;
}

.preview-table tbody tr:hover td {
  background: var(--surface-hover);
}

/* ── Tips panel ────────────────────────────────────────────── */
.panel-tips {
  padding: 18px 20px;
  background: var(--surface-muted);
  border-color: var(--border-subtle);
  box-shadow: none;
}

.tips-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.tips-list {
  margin: 0;
  padding: 0 0 0 18px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.65;
}

.tips-list li + li {
  margin-top: 4px;
}

/* ── App footer ────────────────────────────────────────────── */
.app-footer {
  padding: 16px 24px 24px;
  text-align: center;
}

.app-footer p {
  margin: 0 auto;
  max-width: 560px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-muted);
  opacity: 0.75;
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 300;
  transform: translateX(-50%) translateY(12px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-inverse);
  background: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast.ok {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

/* ── General input (outside spreadsheet) ───────────────────── */
.input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input::placeholder {
  color: var(--text-muted);
}

.input:hover {
  border-color: var(--border-strong);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .workspace-layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .workspace-main {
    min-height: auto;
    order: 1;
  }

  .side-panel {
    order: 2;
  }

  .main-card-header {
    flex-direction: column;
    padding: 22px 20px 0;
  }

  #orderForm {
    padding: 20px 20px 0;
  }

  .processing-block,
  .result-block {
    padding-left: 20px;
    padding-right: 20px;
  }

  .sticky-cta {
    margin-top: 12px;
    padding: 12px 16px;
  }

  .spreadsheet-wrap {
    overflow-x: auto;
  }

  .spreadsheet {
    min-width: 720px;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
  }

  .banner {
    margin: 12px 16px 0;
  }

  .pill-text {
    max-width: 140px;
  }

  .page-title {
    font-size: 19px;
  }

  .sticky-cta {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .btn-cta {
    width: 100%;
  }

  .skeleton-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .segmented-control {
    display: flex;
    width: 100%;
  }

  .seg-btn {
    flex: 1 1 auto;
    text-align: center;
    padding: 8px 8px;
    font-size: 12px;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
  }

  .summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel-card {
    padding: 18px;
  }
}

@media (max-width: 400px) {
  .pill-text {
    display: none;
  }

  .status-pill {
    padding: 5px 8px;
  }
}

/* v4 JS helpers */
.suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition), transform 0.12s ease;
  white-space: nowrap;
}

.suggest-chip:hover {
  background: rgba(var(--primary-rgb), 0.14);
  transform: scale(1.02);
}

.suggest-hs { font-variant-numeric: tabular-nums; }

.suggest-idle,
.suggest-loading {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-icon-sm:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.btn-del:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.row-ops {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

.preview-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.preview-table th,
.preview-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.preview-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.sk-preview {
  height: 80px;
  border-radius: var(--radius-sm);
}

.processing-bar {
  height: 3px;
  background: var(--border-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.processing-bar-fill {
  height: 100%;
  width: 35%;
  background: var(--primary);
  border-radius: 999px;
  animation: progressSlide 1.2s ease-in-out infinite;
}

@keyframes progressSlide {
  0% { transform: translateX(-100%); width: 35%; }
  50% { width: 55%; }
  100% { transform: translateX(280%); width: 35%; }
}

.cta-status.ok { color: var(--success); }
.cta-status.error { color: var(--danger); }

.btn-cta.is-loading .btn-label { opacity: 0; }
.btn-cta.is-loading .btn-spinner {
  display: block;
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-cta { position: relative; }
.btn-spinner { display: none; }

.sheet-empty {
  padding: 32px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.sheet-empty kbd {
  padding: 2px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
}

/* ══════════════════════════════════════════════════════════════
   Enterprise Workspace v5
   ══════════════════════════════════════════════════════════════ */

body.enterprise {
  --side-panel-w: 340px;
  --risk-low: #059669;
  --risk-low-soft: rgba(5, 150, 105, 0.1);
  --risk-medium: #D97706;
  --risk-medium-soft: rgba(217, 119, 6, 0.1);
  --risk-high: #DC2626;
  --risk-high-soft: rgba(220, 38, 38, 0.08);
}

.layer-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.main-workspace {
  padding: 0 0 88px;
  overflow: hidden;
}

.workspace-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 28px 0;
}

.head-chips {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.chip-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.chip-label {
  font-size: 12px;
  color: var(--text-muted);
}

.chip-input {
  width: 88px;
  border: none;
  background: transparent;
  font-size: 13px;
  padding: 4px 0;
  outline: none;
}

.inline-field {
  display: block;
  padding: 16px 28px 0;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-label .opt {
  font-weight: 400;
  color: var(--text-muted);
}

.textarea-compact {
  min-height: 56px;
  resize: vertical;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 10px;
}

.toolbar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Smart table */
.smart-table-wrap {
  margin: 0 28px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.smart-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 13px;
}

.smart-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: left;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.smart-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.smart-table tr:last-child td {
  border-bottom: none;
}

.smart-table tr:hover td {
  background: var(--surface-hover);
}

.w-idx { width: 40px; }
.w-name { min-width: 140px; }
.w-model { min-width: 100px; }
.w-code { width: 90px; }
.w-hs { width: 100px; }
.w-ai { width: 130px; }
.w-risk { width: 88px; }
.w-conf { width: 64px; }
.w-ops { width: 72px; }

.cell-input {
  width: 100%;
  padding: 7px 8px;
  font-size: 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  transition: border-color var(--transition), background var(--transition);
}

.cell-input:hover {
  background: var(--surface-muted);
}

.cell-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.cell-input.is-invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.cell-muted {
  font-size: 12px;
  color: var(--text-muted);
}

.empty-hint {
  margin: 0;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Risk & confidence badges */
.risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  cursor: default;
}

.risk-low {
  color: var(--risk-low);
  background: var(--risk-low-soft);
}

.risk-medium {
  color: var(--risk-medium);
  background: var(--risk-medium-soft);
}

.risk-high {
  color: var(--risk-high);
  background: var(--risk-high-soft);
}

.conf-badge {
  display: inline-flex;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-pill);
}

.conf-high { color: var(--risk-low); background: var(--risk-low-soft); }
.conf-medium { color: var(--risk-medium); background: var(--risk-medium-soft); }
.conf-low { color: var(--risk-high); background: var(--risk-high-soft); }
.conf-none { color: var(--text-muted); background: var(--surface-muted); }

/* Reason popover */
.reason-wrap {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
}

.reason-trigger {
  width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: help;
  line-height: 1;
}

.reason-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: max-content;
  max-width: 280px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.reason-popover.is-visible {
  opacity: 1;
}

/* Processing */
.processing-layer {
  margin: 0 0 16px;
  padding: 0;
  background: linear-gradient(135deg, #F0FDFA 0%, #F0F9FF 100%);
  border-radius: var(--radius);
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.08);
}

.processing-layer.is-active {
  animation: processingPulse 2s ease-in-out infinite;
}

.processing-inner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
}

.processing-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(var(--primary-rgb), 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.85s linear infinite;
}

.processing-body {
  flex: 1;
  min-width: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes processingPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.08); }
  50% { box-shadow: 0 6px 28px rgba(var(--primary-rgb), 0.16); }
}

.progress-track {
  height: 4px;
  background: rgba(var(--primary-rgb), 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, var(--primary), #0ea5e9);
  border-radius: 999px;
  animation: progressSlide 1.2s ease-in-out infinite;
}

.progress-fill.is-indeterminate {
  width: 45%;
  animation: progressSlide 0.9s ease-in-out infinite;
}

.scope-ai-result {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.scope-desc-note {
  margin: 6px 0 0;
  font-size: 12px;
}

.processing-text {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.processing-sub {
  margin: 6px 0 0;
  font-size: 12px;
}

.saas-trial-banner {
  margin: 0 0 12px;
  padding: 0;
}

.saas-trial-banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(var(--primary-rgb), 0.28);
  background: linear-gradient(135deg, #F0FDFA 0%, #ECFEFF 100%);
}

.saas-trial-banner-inner.is-over {
  border-color: rgba(239, 68, 68, 0.35);
  background: linear-gradient(135deg, #fef2f2 0%, #fff7ed 100%);
}

.saas-trial-banner-text {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.saas-trial-warn {
  color: #dc2626;
  font-weight: 600;
}

.ai-action-btn.ai-pro-only {
  opacity: 0.55;
  cursor: not-allowed;
}

.sk-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.sk {
  background: linear-gradient(90deg, var(--border-subtle) 25%, #E8ECF2 50%, var(--border-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}

.sk-stat { height: 48px; }
.sk-block { height: 80px; }
.sk-line { height: 12px; margin-bottom: 8px; border-radius: 4px; }
.sk-line.short { width: 60%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Decision zone */
.decision-zone {
  margin: 24px 28px 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.zone-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.zone-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.zone-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.ai-summary-card {
  padding: 20px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-muted) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.summary-grid-filters {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.summary-stat {
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
}

button.summary-filter-btn {
  cursor: pointer;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition), transform 0.12s ease;
}

button.summary-filter-btn:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

button.summary-filter-btn.is-active {
  border-width: 2px;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

button.summary-filter-btn.stat-low.is-active { border-color: var(--risk-low); background: var(--success-soft); }
button.summary-filter-btn.stat-medium.is-active { border-color: var(--risk-medium); background: var(--warning-soft); }
button.summary-filter-btn.stat-high.is-active { border-color: var(--risk-high); background: var(--danger-soft); }
button.summary-filter-btn.stat-neutral.is-active { border-color: var(--primary); background: var(--primary-soft); }
button.summary-filter-btn.stat-action.is-active { border-color: #ea580c; background: rgba(234, 88, 12, 0.08); }

.stat-action .stat-num { color: #ea580c; }

.stat-num {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-label {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-low .stat-num { color: var(--risk-low); }
.stat-medium .stat-num { color: var(--risk-medium); }
.stat-high .stat-num { color: var(--risk-high); }
.stat-neutral .stat-num { color: var(--text); }

.summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.summary-meta code {
  font-size: 11px;
  padding: 1px 6px;
  background: var(--surface-muted);
  border-radius: 4px;
}

.summary-insight {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.decision-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  width: fit-content;
}

.filter-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}

.filter-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.filter-btn.active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.alert-banner {
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #92400E;
  background: var(--warning-soft);
  border: 1px solid rgba(217, 119, 6, 0.2);
  border-radius: var(--radius-sm);
}

.decision-table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: auto;
  margin-bottom: 16px;
}

.decision-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}

.decision-table th {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: left;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.decision-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.decision-table tr:hover td {
  background: var(--surface-hover);
}

.decision-row.risk-row-high td:first-child {
  box-shadow: inset 3px 0 0 var(--risk-high);
}

.decision-row.risk-row-medium td:first-child {
  box-shadow: inset 3px 0 0 var(--risk-medium);
}

.cell-mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.cell-reason {
  max-width: 220px;
  font-size: 12px;
  color: var(--text-secondary);
}

.empty-decision {
  padding: 20px;
  margin: 0;
}

.zone-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Sticky bar */
.sticky-bar {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.bar-status {
  font-size: 13px;
  color: var(--text-muted);
}

.bar-status.ok { color: var(--success); }
.bar-status.error { color: var(--danger); }

.btn-generate {
  min-width: 160px;
  position: relative;
}

.btn-generate.is-loading .btn-text { opacity: 0; }
.btn-generate.is-loading .btn-spin {
  display: block;
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-spin { display: none; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Tool rail */
.tool-rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
}

.tool-card {
  padding: 20px;
}

.tool-card-featured {
  border-color: rgba(var(--primary-rgb), 0.15);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(var(--primary-rgb), 0.04);
}

.tool-card-head {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.tool-card-head.compact {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tool-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.tool-icon-excel {
  color: #059669;
  background: var(--risk-low-soft);
}

.tool-title {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
}

.tool-title-sm {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}

.tool-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Excel flow steps */
.flow-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 16px;
}

.flow-step {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
  opacity: 0.55;
  transition: opacity var(--transition);
}

.flow-step:last-child {
  border-bottom: none;
}

.flow-step.is-active,
.flow-step.is-done {
  opacity: 1;
}

.step-marker {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 2px solid var(--border);
  border-radius: 50%;
  transition: all var(--transition);
}

.flow-step.is-active .step-marker {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.flow-step.is-done .step-marker {
  color: #fff;
  border-color: var(--risk-low);
  background: var(--risk-low);
}

.step-body {
  flex: 1;
  min-width: 0;
}

.step-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.step-desc,
.step-placeholder {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.btn-block {
  width: 100%;
}

.dropzone-compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  padding: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.dropzone-compact:hover,
.dropzone-compact.is-dragover {
  border-color: var(--primary);
  background: var(--primary-softer);
}

.dropzone-compact.has-file {
  border-style: solid;
  border-color: var(--risk-low);
  background: var(--risk-low-soft);
}

.dz-status {
  font-size: 11px;
  font-weight: 500;
  color: var(--risk-low);
}

.preview-panel {
  margin-top: 4px;
}

.preview-meta {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.preview-scroll {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.preview-decision {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.preview-decision-ok {
  color: #15803d;
  background: rgba(22, 163, 74, 0.12);
}

.preview-decision-pending {
  color: #c2410c;
  background: rgba(234, 88, 12, 0.12);
}

.preview-decision-bad {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
}

.preview-scope {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.parse-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.parse-bar {
  flex: 1;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.parse-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--primary);
  border-radius: 999px;
  animation: progressSlide 1s ease-in-out infinite;
}

.parse-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.parse-ok {
  color: var(--risk-low);
  background: var(--risk-low-soft);
}

.tool-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Resources & jobs */
.resource-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.resource-link {
  display: block;
  width: 100%;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  text-align: left;
  cursor: pointer;
}

.resource-link:hover {
  text-decoration: underline;
}

.resource-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 4px;
}

.job-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.job-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.job-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.job-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.job-id {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.job-time {
  font-size: 11px;
  color: var(--text-muted);
}

.job-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.job-empty {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

.error-text {
  color: var(--danger);
}

@media (max-width: 1023px) {
  .tool-rail {
    position: static;
    order: -1;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .workspace-head {
    flex-direction: column;
    padding: 22px 20px 0;
  }

  .inline-field,
  .toolbar,
  .smart-table-wrap,
  .processing-layer,
  .decision-zone {
    margin-left: 20px;
    margin-right: 20px;
    padding-left: 0;
    padding-right: 0;
  }

  .inline-field { padding-top: 16px; }
}

/* ═══════════════════════════════════════════════════════════
   Decision Engine Workspace v6 — 三段式布局 + 双引擎对比
   ═══════════════════════════════════════════════════════════ */

.decision-workspace .workspace-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: var(--workspace-max);
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 24px;
}

.workspace-top {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.workspace-top-inner {
  max-width: var(--workspace-max);
  width: 100%;
  margin: 0 auto;
  padding: 10px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.topbar-row-primary {
  flex-wrap: wrap;
  align-items: center;
  row-gap: 8px;
}

.topbar-row-secondary {
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.mode-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  transition: var(--transition);
}

.mode-btn:hover { color: var(--text); background: var(--surface-hover); }
.mode-btn.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.task-pill {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.task-pill.ok { color: var(--success); border-color: rgba(22, 163, 74, 0.25); }
.task-pill.error { color: var(--danger); }

.layer-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

/* Scope bar */
.scope-bar { padding: 16px 20px; }

.scope-bar-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
}

.scope-bar-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 160px;
}

.scope-bar-label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 140px;
}

.scope-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 14px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
}

.scope-hint {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.scope-input {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  background: var(--surface-muted);
}

.scope-brand { align-self: center; }

/* Input zone */
.input-zone { padding: 20px; }

.zone-header-inline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.zone-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.zone-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
}

.zone-title-sm {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.zone-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.input-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 20px;
  align-items: start;
}

.material-col-head {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 7.5rem;
  gap: 8px;
  align-items: center;
  padding: 0 12px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.material-col-head-action {
  width: 28px;
}
.material-line-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  width: 100%;
}
.material-line-actions .btn {
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-secondary);
  border-color: transparent;
}
.material-line-actions .btn:hover {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: transparent;
}
.material-line-actions #addLineBtn {
  color: var(--primary);
}

.material-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.material-row.layer-card-inner {
  padding: 10px 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.material-row.is-analyzing {
  opacity: 0.7;
  border-color: var(--primary-ring);
}

.material-row-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 7.5rem;
  gap: 8px;
  align-items: center;
}

.material-row-fields .btn-del {
  justify-self: end;
}

.cell-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
}

.cell-input.is-invalid { border-color: var(--danger); }
.cell-mono { font-variant-numeric: tabular-nums; }

.excel-flow-card {
  padding: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.excel-flow-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
}

.flow-steps-horizontal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.excel-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.input-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* Engine zone */
.engine-zone { padding: 20px; }

.engine-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.engine-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* Engine zone — collapsible summary list */
.report-summary {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.report-summary-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.decision-item {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.decision-item:hover {
  box-shadow: var(--shadow-sm);
}

.decision-item.is-expanded {
  box-shadow: var(--shadow-md);
}

.decision-item.risk-border-low { border-left: 3px solid var(--success); }
.decision-item.risk-border-medium { border-left: 3px solid var(--warning); }
.decision-item.risk-border-high { border-left: 3px solid var(--danger); }

.decision-item.is-blocked {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.06) 0%, var(--surface) 42%);
  border-color: rgba(220, 38, 38, 0.28);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.06);
}
.decision-item.is-blocked .decision-summary {
  background: transparent;
}
.decision-item.is-blocked .risk-badge.risk-high {
  background: rgba(220, 38, 38, 0.16);
  color: #B91C1C;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.22);
}
.decision-item.is-missing-hs .summary-hs.is-empty {
  color: var(--danger);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.decision-item.is-blocked .summary-text {
  color: #9F1239;
  font-weight: 600;
}

.free-match-nudge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 12px 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #FFF7ED;
  border: 1px solid rgba(217, 119, 6, 0.28);
}
.free-match-nudge-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--warning);
  line-height: 1;
  margin-top: 1px;
}
.free-match-nudge-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.free-match-nudge-body strong {
  font-size: 13px;
  font-weight: 700;
  color: #9A3412;
}
.free-match-nudge-body span {
  font-size: 12px;
  line-height: 1.45;
  color: #9A3412;
}
.free-match-nudge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 0 auto;
  align-items: center;
}

.free-summary-nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.06) 0%, rgba(217, 119, 6, 0.08) 100%);
  border: 1px solid rgba(220, 38, 38, 0.18);
}
.free-summary-nudge-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 240px;
}
.free-summary-nudge-copy strong {
  font-size: 14px;
  font-weight: 700;
  color: #9F1239;
}
.free-summary-nudge-copy span {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}
.free-summary-nudge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 720px) {
  .free-match-nudge {
    flex-direction: column;
  }
  .free-match-nudge-actions {
    width: 100%;
  }
}


.decision-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  background: var(--surface);
  transition: background var(--transition);
}

.decision-summary:hover {
  background: var(--surface-hover);
}

.summary-idx {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 18px;
}

.summary-name {
  font-weight: 600;
  font-size: 13px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.summary-model {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.summary-hs {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.summary-text {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.summary-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.decision-item.is-expanded .summary-chevron {
  transform: rotate(180deg);
}

.decision-detail {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-muted);
}

.decision-detail .engine-compare {
  margin-top: 12px;
}

.decision-detail .engine-verdict {
  margin-top: 12px;
}

.engine-zone .zone-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 900px) {
  .decision-summary {
    flex-wrap: wrap;
  }

  .summary-text {
    flex: 1 1 100%;
    order: 10;
  }
}

/* Legacy engine-card kept for detail panel */
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.engine-card.risk-border-low { border-left: 3px solid var(--success); }
.engine-card.risk-border-medium { border-left: 3px solid var(--warning); }
.engine-card.risk-border-high { border-left: 3px solid var(--danger); }

.engine-card-head { margin-bottom: 12px; }

.engine-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.engine-idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-radius: var(--radius-xs);
}

.engine-model {
  font-size: 12px;
  color: var(--text-muted);
}

.engine-compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  margin-bottom: 12px;
}

.engine-divider {
  width: 1px;
  background: var(--border-subtle);
  margin: 0 12px;
}

.engine-side {
  padding: 12px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
}

.engine-side.is-collapsed { display: none; }

.engine-side-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.engine-side-library .engine-side-label { color: #0369A1; }
.engine-side-ai .engine-side-label { color: var(--primary); }

.engine-hs {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.engine-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.engine-reason {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.scope-tag {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-pill);
}

/* Scope verdict — prominent */
.scope-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
}

.scope-badge-lg {
  padding: 4px 10px;
  font-size: 12px;
  letter-spacing: 0.01em;
}

.scope-badge-ok {
  color: #166534;
  background: var(--success-soft);
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.scope-badge-bad {
  color: #991B1B;
  background: var(--danger-soft);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.scope-badge-pending {
  color: #92400E;
  background: var(--warning-soft);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.scope-badge-none {
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.scope-verdict {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.scope-verdict-ok {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.12), rgba(22, 163, 74, 0.04));
  border-color: rgba(22, 163, 74, 0.22);
}

.scope-verdict-bad {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.1), rgba(220, 38, 38, 0.03));
  border-color: rgba(220, 38, 38, 0.2);
}

.scope-verdict-pending {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.1), rgba(217, 119, 6, 0.03));
  border-color: rgba(217, 119, 6, 0.22);
}

.scope-verdict-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
}

.scope-verdict-ok .scope-verdict-icon {
  color: var(--success);
  background: var(--success-soft);
}

.scope-verdict-bad .scope-verdict-icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.scope-verdict-pending .scope-verdict-icon {
  color: var(--warning);
  background: var(--warning-soft);
}

.scope-verdict-body {
  flex: 1;
  min-width: 0;
}

.scope-verdict-body strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.scope-verdict-body p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.decision-summary .scope-badge-lg {
  order: -1;
}

.engine-side-ai .scope-verdict {
  margin-bottom: 14px;
}

.engine-verdict {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary-softer), var(--surface-muted));
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.risk-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
}

.risk-dot-low { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.risk-dot-medium { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.decision-item.is-blocked .risk-dot-high {
  width: 12px;
  height: 12px;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.22);
}

.verdict-body { flex: 1; min-width: 0; }

.verdict-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.verdict-hs {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.verdict-summary {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
}

/* Unified decision output */
.decision-output {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.decision-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.decision-output-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.unified-decisions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 16px;
}

.unified-row {
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.unified-row.risk-border-low { border-left: 3px solid var(--success); }
.unified-row.risk-border-medium { border-left: 3px solid var(--warning); }
.unified-row.risk-border-high { border-left: 3px solid var(--danger); }

.unified-row-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 13px;
}

.unified-row-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.unified-hs {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.unified-summary {
  flex: 1 1 100%;
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Bottom */
.workspace-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card { padding: 16px 20px; }

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.job-list-horizontal {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.job-list-horizontal .job-item {
  flex: 0 0 auto;
  min-width: 180px;
  padding: 10px 14px;
  text-align: left;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.job-list-horizontal .job-item:hover {
  border-color: var(--primary-ring);
  background: var(--surface);
}

.job-list-horizontal .job-id,
.job-list-horizontal .job-title {
  display: block;
  font-size: 12px;
  font-weight: 600;
  font-family: "Plus Jakarta Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-list-horizontal .job-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.job-list-horizontal .job-time {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.aux-info {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.summary-source {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 2px 6px;
  background: var(--surface-muted);
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.scope-hit-line {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.batch-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, max-content);
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  position: relative;
  z-index: 6;
  overflow: visible;
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.04) 0%, var(--surface-muted) 45%, var(--surface-muted) 100%);
  border: 1px solid rgba(var(--primary-rgb), 0.12);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

.batch-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  border-right: 1px solid var(--border-subtle);
}
.export-actions .btn {
  white-space: nowrap;
}

.export-actions.hidden {
  display: none;
}

.export-preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.export-preview-bar .export-actions {
  border-right: 0;
  padding-right: 0;
}
.export-preview-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.export-preview-label strong {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}
.export-preview-label .muted {
  font-size: 12px;
}
.export-preview-bar.is-ready {
  border-color: rgba(var(--primary-rgb), 0.22);
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.04) 0%, var(--surface) 55%);
}

@keyframes scopeShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(2px); }
}
.scope-bar.scope-shake,
.scope-input.scope-shake {
  animation: scopeShake 0.7s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.scope-input.scope-shake {
  border-color: var(--warning) !important;
  box-shadow: 0 0 0 3px var(--warning-soft);
}
@media (prefers-reduced-motion: reduce) {
  .scope-bar.scope-shake,
  .scope-input.scope-shake {
    animation: none;
  }
}

/* DOCX template hover preview */
.doc-preview-wrap {
  position: relative;
  display: inline-flex;
  z-index: 1;
}
.doc-preview-wrap:hover,
.doc-preview-wrap:focus-within {
  z-index: 90;
}
.doc-preview-card {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 80;
  width: min(360px, calc(100vw - 32px));
  padding-top: 2px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.doc-preview-wrap-end .doc-preview-card,
.doc-preview-card-end {
  left: auto;
  right: 0;
}
.doc-preview-card::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 12px;
}
.doc-preview-wrap:hover .doc-preview-card,
.doc-preview-wrap:focus-within .doc-preview-card {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.doc-preview-paper {
  position: relative;
  padding: 14px 16px 12px;
  background:
    linear-gradient(180deg, #FFFEFB 0%, #F7F5F0 100%);
  border: 1px solid #D6D0C4;
  border-radius: 4px 10px 10px 10px;
  box-shadow:
    var(--shadow-lg),
    0 0 0 1px rgba(255, 255, 255, 0.7) inset,
    3px 3px 0 rgba(12, 18, 34, 0.04);
  color: #1A1F2C;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.doc-preview-paper::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, transparent 50%, #E8E2D6 50%);
  border-radius: 0 8px 0 0;
  box-shadow: -1px 1px 0 #C9C2B4;
}
.doc-preview-badge {
  position: absolute;
  top: 10px;
  right: 22px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 4px;
}
.doc-preview-title {
  margin: 0 28px 4px 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  color: #0C1222;
}
.doc-preview-meta {
  margin: 0 0 10px;
  font-size: 10px;
  color: #6B7280;
  text-align: center;
}
.doc-preview-sec {
  margin-bottom: 8px;
}
.doc-preview-sec > strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #1F2937;
}
.doc-preview-sec > p {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: #4B5563;
}
.doc-preview-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 10px;
  line-height: 1.35;
}
.doc-preview-table th,
.doc-preview-table td {
  padding: 3px 5px;
  border: 1px solid #C9C2B4;
  text-align: left;
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-preview-table th {
  background: #EFEAE0;
  font-weight: 600;
  color: #374151;
  text-align: center;
}
.doc-preview-table td {
  background: #FFFEFB;
  color: #4B5563;
}
.doc-preview-table-wide th:last-child,
.doc-preview-table-wide td:last-child {
  width: 38%;
}
.doc-preview-item {
  padding: 6px 8px;
  background: #FFFEFB;
  border: 1px solid #D6D0C4;
  border-radius: 4px;
}
.doc-preview-item-head {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #111827;
}
.doc-preview-dl {
  margin: 0;
  display: grid;
  gap: 2px;
}
.doc-preview-dl > div {
  display: grid;
  grid-template-columns: 4.5em 1fr;
  gap: 4px;
  font-size: 10px;
  line-height: 1.4;
}
.doc-preview-dl dt {
  margin: 0;
  font-weight: 600;
  color: #374151;
}
.doc-preview-dl dd {
  margin: 0;
  color: #6B7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-preview-footnote {
  margin: 2px 0 0;
  padding-top: 6px;
  border-top: 1px dashed #D6D0C4;
  font-size: 10px;
  color: #9CA3AF;
}

@media (max-width: 720px) {
  .doc-preview-card,
  .doc-preview-wrap-end .doc-preview-card,
  .doc-preview-card-end {
    left: 50%;
    right: auto;
    width: min(340px, calc(100vw - 24px));
    transform: translateX(-50%) translateY(6px);
  }
  .doc-preview-wrap:hover .doc-preview-card,
  .doc-preview-wrap:focus-within .doc-preview-card {
    transform: translateX(-50%) translateY(0);
  }
}

@media (hover: none) {
  .doc-preview-wrap:not(:focus-within) .doc-preview-card {
    display: none;
  }
}

.batch-toolbar-stats {
  min-width: 0;
}

.batch-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.batch-toolbar-utils {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.ai-core-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(var(--primary-rgb), 0.16);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.08);
}

.ai-core-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4f46e5;
  padding: 0 4px 0 2px;
  white-space: nowrap;
}

.ai-core-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-core-strip.has-work {
  border-color: rgba(var(--primary-rgb), 0.35);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.08);
  background: linear-gradient(135deg, #faf5ff 0%, #f0f9ff 100%);
}

.ai-action-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  min-width: 168px;
  padding: 10px 14px 10px 12px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.ai-action-btn.ai-action-highlight {
  border-width: 2px;
  transform: scale(1.02);
}

.ai-action-scope.ai-action-highlight {
  border-color: #4f46e5;
  box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.22);
}

.ai-action-hs.ai-action-highlight {
  border-color: #0284c7;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.22);
  animation: aiHsGlow 2s ease-in-out infinite;
}

@keyframes aiHsGlow {
  0%, 100% { box-shadow: 0 8px 24px rgba(14, 165, 233, 0.22); }
  50% { box-shadow: 0 8px 32px rgba(14, 165, 233, 0.38); }
}

.ai-action-title {
  font-size: 14px;
  font-weight: 700;
}

.ai-action-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
}

.ai-action-btn:active:not(:disabled) {
  transform: translateY(0);
}

.ai-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.ai-action-progress {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(var(--primary-rgb), 0.12);
}

.ai-action-progress::after {
  content: "";
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--primary), #0ea5e9);
  animation: progressSlide 0.9s ease-in-out infinite;
}

.ai-action-btn.is-loading .ai-action-progress {
  display: block;
}

.ai-action-btn.is-loading {
  opacity: 0.92;
}

.ai-action-btn.is-loading .ai-action-icon {
  animation: spin 0.85s linear infinite;
}

.ai-action-scope {
  border-color: rgba(var(--primary-rgb), 0.22);
  background: linear-gradient(135deg, #ffffff 0%, #F0FDFA 100%);
}

.ai-action-scope:hover:not(:disabled) {
  border-color: rgba(var(--primary-rgb), 0.45);
  box-shadow: 0 6px 18px rgba(var(--primary-rgb), 0.16);
}

.ai-action-hs {
  border-color: rgba(14, 165, 233, 0.22);
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
}

.ai-action-hs:hover:not(:disabled) {
  border-color: rgba(14, 165, 233, 0.45);
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.16);
}

.ai-action-adopt {
  border-color: rgba(22, 163, 74, 0.22);
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}

.ai-action-adopt:hover:not(:disabled) {
  border-color: rgba(22, 163, 74, 0.45);
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.14);
}

.ai-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
}

.ai-action-scope .ai-action-icon {
  color: #4f46e5;
  background: rgba(var(--primary-rgb), 0.1);
}

.ai-action-hs .ai-action-icon {
  color: #0284c7;
  background: rgba(14, 165, 233, 0.1);
}

.ai-action-adopt .ai-action-icon {
  color: #16a34a;
  background: rgba(22, 163, 74, 0.1);
}

.ai-action-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ai-action-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
}

.ai-action-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.2;
  white-space: nowrap;
}

.ai-action-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  margin-left: 2px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #4f46e5;
  flex-shrink: 0;
}

.ai-action-hs .ai-action-badge {
  background: #0284c7;
}

.ai-action-badge-ok {
  background: #16a34a;
}

.ai-action-btn:disabled .ai-action-badge {
  background: #94a3b8;
}

@media (max-width: 1100px) {
  .summary-grid-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .batch-toolbar {
    grid-template-columns: 1fr;
  }

  .batch-toolbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .export-actions {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding-right: 0;
    padding-bottom: 10px;
  }

  .ai-core-strip {
    width: 100%;
  }

  .batch-toolbar-utils {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .summary-grid-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .ai-action-desc {
    display: none;
  }

  .ai-action-btn {
    min-height: 44px;
    padding: 8px 10px;
  }
}

.live-analyze-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: rgba(var(--primary-rgb), 0.04);
  border: 1px dashed rgba(var(--primary-rgb), 0.2);
  border-radius: var(--radius-sm);
}

.live-analyze-bar .muted {
  font-size: 12px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
}

.detail-source {
  margin-left: auto;
  font-size: 11px;
}

.history-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-filter {
  width: 140px;
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
}

.scope-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.scope-toggle-btn {
  align-self: flex-start;
}

.scope-full-text {
  margin: 0;
  padding: 10px 12px;
  max-height: 120px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.evidence-chain {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.evidence-block {
  min-width: 0;
}

.evidence-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.evidence-block p {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.45;
}

.evidence-hs {
  font-size: 15px !important;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
}

.elem-list {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  line-height: 1.45;
}

.elem-gap-note {
  margin: 6px 0 0 !important;
  font-size: 11px;
  color: #c2410c;
}

.material-hint {
  margin: 6px 0 0;
  padding: 6px 10px;
  font-size: 11px;
  color: #0369a1;
  background: rgba(14, 165, 233, 0.08);
  border-radius: var(--radius-xs);
}

.preview-decision-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--surface-muted);
  border-radius: var(--radius-xs);
}

.preview-chip {
  display: inline-flex;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
}

.preview-chip-ok {
  color: #15803d;
  background: rgba(22, 163, 74, 0.12);
}

.preview-chip-pending {
  color: #c2410c;
  background: rgba(234, 88, 12, 0.12);
}

.preview-chip-bad {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
}

.preview-bar-hint {
  font-size: 11px;
  margin-left: auto;
}

.risk-badge.risk-partial {
  color: #15803d;
  background: rgba(22, 163, 74, 0.15);
  border: 1px dashed rgba(22, 163, 74, 0.45);
}

@media (max-width: 900px) {
  .evidence-chain {
    grid-template-columns: 1fr;
  }
}

.job-client {
  display: block;
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
}

@media (min-width: 1600px) {
  :root {
    --workspace-max: min(1680px, calc(100vw - 48px));
  }

  .input-split {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  }
}

@media (max-width: 900px) {
  .workspace-top-inner {
    padding: 8px 14px 10px;
  }

  .topbar-row-primary {
    flex-wrap: wrap;
  }

  .saas-plan-bar {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-row-secondary {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-meta {
    margin-left: 0;
    justify-content: flex-end;
  }

  .scope-bar-inner {
    grid-template-columns: 1fr;
  }

  .scope-bar-side {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .input-split {
    grid-template-columns: 1fr;
  }

  .material-row-fields,
  .material-col-head {
    grid-template-columns: 1fr 1fr;
  }
  .material-col-head > span:nth-child(3),
  .material-col-head > span:nth-child(4) {
    display: none;
  }
  .material-line-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 4px;
  }
  .material-row-fields .btn-del {
    grid-column: 1 / -1;
    justify-self: end;
  }
  .saas-entitlement {
    white-space: normal;
  }
  .saas-meter {
    min-width: 100px;
    flex: 1 1 100px;
  }

  .engine-compare {
    grid-template-columns: 1fr;
  }

  .engine-divider {
    width: 100%;
    height: 1px;
    margin: 8px 0;
  }

  .topbar-meta {
    width: 100%;
    justify-content: flex-end;
  }

  .aux-info {
    flex-direction: column;
  }
}

body.saas-login-open .app-shell {
  pointer-events: none;
  user-select: none;
  filter: blur(2px);
}
body.saas-login-open #saasLoginModal {
  pointer-events: auto;
}
.saas-plan-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.saas-plan-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 280px;
  min-width: 0;
}
.saas-usage-meters {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}
.saas-meter {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 118px;
  padding: 6px 10px;
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 10px;
}
.saas-meter.is-warn {
  background: rgba(180, 83, 9, 0.1);
  border-color: rgba(180, 83, 9, 0.28);
}
.saas-meter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.saas-meter-value {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
  color: #0f766e;
  font-variant-numeric: tabular-nums;
}
.saas-meter.is-warn .saas-meter-value {
  color: #b45309;
}
.saas-meter-value span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 1px;
}
.saas-meter-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}
.saas-meter-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}
.saas-meter.is-warn .saas-meter-bar i {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}
.saas-entitlement {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saas-plan-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.saas-plan-bar .btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.saas-trial-cta {
  position: relative;
  overflow: visible;
  border: none;
  color: #fff !important;
  font-weight: 700 !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 55%, #14b8a6 100%) !important;
  box-shadow: 0 2px 10px rgba(15, 118, 110, 0.35);
  animation: saas-trial-cta-glow 2.4s ease-in-out infinite;
}
.saas-trial-cta:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.45);
}
.saas-trial-cta-pulse {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 2px solid rgba(20, 184, 166, 0.55);
  animation: saas-trial-ring 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes saas-trial-cta-glow {
  0%, 100% { box-shadow: 0 2px 10px rgba(15, 118, 110, 0.35); }
  50% { box-shadow: 0 4px 18px rgba(20, 184, 166, 0.55); }
}
@keyframes saas-trial-ring {
  0% { opacity: 0.9; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.12); }
}
.saas-plan-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #eef2f7;
}
.saas-plan-pro {
  background: #dbeafe;
  color: #1d4ed8;
}
.saas-usage {
  font-size: 0.75rem;
}
.saas-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 1rem;
}
.saas-modal.hidden {
  display: none;
}
.saas-modal-card {
  position: relative;
  width: min(100%, 400px);
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.saas-modal-card-wide {
  width: min(100%, 420px);
}

.saas-login-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 1rem;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 10px;
}

.saas-login-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.saas-login-tab:hover {
  color: #334155;
}

.saas-login-tab.active {
  color: #1e293b;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.btn-link {
  border: 0;
  background: none;
  color: var(--primary);
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.saas-login-footnote {
  margin: 1.25rem 0 0;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}
.saas-footnote-sep {
  margin: 0 0.35rem;
  opacity: 0.45;
}
.saas-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: none;
  background: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #64748b;
}
.saas-code-row {
  display: flex;
  gap: 0.5rem;
}
.saas-code-row input {
  flex: 1;
}
.saas-price-line {
  font-size: 1.25rem;
  margin: 0.5rem 0 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
}
.saas-price-was {
  font-size: 0.85rem;
  text-decoration: line-through;
  font-weight: 400;
}
.saas-feature-list {
  margin: 0 0 1rem 1.1rem;
  font-size: 0.9rem;
  color: #334155;
}
.saas-divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 1rem 0;
}
.btn-block {
  width: 100%;
  margin-top: 0.75rem;
}
.field {
  display: block;
  margin-bottom: 0.75rem;
}
.field span {
  display: block;
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 0.25rem;
}

/* ── Admin console (spacious ops layout) ───────────────────── */
body.admin-page {
  --admin-font: "Plus Jakarta Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --admin-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
  font-family: var(--admin-font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1200px 480px at 10% -10%, rgba(var(--primary-rgb), 0.07), transparent 55%),
    var(--bg);
  min-height: 100dvh;
}
body.admin-page input,
body.admin-page select,
body.admin-page button,
body.admin-page textarea {
  font-family: inherit;
}
.admin-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 28px 64px;
}
.admin-shell-wide {
  max-width: 1440px;
}
.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.admin-header-left h1 {
  margin: 10px 0 6px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--text);
}
.admin-header-left .muted {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 36em;
}
.admin-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
}
.admin-back:hover { color: var(--primary-hover); }
.admin-user-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  font-size: 0.9rem;
}
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
.admin-card > h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.admin-card > .muted {
  margin: 0 0 20px;
  font-size: 0.92rem;
  line-height: 1.55;
}
.admin-card-compact h3 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
  padding: 6px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  width: fit-content;
  max-width: 100%;
}
.admin-tab {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.admin-tab:hover {
  color: var(--text);
  background: var(--surface);
}
.admin-tab.active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}
.admin-tab-panel.hidden { display: none; }
.admin-toolbar { margin-bottom: 16px; }
.admin-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 20px;
}
.admin-filter-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.admin-filter-row select,
.admin-filter-row input[type="search"] {
  margin-left: 0;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.95rem;
  color: var(--text);
}
.admin-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 480px));
  gap: 20px;
  margin-bottom: 20px;
}
.admin-invite-grid {
  align-items: start;
}
.admin-panel-card {
  padding: 20px 24px;
}
.admin-panel-card > h3 {
  margin: 0 0 14px;
}
.admin-panel-card > .admin-hint:first-of-type,
.admin-panel-card > .admin-edit-hint:first-of-type {
  margin: 0 0 16px;
}
.admin-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 24px;
}
.admin-filter-row-inline {
  margin: 0;
  flex: 0 0 auto;
}
.admin-upgrade-panel {
  margin-bottom: 16px;
}
.admin-activate-card {
  max-width: 640px;
}
.admin-form-compact .field.field-wide {
  grid-column: 1 / -1;
  max-width: 496px;
}
.admin-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.admin-form .field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-form .field > span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.admin-form .field input,
.admin-form .field select {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.95rem;
  line-height: 1.4;
}
.admin-form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 18px;
  align-items: flex-end;
}
.admin-form-inline .field {
  margin-bottom: 0;
  flex: 0 1 200px;
  max-width: 260px;
  min-width: 150px;
}
.admin-form-inline input,
.admin-form-inline select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.95rem;
}

/* User edit panel — compact grid, fields stay near section titles */
.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.admin-modal.hidden {
  display: none;
}
.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}
.admin-modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  max-height: min(92vh, 880px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}
.admin-modal-body {
  overflow-y: auto;
  padding: 4px 24px 24px;
  flex: 1 1 auto;
  min-height: 0;
}
body.admin-modal-open {
  overflow: hidden;
}
.admin-user-edit {
  padding: 0;
}
.admin-user-edit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex: 0 0 auto;
  background: var(--surface);
}
.admin-user-edit-meta {
  margin: 6px 0 0;
}
.admin-edit-section {
  padding: 18px 0;
  border-top: 1px solid var(--border-subtle);
}
.admin-edit-section:first-of-type {
  border-top: 0;
  padding-top: 12px;
}
.admin-edit-section .admin-subhead {
  margin: 0 0 14px;
  padding-top: 0;
  border-top: 0;
}
.admin-edit-hint {
  margin: 12px 0 0;
  max-width: 52em;
}
.admin-form-compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 240px));
  gap: 14px 16px;
  align-items: end;
  max-width: 920px;
}
.admin-form-compact .field {
  margin: 0;
  min-width: 0;
}
.admin-form-compact .admin-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  grid-column: 1 / -1;
  padding-top: 2px;
}
@media (max-width: 640px) {
  .admin-form-compact {
    grid-template-columns: 1fr;
    max-width: none;
  }
  .admin-modal {
    padding: 12px;
    align-items: flex-end;
  }
  .admin-modal-card {
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 12px 12px;
  }
}
.admin-table-wrap { padding: 0; overflow: hidden; }
.admin-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
}
.admin-table-head h3 { font-size: 1.05rem; }
.admin-table-scroll { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}
.admin-table th,
.admin-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.admin-table th {
  background: var(--surface-muted);
  font-weight: 650;
  color: var(--text-secondary);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: none;
  white-space: nowrap;
}
.admin-table td {
  color: var(--text);
  white-space: nowrap;
}
.admin-table tbody tr:hover td { background: var(--primary-softer); }
.admin-table code {
  font-family: var(--admin-mono);
  font-size: 0.86em;
  background: var(--surface-muted);
  padding: 3px 7px;
  border-radius: 5px;
}
.admin-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 650;
}
.admin-badge-open { color: var(--success); background: var(--success-soft); }
.admin-badge-used { color: var(--text-muted); background: var(--surface-muted); }
.admin-badge-pro { color: var(--primary); background: var(--primary-soft); }
.admin-badge-free { color: var(--text-secondary); background: var(--surface-muted); }
.admin-badge-pending { color: var(--warning); background: var(--warning-soft); }
.admin-filter-row input[type="search"] { min-width: 240px; }
.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-subhead {
  margin: 28px 0 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.admin-subhead:first-of-type {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}
.admin-audit-list {
  margin-top: 4px;
  padding: 14px 16px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.65;
  max-height: 220px;
  overflow-y: auto;
}
.admin-audit-list div { padding: 4px 0; }
.admin-log-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.admin-batch-result {
  margin: 0 0 20px;
  padding: 16px 18px;
  background: var(--primary-softer);
  border: 1px solid var(--primary-ring);
  border-radius: var(--radius-sm);
}
.admin-batch-result pre {
  margin: 10px 0 0;
  font-family: var(--admin-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}
.admin-result-msg {
  margin-top: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--success);
}
.admin-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--text-inverse);
  font-size: 0.92rem;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
}
.admin-toast-error { background: var(--danger); }
.admin-toast-ok { background: var(--success); }
.admin-hint {
  margin: 12px 0 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
}
@media (max-width: 720px) {
  .admin-shell { padding: 20px 16px 48px; }
  .admin-header { flex-direction: column; }
  .admin-card { padding: 20px; }
  .admin-table th,
  .admin-table td { padding: 12px 14px; }
}

/* ══════════════════════════════════════════════════════════════
   Taste v7 — B2B workspace visual refresh
   ══════════════════════════════════════════════════════════════ */

body.taste-v7 {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(12, 18, 34, 0.045) 1px, transparent 0);
  background-size: 24px 24px;
}

body.taste-v7 .app-shell {
  animation: tasteFadeIn 0.45s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes tasteFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  body.taste-v7 .app-shell {
    animation: none;
  }
}

/* Topbar */
body.taste-v7 .workspace-top {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid rgba(221, 227, 234, 0.9);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

body.taste-v7 .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--primary-soft) 0%, rgba(var(--primary-rgb), 0.14) 100%);
  color: var(--primary);
  border: 1px solid rgba(var(--primary-rgb), 0.12);
}

body.taste-v7 .brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

body.taste-v7 .brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

body.taste-v7 .mode-switch {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

body.taste-v7 .mode-btn.active {
  color: var(--primary-active);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

body.taste-v7 .status-pill.is-live {
  border-color: rgba(5, 150, 105, 0.25);
  background: var(--success-soft);
}

/* Workspace intro strip */
body.taste-v7 .workspace-intro {
  margin: -4px 0 -4px;
}

body.taste-v7 .workspace-intro-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 2px 6px;
}

body.taste-v7 .workspace-intro-tag {
  display: inline-flex;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--primary-active);
  background: var(--primary-soft);
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: var(--radius-pill);
}

body.taste-v7 .workspace-intro-text {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

/* Cards */
body.taste-v7 .layer-card {
  border-color: var(--border);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition), border-color var(--transition);
}

body.taste-v7 .layer-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

body.taste-v7 .zone-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

body.taste-v7 .zone-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  margin-right: 10px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--primary);
}

body.taste-v7 .scope-icon {
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid rgba(var(--primary-rgb), 0.1);
}

body.taste-v7 .scope-input {
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.scope-input.scope-input-locked {
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}

body.taste-v7 .scope-bar.scope-bar-locked {
  opacity: 0.92;
}

body.taste-v7 .scope-bar.scope-bar-locked .scope-icon {
  color: var(--text-muted);
  background: var(--surface-muted);
  border-color: var(--border);
}

/* Excel flow */
body.taste-v7 .excel-flow-card {
  background: linear-gradient(160deg, var(--surface-muted) 0%, #fff 100%);
  border-color: var(--border);
}

body.taste-v7 .flow-step .step-marker {
  background: var(--primary);
  color: var(--text-inverse);
  font-weight: 700;
}

/* Primary CTA */
body.taste-v7 .btn-primary {
  background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 100%);
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(var(--primary-rgb), 0.2), 0 4px 12px rgba(var(--primary-rgb), 0.15);
}

body.taste-v7 .btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #14B8A6 0%, var(--primary-hover) 100%);
  box-shadow: 0 2px 4px rgba(var(--primary-rgb), 0.22), 0 6px 16px rgba(var(--primary-rgb), 0.18);
  transform: translateY(-1px);
}

body.taste-v7 .btn-generate {
  min-width: 172px;
  padding: 10px 20px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

/* Engine empty state */
body.taste-v7 .engine-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 56px 32px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(var(--primary-rgb), 0.05) 0%, transparent 70%),
    var(--surface-muted);
  border-style: solid;
  border-color: var(--border);
}

body.taste-v7 .engine-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid rgba(var(--primary-rgb), 0.12);
  border-radius: 14px;
}

body.taste-v7 .engine-empty-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

body.taste-v7 .engine-empty-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 36ch;
  text-align: center;
  line-height: 1.55;
}

/* Decision items */
body.taste-v7 .decision-item {
  border-color: var(--border);
}

body.taste-v7 .summary-hs,
body.taste-v7 .evidence-hs {
  font-family: var(--font-mono);
}

/* Batch toolbar */
body.taste-v7 .batch-toolbar {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.04) 0%, var(--surface-muted) 50%);
  border-color: rgba(var(--primary-rgb), 0.12);
  border-radius: var(--radius);
}

/* History jobs */
body.taste-v7 .job-list-horizontal .job-item:hover {
  border-color: rgba(var(--primary-rgb), 0.28);
  box-shadow: var(--shadow-sm);
}

body.taste-v7 .job-list-horizontal .job-id,
body.taste-v7 .job-list-horizontal .job-title {
  font-family: var(--font-sans, "Plus Jakarta Sans", "PingFang SC", sans-serif);
  font-size: 12px;
}

/* SaaS modals */
body.taste-v7 .saas-modal-card {
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}

body.taste-v7 .saas-plan-pro {
  background: var(--primary-soft);
  color: var(--primary-active);
}

body.taste-v7 .aux-info {
  padding: 4px 6px 8px;
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 720px) {
  body.taste-v7 .workspace-intro-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  body.taste-v7 .zone-title::before {
    display: none;
  }
}
