/* ============================================================
   BlackBee.W8Fuel.Ai — EFRS design tokens & foundation
   Ported from the W8Sense design system. Bootstrap is still
   loaded during the staged migration; this sheet is linked
   last so its tokens/foundation win on equal specificity.
   ============================================================ */

:root {
  /* Accent (teal — overridden at runtime by the appearance service) */
  --accent: #0E9F9C;
  --accent-2: color-mix(in oklab, var(--accent) 75%, white);
  --accent-soft: color-mix(in oklab, var(--accent) 14%, white);
  --accent-text: white;

  /* Neutrals — cool */
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #FBFCFD;
  --soft: #F1F4F7;
  --line: #E5E9EE;
  --line-strong: #D4DAE2;
  --text: #0F1620;
  --text-2: #3A4654;
  --muted: #6A7585;
  --muted-2: #9098A3;

  /* Status */
  --ok: #16A34A;
  --ok-bg: #DCFCE7;
  --warn: #D97706;
  --warn-bg: #FEF3C7;
  --crit: #DC2626;
  --crit-bg: #FEE2E2;
  --info: #2563EB;
  --info-bg: #DBEAFE;

  /* Radius scale */
  --r1: 6px;
  --r2: 10px;
  --r3: 14px;
  --r4: 20px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(15, 22, 32, 0.05), 0 1px 3px rgba(15, 22, 32, 0.04);
  --shadow-2: 0 4px 12px rgba(15, 22, 32, 0.06), 0 2px 4px rgba(15, 22, 32, 0.04);
  --shadow-3: 0 12px 32px rgba(15, 22, 32, 0.12);

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Density */
  --pad-card: 18px;
  --pad-screen: 28px;
  --gap-grid: 16px;
  --sidebar-w: 248px;
  --topbar-h: 60px;

  /* Native UI (autofill, scrollbars, pickers) follows the theme. */
  color-scheme: light;
}

