/* ============================================================
 * Pacifico RMS — App stylesheet (built on tokens.css)
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');
@import './tokens.css';

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-2);
  background: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Skylrk shader backdrop (full-viewport, behind UI) ---------- */
.bg-shader-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms ease-out;
}
.bg-shader-canvas.is-active { opacity: 0.95; }
.bg-shader-veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(80% 60% at 50% 20%, rgba(10, 11, 15, 0) 0%, rgba(10, 11, 15, 0.25) 70%, rgba(10, 11, 15, 0.55) 100%);
}
.app-shell { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) {
  .bg-shader-canvas { display: none; }
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: transparent; padding: 0; }
img, svg { display: block; max-width: 100%; }
hr { border: 0; height: 1px; background: var(--border); margin: var(--space-6) 0; }
::selection { background: var(--brand); color: white; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Typography primitives ---------- */
.t-display {
  font-size: var(--fs-5xl);
  line-height: var(--lh-tight);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-1);
}
.t-h1 { font-size: var(--fs-4xl); line-height: var(--lh-tight); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); color: var(--text-1); }
.t-h2 { font-size: var(--fs-3xl); line-height: var(--lh-snug); font-weight: var(--fw-semibold); color: var(--text-1); }
.t-h3 { font-size: var(--fs-2xl); line-height: var(--lh-snug); font-weight: var(--fw-semibold); color: var(--text-1); }
.t-h4 { font-size: var(--fs-xl); line-height: var(--lh-snug); font-weight: var(--fw-medium); color: var(--text-1); }
.t-body { font-size: var(--fs-base); line-height: var(--lh-normal); color: var(--text-2); }
.t-small { font-size: var(--fs-sm); color: var(--text-3); }
.t-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-uppercase);
  color: var(--text-4);
  font-weight: var(--fw-medium);
}
.t-mono { font-family: var(--font-mono); }
.t-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Layout shells ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}
.app-sidebar { grid-area: sidebar; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.app-topbar  { grid-area: topbar;  background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 var(--space-6); gap: var(--space-4); position: sticky; top: 0; z-index: 20; }
.app-main    { grid-area: main; padding: var(--space-7); overflow-y: auto; }
.app-main.is-fluid { padding: 0; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .app-sidebar { display: none; }
}

/* ---------- Sidebar nav ---------- */
.sidebar-brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand-logo {
  width: 32px; height: 32px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand), var(--pacifico));
  display: grid; place-items: center;
  box-shadow: var(--shadow-glow);
  position: relative;
}
.sidebar-brand-logo::after {
  content: '';
  position: absolute; inset: 1px;
  background: var(--surface);
  border-radius: calc(var(--r-md) - 1px);
}
.sidebar-brand-logo svg { position: relative; z-index: 1; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-brand-name { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text-1); letter-spacing: var(--tracking-tight); }
.sidebar-brand-tag  { font-size: var(--fs-xs); color: var(--text-4); letter-spacing: var(--tracking-uppercase); text-transform: uppercase; }

/* Real Pacifico wordmark (replaces the abstract mark) */
.sidebar-brand-real {
  display: flex; align-items: center;
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand-real img {
  height: 30px; width: auto;
  background: #fff; padding: 8px 14px; border-radius: var(--r-md);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.login-brand-real { display: flex; justify-content: center; margin-bottom: var(--space-4); }
.login-brand-real img {
  height: 56px; width: auto;
  background: #fff; padding: 14px 22px; border-radius: var(--r-lg, 12px);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.sidebar-nav { padding: var(--space-3); flex: 1; overflow-y: auto; }
.sidebar-section { margin-top: var(--space-5); }
.sidebar-section:first-child { margin-top: 0; }
.sidebar-section-title {
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-uppercase);
  color: var(--text-4);
  font-weight: var(--fw-medium);
}
.sidebar-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  cursor: pointer;
  margin-bottom: 2px;
}
.sidebar-link:hover { background: var(--surface-2); color: var(--text-1); }
.sidebar-link.is-active {
  background: var(--brand-soft);
  color: var(--text-1);
  position: relative;
}
.sidebar-link.is-active::before {
  content: '';
  position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  box-shadow: 0 0 8px var(--brand-glow);
}
.sidebar-link i { width: 16px; text-align: center; color: var(--text-4); transition: color var(--dur-fast); }
.sidebar-link:hover i, .sidebar-link.is-active i { color: var(--brand); }
.sidebar-link .badge { margin-left: auto; }
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-3);
}

