/* =====================================================
   CCM Design System — Pengurusan Tender
   Dark theme matching CCM Command Centre
   ===================================================== */

:root {
  --bg: #0b1121;
  --surface: rgba(255,255,255,0.035);
  --surface-hover: rgba(255,255,255,0.06);
  --surface-strong: rgba(255,255,255,0.055);
  --border: rgba(255,255,255,0.07);
  --border-active: rgba(59,130,246,0.5);
  --ink: #e2e8f0;
  --ink-soft: #94a3b8;
  --ink-muted: #64748b;
  --blue: #3b82f6;
  --blue-deep: #2563eb;
  --teal: #22d3ee;
  --teal-deep: #0891b2;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --green: #22c55e;
  --red: #ef4444;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --radius-xl: 14px;
  --radius-lg: 12px;
  --radius-md: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

/* Skip link & SR */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden; z-index: 10000;
  padding: 12px 20px; background: var(--blue); color: white;
  font-weight: 700; border-radius: 0 0 10px 10px; text-decoration: none;
}
.skip-link:focus {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: auto; height: auto;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Page Shell */
.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

/* ===== HERO ===== */
.hero {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr;
  gap: 20px;
  padding: 24px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.hero::after { display: none; }
.section-card::after { display: none; }

.eyebrow, .section-kicker {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--blue);
}

h1, h2, h3 {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); color: var(--ink); }
h2 { font-size: clamp(1.1rem, 2vw, 1.4rem); color: var(--ink); }
h3 { font-size: clamp(0.95rem, 1.5vw, 1.15rem); color: var(--ink); }

.hero-text, .section-note, .helper-text,
#nfa-explainer, #lcco-explainer, #cia-gap-percent,
#cia-insight, #cia-lowest-name {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.hero-text { margin-top: 10px; max-width: 60ch; font-size: 13px; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.export-feedback {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
}

/* ===== BUTTONS ===== */
.button, .icon-button {
  appearance: none;
  border: none;
  font: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
}

.button:hover { opacity: 0.88; transform: translateY(-1px); }
.button:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.button-primary {
  background: linear-gradient(135deg, var(--blue-deep), var(--blue));
  color: white;
}

.button-secondary {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--ink-soft);
}

.button-secondary:hover {
  background: rgba(255,255,255,0.09);
  color: var(--ink);
}

/* ===== HERO PANEL (mini stats) ===== */
.hero-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.mini-stat {
  padding: 14px 16px;
  background: rgba(8,14,30,0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.mini-stat-label, .label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.mini-stat strong, .result-panel strong, .summary-block strong {
  font-size: clamp(1.1rem, 1.8vw, 1.5rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
}

/* ===== TOOLBAR ===== */
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.toolbar-left, .toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar-btn { min-height: 34px; padding: 0 12px; font-size: 12px; }

.toolbar-select-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.toolbar-select {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.3);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.toolbar-select:focus { outline: none; border-color: var(--blue); }

/* ===== TABS NAV ===== */
.tabs-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.tab-button {
  display: grid;
  gap: 4px;
  min-height: 70px;
  padding: 12px 14px;
  text-align: left;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-button:hover { background: var(--surface-hover); }

.tab-button.is-active {
  background: rgba(59,130,246,0.15);
  border-color: rgba(59,130,246,0.4);
}

.tab-index {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.tab-button.is-active .tab-index { color: var(--blue); }

.tab-copy {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink-soft);
}

.tab-button.is-active .tab-copy { color: var(--ink); }

.tab-progress {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.06);
  margin-top: 4px;
  overflow: hidden;
}

.tab-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--blue);
  transition: width 400ms ease;
  width: 0%;
}

.tab-button:not(.is-active) .tab-progress-fill { background: var(--blue); }
.tab-button.is-active .tab-progress-fill { background: rgba(255,255,255,0.7); }

/* ===== SECTION CARD ===== */
.section-card {
  padding: 22px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  animation: rise 450ms ease both;
  position: relative;
  overflow: hidden;
}

.tab-panel[hidden] { display: none; }

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.section-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.section-heading-actions .section-note {
  max-width: 42ch;
  text-align: right;
}

/* ===== GRID LAYOUTS ===== */
.content-grid { display: grid; gap: 18px; margin-top: 18px; }
.matrix-layout, .calculator-grid, .cia-layout, .subcon-layout { display: grid; gap: 14px; }
.matrix-layout { grid-template-columns: minmax(0,1.5fr) minmax(240px,0.65fr); align-items: start; }
.subcon-layout { grid-template-columns: minmax(0,1.12fr) minmax(280px,0.88fr); align-items: start; }
.two-columns { grid-template-columns: minmax(0,1fr) minmax(240px,0.8fr); }
.three-columns { grid-template-columns: repeat(3,minmax(0,1fr)); }
.subcon-meta-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.subcon-groups, .subcon-dashboard, .subcon-toolbar { display: grid; gap: 12px; }

/* ===== FORMULA GUIDE ===== */
.formula-guide {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: rgba(8,14,30,0.5);
  border: 1px solid var(--border);
}

.formula-guide p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.formula-guide strong { color: var(--teal); }

/* ===== PANELS (table-wrap, result-panel, summary-panel) ===== */
.mini-stat, .result-panel, .summary-panel,
.table-wrap, .field, .cia-controls {
  border-radius: var(--radius-lg);
}

.table-wrap, .summary-panel, .cia-controls, .result-panel {
  padding: 16px;
  background: rgba(8,14,30,0.5);
  border: 1px solid var(--border);
}

.summary-panel { display: grid; gap: 14px; }
.summary-block { display: grid; gap: 6px; }

.threshold-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
}

