/* ============================================================
   ICOS Digital Warehouse v1.0 — Refined Technical Design System
   Canonical direction: thoughts/mockups/06-refined-technical.html
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */

:root,
[data-theme="light"] {
  --bg: #f4f6f8;
  --card: #fff;
  --ink: #1a2332;
  --navy: #1a3a5c;
  --cad-blue: #3d7ea6;
  --blue: #2563a0;
  --gold: #a87820;
  --green: #2d7d4f;
  --red: #c0392b;
  --amber: #a07018;
  --text: #1a2638;
  --muted: #556270;
  --border: #d0d7e0;
  --hover-bg: #f0f4f8;
  --input-bg: #fff;
  --shadow: rgba(61, 126, 166, .10);
  --accent: var(--cad-blue);

  /* Theme-aware backgrounds */
  --badge-live-bg: #e6f4ee;
  --badge-conf-bg: #fdf6e3;
  --badge-offline-bg: #f0f4f8;
  --nav-active-bg: #eaf1f9;
  --card-thumb-bg: linear-gradient(135deg, #eef3f8, #dde6f0);
  --data-item-bg: #f8fafc;
  --alert-warn-bg: #fdf6e3;
  --alert-warn-border: #f5d089;
  --alert-warn-color: #8a5e00;
  --matrix-yes-bg: #e6f4ee;
  --matrix-yes-hover-bg: #c8e6d2;
  --matrix-no-bg: #f8f9fb;

  /* SVG thumbnail palette */
  --svg-body: #d8e2ee;
  --svg-hex: #b0c5d8;
  --svg-stroke: #2a4a6a;
  --svg-dim: #8a9ab0;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --radius: 4px;
}

[data-theme="dark"] {
  --bg: #0f1923;
  --card: #162231;
  --ink: #e1e8f0;
  --navy: #5a9fd4;
  --cad-blue: #4a90c4;
  --blue: #64b5f6;
  --gold: #d4a843;
  --green: #4caf82;
  --red: #e57373;
  --amber: #d4a843;
  --text: #d5dce6;
  --muted: #7a8ea0;
  --border: #1e3048;
  --hover-bg: #1a2d42;
  --input-bg: #1a2638;
  --shadow: rgba(0, 0, 0, .3);
  --accent: var(--cad-blue);

  --badge-live-bg: #1a3a3a;
  --badge-conf-bg: #3a2a1a;
  --badge-offline-bg: #1a2d42;
  --nav-active-bg: #1a2a3a;
  --card-thumb-bg: linear-gradient(135deg, #1a2a3a, #0f1a28);
  --data-item-bg: #1a2232;
  --alert-warn-bg: #3a2a1a;
  --alert-warn-border: #5a4a2a;
  --alert-warn-color: #d4a843;
  --matrix-yes-bg: #1a3a3a;
  --matrix-yes-hover-bg: #1a4a3a;
  --matrix-no-bg: #1a2232;

  --svg-body: #2a3a4a;
  --svg-hex: #3a4a5a;
  --svg-stroke: #8a9ab0;
  --svg-dim: #5a6a7a;
}

/* Theme transition */
[data-theme] { transition: background .3s, color .3s; }
@media (prefers-reduced-motion: reduce) { [data-theme] { transition: none; } }

/* ── Reset ─────────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

/* ── Header ────────────────────────────────────────────────── */

header {
  background: var(--card);
  border-bottom: 2px solid var(--accent);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 30px; height: 30px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.929rem; font-family: var(--mono); font-weight: 600;
}
.logo h1 { font-size: 1rem; font-weight: 600; color: var(--navy); }
.logo small { font-size: 0.714rem; color: var(--muted); display: block; }

/* Header meta area */
.header-right { display: flex; align-items: center; gap: 10px; font-size: 0.786rem; }

/* ── User Menu ──────────────────────────────────────────────── */

.user-menu { position: relative; }
.user-menu-trigger {
  background: none; border: 1px solid var(--border); border-radius: 50%;
  width: 32px; height: 32px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.user-menu-trigger:hover { border-color: var(--accent); background: var(--hover-bg); }

.user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.714rem; font-weight: 600; font-family: var(--mono);
  text-transform: uppercase;
}
.user-avatar-lg {
  width: 36px; height: 36px; font-size: 1rem; flex-shrink: 0;
}

.user-dropdown {
  display: none; position: absolute; top: 38px; right: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 220px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 200; padding: 8px 0;
}
.user-dropdown.open { display: block; }

.user-dropdown-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
}
.user-dropdown-name {
  font-size: 0.929rem; font-weight: 500; color: var(--text);
}
.user-dropdown-role {
  font-size: 0.714rem; color: var(--muted); text-transform: capitalize;
}

.user-dropdown hr {
  border: none; border-top: 1px solid var(--border); margin: 6px 0;
}

.user-dropdown-item {
  display: block; width: 100%; text-align: left; padding: 8px 14px;
  border: none; background: none; font-family: var(--font);
  font-size: 0.857rem; color: var(--text); cursor: pointer;
}
.user-dropdown-item:hover { background: var(--hover-bg); }
.user-dropdown-logout { color: var(--red); }

/* Status badges (non-interactive informational) */
.badge {
  padding: 2px 8px; font-size: 0.714rem; font-weight: 500;
  border: 1px solid var(--border);
  display: inline-flex; align-items: center;
}
.badge-live { background: var(--badge-live-bg); color: var(--green); border-color: transparent; }
.badge-conf { background: var(--badge-conf-bg); color: var(--amber); border-color: transparent; }

/* ── Segmented Controls ────────────────────────────────────── */

.segmented { display: flex; gap: 0; }
.segmented button,
.segmented .seg-btn {
  padding: 4px 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.786rem;
  font-family: var(--font);
  font-weight: 500;
  border-right: none;
  min-height: 32px;
  display: inline-flex; align-items: center;
}
.segmented button:first-child,
.segmented .seg-btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}
.segmented button:last-child,
.segmented .seg-btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-right: 1px solid var(--border);
}
.segmented button.active,
.segmented .seg-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.segmented button:hover:not(.active),
.segmented .seg-btn:hover:not(.active) {
  background: var(--hover-bg);
}