/* ---------- Topbar ---------- */
.topbar-search {
  flex: 1; max-width: 480px; position: relative;
}
.topbar-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 12px 8px 36px;
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.topbar-search input::placeholder { color: var(--text-4); }
.topbar-search input:focus { outline: none; border-color: var(--border-focus); background: var(--surface-2); }
.topbar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-4); }
.topbar-search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 10px;
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-base); color: var(--text-3);
}
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-base);
  border: 1px solid transparent;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn--sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn--lg { padding: 12px 20px; font-size: var(--fs-md); }

.btn--primary { background: var(--brand); color: white; box-shadow: 0 0 0 1px var(--brand), var(--shadow-glow); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--primary:active { background: var(--brand-active); }

.btn--secondary { background: var(--surface-2); color: var(--text-1); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-3); border-color: var(--text-4); }

.btn--ghost { color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text-1); }

.btn--destructive { background: var(--status-denied); color: white; }
.btn--destructive:hover { background: #e11d48; }

.btn--icon { padding: 8px; aspect-ratio: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-6);
}
.card--padless { padding: 0; }
.card--elev { box-shadow: var(--shadow-md); }
.card-header { padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: var(--space-6); }
.card-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text-1); margin: 0; }

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur-base), transform var(--dur-base);
}
.kpi:hover { border-color: var(--border-strong); }
.kpi-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-uppercase); color: var(--text-4); font-weight: var(--fw-medium); margin-bottom: var(--space-3); }
.kpi-value { font-family: var(--font-mono); font-size: var(--fs-4xl); font-weight: var(--fw-semibold); color: var(--text-1); line-height: 1; letter-spacing: var(--tracking-tight); }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; margin-top: var(--space-3); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.kpi-delta.up   { color: var(--status-approved); }
.kpi-delta.down { color: var(--status-denied); }
.kpi-delta.flat { color: var(--text-3); }
.kpi-spark { margin-top: var(--space-3); height: 28px; }

/* ---------- Pills / chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  line-height: 1;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill--draft     { color: var(--status-draft);     background: var(--status-draft-bg);     }
.pill--open      { color: var(--status-open);      background: var(--status-open-bg);      }
.pill--progress  { color: var(--status-progress);  background: var(--status-progress-bg);  }
.pill--review    { color: var(--status-review);    background: var(--status-review-bg);    }
.pill--submitted { color: var(--status-submitted); background: var(--status-submitted-bg); }
.pill--approved  { color: var(--status-approved);  background: var(--status-approved-bg);  }
.pill--paid      { color: var(--status-paid);      background: var(--status-paid-bg);      }
.pill--denied    { color: var(--status-denied);    background: var(--status-denied-bg);    }
.pill--hold      { color: var(--status-hold);      background: var(--status-hold-bg);      }

/* FEMA category chips — square corners, monospace letter badge */
.fema {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 2px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1;
}
.fema-letter {
  font-family: var(--font-mono);
  font-weight: var(--fw-semibold);
  width: 20px; height: 20px;
  border-radius: var(--r-xs);
  display: grid; place-items: center;
  color: var(--text-inverse);
  background: var(--text-3);
}
.fema--a  { background: var(--fema-a-bg);  color: var(--fema-a); } .fema--a  .fema-letter { background: var(--fema-a); }
.fema--b  { background: var(--fema-b-bg);  color: var(--fema-b); } .fema--b  .fema-letter { background: var(--fema-b); }
.fema--c  { background: var(--fema-c-bg);  color: var(--fema-c); } .fema--c  .fema-letter { background: var(--fema-c); }
.fema--d  { background: var(--fema-d-bg);  color: var(--fema-d); } .fema--d  .fema-letter { background: var(--fema-d); }
.fema--e  { background: var(--fema-e-bg);  color: var(--fema-e); } .fema--e  .fema-letter { background: var(--fema-e); }
.fema--f  { background: var(--fema-f-bg);  color: var(--fema-f); } .fema--f  .fema-letter { background: var(--fema-f); color: var(--text-inverse); }
.fema--g  { background: var(--fema-g-bg);  color: var(--fema-g); } .fema--g  .fema-letter { background: var(--fema-g); }
.fema--z  { background: var(--fema-z-bg);  color: var(--fema-z); } .fema--z  .fema-letter { background: var(--fema-z); }