.threshold-input input { width: 72px; }

.threshold-input input, .score-input {
  appearance: textfield;
  -moz-appearance: textfield;
}

.threshold-input input::-webkit-outer-spin-button,
.threshold-input input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
  margin: 0; -webkit-appearance: none;
}

/* ===== RESULT PANEL ACCENTS ===== */
.result-panel { display: grid; align-content: start; gap: 8px; }

.accent-teal { background: rgba(34,211,238,0.07); border-color: rgba(34,211,238,0.18); }
.accent-sand { background: rgba(245,158,11,0.07); border-color: rgba(245,158,11,0.18); }
.accent-coral { background: rgba(239,68,68,0.07); border-color: rgba(239,68,68,0.18); }
.accent-gold { background: rgba(251,191,36,0.07); border-color: rgba(251,191,36,0.18); }
.accent-ink { background: rgba(255,255,255,0.04); border-color: var(--border); }

/* ===== MATRIX TABLE ===== */
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.matrix-table th, .matrix-table td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle;
}

.matrix-table th {
  font-size: 10.5px;
  text-align: left;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
}

.matrix-table tbody tr:hover { background: rgba(255,255,255,0.025); }
.matrix-table tfoot td { font-weight: 800; border-bottom: none; color: var(--ink); }

.category-cell { font-weight: 800; color: var(--teal); }
.criteria-cell { max-width: 420px; }
.weight-value-cell { font-weight: 700; color: var(--ink); }
.weighted-score-cell, .variance-cell { font-weight: 700; color: var(--blue); }

/* ===== INPUTS ===== */
.table-input, .field input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.35);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  transition: border-color 180ms, box-shadow 180ms;
}