/* ── Layout ────────────────────────────────────────────────── */

.container { display: flex; min-height: calc(100vh - 95px); }

aside {
  width: 220px; min-width: 220px;
  background: var(--card);
  padding: 16px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

aside h2 {
  font-size: 0.857rem; font-weight: 600;
  color: var(--text); margin-bottom: 8px; padding-left: 8px;
}
aside h3 {
  font-size: 0.714rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); margin: 14px 0 8px; padding-left: 8px;
}

/* Navigation — left-edge active indicator */
.nav-item {
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.857rem;
  color: var(--muted);
  margin-bottom: 2px;
  display: flex; align-items: center; gap: 7px;
  border-left: 2px solid transparent;
  min-height: 36px;
}
.nav-item:hover { background: var(--hover-bg); color: var(--ink); }
.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--accent);
  font-weight: 500;
  border-left-color: var(--accent);
}
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: .65; }
.nav-item.active .nav-icon { opacity: 1; }

main { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ── KPI Section (asymmetric 2+1+1+1) ──────────────────────── */

.kpi-section {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.kpi-primary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; justify-content: center;
}
.kpi-primary .kpi-value {
  font-family: var(--mono);
  font-size: 36px; font-weight: 300;
  color: var(--ink); line-height: 1;
}
.kpi-primary .kpi-label {
  font-size: 0.929rem; color: var(--muted); margin-top: 4px;
}
.kpi-primary .kpi-detail {
  font-size: 0.786rem; color: var(--muted); margin-top: 8px;
}
.kpi-secondary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; justify-content: center;
}
.kpi-secondary .kpi-value {
  font-family: var(--mono);
  font-size: 22px; font-weight: 400;
  color: var(--ink); line-height: 1;
}
.kpi-secondary .kpi-label {
  font-size: 0.786rem; color: var(--muted); margin-top: 3px;
}

/* ── Toolbar ────────────────────────────────────────────────── */

.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.toolbar h2 { font-size: 1.286rem; font-weight: 600; }

/* ── Family Bar (segmented control) ────────────────────────── */