:root[data-density="compact"] {
  --pad-card: 12px;
  --pad-screen: 20px;
  --gap-grid: 12px;
  --topbar-h: 52px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0F14;
  --surface: #131922;
  --surface-2: #181F2A;
  --soft: #1B2330;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #ECF1F7;
  --text-2: #BCC6D3;
  --muted: #8492A4;
  --muted-2: #5F6C7E;
  --accent-soft: color-mix(in oklab, var(--accent) 22%, #131922);
  --ok-bg: color-mix(in oklab, var(--ok) 18%, #131922);
  --warn-bg: color-mix(in oklab, var(--warn) 18%, #131922);
  --crit-bg: color-mix(in oklab, var(--crit) 18%, #131922);
  --info-bg: color-mix(in oklab, var(--info) 18%, #131922);
  --shadow-1: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-3: 0 12px 32px rgba(0,0,0,0.5);
}

/* ============================================================
   Reset / base
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); cursor: pointer; text-decoration: none; }
a.link:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 500; font-size: 14px;
  border-radius: var(--r2); border: 1px solid transparent;
  transition: background 120ms, border-color 120ms, color 120ms, transform 80ms;
  cursor: pointer; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-md { padding: 9px 14px; }
.btn-lg { padding: 12px 18px; font-size: 15px; }
.btn-primary {
  background: var(--accent); color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: 0 1px 0 color-mix(in oklab, var(--accent) 70%, black) inset;
}
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 88%, black); }
.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--soft); }
.btn-ghost {
  background: transparent; color: var(--text-2); border-color: transparent;
}
.btn-ghost:hover { background: var(--soft); }
.btn-danger {
  background: var(--crit); color: white; border-color: var(--crit);
}
.btn-danger:hover { background: color-mix(in oklab, var(--crit) 88%, black); }
.btn-success {
  background: var(--ok); color: white; border-color: var(--ok);
}
.btn-success:hover { background: color-mix(in oklab, var(--ok) 88%, black); }
.btn-outline-primary {
  background: transparent; color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 45%, transparent);
}
.btn-outline-primary:hover { background: var(--accent-soft); }
.btn-outline-danger {
  background: transparent; color: var(--crit);
  border-color: color-mix(in oklab, var(--crit) 45%, transparent);
}
.btn-outline-danger:hover { background: var(--crit-bg); }
.btn-row { display: inline-flex; gap: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Re-assert token colours on disabled — Bootstrap's .btn-*:disabled has pseudo-class
   specificity that would otherwise win while both sheets are loaded. */
.btn-primary:disabled { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-success:disabled { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger:disabled  { background: var(--crit); border-color: var(--crit); color: #fff; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r2);
  background: transparent; border: 1px solid transparent; color: var(--text-2);
  position: relative;
}
.icon-btn:hover { background: var(--soft); color: var(--text); }

/* ============================================================
   Fields
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r2); padding: 10px 12px;
  transition: border-color 120ms, box-shadow 120ms;
  color: var(--muted);
}
.field-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.field-input input, .field-input select, .field-input textarea {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14.5px; color: var(--text);
  min-width: 0;
}
.field-input textarea { resize: vertical; }
/* Chrome autofill repaint — keeps the surface + text colours on autofill. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}
.field-eye {
  background: transparent; border: none; padding: 2px; color: var(--muted);
  display: inline-flex;
}
.field.has-error .field-input { border-color: var(--crit); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--crit); }

.check {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-2); cursor: pointer; user-select: none; font-size: 13px;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ============================================================
   App shell
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  height: var(--topbar-h);
}
.logo-row { display: flex; align-items: center; gap: 10px; }
.logo-mini {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 8px; background: var(--accent); color: #fff;
  font-weight: 700; font-size: .8rem;
}
.logo-text-sm { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.logo-text-sm span { font-weight: 400; color: var(--muted); }
.logo-text-sm small {
  display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.14em;
  color: var(--muted); text-transform: uppercase;
}
.sidebar-close { display: none; }

.sidebar-nav {
  flex: 1; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.nav-heading {
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted-2); padding: 14px 12px 4px;
  display: flex; align-items: center; gap: 6px;
}
.nav-heading-tag {
  font-size: 9.5px; background: var(--soft); color: var(--muted);
  border-radius: 6px; padding: 1px 6px; letter-spacing: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r2);
  color: var(--text-2); font-size: 14px; font-weight: 500;
  cursor: pointer; position: relative;
}
.nav-item:hover { background: var(--soft); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.nav-item-muted { color: var(--muted); }
.nav-item .nav-ico { display: inline-flex; width: 20px; justify-content: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--crit); color: white;
  font-size: 11px; font-style: normal; font-weight: 600;
  padding: 2px 6px; border-radius: var(--r-pill);
  min-width: 18px; text-align: center;
}
.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.avatar-sm { width: 30px; height: 30px; font-size: 12px; cursor: pointer; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: var(--muted); }

.app-main {
  display: flex; flex-direction: column; min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--pad-screen);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 600; color: var(--text); flex: 1; min-width: 0; }
.mobile-menu { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Persona switcher (mock-auth affordance) */
.persona-switch { display: flex; align-items: center; gap: 6px; }
.persona-switch label { font-size: 12px; color: var(--muted); }
.persona-switch select {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r2); padding: 6px 10px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; font-size: 13.5px; }

.content {
  flex: 1;
  padding: var(--pad-screen);
  min-width: 0;
}

/* ============================================================
   Page heads
   ============================================================ */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-head-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  color: var(--text); /* override Bootstrap's fixed .card colour during migration */
  border: 1px solid var(--line);
  border-radius: var(--r3);
  padding: var(--pad-card);
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; gap: 12px;
}
.card-head h3 { font-size: 14px; }
.card-sub { font-size: 12px; color: var(--muted); }

/* ============================================================
   Badges / pills
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: var(--r-pill);
  white-space: nowrap;
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok);   }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-crit { background: var(--crit-bg); color: var(--crit); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--soft); color: var(--muted); }
.status-dot-inline { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ============================================================
   Segmented control
   ============================================================ */
.seg {
  display: inline-flex; background: var(--soft);
  border-radius: var(--r2); padding: 3px;
}
.seg button {
  background: transparent; border: none; padding: 5px 12px;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  border-radius: 7px; cursor: pointer;
}
.seg button.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-1);
}

/* ============================================================
   Tabs
   ============================================================ */
.tab-row {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  margin-bottom: 16px; overflow-x: auto;
}
.tab {
  background: transparent; border: none; padding: 10px 14px;
  font-size: 13.5px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--text-2); }

/* ============================================================
   Filter bar
   ============================================================ */
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.search-input {
  flex: 1; min-width: 220px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r2); padding: 8px 12px;
  color: var(--muted);
}
.search-input input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--text);
}
.filter-bar select {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r2); padding: 8px 12px;
  font-size: 14px; color: var(--text);
  cursor: pointer;
  min-width: 160px;
}