.table-input:focus, .field input:focus {
  outline: none;
  border-color: rgba(59,130,246,0.5);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.table-input.has-error, .field input.has-error {
  border-color: var(--red);
  background: rgba(239,68,68,0.06);
}

.table-input.has-value, .field input.has-value {
  border-color: rgba(34,211,238,0.25);
}

.error-message { margin-top: 5px; font-size: 12px; color: var(--red); font-weight: 600; }

/* ===== DECISION PILL ===== */
.decision-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.decision-go { color: white; background: linear-gradient(135deg, #059669, #10b981); }
.decision-review { color: white; background: linear-gradient(135deg, #d97706, #f59e0b); }
.decision-no-go { color: white; background: linear-gradient(135deg, #dc2626, #ef4444); }
.decision-pending { background: rgba(255,255,255,0.07); color: var(--ink-soft); }

/* ===== FORM FIELD ===== */
.form-grid { display: grid; gap: 12px; }

.field {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: rgba(8,14,30,0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.field span { font-weight: 700; font-size: 13px; color: var(--ink-soft); }

/* ===== CIA CONTROLS ===== */
.cia-layout { gap: 14px; }

.cia-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.cia-controls .field { flex: 1 1 280px; }

/* ===== ICON BUTTON ===== */
.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(239,68,68,0.1);
  color: var(--red);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}

.icon-button:hover { background: rgba(239,68,68,0.2); }

/* ===== SUBCON COMPONENTS ===== */
.subcon-group-card, .subcon-decision-card, .chart-card, .subcon-metric-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(8,14,30,0.5);
  border: 1px solid var(--border);
}

.subcon-group-head, .subcon-table-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.subcon-group-head strong { font-size: 13.5px; color: var(--ink); }

.subcon-weight-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(59,130,246,0.12);
  color: var(--blue);
  font-size: 11.5px;
  font-weight: 800;
  border: 1px solid rgba(59,130,246,0.2);
}

.subcon-criteria-list { display: grid; gap: 10px; margin-top: 12px; }

.subcon-slider-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 88px;
  gap: 12px;
  align-items: center;
}

.subcon-slider-head { display: block; }
.subcon-slider-label { font-weight: 700; color: var(--ink); font-size: 13px; }

.subcon-score-input { text-align: center; font-weight: 800; }
.subcon-score-input { appearance: textfield; -moz-appearance: textfield; }
.subcon-score-input::-webkit-outer-spin-button,
.subcon-score-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

.subcon-decision-card { display: grid; gap: 8px; }
.subcon-chart-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.chart-card { display: grid; gap: 10px; min-width: 0; }
.chart-svg { display: block; width: 100%; height: auto; }
.subcon-metrics-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: 10px; }
.subcon-metric-card { display: grid; min-width: 0; gap: 5px; padding: 14px 12px; }

.chart-card .label, .subcon-metric-card .label {
  font-size: 10px; letter-spacing: 0.12em; line-height: 1.4;
}

.subcon-metric-card .label, .subcon-metric-card .helper-text {
  overflow-wrap: anywhere; word-break: break-word;
}

.subcon-metric-card strong { font-size: 1rem; line-height: 1.2; color: var(--ink); }
.subcon-metric-card .helper-text { font-size: 12px; line-height: 1.45; }
.subcon-table-wrap { display: grid; gap: 14px; }
.subcon-row-score { font-weight: 800; color: var(--blue); }
.subcon-remove-row { width: 36px; height: 36px; }

/* ===== TABLE CONTROLS ===== */
.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.table-search, .table-filter {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.35);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.table-search { flex: 1 1 200px; }
.table-search:focus, .table-filter:focus {
  outline: none; border-color: rgba(59,130,246,0.5);
}

/* ===== NOTIFICATIONS ===== */
#notification-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 10000;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.notification {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  color: white;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: notifSlideIn 300ms ease both;
  max-width: 360px;
}

.notification-success { background: linear-gradient(135deg, #059669, #10b981); }
.notification-warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
.notification-error { background: linear-gradient(135deg, #dc2626, #ef4444); }
.notification-info { background: linear-gradient(135deg, var(--blue-deep), var(--blue)); }
.notification.is-leaving { animation: notifSlideOut 300ms ease both; }

@keyframes notifSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes notifSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  animation: fadeIn 200ms ease;
}

.modal-overlay[hidden] { display: none; }

.modal-dialog {
  width: min(580px, calc(100% - 32px));
  max-height: 82vh;
  overflow-y: auto;
  background: #111827;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: rise 300ms ease both;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px 0;
}

.modal-header h3 { font-size: 1.1rem; color: var(--ink); }

.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,0.07);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.15s;
}

.modal-close:hover { background: rgba(255,255,255,0.12); color: var(--ink); }

.modal-body {
  padding: 16px 22px;
  line-height: 1.65;
  color: var(--ink-soft);
  font-size: 13px;
}

.modal-body ul { margin: 8px 0; padding-left: 18px; }
.modal-body li { margin-bottom: 5px; }
.modal-body .issue-error { color: var(--red); font-weight: 700; }
.modal-body .issue-warning { color: var(--amber); font-weight: 600; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 22px 20px;
}

/* ===== HELP ICON ===== */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(59,130,246,0.12);
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
  transition: background 180ms;
}

.help-icon:hover { background: rgba(59,130,246,0.24); }

.has-tooltip { cursor: help; position: relative; }

.has-tooltip:hover::after {
  content: attr(data-formula);
  position: absolute;
  top: 100%; left: 0;
  margin-top: 6px;
  padding: 8px 12px;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: grid; gap: 8px;
  justify-items: center;
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-muted);
}

.empty-state h3 { color: var(--ink-soft); }
.empty-state p { margin: 0; max-width: 40ch; line-height: 1.65; font-size: 13px; }

/* ===== COMPARISON TABLE ===== */
.comparison-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.comparison-table th, .comparison-table td {
  padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); text-align: left;
}

.comparison-table th {
  font-size: 10.5px; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted);
}