.family-bar { display: flex; gap: 0; margin-bottom: 16px; }
.family-chip {
  padding: 5px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.857rem; font-weight: 500;
  color: var(--muted);
  border-right: none;
  font-family: var(--font);
  min-height: 34px;
  display: inline-flex; align-items: center;
}
.family-chip:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.family-chip:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-right: 1px solid var(--border); }
.family-chip:hover:not(.active) { background: var(--hover-bg); }
.family-chip.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.family-chip .count {
  opacity: .6; font-size: 0.786rem; margin-left: 4px;
}

/* ── Card Grid ──────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--shadow);
}
@media (prefers-reduced-motion: reduce) { .card:hover { transition: none; } }

.card-thumb {
  height: 76px;
  background: var(--card-thumb-bg);
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.card-thumb svg { max-height: 60px; width: 100%; }
.card-body { padding: 12px 14px; }

.card-id {
  font-family: var(--mono);
  font-size: 0.786rem; color: var(--accent);
  font-weight: 500; margin-bottom: 2px;
}
.card-title {
  font-size: 0.929rem; font-weight: 500;
  color: var(--ink); margin-bottom: 4px;
}
.card-meta {
  font-size: 0.786rem; color: var(--muted);
  margin-bottom: 8px; font-family: var(--mono);
}
.card-row {
  display: flex; justify-content: space-between;
  align-items: center; font-size: 0.786rem;
}
.card-stats { display: flex; gap: 16px; }
.card-stats b {
  font-family: var(--mono); font-weight: 500;
  font-size: 0.929rem; color: var(--ink);
}

/* ── Tags (rectangular, left-edge accent bar) ──────────────── */

.tag {
  display: inline-flex; align-items: center;
  padding: 1px 6px 1px 5px;
  font-size: 0.714rem; font-weight: 500;
  border: 1px solid var(--border);
  border-left: 2px solid;
  margin-right: 3px;
}
.tag-base { border-left-color: var(--accent); color: var(--accent); }
.tag-pub { border-left-color: var(--green); color: var(--green); }
.tag-dig { border-left-color: var(--amber); color: var(--amber); }
.tag-rev { border-left-color: var(--red); color: var(--red); }
.tag-high { border-left-color: var(--red); color: var(--red); }
.tag-med { border-left-color: var(--amber); color: var(--amber); }
.tag-low { border-left-color: var(--muted); color: var(--muted); }

/* ── Detail ────────────────────────────────────────────────── */

.detail { max-width: 900px; }
.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.detail-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px; margin-bottom: 20px;
}
.detail-head h2 { font-size: 1.286rem; font-weight: 600; }
.detail-head .ref {
  font-family: var(--mono);
  font-size: 0.857rem; color: var(--accent);
  margin: 4px 0 8px;
}
.meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 0.857rem; color: var(--muted); margin-top: 8px;
}

/* ── Tabs ──────────────────────────────────────────────────── */

.tabs { display: flex; gap: 2px; margin-bottom: 16px; }
.tab {
  padding: 8px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.857rem; cursor: pointer;
  color: var(--muted);
  border: 1px solid transparent; border-bottom: none;
  min-height: 36px;
  display: inline-flex; align-items: center;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--card);
  border-color: var(--border);
  color: var(--accent);
  font-weight: 500;
}

/* ── Data Grid ──────────────────────────────────────────────── */

.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.data-item {
  padding: 10px;
  background: var(--data-item-bg);
  border-radius: var(--radius);
}
.data-item label {
  font-size: 0.714rem; font-weight: 500;
  color: var(--muted); display: block;
}
.data-item span {
  font-size: 0.929rem; font-family: var(--mono);
}

.toggle {
  font-size: 0.786rem; color: var(--muted);
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}

/* ── Dashboard panels ──────────────────────────────────────── */

.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* ── Section ───────────────────────────────────────────────── */

.section h4 {
  font-size: 0.857rem; font-weight: 600;
  color: var(--muted); margin-bottom: 8px;
}

/* ── Score ──────────────────────────────────────────────────── */

.score { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.score-bar { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 3px; background: var(--accent); }

/* ── Spec Table ─────────────────────────────────────────────── */

.spec-table { width: 100%; font-size: 0.929rem; border-collapse: collapse; }
.spec-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); }
.spec-table td:first-child { color: var(--muted); width: 40%; }
.spec-table td:last-child { font-family: var(--mono); }

/* ── Buttons (rectangular, border-based) ───────────────────── */