/* Priority */
.prio { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: var(--fw-medium); }
.prio::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.prio--low::before    { background: var(--priority-low); }
.prio--medium::before { background: var(--priority-medium); }
.prio--high::before   { background: var(--priority-high); box-shadow: 0 0 6px var(--priority-high); }
.prio--low    { color: var(--priority-low); }
.prio--medium { color: var(--priority-medium); }
.prio--high   { color: var(--priority-high); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table thead th {
  text-align: left;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-uppercase);
  color: var(--text-4);
  font-weight: var(--fw-medium);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
.table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast) var(--ease-out);
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-2);
  height: var(--row-height);
  vertical-align: middle;
}
.table tbody td.t-num, .table tbody td .t-num { color: var(--text-1); }
.table-id { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-3); }
.table-actions { display: flex; gap: var(--space-1); justify-content: flex-end; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.field-hint  { font-size: var(--fs-xs); color: var(--text-4); }
.field-error { font-size: var(--fs-xs); color: var(--status-denied); }
.field-required::after { content: ' *'; color: var(--status-denied); }

.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-1);
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  background: var(--surface-2);
}
.textarea { resize: vertical; min-height: 96px; line-height: var(--lh-normal); }

.input-group { position: relative; }
.input-group .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.input-group .input { padding-left: 36px; }

/* ---------- Avatars ---------- */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-1);
  border: 1px solid var(--border-strong);
  overflow: hidden;
}
.avatar--sm { width: 24px; height: 24px; font-size: var(--fs-xs); }
.avatar--lg { width: 40px; height: 40px; }

/* ---------- Utility ---------- */
.row { display: flex; align-items: center; gap: var(--space-3); }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: var(--space-3); }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); } .gap-5 { gap: var(--space-5); } .gap-6 { gap: var(--space-6); }
.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); } .mt-5 { margin-top: var(--space-5); } .mt-6 { margin-top: var(--space-6); } .mt-7 { margin-top: var(--space-7); }
.mb-1 { margin-bottom: var(--space-1); } .mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); } .mb-5 { margin-bottom: var(--space-5); } .mb-6 { margin-bottom: var(--space-6); }
.text-1 { color: var(--text-1); } .text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); } .text-4 { color: var(--text-4); }
.brand { color: var(--brand); }
.cyan  { color: var(--pacifico); }
.hide-sm { } @media (max-width: 640px) { .hide-sm { display: none !important; } }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
@media (max-width: 960px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .app-topbar { padding: 0 var(--space-3); gap: var(--space-2); }
  .app-topbar .crumb { display: none; }
  .app-topbar .topbar-cmdk { display: none; }
  .app-main { padding: var(--space-4); }

  .page-header { flex-direction: column; align-items: stretch; gap: var(--space-3); }
  .page-actions { flex-wrap: wrap; gap: var(--space-2); }
  .page-title { font-size: var(--fs-2xl); }
}

/* ---------- Skylrk gradient surface ---------- */
.skylrk-stage {
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--bg-base);
}
.skylrk-stage canvas {
  width: 100%; height: 100%;
  opacity: 0;
  transition: opacity 600ms ease;
}
.skylrk-stage canvas.is-active { opacity: 1; }
.skylrk-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, transparent 0%, rgba(2, 6, 23, 0.65) 70%, rgba(2, 6, 23, 0.92) 100%);
  pointer-events: none;
}