/* ============================================================
   Form controls (standalone, bordered)
   ============================================================ */
.input, .select, .textarea {
  width: 100%;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r2);
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  transition: border-color 120ms, box-shadow 120ms;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.textarea { resize: vertical; min-height: 84px; }
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--crit); }
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--soft); color: var(--muted); cursor: not-allowed;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.req { color: var(--crit); }

/* Two-column form grid (collapses on narrow screens) */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid > * { min-width: 0; } /* let grid tracks shrink below input intrinsic width */
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-narrow { max-width: 760px; margin: 0 auto; }

/* Inline code + stub box */
code {
  font-family: var(--font-mono); font-size: 0.85em;
  background: var(--soft); padding: 1px 6px; border-radius: 5px; color: var(--accent);
}
.stub-box {
  border: 1px dashed var(--line-strong); border-radius: var(--r2);
  padding: 16px; text-align: center; color: var(--muted); font-size: 13px;
  background: var(--surface-2);
}

/* In-button spinner */
.spinner-sm {
  width: 14px; height: 14px; display: inline-block; vertical-align: -2px; margin-right: 6px;
  border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================
   Dialog / modal
   ============================================================ */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 1090; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r4);
  padding: 24px; width: 100%; max-width: 460px; box-shadow: var(--shadow-3);
}
.dialog h2 { margin-bottom: 16px; }
.dialog-form { display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ============================================================
   Data table
   ============================================================ */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; font-weight: 500; color: var(--muted);
  padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th.num, .data-table td.num { text-align: right; font-family: var(--font-mono); }
.data-table th.center, .data-table td.center { text-align: center; }
.data-table th.right, .data-table td.right { text-align: right; }
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.row-click { cursor: pointer; }
.row-click:hover { background: var(--soft); }

/* ============================================================
   Misc
   ============================================================ */
.empty { padding: 60px; text-align: center; color: var(--muted); }
.empty-small { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.scrim {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 50;
}
.validation-message, .field-validation-error { color: var(--crit); font-size: 12px; }

/* ============================================================
   Stat tiles + dashboard layout
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap-grid);
  margin-bottom: 20px;
}
.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.stat-icon { font-size: 18px; opacity: 0.5; line-height: 1; }
.stat-value {
  font-family: var(--font-mono); font-size: 30px; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.1; color: var(--text);
}
.stat-sub { font-size: 12px; color: var(--muted); }

/* Dashboard: quick actions row + spacing between permission-gated sections */
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.dash-section { display: block; margin-bottom: 24px; }

/* Two-column dashboard rows (collapse to one column on tablet) */
.dash-row { display: grid; gap: var(--gap-grid); grid-template-columns: 5fr 7fr; }
.dash-row.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .dash-row, .dash-row.even { grid-template-columns: 1fr; } }

/* Key/value rows (e.g. severity → count) */
.kv-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line);
}
.kv-row:last-child { border-bottom: none; }
.kv-val { font-weight: 600; font-family: var(--font-mono); }