.btn-primary, .btn-gold, .btn-ghost, .btn-onhead {
  padding: 6px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.857rem;
  font-family: var(--font);
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 36px;
}
.btn-primary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-gold {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
}
.btn-gold:hover { background: var(--gold); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--hover-bg); }
.btn-onhead {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
}

/* ── Tables ────────────────────────────────────────────────── */

table { width: 100%; max-width: 100%; border-collapse: collapse; font-size: 0.857rem; }
thead th {
  text-align: left; padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted); font-weight: 600;
  font-size: 0.714rem;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--hover-bg); }

/* ── Modal ──────────────────────────────────────────────────── */

.modal {
  display: none; position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(26, 35, 50, .6); z-index: 100;
  align-items: center; justify-content: center;
}
.modal.show { display: flex; }
.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px; max-width: 480px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-box h3 { margin-bottom: 12px; }
.modal-box label {
  display: block; font-size: 0.857rem;
  color: var(--muted); margin: 10px 0 4px;
}
.modal-box input, .modal-box select, .modal-box textarea {
  width: 100%; padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit; font-size: 0.857rem;
  background: var(--input-bg); color: var(--text);
}
.modal-actions {
  display: flex; justify-content: flex-end;
  gap: 8px; margin-top: 16px;
}

/* ── Alerts ─────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 0.857rem; margin-bottom: 12px;
}
.alert-warn {
  background: var(--alert-warn-bg);
  border: 1px solid var(--alert-warn-border);
  color: var(--alert-warn-color);
}

/* ── Order Form ──────────────────────────────────────────────── */

.order-form-wrapper {
  max-width: 520px;
  margin: 0 auto;
  display: none;
}

.order-form-wrapper.visible {
  display: block;
  margin-top: 20px;
}

.order-form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.order-form-card h4 {
  font-size: 0.929rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.order-form-fieldset {
  border: none;
  padding: 0;
  margin: 0 0 16px 0;
}

.order-form-fieldset:last-of-type {
  margin-bottom: 12px;
}

.order-form-fieldset-legend {
  font-size: 0.714rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding: 0;
}

.order-form-group {
  margin-bottom: 12px;
}

.order-form-group:last-child {
  margin-bottom: 0;
}

.order-form-label {
  display: block;
  font-size: 0.786rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.order-form-input,
.order-form-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.857rem;
  background: var(--input-bg);
  color: var(--text);
  line-height: 1.4;
  transition: border-color .12s;
}

.order-form-input:focus,
.order-form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(61,126,166,.15);
}

.order-form-input::placeholder,
.order-form-textarea::placeholder {
  color: var(--muted);
  opacity: .6;
}

.order-form-textarea {
  resize: vertical;
  min-height: 52px;
}

.order-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.order-form-error {
  color: var(--red);
  margin-top: 10px;
  font-size: 0.786rem;
  display: none;
  padding: 8px 10px;
  background: rgba(192,57,43,.08);
  border-radius: var(--radius);
  border: 1px solid rgba(192,57,43,.2);
}

.order-form-success {
  color: var(--green);
  margin-top: 10px;
  font-size: 0.786rem;
  display: none;
  padding: 8px 10px;
  background: rgba(45,125,79,.08);
  border-radius: var(--radius);
  border: 1px solid rgba(45,125,79,.2);
}

/* Submit button states */
.btn-primary.loading {
  opacity: .7;
  cursor: wait;
  pointer-events: none;
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Empty state ────────────────────────────────────────────── */

.empty {
  text-align: center; padding: 40px 20px;
  color: var(--muted); font-size: 0.929rem;
}

/* ── Footer ─────────────────────────────────────────────────── */

footer {
  text-align: center; padding: 8px;
  font-size: 0.714rem; color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--card);
}

/* ── Header controls ────────────────────────────────────────── */

.header-control {
  cursor: pointer; border: none; font-family: inherit;
  padding: 4px 10px; border-radius: var(--radius);
  font-size: 0.786rem;
  background: var(--hover-bg); color: var(--text);
  min-height: 32px;
  display: inline-flex; align-items: center;
}
[data-theme="dark"] .header-control {
  background: rgba(255,255,255,.12); color: #fff;
}

/* ── Confirm overlay ────────────────────────────────────────── */