/* ---------- Auth screens ---------- */
.auth-page {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: var(--space-7);
  position: relative;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--space-8) var(--space-7);
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}
.auth-brand {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-7);
}
.auth-brand-mark {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand), var(--pacifico));
  display: grid; place-items: center;
  box-shadow: 0 8px 24px var(--brand-glow);
  position: relative;
}
.auth-brand-mark::after {
  content: ''; position: absolute; inset: 1px;
  background: var(--surface);
  border-radius: calc(var(--r-md) - 1px);
}
.auth-brand-mark svg { position: relative; z-index: 1; }
.auth-title { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); color: var(--text-1); margin: 0 0 4px; }
.auth-subtitle { font-size: var(--fs-base); color: var(--text-3); margin: 0; }
.auth-divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-5) 0; color: var(--text-4); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-uppercase); }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-footer { margin-top: var(--space-6); text-align: center; font-size: var(--fs-sm); color: var(--text-4); }
.auth-footer a { color: var(--brand); font-weight: var(--fw-medium); }
.auth-footer a:hover { color: var(--brand-hover); }
.auth-stamp {
  position: absolute;
  bottom: var(--space-6);
  left: 50%; transform: translateX(-50%);
  font-size: var(--fs-xs);
  color: var(--text-4);
  letter-spacing: var(--tracking-uppercase);
  text-transform: uppercase;
  z-index: 2;
  display: flex; align-items: center; gap: var(--space-2);
}
.auth-stamp::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 8px var(--brand-glow); animation: stamp-pulse 2.4s var(--ease-in-out) infinite; }
@keyframes stamp-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: var(--r-full); background: var(--brand); color: white; font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.badge--muted { background: var(--surface-3); color: var(--text-2); }
.kbd { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg-base); color: var(--text-3); }

/* ---------- Status pill: held + archived (added for 8-state contract) ---------- */
.pill--held     { color: var(--status-held);     background: var(--status-held-bg);     }
.pill--archived { color: var(--status-archived); background: var(--status-archived-bg); }
.pill--in-progress { color: var(--status-progress); background: var(--status-progress-bg); }

/* ---------- Button: locked height (synthesis §3.4) ---------- */
.btn { height: var(--btn-height); padding: 0 14px; }
.btn--sm { height: 28px; padding: 0 10px; }
.btn--lg { height: 44px; padding: 0 20px; }
.btn--icon { width: var(--btn-height); height: var(--btn-height); padding: 0; }

/* ---------- Form fields: locked height ---------- */
.input, .select { height: var(--field-height); padding: 0 12px; }
.textarea { padding: 10px 12px; }
.input { background: var(--bg-elev-1); }  /* recessed under cards */

/* ---------- Sidebar item: locked height ---------- */
.sidebar-link { height: var(--sidebar-item); padding: 0 var(--space-3); }

/* ---------- Side panel (slide-in from right, replaces modals for non-destructive detail) ---------- */
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--side-panel-w);
  background: var(--surface-2);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-xl);
  z-index: 30;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 180ms var(--ease-out);
}
.side-panel.is-open { transform: translateX(0); }
.side-panel-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
  z-index: 25;
}
.side-panel-scrim.is-open { opacity: 1; pointer-events: auto; }
.side-panel-header {
  height: 56px;
  padding: 0 var(--space-5);
  display: flex; align-items: center; gap: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.side-panel-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text-1); flex: 1; }
.side-panel-body { flex: 1; overflow-y: auto; padding: var(--space-6); }
.side-panel-footer { height: 64px; padding: 0 var(--space-5); display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); border-top: 1px solid var(--border); }

/* ---------- Modal (destructive confirms only) ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 40; display: grid; place-items: center; }
.modal {
  width: 400px; background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-6);
}
.modal-title { font-size: var(--fs-xl); font-weight: var(--fw-semibold); color: var(--text-1); margin: 0 0 var(--space-3); }
.modal-body { color: var(--text-3); margin-bottom: var(--space-6); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); }

/* ---------- Command palette (Cmd-K) ---------- */
.cmdk-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 96px;
}
.cmdk {
  width: var(--cmdk-w); max-width: calc(100vw - 48px);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: cmdk-enter 200ms var(--ease-out);
}
@keyframes cmdk-enter {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cmdk-input {
  width: 100%; height: 52px;
  padding: 0 20px;
  border: 0; border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-1);
  font-size: var(--fs-md);
  font-family: var(--font-sans);
}
.cmdk-input::placeholder { color: var(--text-4); }
.cmdk-input:focus { outline: none; }
.cmdk-list { max-height: 420px; overflow-y: auto; padding: var(--space-2); }
.cmdk-section-title {
  padding: var(--space-3) var(--space-3) 6px;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-uppercase);
  color: var(--text-4);
  font-weight: var(--fw-medium);
}
.cmdk-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  font-size: var(--fs-base);
}
.cmdk-item i { width: 16px; color: var(--text-4); }
.cmdk-item kbd { margin-left: auto; }
.cmdk-item.is-focus, .cmdk-item:hover { background: var(--brand-soft); color: var(--text-1); }
.cmdk-item.is-focus i, .cmdk-item:hover i { color: var(--brand); }
.cmdk-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-4);
  color: var(--text-4); font-size: var(--fs-xs);
}
.cmdk-footer kbd + span { margin-right: var(--space-3); margin-left: 6px; }