/* Job-card number + overdue marker (shared across job-card lists) */
.jc-number { font-family: var(--font-mono); font-weight: 600; color: var(--accent); }
.overdue-dot { color: var(--crit); margin-left: 4px; }

/* Horizontal scroll wrapper for wide tables */
.table-wrap { overflow-x: auto; }

/* Spacing helpers (self-contained so they survive Bootstrap removal) */
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.p-4 { padding: 1.5rem; }

/* ============================================================
   Toasts
   ============================================================ */
.toast-stack {
  position: fixed; top: 16px; right: 16px; z-index: 1080;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r2);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-left: 3px solid var(--muted);
  box-shadow: var(--shadow-2);
  animation: toast-in 160ms ease-out;
}
.toast-item.success { border-left-color: var(--ok); }
.toast-item.danger  { border-left-color: var(--crit); }
.toast-item.primary { border-left-color: var(--accent); }
.toast-item.info    { border-left-color: var(--info); }
.toast-item.warning { border-left-color: var(--warn); }
.toast-body { flex: 1; font-size: 13.5px; }
.toast-close {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 0; line-height: 1; font-size: 15px;
}
.toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }

/* ============================================================
   PWA install banner
   ============================================================ */
.install-banner {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 1070; width: calc(100% - 32px); max-width: 460px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 38px 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r2);
  box-shadow: var(--shadow-3);
  animation: install-in 220ms ease-out;
}
.install-badge {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  font-weight: 700; font-size: 15px; letter-spacing: .5px;
}
.install-copy { flex: 1; min-width: 0; }
.install-title { font-weight: 600; font-size: 14px; }
.install-sub { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.install-sub strong { color: var(--text); font-weight: 600; }
.install-sub svg { vertical-align: -3px; }
.install-actions { flex: none; }
.install-actions .btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.install-close {
  position: absolute; top: 8px; right: 8px;
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 2px; line-height: 1; font-size: 14px;
}
.install-close:hover { color: var(--text); }
@keyframes install-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============================================================
   Image upload + thumbnails
   ============================================================ */
.file-drop { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
/* Keep the native input in the DOM (so the label click works) but visually hidden. */
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-drop span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r2);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500;
}
.file-drop:hover span { background: var(--soft); }
.thumb-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.thumb {
  position: relative; width: 84px; height: 84px; border-radius: var(--r2);
  overflow: hidden; border: 1px solid var(--line); background: var(--soft);
  display: block; padding: 0; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Full-image lightbox (data: URLs can't be opened as a new tab, so view in-app). */
.lightbox {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(0, 0, 0, 0.85);
  display: grid; place-items: center; padding: 24px;
  cursor: zoom-out; animation: fade-in 140ms ease-out;
}
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: var(--r2); box-shadow: var(--shadow-3);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.thumb-remove {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.6); color: #fff; cursor: pointer;
  font-size: 11px; line-height: 1; display: grid; place-items: center;
}
.thumb-remove:hover { background: rgba(0,0,0,0.85); }

/* Loading spinner */
.loading-wrap { display: grid; place-items: center; padding: 60px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--soft); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive table column visibility (scroll mode, above the card breakpoint) */
@media (max-width: 768px) { .hide-tablet { display: none !important; } }
@media (max-width: 480px) { .hide-phone { display: none !important; } }

/* Long-text cell: capped width + two-line clamp so descriptions don't force the table wide.
   The clamp lives on an inner element — a <td> must stay display:table-cell in table mode. */
.cell-desc { max-width: 320px; }
.cell-desc .clamp-2 {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden;
}

/* ============================================================
   Data grid -> stacked cards on phones
   A grid marked `.data-table.cards` collapses each row into a
   labelled card (label pulled from each cell's data-label), so
   every field stays visible on a phone with no horizontal scroll
   and no dropped columns.
   ============================================================ */
@media (max-width: 640px) {
  .data-table.cards,
  .data-table.cards tbody,
  .data-table.cards tr { display: block; }

  /* Header row is redundant once each cell carries its own label. */
  .data-table.cards thead { display: none; }

  .data-table.cards tr {
    border: 1px solid var(--line); border-radius: var(--r2);
    padding: 2px 14px; margin-bottom: 10px; background: var(--surface-2);
  }
  .data-table.cards tr:last-child { margin-bottom: 0; }

  .data-table.cards td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; text-align: right; white-space: normal; overflow-wrap: anywhere;
    padding: 8px 0; border-bottom: 1px solid var(--line);
  }
  .data-table.cards td:last-child { border-bottom: none; }
  .data-table.cards td:empty { display: none; }

  /* Field label, drawn from each cell's data-label attribute. */
  .data-table.cards td::before {
    content: attr(data-label); flex: none; text-align: left;
    font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--muted);
  }

  /* First cell reads as the card title: prominent, left-aligned, unlabelled. */
  .data-table.cards td.cell-title {
    justify-content: flex-start; text-align: left;
    font-size: 14px; font-weight: 600; padding: 10px 0 9px;
  }
  .data-table.cards td.cell-title::before { content: none; }

  /* Long-text cell: label above, full text below (no clamp — show everything). */
  .data-table.cards td.cell-desc {
    flex-direction: column; align-items: stretch; text-align: left;
    gap: 3px; max-width: none;
  }
  .data-table.cards td.cell-desc .clamp-2 { -webkit-line-clamp: unset; }

  /* Action cell (buttons): full-width, right-aligned, unlabelled. */
  .data-table.cards td.cell-actions { justify-content: flex-end; }
  .data-table.cards td.cell-actions::before { content: none; }
  .data-table.cards td.cell-actions .btn { width: 100%; }

  /* Cards have vertical room, so restore columns dropped in scroll mode. */
  .data-table.cards .hide-tablet,
  .data-table.cards .hide-phone { display: flex !important; }
}