.confirm-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(26,35,50,.6); z-index: 200;
  display: none; align-items: center; justify-content: center;
}
.confirm-overlay.show { display: flex; }
.confirm-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px; max-width: 420px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.confirm-box p { margin-bottom: 16px; font-size: 0.929rem; line-height: 1.5; }

/* ── Login page ─────────────────────────────────────────────── */

.login-container {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px; width: 100%; max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand-circle {
  width: 48px; height: 48px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.286rem;
  font-family: var(--mono); font-weight: 600;
  margin: 0 auto 12px;
}
.login-heading {
  font-size: 1.143rem; font-weight: 600;
  color: var(--navy); margin-bottom: 4px;
}
.login-subtitle { font-size: 0.857rem; color: var(--muted); }
.login-input {
  width: 100%; padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.929rem; font-family: inherit;
  background: var(--input-bg); color: var(--text);
}
.login-input:last-of-type { margin-bottom: 20px; }
.login-btn {
  width: 100%; padding: 12px;
  background: var(--navy); color: #fff; border: none;
  border-radius: var(--radius);
  font-size: 0.929rem; font-weight: 500; cursor: pointer;
}
.login-btn:hover { background: var(--blue); }
.login-error-text {
  color: var(--red); margin-top: 12px; text-align: center;
  font-size: 0.857rem; display: none;
}
.login-footer-text {
  text-align: center; margin-top: 24px;
  font-size: 0.714rem; color: var(--muted);
}

body.login-page header,
body.login-page aside,
body.login-page footer { display: none !important; }
body.login-page .container { display: block; }
body.login-page main { padding: 0; margin: 0; }

/* ── Upload error ───────────────────────────────────────────── */

.upload-error {
  color: var(--red); margin-top: 8px;
  font-size: 0.857rem; display: none;
}

/* ── Gestor ─────────────────────────────────────────────────── */

.gestor-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
.gestor-side {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.gap-row {
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; margin-bottom: 4px;
}
.gap-row:hover { background: var(--hover-bg); }
.gap-row.active { background: var(--nav-active-bg); }
.gap-id { font-family: var(--mono); font-size: 0.857rem; }
.gap-bar { height: 4px; background: var(--bg); border-radius: 2px; flex: 1; }
.gap-fill { height: 100%; border-radius: 2px; background: var(--accent); }
.gap-pct { font-family: var(--mono); font-size: 0.786rem; color: var(--muted); }
.slot-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 6px;
  background: var(--card);
}
.slot-row:hover { border-color: var(--accent); }
.slot-mark { font-size: 1.286rem; width: 24px; text-align: center; }
.slot-mark.ok { color: var(--green); }
.slot-mark.miss { color: var(--red); }
.slot-mark.opt { color: var(--muted); }
.slot-info { flex: 1; min-width: 0; }
.slot-label { font-weight: 600; color: var(--navy); font-size: 0.929rem; }
.slot-detail {
  font-size: 0.786rem; color: var(--muted); margin-top: 2px;
  font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot-actions { display: flex; gap: 6px; flex-shrink: 0; }
.slot-cat { margin-bottom: 18px; }
.slot-cat-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; color: var(--navy);
  font-weight: 600; font-size: 0.929rem;
}

/* ── Matrix ─────────────────────────────────────────────────── */

.bsp-matrix-section {
  max-width: 960px;
}

.bsp-matrix-section .section-heading {
  margin-bottom: 8px;
}

.bsp-matrix-section .section-heading h2 {
  font-size: 1.286rem;
  font-weight: 600;
  color: var(--ink);
}

.bsp-matrix-section .section-description {
  font-size: 0.857rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 20px;
  max-width: 600px;
}

.matrix { overflow-x: auto; max-width: 100%; }
.matrix table { font-size: 0.857rem; }
.matrix th {
  font-family: var(--mono); font-size: 0.786rem;
  padding: 6px 12px; text-align: center;
}
.matrix td { text-align: center; padding: 6px; cursor: pointer; }
.matrix .yes { background: var(--matrix-yes-bg); color: var(--green); }
.matrix .yes:hover { background: var(--matrix-yes-hover-bg); }
.matrix .no { background: var(--matrix-no-bg); color: var(--border); }

/* ── BSP Compatibility Matrix (redesigned) ──────────────────── */

.bsp-matrix-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.bsp-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.786rem;
  min-width: 600px;
}