.cmdk-trigger {
  position: fixed; bottom: var(--space-6); right: var(--space-6);
  z-index: 20;
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  color: var(--text-3);
  font-size: var(--fs-xs);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.cmdk-trigger:hover { color: var(--text-1); border-color: var(--text-4); }

/* ---------- Event log (Stripe-style audit row) ---------- */
.event-log { display: flex; flex-direction: column; }
.event-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: var(--space-4);
  padding: 12px 0;
  align-items: start;
  border-bottom: 1px solid var(--border);
}
.event-row:last-child { border-bottom: 0; }
.event-row .event-time { color: var(--text-4); font-size: var(--fs-sm); font-family: var(--font-mono); padding-top: 1px; }
.event-row .event-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.event-row .event-line { display: flex; align-items: center; gap: var(--space-2); color: var(--text-2); font-size: var(--fs-base); flex-wrap: wrap; }
.event-row .event-id { font-family: var(--font-mono); color: var(--text-3); font-size: var(--fs-sm); }
.event-row .event-sub { color: var(--text-4); font-size: var(--fs-sm); }
.event-row .event-actor { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; }
.event-row .event-icon {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
}
.event-row .event-icon.is-ok   { background: var(--status-approved-bg); color: var(--status-approved); }
.event-row .event-icon.is-warn { background: var(--status-held-bg);     color: var(--status-held); }
.event-row .event-icon.is-err  { background: var(--status-denied-bg);   color: var(--status-denied); }
.event-row .event-icon.is-info { background: var(--status-progress-bg); color: var(--status-progress); }

/* ---------- KPI sparkline strip (dashboard top) ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  transition: border-color var(--dur-base);
}
.kpi-card:hover { border-color: var(--border-strong); }
.kpi-card .kpi-card-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-uppercase); color: var(--text-4); font-weight: var(--fw-medium); }
.kpi-card .kpi-card-value { font-family: var(--font-mono); font-size: 32px; font-weight: var(--fw-semibold); color: var(--text-1); line-height: 1.1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi-card .kpi-card-value .currency { color: var(--text-3); margin-right: 2px; font-weight: var(--fw-regular); }
.kpi-card .kpi-card-spark { height: 28px; margin-top: 4px; }
.kpi-card .kpi-card-delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); margin-top: 4px; }
.kpi-card .kpi-card-delta.up { color: var(--status-approved); }
.kpi-card .kpi-card-delta.down { color: var(--status-denied); }

/* ---------- Photo gallery (damage inventory) ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.photo-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 200ms var(--ease-out); }
.photo-tile:hover img { transform: scale(1.04); }
.photo-tile .photo-meta {
  position: absolute; left: 8px; bottom: 8px;
  font-family: var(--font-mono); font-size: 10px;
  padding: 2px 6px; border-radius: 3px;
  background: rgba(10, 11, 15, 0.7);
  color: var(--text-2);
}

/* ---------- Audit trail timeline (vertical) ---------- */
.audit { position: relative; padding-left: 24px; }
.audit::before {
  content: '';
  position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border-strong);
}
.audit-row { position: relative; padding-bottom: var(--space-4); display: flex; flex-direction: column; gap: 4px; }
.audit-row::before {
  content: '';
  position: absolute; left: -22px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--brand);
  box-shadow: 0 0 0 3px var(--bg-base), 0 0 12px var(--brand-glow);
}
.audit-row.is-ok::before   { border-color: var(--status-approved); box-shadow: 0 0 0 3px var(--bg-base), 0 0 12px rgba(94, 173, 122, 0.4); }
.audit-row.is-warn::before { border-color: var(--status-held); }
.audit-row.is-err::before  { border-color: var(--status-denied); }
.audit-row .audit-time { color: var(--text-4); font-size: var(--fs-xs); font-family: var(--font-mono); }
.audit-row .audit-line { color: var(--text-2); font-size: var(--fs-sm); }
.audit-row .audit-actor { color: var(--text-3); font-size: var(--fs-xs); }

