/* ============================================================
   IMTRACK — Global stylesheet
   Tokens & components per 23_UI_DESIGN_SYSTEM.md
   ============================================================ */

:root {
  /* Primary — navy */
  --color-navy-900: #0a1628;
  --color-navy-800: #0f1f3d;
  --color-navy-700: #1a3054;
  --color-navy-600: #1e3a5f;
  --color-navy-100: #dce8f5;
  --color-navy-50:  #eef4fb;

  /* Neutral — slate */
  --color-slate-900: #0f172a;
  --color-slate-700: #334155;
  --color-slate-500: #64748b;
  --color-slate-400: #94a3b8;
  --color-slate-300: #cbd5e1;
  --color-slate-200: #e2e8f0;
  --color-slate-100: #f1f5f9;
  --color-slate-50:  #f8fafc;
  --color-white: #ffffff;

  /* Accent — blue */
  --color-blue-700: #1d4ed8;
  --color-blue-600: #2563eb;
  --color-blue-100: #dbeafe;
  --color-blue-50:  #eff6ff;

  /* Destructive (red — buttons, confirm dialogs only; NOT operational) */
  --color-red-700: #b91c1c; --color-red-600: #dc2626;
  --color-red-200: #fecaca; --color-red-100: #fee2e2; --color-red-50: #fef2f2;

  /* Critical severity (overrun, CRITICAL flag) */
  --color-critical-700: #b45309; --color-critical-600: #b45309;
  --color-critical-200: #fde68a; --color-critical-100: #fef3c7; --color-critical-50: #fffbeb;

  /* Warning severity (attention, WARNING flag) */
  --color-warning-700: #92400e; --color-warning-600: #d97706; --color-warning-500: #f59e0b;
  --color-warning-200: #fde68a; --color-warning-100: #fef3c7; --color-warning-50: #fffbeb;

  /* Green — on track / healthy */
  --color-green-700: #15803d; --color-green-600: #16a34a;
  --color-green-200: #bbf7d0; --color-green-100: #dcfce7; --color-green-50: #f0fdf4;

  /* Flag (indigo-violet) */
  --color-flag-700: #6d28d9; --color-flag-600: #7c3aed;
  --color-flag-200: #ddd6fe; --color-flag-100: #ede9fe; --color-flag-50: #f5f3ff;

  /* Semantic */
  --bg-page: var(--color-slate-50);
  --bg-card: var(--color-white);
  --bg-sidebar: var(--color-navy-900);
  --bg-topbar: var(--color-navy-900);
  --bg-table-head: var(--color-slate-100);
  --bg-row-alt: var(--color-slate-50);
  --bg-row-hover: var(--color-blue-50);
  --bg-row-selected: var(--color-navy-50);

  --text-primary: var(--color-slate-900);
  --text-secondary: var(--color-slate-700);
  --text-muted: var(--color-slate-500);
  --text-disabled: var(--color-slate-400);
  --text-on-dark: #e2e8f0;
  --text-on-dark-muted: #94a3b8;

  --border-default: var(--color-slate-200);
  --border-strong: var(--color-slate-400);
  --border-focus: var(--color-blue-600);

  /* Type */
  --font-sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.9375rem;
  --text-lg: 1.0625rem; --text-xl: 1.25rem; --text-2xl: 1.5rem; --text-3xl: 1.875rem;

  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-xl: 12px;

  --sidebar-w: 240px;
  --topbar-h: 56px;

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 12px rgba(15,23,42,.10);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.18);

  /* tweakable */
  --accent: var(--color-blue-600);
  --accent-hover: var(--color-blue-700);
  --row-pad-y: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { height: 100vh; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--color-slate-300); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--color-slate-400); background-clip: content-box; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; height: 100vh; grid-template-areas: "logo topbar" "sidebar main"; }
.topbar { grid-area: topbar; background: var(--bg-topbar); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--color-navy-700); z-index: 50; }
.logo-area { grid-area: logo; background: var(--bg-sidebar); display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--color-navy-700); border-right: 1px solid var(--color-navy-700); }
.sidebar { grid-area: sidebar; background: var(--bg-sidebar); overflow-y: auto; padding: 12px 0; display: flex; flex-direction: column; }
.main { grid-area: main; overflow-y: auto; background: var(--bg-page); }