/* Sticky column headers (top row) */
.bsp-matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
  border-bottom: 2px solid var(--border);
  padding: 10px 6px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.714rem;
  color: var(--muted);
  text-align: center;
  min-width: 52px;
  white-space: nowrap;
}

/* Sticky row labels (first column) */
.bsp-matrix-table thead th:first-child,
.bsp-matrix-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--card);
  padding: 8px 10px;
  text-align: left;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.714rem;
  color: var(--muted);
  border-right: 1px solid var(--border);
  min-width: 48px;
  white-space: nowrap;
}

.bsp-matrix-table thead th:first-child {
  z-index: 3; /* top-left corner: above both sticky layers */
}

/* Cells */
.bsp-matrix-cell {
  text-align: center;
  padding: 6px 4px;
  font-family: var(--mono);
  font-size: 0.643rem;
  font-weight: 500;
  transition: background .12s, border-color .12s;
  cursor: default;
  border: 1px solid transparent;
}

.bsp-matrix-cell a,
.bsp-matrix-cell button {
  display: block;
  text-decoration: none;
  color: inherit;
  font: inherit;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: var(--radius);
}

.bsp-matrix-cell.base {
  background: var(--matrix-yes-bg);
  color: var(--green);
  border-color: var(--green);
}
.bsp-matrix-cell.base:hover {
  background: var(--matrix-yes-hover-bg);
}
.bsp-matrix-cell.base a:hover,
.bsp-matrix-cell.base button:hover {
  background: rgba(45,125,79,.1);
}

.bsp-matrix-cell.available {
  background: var(--nav-active-bg);
  color: var(--accent);
  border-color: var(--accent);
}
.bsp-matrix-cell.available:hover {
  background: var(--hover-bg);
}
.bsp-matrix-cell.available a:hover,
.bsp-matrix-cell.available button:hover {
  background: rgba(61,126,166,.1);
}

.bsp-matrix-cell.empty {
  background: transparent;
  color: var(--border);
  border-color: transparent;
}

/* Diagonal (dash1 == dash2) — subtle highlight */
.bsp-matrix-cell.diagonal {
  border-color: var(--border);
}

/* Row hover highlight */
.bsp-matrix-table tbody tr:hover th {
  background: var(--hover-bg);
}

.bsp-matrix-table tbody tr:hover .bsp-matrix-cell.empty {
  background: var(--matrix-no-bg);
}

/* Matrix legend */
.bsp-matrix-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 14px;
  font-size: 0.714rem;
  color: var(--muted);
}

.bsp-matrix-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bsp-matrix-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.bsp-matrix-legend-swatch.base {
  background: var(--green);
}

.bsp-matrix-legend-swatch.available {
  background: var(--accent);
}

.bsp-matrix-legend-swatch.empty {
  background: var(--border);
}

@media (max-width: 768px) {
  .bsp-matrix-wrap {
    border-radius: var(--radius);
  }
  .bsp-matrix-cell {
    font-size: 0.571rem;
    padding: 4px 2px;
  }
  .bsp-matrix-table thead th,
  .bsp-matrix-table tbody th {
    font-size: 0.643rem;
    padding: 6px;
    min-width: 36px;
  }
}

/* ── Completion bar ─────────────────────────────────────────── */

.completion-bar {
  height: 6px; background: var(--bg);
  border-radius: 3px; overflow: hidden; margin: 10px 0;
}
.completion-fill {
  height: 100%; background: var(--accent);
  transition: width .3s;
}

/* ── Status dot ─────────────────────────────────────────────── */

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.status-dot.active { background: var(--green); }
.status-dot.inactive { background: var(--muted); }

/* ── Orders View ─────────────────────────────────────────────── */

.orders-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.orders-main {
  min-width: 0;
}
.orders-side {
  position: sticky;
  top: 20px;
}