/* ---------- Filter chip bar ---------- */
.chip-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: 0 0 var(--space-4); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}
.chip button { color: var(--text-4); padding: 0 0 0 6px; }
.chip button:hover { color: var(--text-1); }
.chip-clear { font-size: var(--fs-xs); color: var(--brand); padding: 4px 8px; }
.chip-clear:hover { color: var(--brand-hover); }

/* ---------- Breadcrumb ---------- */
.crumb { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-sm); }
.crumb a { color: var(--text-3); transition: color var(--dur-fast); }
.crumb a:hover { color: var(--text-1); }
.crumb .sep { color: var(--text-4); font-size: var(--fs-xs); }
.crumb .last { color: var(--text-1); font-weight: var(--fw-medium); }

/* ---------- Empty state ---------- */
.empty {
  padding: var(--space-9) var(--space-6);
  text-align: center;
  color: var(--text-3);
}
.empty-text { font-size: var(--fs-base); margin-bottom: var(--space-4); }
.empty-cta { display: inline-flex; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.page-title { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); color: var(--text-1); margin: 0; letter-spacing: var(--tracking-tight); }
.page-subtitle { font-size: var(--fs-sm); color: var(--text-3); margin: 4px 0 0; }
.page-actions { display: flex; align-items: center; gap: var(--space-3); }

/* ---------- Detail header (Stripe-style) ---------- */
.detail-header { display: flex; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-6); }
.detail-header .detail-title-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.detail-header .detail-title { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); color: var(--text-1); margin: 0; letter-spacing: var(--tracking-tight); font-family: var(--font-mono); }
.detail-header .detail-meta { display: flex; align-items: center; gap: var(--space-3); margin-top: 8px; color: var(--text-3); font-size: var(--fs-sm); flex-wrap: wrap; }
.detail-header .detail-meta .dot::before { content: '·'; margin: 0 6px; color: var(--text-4); }
.detail-header .detail-actions { margin-left: auto; display: flex; gap: var(--space-2); }

/* ID copy affordance */
.copy-id { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--text-3); font-family: var(--font-mono); font-size: var(--fs-sm); transition: color var(--dur-fast); }
.copy-id:hover { color: var(--text-1); }
.copy-id i { opacity: 0; transition: opacity var(--dur-fast); }
.copy-id:hover i { opacity: 1; }

/* ---------- Category left-rail (4×row-height bar on category-tagged rows) ---------- */
.cat-rail { position: relative; }
.cat-rail::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--text-4); border-radius: 0 var(--r-xs) var(--r-xs) 0; }
.cat-rail.cat-a::before { background: var(--fema-a); }
.cat-rail.cat-b::before { background: var(--fema-b); }
.cat-rail.cat-c::before { background: var(--fema-c); }
.cat-rail.cat-d::before { background: var(--fema-d); }
.cat-rail.cat-e::before { background: var(--fema-e); }
.cat-rail.cat-f::before { background: var(--fema-f); }
.cat-rail.cat-g::before { background: var(--fema-g); }
.cat-rail.cat-z::before { background: var(--fema-z); }

/* ============================================================
   v2 SHARED LAYER — toasts, dropdown menus, soon-tags, banners
   ============================================================ */