.logo-mark { width: 28px; height: 28px; border-radius: 6px; background: linear-gradient(135deg, var(--color-blue-600), #3b82f6); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; letter-spacing: -.5px; flex-shrink: 0; }
.logo-word { color: #fff; font-weight: 600; font-size: 16px; letter-spacing: .5px; }

.topbar-breadcrumb { color: var(--text-on-dark-muted); font-size: var(--text-sm); display: flex; align-items: center; gap: 8px; }
.topbar-breadcrumb .crumb-current { color: var(--text-on-dark); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

/* role switcher */
.role-switch { display: flex; align-items: center; gap: 0; background: var(--color-navy-800); border: 1px solid var(--color-navy-600); border-radius: var(--radius-md); padding: 3px; }
.role-switch button { background: transparent; border: none; color: var(--text-on-dark-muted); font-size: var(--text-xs); font-weight: 500; padding: 5px 11px; border-radius: 4px; cursor: pointer; transition: background .1s; }
.role-switch button:hover { color: var(--text-on-dark); }
.role-switch button.active { background: var(--color-blue-600); color: #fff; }
.role-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-on-dark-muted); margin-right: 2px; }

.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--color-navy-600); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.user-chip .uname { color: var(--text-on-dark); font-size: var(--text-sm); font-weight: 500; line-height: 1.1; }
.user-chip .urole { color: var(--text-on-dark-muted); font-size: 11px; }

/* ---------- Sidebar nav ---------- */
.nav-item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 16px; color: var(--text-on-dark-muted); font-size: var(--text-sm); font-weight: 500; cursor: pointer; border-left: 3px solid transparent; transition: background .1s, color .1s; position: relative; }
.nav-item:hover { background: var(--color-navy-700); color: var(--text-on-dark); }
.nav-item.active { background: var(--color-navy-800); color: #fff; border-left-color: var(--color-blue-600); }
.nav-item.disabled { opacity: .35; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; color: var(--text-on-dark-muted); }
.nav-item svg { flex-shrink: 0; }
.nav-item > span:not(.nav-count) { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count { margin-left: auto; background: #b45309; color: #fff; font-size: 10px; font-weight: 600; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.nav-divider { height: 1px; background: var(--color-navy-700); margin: 8px 16px; }
.nav-section-label { color: var(--text-on-dark-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; padding: 8px 16px 4px; opacity: .7; }

/* ---------- Page ---------- */
.page { padding: 24px; max-width: 1600px; }
.page-wide { max-width: none; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-default); }
.page-title { font-size: var(--text-xl); font-weight: 600; color: var(--text-primary); line-height: 1.2; margin: 0; }
.page-subtitle { font-size: var(--text-sm); color: var(--text-muted); margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---------- Cards ---------- */
.card { background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.card-pad { padding: 20px; }
.card-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border-default); }
.section-title { font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); margin: 0 0 12px; }

/* ---------- Buttons ---------- */
.btn { height: 36px; padding: 0 14px; border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500; border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .1s, border-color .1s, color .1s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--color-white); color: var(--text-primary); border-color: var(--border-default); }
.btn-secondary:hover { background: var(--color-slate-50); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--color-slate-100); color: var(--text-primary); }
.btn-destructive { background: var(--color-red-600); color: #fff; }
.btn-destructive:hover { background: var(--color-red-700); }
.btn-sm { height: 30px; padding: 0 11px; font-size: var(--text-xs); }
.btn-icon { width: 34px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

/* ---------- Inputs ---------- */
.input, .select { height: 34px; padding: 0 11px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--color-white); font-size: var(--text-sm); color: var(--text-primary); font-family: var(--font-sans); }
.input:focus, .select:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.input::placeholder { color: var(--text-muted); }
.input.mono { font-family: var(--font-mono); }
textarea.input { height: auto; min-height: 76px; padding: 8px 11px; resize: vertical; line-height: 1.5; }
.select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 28px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); }
.field-label .req { color: #b45309; margin-left: 2px; }
.field-hint { font-size: var(--text-xs); color: var(--text-muted); }
.field-readonly { height: 34px; display: flex; align-items: center; padding: 0 11px; background: var(--color-slate-100); border: 1px solid var(--border-default); border-radius: var(--radius-md); color: var(--text-secondary); font-size: var(--text-sm); }

/* search input with icon */
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box svg { position: absolute; left: 9px; color: var(--color-slate-400); pointer-events: none; }
.search-box .input { padding-left: 30px; }

/* ---------- Filter bar ---------- */
.filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filterbar .spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 10px; background: var(--color-blue-50); border: 1px solid var(--color-blue-100); color: var(--color-blue-700); border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 500; }
.chip button { background: none; border: none; color: var(--color-blue-700); cursor: pointer; display: flex; padding: 2px; border-radius: 3px; }
.chip button:hover { background: var(--color-blue-100); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 500; max-width: 180px; white-space: nowrap; line-height: 1; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge.muted { opacity: .55; text-decoration: line-through; }
.badge-green { background: var(--color-green-50); color: var(--color-green-700); }
.badge-critical { background: var(--color-critical-50); color: var(--color-critical-700); }
.badge-warning { background: var(--color-warning-50); color: var(--color-warning-700); }
.badge-flag { background: var(--color-flag-50); color: var(--color-flag-700); }
.badge-blue { background: var(--color-blue-50); color: var(--color-blue-700); }
.badge-navy { background: var(--color-navy-50); color: var(--color-navy-600); }
.badge-neutral { background: var(--color-slate-100); color: var(--color-slate-700); }
.badge-imported { background: #ede9fe; color: #7c3aed; font-weight: 600; margin-left: 4px; }
.badge-user { background: #e0f2fe; color: #0369a1; font-size: 10px; padding: 0 5px; height: 18px; }

/* alert badge (solid) */
.abadge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 9px; border-radius: 10px; font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; }
.abadge-critical { background: #b45309; }
.abadge-warning { background: var(--color-warning-600); }
.abadge-flag { background: var(--color-flag-600); }
.abadge-green { background: var(--color-green-600); }

/* traffic light */
.tl-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.tl-square { width: 26px; height: 26px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.tl-green { background: var(--color-green-600); }
.tl-warning { background: var(--color-warning-600); }
.tl-critical { background: var(--color-critical-600); }
.tl-neutral { background: var(--color-slate-300); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); background: var(--color-white); }
.tbl thead th { background: var(--bg-table-head); text-align: left; font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-secondary); padding: 8px 12px; border-bottom: 1.5px solid var(--color-slate-300); white-space: nowrap; position: sticky; top: 0; z-index: 2; }
.tbl thead th.sortable { cursor: pointer; user-select: none; }
.tbl thead th.sortable:hover { color: var(--text-primary); }
.tbl thead th .th-inner { display: inline-flex; align-items: center; gap: 4px; }
.tbl thead th.num-col, .tbl tbody td.num-col { text-align: right; }
.tbl tbody td.sub-col { color: var(--text-muted); font-size: var(--text-xs); }
.tbl tbody td { padding: var(--row-pad-y) 12px; border-bottom: 1px solid var(--color-slate-100); color: var(--text-primary); vertical-align: middle; }
.tbl tbody tr:nth-child(even) { background: var(--bg-row-alt); }
.tbl tbody tr:hover { background: var(--bg-row-hover); }
.tbl tbody tr.row-imported { background: #f5f3ff; }
.tbl tbody tr.row-imported:hover { background: #ede9fe; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.selected { background: var(--bg-row-selected); box-shadow: inset 2px 0 0 var(--color-blue-600); }
.tbl td .neg { color: #b45309; }
.tbl-compact tbody td { padding: 6px 12px; }
.col-actions { width: 1%; white-space: nowrap; }
.cell-actions { display: flex; gap: 2px; }
.icon-btn { width: 28px; height: 28px; border: none; background: transparent; border-radius: var(--radius-sm); color: var(--color-slate-500); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--color-slate-100); color: var(--text-primary); }
.icon-btn.danger:hover { background: var(--color-red-50); color: var(--color-red-600); }

.table-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border-default); flex-wrap: wrap; }
.table-toolbar .spacer { flex: 1; }
.table-meta { font-size: var(--text-xs); color: var(--text-muted); padding: 8px 12px; border-top: 1px solid var(--border-default); display: flex; justify-content: space-between; align-items: center; }

/* empty state */
.empty { text-align: center; padding: 64px 24px; }
.empty svg { color: var(--color-slate-300); margin-bottom: 12px; }
.empty .et { font-size: var(--text-base); color: var(--text-secondary); font-weight: 500; }
.empty .es { font-size: var(--text-sm); color: var(--text-muted); margin-top: 4px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl); padding: 18px 18px 16px; cursor: pointer; transition: border-color .12s, box-shadow .12s; display: flex; flex-direction: column; gap: 4px; }
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.kpi .kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 500; }
.kpi .kpi-num { font-size: 30px; font-weight: 600; color: var(--text-primary); line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .kpi-num.sm { font-size: 24px; }
.kpi .kpi-sub { font-size: 11px; color: var(--text-muted); }
.kpi .kpi-bar { height: 6px; border-radius: 3px; background: var(--color-slate-100); overflow: hidden; margin-top: 4px; }
.kpi .kpi-bar > span { display: block; height: 100%; border-radius: 3px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-default); margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.subtabs { display: inline-flex; background: var(--color-slate-100); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.subtab { padding: 6px 14px; font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); border-radius: 4px; cursor: pointer; border: none; background: transparent; }
.subtab.active { background: #fff; color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; animation: fade .15s ease-out; }
.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 560px; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column; animation: pop .15s ease-out; }
.modal.lg { width: 760px; } .modal.xl { width: 1040px; } .modal.sm { width: 440px; }
.modal-head { padding: 18px 24px; border-bottom: 1px solid var(--border-default); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h3 { margin: 0; font-size: var(--text-lg); font-weight: 600; }
.modal-head .sub { font-size: var(--text-sm); color: var(--text-muted); margin-top: 3px; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border-default); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }

/* form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span2 { grid-column: span 2; }

/* ---------- misc ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-secondary); }
.dash { color: var(--color-slate-400); }
.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mt20{margin-top:20px}.mt24{margin-top:24px}
.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.stat-line { display: flex; align-items: center; gap: 16px; font-size: var(--text-sm); color: var(--text-secondary); flex-wrap: wrap; }
.stat-line .sep { color: var(--color-slate-300); }
.kv { display: flex; flex-direction: column; gap: 3px; }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 500; }
.kv .v { font-size: var(--text-sm); color: var(--text-primary); }

/* expandable caret */
.caret { display: inline-flex; transition: transform .15s; color: var(--color-slate-400); }
.caret.open { transform: rotate(90deg); }

/* progress bar */
.pbar { height: 7px; border-radius: 4px; background: var(--color-slate-100); overflow: hidden; min-width: 60px; }
.pbar > span { display: block; height: 100%; }

/* toast */
.toast-wrap { position: fixed; top: 70px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #fff; border: 1px solid var(--border-default); border-left: 3px solid var(--accent); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 12px 16px; font-size: var(--text-sm); min-width: 260px; animation: slidein .2s ease-out; display: flex; align-items: center; gap: 10px; }
.toast.good { border-left-color: var(--color-green-600); }
.toast.warn { border-left-color: var(--color-warning-600); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }

/* waterfall hierarchy rows */
.wf-schedule td { background: var(--color-navy-800) !important; color: var(--text-on-dark) !important; font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.wf-schedule td .num { color: var(--text-on-dark) !important; }
.wf-line td { background: var(--color-slate-100) !important; font-weight: 600; font-size: var(--text-sm); }
.wf-item td:first-child { padding-left: 32px; }
.wf-toggle { cursor: pointer; }

/* drilldown panel */
.drill { background: var(--color-slate-50); border-top: 1px solid var(--border-default); }
.drill-inner { padding: 12px 16px 14px 32px; }

/* amendment timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--color-slate-200); }
.tl-node { position: relative; margin-bottom: 16px; }
.tl-node::before { content: ""; position: absolute; left: -25px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--color-slate-400); border: 2px solid #fff; }
.tl-node.recent::before { background: var(--color-blue-600); }
.tl-node.original::before { background: #fff; border: 2px dashed var(--color-slate-400); }

/* split panel */
.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }

/* role banner */
.demo-banner { background: var(--color-warning-50); border: 1px solid var(--color-warning-200); color: var(--color-warning-700); font-size: var(--text-xs); padding: 7px 12px; border-radius: var(--radius-md); display: flex; align-items: center; gap: 8px; }

/* settings layout */
.settings-layout { display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.settings-nav button { text-align: left; padding: 9px 12px; border-radius: var(--radius-md); border: none; background: transparent; font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); cursor: pointer; }
.settings-nav button:hover { background: var(--color-slate-100); }
.settings-nav button.active { background: var(--color-navy-50); color: var(--color-navy-600); }

/* permission matrix */
.perm-tbl td, .perm-tbl th { text-align: center; }
.perm-tbl td:first-child, .perm-tbl th:first-child { text-align: left; }
.perm-yes { color: var(--color-green-600); }
.perm-no { color: var(--color-slate-300); }

/* stepper */
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.step { display: flex; align-items: center; gap: 8px; }
.step .sdot { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: 600; background: var(--color-slate-100); color: var(--text-muted); border: 1px solid var(--border-default); }
.step.active .sdot { background: var(--accent); color: #fff; border-color: var(--accent); }
.step.done .sdot { background: var(--color-green-600); color: #fff; border-color: var(--color-green-600); }
.step .slabel { font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); }
.step.active .slabel, .step.done .slabel { color: var(--text-primary); }
.step-line { flex: 1; height: 1px; background: var(--border-default); min-width: 20px; }

.dropzone { border: 2px dashed var(--color-slate-300); border-radius: var(--radius-lg); background: var(--color-slate-50); padding: 40px; text-align: center; color: var(--text-muted); cursor: pointer; }
.dropzone:hover { border-color: var(--accent); background: var(--color-blue-50); }

.summary-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 13px; font-size: var(--text-xs); font-weight: 600; }

/* link */
.link { color: var(--accent); cursor: pointer; font-weight: 500; }
.link:hover { color: var(--accent-hover); text-decoration: underline; }

/* tooltip */
.tip { position: relative; }
.tip:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--color-navy-900); color: #fff; font-size: 11px; padding: 5px 8px; border-radius: 4px; white-space: nowrap; z-index: 30; pointer-events: none; }

/* ---------- Source-owned cell (AFOP & PO tab) ---------- */
:root {
  --color-sky-50: #f0f9ff;
  --color-sky-100: #e0f2fe;
  --color-sky-500: #0ea5e9;
  --color-sky-700: #0369a1;
}
.cell-locked { background: var(--color-sky-50) !important; }
.lock-icon { color: var(--color-sky-500); flex-shrink: 0; }

/* ---------- KPI inline expansion ---------- */
.kpi.expanded { border-color: var(--accent); background: var(--color-blue-50); }
.kpi-detail { grid-column: 1 / -1; background: var(--bg-card); border: 1px solid var(--border-default); border-top: 2px solid var(--accent); border-radius: var(--radius-lg); overflow: hidden; margin-top: -8px; }
.kpi-detail-head { padding: 10px 16px; border-bottom: 1px solid var(--border-default); display: flex; align-items: center; gap: 8px; }

/* ---------- Amendment diff view ---------- */
.diff-old { color: var(--color-warning-700); text-decoration: line-through; }
.diff-new { color: var(--color-green-700); font-weight: 500; }
.impact-preview { background: var(--color-blue-50); border: 1px solid var(--color-blue-100); border-radius: var(--radius-md); padding: 14px 16px; }

/* ---------- AC blocked state ---------- */
.ac-blocked { opacity: 0.7; font-style: italic; }

/* ---------- Alert panel filter tabs ---------- */
.alert-tabs { display: flex; gap: 2px; padding: 8px 16px 0; border-bottom: 1px solid var(--border-default); }
.alert-tab { padding: 6px 14px; font-size: var(--text-xs); font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; white-space: nowrap; }
.alert-tab:hover { color: var(--text-primary); }
.alert-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* ---------- Closeout review panel ---------- */
.closeout-review { background: var(--color-warning-50); border: 1px solid var(--color-warning-200); border-radius: var(--radius-lg); padding: 16px 20px; }
.readiness-checklist { background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: 16px; }
.readiness-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--color-slate-100); font-size: var(--text-sm); }
.readiness-item:last-child { border-bottom: none; }

/* ---------- AC gap column ---------- */
.gap-positive { color: var(--color-sky-700); font-weight: 500; }
.gap-negative { color: var(--color-warning-700); font-weight: 500; }

/* ---------- Deleted row ---------- */
.deleted-row { opacity: 0.5; background: var(--color-slate-100) !important; }
.deleted-row:hover { background: var(--color-slate-100) !important; }

/* ---------- Duplicate row ---------- */
.dupe-row { border-left: 3px solid var(--color-warning-500) !important; }

/* ---------- Locked row ---------- */
.locked-row { border-left: 3px solid var(--color-slate-400) !important; }

/* ---------- SAP dates popup ---------- */
.sap-dates-popup {
  position: absolute; z-index: 20; background: var(--color-navy-800); color: #fff;
  border-radius: 6px; padding: 8px 12px; font-size: 11px; margin-top: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); white-space: nowrap;
}
.sap-date-row { display: flex; gap: 8px; padding: 2px 0; }
.sap-date-row .muted { opacity: 0.6; min-width: 70px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