/* Filter chips */
.filter-chips {
  display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-chip {
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.786rem;
  font-family: var(--font);
  font-weight: 500;
  min-height: 30px;
}
.filter-chip:hover { background: var(--hover-bg); color: var(--text); }
.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Orders stats row */
.orders-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stat-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  min-width: 120px;
}
.stat-value {
  font-size: 1.286rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.stat-label {
  font-size: 0.714rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Orders table enhancements */
.orders-table tbody tr.order-row:nth-child(4n+3) {
  /* Already handled by .stripe class for clarity across expand/collapse */
}
.orders-table tbody tr.stripe {
  background: var(--data-item-bg);
}
.orders-table tbody tr.order-row {
  cursor: pointer;
}
.orders-table tbody tr.order-row:hover {
  background: var(--hover-bg);
}
.orders-table tbody tr.expanded {
  background: var(--nav-active-bg);
}
.orders-table tbody tr.order-detail {
  display: none;
}
.orders-table tbody tr.order-detail.visible {
  display: table-row;
}
.orders-table tbody tr.order-detail td {
  background: var(--data-item-bg);
  padding: 16px 20px;
  border-bottom: 2px solid var(--border);
}

/* Order row data cells */
.order-row-mono {
  font-family: var(--mono);
}
.order-row-date {
  font-size: 11px;
  color: var(--muted);
}

/* Order detail grid */
.order-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.order-detail-notes {
  margin-top: 8px;
}

.order-detail-notes label {
  font-size: 0.714rem;
  font-weight: 500;
  color: var(--muted);
}

.order-detail-notes p {
  font-size: 0.857rem;
  margin: 4px 0 0 0;
}

/* Empty state */
.empty-state-container {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state-container h3 {
  font-size: 1.143rem;
  font-weight: 600;
  color: var(--text);
  margin: 16px 0 8px;
}
.empty-state-container p {
  font-size: 0.857rem;
  margin-bottom: 20px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
}

/* ── Governance / Docs ────────────────────────────────────────── */

.gov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.gov-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.gov-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--shadow);
}
.gov-card .gov-code {
  font-family: var(--mono);
  font-size: 0.714rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.gov-card .gov-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.3;
}
.gov-card .gov-desc {
  font-size: 0.786rem;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.gov-card .gov-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gov-card .gov-toggle {
  font-size: 0.786rem;
  color: var(--accent);
  font-weight: 500;
}
.gov-card.expanded {
  border-color: var(--accent);
}
.gov-content {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: none;
}
.gov-card.expanded .gov-content {
  display: block;
}
.gov-content h4 {
  font-size: 0.929rem;
  font-weight: 600;
  color: var(--navy);
  margin: 14px 0 6px;
}
.gov-content h4:first-child {
  margin-top: 0;
}
.gov-content p {
  font-size: 0.857rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 10px;
}
.gov-content ul {
  margin: 0 0 10px 18px;
  font-size: 0.857rem;
  color: var(--text);
  line-height: 1.6;
}
.gov-content li {
  margin-bottom: 4px;
}
.gov-content .gov-status {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.714rem;
  font-weight: 500;
  border: 1px solid var(--green);
  color: var(--green);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 768px) {
  .orders-layout { grid-template-columns: 1fr; }
  .orders-side { position: static; }
  .gov-grid { grid-template-columns: 1fr; }
  .stat-item { min-width: 90px; padding: 10px 14px; }
  .stat-value { font-size: 1rem; }
  .container { flex-direction: column; }
  aside { width: 100%; min-width: 0; }
  .gestor-layout { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .dashboard-panels { grid-template-columns: 1fr; }
  .kpi-section { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  header { padding: 8px 12px; }
  header .logo { margin-bottom: 4px; width: 100%; }
  .logo h1 { font-size: 0.929rem; }
  .role-switch { width: 100%; }
  .role-btn { padding: 4px 10px; font-size: 0.714rem; }
  .modal-box, .confirm-box {
    max-width: calc(100% - 24px); width: auto; margin: 12px;
  }
  .nav-item { padding: 8px 10px; font-size: 0.786rem; }
  main { padding: 14px; }
  .card-body { padding: 10px; }
  .detail-card { padding: 16px; }
  .family-chip { padding: 4px 12px; font-size: 0.714rem; }
  .kpi-section { grid-template-columns: 1fr; }
  .kpi-primary .kpi-value { font-size: 28px; }
  .kpi-secondary .kpi-value { font-size: 18px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  aside { width: 56px; min-width: 56px; }
  aside h2, aside h3,
  aside .nav-item span { display: none; }
  aside .nav-item { justify-content: center; padding: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .kpi-section { grid-template-columns: 1fr 1fr 1fr; }
  .kpi-primary { grid-column: span 2; }
}