/* Table footer (pagination) */
.table-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 14px; gap: 12px; flex-wrap: wrap;
}

/* ============================================================
   Detail screen (job card)
   ============================================================ */
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 13px; margin-bottom: 12px;
}
.back-link:hover { color: var(--text); }

.detail-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.detail-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-title-row h1 { margin: 0; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-cols {
  display: grid; gap: var(--gap-grid);
  grid-template-columns: 2fr 1fr; align-items: start;
}
@media (max-width: 900px) { .detail-cols { grid-template-columns: 1fr; } }
.detail-col { display: flex; flex-direction: column; gap: var(--gap-grid); }

/* Definition list (key/value details) */
.info-grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.info-grid dt { color: var(--muted); font-weight: 500; font-size: 13px; }
.info-grid dd { margin: 0; font-weight: 500; font-size: 13.5px; min-width: 0; overflow-wrap: anywhere; }

/* Activity timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline:before {
  content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px;
  width: 2px; background: var(--line);
}
.timeline li { position: relative; padding: 0 0 14px 26px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:before {
  content: ""; position: absolute; left: 1px; top: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
}
.t-action { font-weight: 600; font-size: 13.5px; text-transform: capitalize; }
.t-meta { font-size: 12.5px; color: var(--muted); }

/* Comments */
.comment {
  border: 1px solid var(--line); border-radius: var(--r2);
  padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2);
}
.comment .c-head { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.comment .c-author { font-weight: 600; color: var(--text-2); }

/* Inline notice (warning/info banner) */
.notice {
  padding: 14px 16px; border-radius: var(--r2);
  background: var(--warn-bg); color: var(--warn);
  border: 1px solid color-mix(in oklab, var(--warn) 30%, transparent);
}
.notice-info {
  background: var(--info-bg); color: var(--info);
  border-color: color-mix(in oklab, var(--info) 30%, transparent);
}
.notice-success {
  background: var(--ok-bg); color: var(--ok);
  border-color: color-mix(in oklab, var(--ok) 30%, transparent);
}
.notice-error {
  background: var(--crit-bg); color: var(--crit);
  border-color: color-mix(in oklab, var(--crit) 30%, transparent);
}
.notice-sm { padding: 10px 12px; font-size: 12.5px; }
.pre-wrap { white-space: pre-wrap; }
.btn-block { width: 100%; }

/* ============================================================
   Appearance settings page
   ============================================================ */
.appearance-card { margin-bottom: 16px; }
.appearance-seg button { display: inline-flex; align-items: center; gap: 6px; }
.accent-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.accent-picker {
  width: 40px; height: 40px; padding: 2px; cursor: pointer;
  background: transparent; border: 1px solid var(--line-strong); border-radius: var(--r2);
}
.accent-hex { background: var(--soft); padding: 3px 10px; border-radius: var(--r-pill); font-size: 12.5px; }
.swatch-row { display: inline-flex; gap: 8px; }
.swatch {
  width: 26px; height: 26px; padding: 0; cursor: pointer;
  border-radius: 7px; background: var(--swatch);
  border: 1px solid color-mix(in oklab, var(--text) 14%, transparent);
}
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.appearance-foot { margin-top: 4px; }

/* ============================================================
   Auth screens (split-screen brand + card)
   ============================================================ */
.auth-shell {
  display: grid; grid-template-columns: 1.05fr 1fr;
  min-height: 100vh; background: var(--bg);
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}
.auth-brand {
  background: linear-gradient(155deg, var(--accent) 0%, color-mix(in oklab, var(--accent) 60%, #0a0f1a) 100%);
  color: white; padding: 40px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-brand::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.16), transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(0,0,0,0.18), transparent 50%);
  pointer-events: none;
}
.auth-brand::after {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  mask-image: linear-gradient(180deg, transparent, black 30%, black 70%, transparent);
  pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand-mark { display: flex; align-items: center; gap: 12px; }
.auth-brand .logo {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: rgba(255,255,255,0.14); border-radius: 10px;
  font-weight: 700; font-size: 14px;
}
.auth-brand .logo-text { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.auth-brand .logo-text span { font-weight: 400; opacity: 0.75; }
.auth-brand-copy h1 { font-size: 38px; line-height: 1.1; font-weight: 600; max-width: 460px; }
.auth-brand-copy p { margin-top: 16px; max-width: 460px; font-size: 15px; opacity: 0.85; line-height: 1.55; }
.auth-brand-meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; opacity: 0.9; }
.ticker { display: flex; align-items: center; gap: 8px; }
.ticker .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6EE7B7; box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.25);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: var(--r4);
  padding: 36px; box-shadow: var(--shadow-2); border: 1px solid var(--line);
}
@media (max-width: 900px) {
  .auth-card { box-shadow: none; border: none; padding: 24px; max-width: 460px; }
}
.auth-head { margin-bottom: 24px; }
.auth-head h2 { font-size: 24px; margin-bottom: 6px; }
.auth-head p { color: var(--muted); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-foot { text-align: center; margin-top: 4px; font-size: 14px; color: var(--muted); }

/* ============================================================
   Responsive (mobile/tablet)
   ============================================================ */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 280px;
    transform: translateX(-100%); transition: transform 220ms;
    z-index: 60; box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .mobile-menu { display: inline-flex; }
  .scrim { display: block; }
  .content { padding: 16px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .persona-switch label { display: none; }
  h1 { font-size: 20px; }
}

/* ============================================================
   Settings (combined Appearance + EFRS) — tab shell
   ============================================================ */
.settings-layout {
  display: grid; grid-template-columns: 200px 1fr; gap: 20px;
}
@media (max-width: 720px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; }
}
.settings-nav {
  display: flex; flex-direction: column; gap: 2px;
}
.settings-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r2);
  color: var(--text-2); font-size: 14px; font-weight: 500; cursor: pointer;
  white-space: nowrap;
}
.settings-nav a:hover { background: var(--soft); color: var(--text); }
.settings-nav a.active { background: var(--accent-soft); color: var(--accent); }
.settings-content { min-width: 0; }