/* ---- Toast stack ---- */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 1200;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
  max-width: min(420px, calc(100vw - 40px));
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-2, #14161d); border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
  color: var(--text-1); font-size: 13px; line-height: 1.45;
  animation: toast-in .22s cubic-bezier(.21,1.02,.73,1) both;
}
.toast i { margin-top: 2px; font-size: 13px; color: var(--brand); }
.toast--ok   { border-left-color: var(--status-approved, #3fb27f); }
.toast--ok i { color: var(--status-approved, #3fb27f); }
.toast--warn   { border-left-color: var(--status-held, #d9a13f); }
.toast--warn i { color: var(--status-held, #d9a13f); }
.toast--err   { border-left-color: var(--status-denied, #d9554f); }
.toast--err i { color: var(--status-denied, #d9554f); }
.toast.is-leaving { animation: toast-out .18s ease both; }
.toast-msg b, .toast-msg strong { color: var(--text-1); font-weight: 600; }
.toast-msg { color: var(--text-2); }
.toast-msg .t-mono { font-size: 12px; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.is-leaving { animation: none; } }

/* ---- Dropdown menus (notifications, user, filters) ---- */
.menu-pop {
  position: absolute; z-index: 1100; min-width: 230px;
  background: var(--surface-2, #14161d); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px;
  box-shadow: 0 16px 44px rgba(0,0,0,.5);
  animation: toast-in .16s ease both;
}
.menu-pop-head {
  padding: 8px 10px 6px; font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-4);
  display: flex; align-items: center; justify-content: space-between;
}
.menu-pop-head a { color: var(--brand-hover); font-size: 11px; text-transform: none; letter-spacing: 0; cursor: pointer; }
.menu-pop-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; background: transparent; text-align: left;
  border-radius: 8px; color: var(--text-2); font-size: 13px; cursor: pointer;
}
.menu-pop-item:hover { background: var(--surface-3, rgba(255,255,255,.05)); color: var(--text-1); }
.menu-pop-item i { width: 14px; text-align: center; margin-top: 2px; font-size: 12px; color: var(--text-4); }
.menu-pop-item:hover i { color: var(--brand); }
.menu-pop-item .mi-title { display: block; color: var(--text-1); font-weight: 500; }
.menu-pop-item .mi-sub { display: block; color: var(--text-4); font-size: 11.5px; margin-top: 1px; }
.menu-pop-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-pop-item.is-danger, .menu-pop-item.is-danger i { color: var(--status-denied, #d9554f); }
.notif-dot {
  position: absolute; top: 7px; right: 7px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--status-denied, #d9554f);
  border: 2px solid var(--bg-base); pointer-events: none;
}
.topbar-bell { position: relative; }
.menu-pop-item.is-unread .mi-title::after {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand); margin-left: 6px; vertical-align: middle;
}

/* ---- "Phase 2" soon tag on nav ---- */
.sidebar-link .soon-tag {
  margin-left: auto; font-size: 9px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-4);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 6px;
  opacity: .85;
}
.sidebar-link .soon-tag + .badge { margin-left: 6px; }

/* ---- Inline new-entries banner (timecard) ---- */
.new-entries-banner {
  display: flex; align-items: flex-start; gap: 12px;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  border-radius: 12px; padding: 12px 16px; margin-bottom: var(--space-5, 20px);
  font-size: 13px; color: var(--text-2);
}
.new-entries-banner i { color: var(--brand); margin-top: 2px; }
.new-entries-banner .neb-list { margin: 4px 0 0; padding: 0; list-style: none; }
.new-entries-banner .neb-list li { padding: 2px 0; color: var(--text-3, var(--text-2)); }
.new-entries-banner .neb-close {
  margin-left: auto; background: none; border: 0; color: var(--text-4);
  cursor: pointer; font-size: 13px; padding: 2px 4px;
}
.new-entries-banner .neb-close:hover { color: var(--text-1); }

/* ---- Blocked-approve shake ---- */
@keyframes row-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.is-shake { animation: row-shake .28s ease 2; }
@media (prefers-reduced-motion: reduce) { .is-shake { animation: none; outline: 1px solid var(--status-denied, #d9554f); } }

/* ---- Row highlight for fresh/changed rows ---- */
@keyframes row-glow { from { background: color-mix(in srgb, var(--brand) 16%, transparent); } to { background: transparent; } }
.row-fresh td { animation: row-glow 2.4s ease 1; }

/* ---- Filter pop checkbox rows ---- */
.menu-pop-check { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.menu-pop-check:hover { background: var(--surface-3, rgba(255,255,255,.05)); }
.menu-pop-check input { accent-color: var(--brand); }

/* ---- Photo grid responsive fix (damage inventory) ---- */
@media (max-width: 1100px) { .photo-grid { grid-template-columns: repeat(2, 1fr) !important; } }
@media (max-width: 640px)  { .photo-grid { grid-template-columns: 1fr !important; } }

/* ---- Shared topbar controls (v2): identical chrome on every page ---- */
.topbar-bell {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 8px; color: var(--text-3); position: relative;
  background: transparent; border: 0; cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.topbar-bell:hover { background: var(--surface-2, rgba(255,255,255,.05)); color: var(--text-1); }
.topbar-user {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px; border-radius: 8px;
  color: var(--text-2); background: transparent; border: 0; cursor: pointer;
  font-size: 13px; transition: background .14s ease, color .14s ease;
}
.topbar-user:hover { background: var(--surface-2, rgba(255,255,255,.05)); color: var(--text-1); }
.topbar-user-name { font-weight: 500; }
.topbar-user > i { font-size: 10px; color: var(--text-4); }