.comparison-table .best-value { color: var(--green); font-weight: 800; }

/* ===== SHORTCUTS ===== */
.shortcuts-list { display: grid; gap: 6px; }

.shortcut-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px; color: var(--ink-soft);
}

.shortcut-key { display: inline-flex; align-items: center; gap: 4px; }

.shortcut-key kbd {
  display: inline-block; padding: 3px 8px; border-radius: 5px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  font-family: inherit; font-size: 11.5px; font-weight: 800; color: var(--ink);
}

/* ===== DRAG ===== */
.drag-handle {
  cursor: grab; color: var(--ink-muted);
  font-size: 1rem; user-select: none; padding: 0 5px;
}
.drag-handle:active { cursor: grabbing; }
tr.is-dragging { opacity: 0.45; background: rgba(59,130,246,0.06); }

/* ===== BUTTON LOADING ===== */
.button.is-loading { position: relative; color: transparent; pointer-events: none; }
.button.is-loading::after {
  content: ''; position: absolute;
  width: 14px; height: 14px;
  border: 2px solid white; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}

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

/* ===== FOCUS ===== */
*:focus-visible {
  outline: 2px solid rgba(59,130,246,0.6);
  outline-offset: 2px; border-radius: 4px;
}
.button:focus-visible { outline-offset: 3px; }
*:focus:not(:focus-visible) { outline: none; }

/* ===== ANIMATION ===== */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1080px) {
  .hero, .matrix-layout, .subcon-layout, .two-columns, .three-columns {
    grid-template-columns: 1fr;
  }
  .tabs-nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .section-heading { align-items: start; flex-direction: column; }
  .section-heading-actions { justify-content: flex-start; }
  .section-heading-actions .section-note { text-align: left; }
  .subcon-meta-grid, .subcon-chart-grid, .subcon-metrics-grid { grid-template-columns: 1fr; }
  .toolbar-row { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { justify-content: center; }
}

@media (max-width: 720px) {
  .page-shell { width: min(100% - 16px, 100%); padding-top: 14px; padding-bottom: 28px; }
  .hero, .section-card { padding: 16px; border-radius: 12px; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.15rem; }
  .matrix-table { min-width: 680px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .button { width: 100%; }
  .hero-actions { width: 100%; }
  .tabs-nav { grid-template-columns: 1fr; position: sticky; top: 0; z-index: 100; background: var(--bg); padding: 8px 0; }
  .tab-button { min-height: 52px; padding: 10px 12px; }
  .tab-copy { font-size: 12px; }
  .subcon-group-head, .subcon-table-header { flex-direction: column; }
  .subcon-slider-row { grid-template-columns: 1fr; }
  .toolbar-btn { width: 100%; justify-content: center; }
  .toolbar-select-label { width: 100%; }
  .toolbar-select { flex: 1; }
  #notification-container { left: 8px; right: 8px; top: 8px; }
  .notification { max-width: 100%; }
}

/* ===== HIGH CONTRAST ===== */
@media (prefers-contrast: high) {
  :root { --ink: #ffffff; --ink-soft: #d1d5db; --border: rgba(255,255,255,0.25); }
  .button-primary { background: #2563eb; border: 2px solid #fff; }
  .decision-pill { border: 2px solid currentColor; }
  .table-input, .field input { border-width: 2px; }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ===== PRINT ===== */
@page { size: A4; margin: 12mm; }

@media print {
  body { background: white; color: #000; }
  .page-shell { width: 100%; padding: 0; }
  .hero, .section-card, .table-wrap, .summary-panel,
  .result-panel, .field, .cia-controls, .mini-stat,
  .subcon-group-card, .subcon-decision-card, .chart-card, .subcon-metric-card {
    background: white; border: 1px solid #ddd; box-shadow: none; backdrop-filter: none;
    color: #000;
  }
  .hero-actions, .tabs-nav, .export-feedback,
  .toolbar-row, .table-controls, #notification-container, .modal-overlay {
    display: none;
  }
  .section-card, .hero { break-inside: avoid; }
  .ink, h1, h2, h3, .category-cell, .weighted-score-cell { color: #000 !important; }
}
