@import url('https://fonts.googleapis.com/css2?family=Fustat:wght@200;300;400;500;600;700;800&display=swap');

/* ── Design tokens ───────────────────────────────────────────── */
:root {
  /* Surfaces */
  --ph-page:          #F8F5F0;
  --ph-surface:       #FFFFFF;
  --ph-surface-elev:  #FFFDFB;
  --ph-surface-muted: #F4F1EB;

  /* Ink */
  --ph-ink:   #1D1D1D;
  --ph-ink-2: #3F3D3A;
  --ph-ink-3: #6B6760;
  --ph-ink-4: #9A958C;

  /* Brand */
  --ph-orange:     #F77C0B;
  --ph-orange-600: #E56F00;
  --ph-orange-100: #FFE3C2;
  --ph-orange-50:  #FFF4E6;

  /* Borders */
  --ph-border:        #ECE7DE;
  --ph-border-strong: #D9D2C5;

  /* Semantic */
  --ph-success: #1E8A55;
  --ph-warn:    #B5751A;
  --ph-danger:  #C0392B;
  --ph-info:    #2B5BD7;
  --ph-success-bg: #E4F4EB;
  --ph-warn-bg:    #FBEFD8;
  --ph-danger-bg:  #FBE4DF;
  --ph-info-bg:    #E2EAFB;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Shadow */
  --sh-1: 0 1px 0 rgba(29,29,29,.04), 0 1px 2px rgba(29,29,29,.04);
  --sh-2: 0 4px 12px -2px rgba(29,29,29,.08);
  --sh-3: 0 18px 40px -12px rgba(29,29,29,.18);

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px;

  /* Sidebar / topbar */
  --sidebar-w: 248px;
  --topbar-h:  56px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }
body {
  font-family: 'Fustat', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--ph-page);
  color: var(--ph-ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────────────── */
.t-display { font-size: 28px; line-height: 34px; font-weight: 800; color: var(--ph-ink); margin: 0; letter-spacing: -.01em; }
.t-h1      { font-size: 22px; line-height: 28px; font-weight: 800; color: var(--ph-ink); margin: 0; letter-spacing: -.005em; }
.t-h2      { font-size: 17px; line-height: 24px; font-weight: 700; color: var(--ph-ink); margin: 0; }
.t-body    { font-size: 14px; line-height: 22px; color: var(--ph-ink-2); margin: 0; }
.t-muted   { font-size: 13px; line-height: 20px; color: var(--ph-ink-3); margin: 0; }
.t-label   { font-size: 11px; line-height: 16px; font-weight: 700; color: var(--ph-ink-3); text-transform: uppercase; letter-spacing: .06em; }
.t-mono    { font-family: 'IBM Plex Mono','SFMono-Regular',Menlo,monospace; font-size: 13px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.ph-btn {
  background: var(--ph-orange);
  color: white;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--r-md);
  padding: 9px 16px;
  border: 1px solid var(--ph-orange);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-align: center;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .08s;
  line-height: 1.2;
}
.ph-btn:hover  { background: var(--ph-orange-600); border-color: var(--ph-orange-600); }
.ph-btn:active { transform: translateY(1px); }
.ph-btn:disabled { background: var(--ph-border-strong); border-color: var(--ph-border-strong); cursor: not-allowed; }
.ph-btn-block { display: flex; width: 100%; justify-content: center; }
.ph-btn-sm    { padding: 6px 12px; font-size: 12px; }

.btn-outline {
  background: var(--ph-surface);
  border: 1px solid var(--ph-border-strong);
  color: var(--ph-ink-2);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--r-md);
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-outline:hover { border-color: var(--ph-orange); color: var(--ph-orange); }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--ph-ink-3);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, color .15s;
}
.btn-ghost:hover { background: var(--ph-surface-muted); color: var(--ph-ink); }

.btn-danger {
  background: var(--ph-surface);
  border: 1px solid var(--ph-border-strong);
  color: var(--ph-danger);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--r-md);
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-danger:hover { background: var(--ph-danger); border-color: var(--ph-danger); color: white; }

.btn-success {
  background: var(--ph-success);
  border: 1px solid var(--ph-success);
  color: white;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--r-md);
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .15s;
}
.btn-success:hover { background: #166d44; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ph-ink-3);
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--ph-surface-muted); color: var(--ph-ink); }
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.75; }

/* Lucide icon sizing defaults */
[data-lucide] { width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; }

/* ── Form inputs ─────────────────────────────────────────────── */
.input-field {
  border: 1px solid var(--ph-border-strong);
  border-radius: var(--r-md);
  padding: 9px 12px;
  width: 100%;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--ph-surface);
  color: var(--ph-ink);
  transition: border-color .15s, box-shadow .15s;
}
.input-field:focus {
  border-color: var(--ph-orange);
  box-shadow: 0 0 0 3px rgba(247,124,11,.16);
}
.input-field::placeholder { color: var(--ph-ink-4); }
.input-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--ph-ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.form-row { margin-bottom: 14px; }

select.input-field, select.filter-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6760' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Search-prefixed input */
.search-wrap { position: relative; display: inline-flex; align-items: center; flex: 1; min-width: 0; }
.search-wrap [data-lucide] { position: absolute; left: 11px; color: var(--ph-ink-3); pointer-events: none; }
.search-wrap .input-field { padding-left: 34px; }

/* ── Plates & photos ─────────────────────────────────────────── */
.plate-hero {
  background: var(--ph-ink);
  color: white;
  font-weight: 800;
  letter-spacing: .12em;
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-size: 26px;
  text-align: center;
  display: block;
  font-family: 'Courier New', monospace;
}

/* ── Status badges ───────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.5;
  text-transform: capitalize;
}
.badge-violator,
.badge-overdue,
.badge-danger      { background: var(--ph-danger-bg);  color: var(--ph-danger); }
.badge-clean,
.badge-paid,
.badge-issued,
.badge-active,
.badge-success     { background: var(--ph-success-bg); color: var(--ph-success); }
.badge-whitelisted,
.badge-tenant,
.badge-pending,
.badge-info        { background: var(--ph-info-bg);    color: var(--ph-info); }
.badge-unpaid,
.badge-warn,
.badge-disability,
.badge-expiring    { background: var(--ph-warn-bg);    color: var(--ph-warn); }
.badge-voided,
.badge-skipped,
.badge-contractor,
.badge-inactive,
.badge-neutral     { background: var(--ph-surface-muted); color: var(--ph-ink-3); }
.badge-brand       { background: var(--ph-orange-50);  color: var(--ph-orange-600); }
.badge-staff       { background: #EFE7F8;              color: #6B3FA0; }
.badge-visitor     { background: #DEF4F0;              color: #0F6B5A; }
.badge-expired     { background: var(--ph-surface-muted); color: var(--ph-ink-4); text-decoration: line-through; }
.badge-important   { background: var(--ph-orange);    color: white; }

/* Dot variant */
.dot-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--ph-ink-2);
}
.dot-badge::before {
  content: ''; width: 8px; height: 8px; border-radius: 9999px; background: var(--ph-ink-4);
}
.dot-badge.dot-success::before  { background: var(--ph-success); }
.dot-badge.dot-warn::before     { background: var(--ph-warn); }
.dot-badge.dot-danger::before   { background: var(--ph-danger); }
.dot-badge.dot-brand::before    { background: var(--ph-orange); }
.dot-badge.dot-info::before     { background: var(--ph-info); }

/* ── Stat cards ──────────────────────────────────────────────── */
.stat-card {
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--sh-1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 124px;
  transition: border-color .15s, box-shadow .15s;
}
.stat-card:hover { border-color: var(--ph-border-strong); box-shadow: var(--sh-2); }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-card-label { font-size: 11px; font-weight: 700; color: var(--ph-ink-3); text-transform: uppercase; letter-spacing: .06em; }
.stat-card-icon  { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--ph-orange-50); color: var(--ph-orange-600); display: inline-flex; align-items: center; justify-content: center; }
.stat-card-icon [data-lucide] { width: 18px; height: 18px; }
.stat-card-value { font-size: 28px; font-weight: 800; color: var(--ph-ink); line-height: 1.05; letter-spacing: -.01em; }
.stat-card-foot  { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 9999px;
}
.stat-delta.up   { background: var(--ph-success-bg); color: var(--ph-success); }
.stat-delta.down { background: var(--ph-danger-bg);  color: var(--ph-danger); }
.stat-delta.flat { background: var(--ph-surface-muted); color: var(--ph-ink-3); }
.stat-spark { height: 28px; flex: 1; }
.stat-spark svg { display: block; width: 100%; height: 100%; }
.stat-progress {
  height: 6px; background: var(--ph-surface-muted); border-radius: 9999px; overflow: hidden; flex: 1;
}
.stat-progress > span { display: block; height: 100%; background: var(--ph-orange); border-radius: 9999px; }
.stat-progress.bar-success > span { background: var(--ph-success); }
.stat-progress.bar-warn > span    { background: var(--ph-warn); }
.stat-progress.bar-danger > span  { background: var(--ph-danger); }

.stat-ring { position: relative; width: 56px; height: 56px; }
.stat-ring svg { transform: rotate(-90deg); }
.stat-ring .ring-track { stroke: var(--ph-surface-muted); }
.stat-ring .ring-value { stroke: var(--ph-orange); transition: stroke-dashoffset .5s; }
.stat-ring .ring-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--ph-ink);
}

/* ── Tables ──────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  background: var(--ph-surface-muted);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--ph-ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--ph-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.admin-table td {
  padding: 12px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--ph-border);
  vertical-align: middle;
  color: var(--ph-ink-2);
}
.admin-table tbody tr { cursor: pointer; transition: background .12s; }
.admin-table tbody tr:hover { background: var(--ph-surface-muted); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table td .row-title { font-weight: 700; color: var(--ph-ink); }
.admin-table td .row-sub   { font-size: 12px; color: var(--ph-ink-3); margin-top: 2px; }
.admin-table .col-right { text-align: right; }
.admin-table .col-actions { text-align: right; white-space: nowrap; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-top: 1px solid var(--ph-border);
  font-size: 12.5px; color: var(--ph-ink-3);
  background: var(--ph-surface-elev);
}
.pagination-controls { display: inline-flex; gap: 6px; }

/* ── Panel ───────────────────────────────────────────────────── */
.panel {
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ph-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-title { font-size: 15px; font-weight: 800; color: var(--ph-ink); margin: 0; }
.panel-subtitle { font-size: 12.5px; color: var(--ph-ink-3); margin: 2px 0 0; }
.panel-body { padding: 18px 20px; }
.panel-body.flush { padding: 0; }

/* ── Slide-over ──────────────────────────────────────────────── */
.slide-over {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(520px, 100vw);
  background: var(--ph-surface-elev);
  box-shadow: var(--sh-3);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  z-index: 300;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.slide-over.open { transform: translateX(0); }
.slide-over-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,12,8,.34);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.slide-over-backdrop.open { opacity: 1; pointer-events: auto; }
.slide-over-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ph-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  background: var(--ph-surface-elev);
  z-index: 1;
}
.slide-over-body { padding: 18px 20px; flex: 1; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,12,8,.42);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--ph-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--ph-border);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sh-3);
  transform: translateY(12px);
  transition: transform .2s;
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ph-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 18px 20px; }

/* ── App shell ───────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--ph-ink);
  color: rgba(255,255,255,.78);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand {
  padding: 18px 20px 12px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-section {
  padding: 14px 14px 4px 18px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.42);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px 9px 15px;
  color: rgba(255,255,255,.74);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: white; }
.nav-item.active {
  background: rgba(247,124,11,.16);
  color: var(--ph-orange-50);
  border-left-color: var(--ph-orange);
}
.nav-item [data-lucide] { width: 17px; height: 17px; stroke-width: 1.6; opacity: .85; }
.nav-item.active [data-lucide] { color: var(--ph-orange); opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 9999px;
  background: rgba(255,255,255,.12);
  color: white;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px;
  flex-shrink: 0;
}
.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .user-name { color: white; font-weight: 700; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .user-role { color: rgba(255,255,255,.55); font-size: 11px; }
.sidebar-footer .icon-btn { color: rgba(255,255,255,.6); }
.sidebar-footer .icon-btn:hover { background: rgba(255,255,255,.08); color: white; }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(15,12,8,.45);
  z-index: 99;
  display: none;
}
.sidebar-overlay.open { display: block; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--ph-surface);
  border-bottom: 1px solid var(--ph-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  z-index: 50;
}
.topbar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar-title .crumb {
  font-size: 11.5px; color: var(--ph-ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
.topbar-title .page-title { font-size: 16px; font-weight: 800; color: var(--ph-ink); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-search {
  width: 240px;
  max-width: 30vw;
  position: relative;
  display: flex; align-items: center;
}
.topbar-search [data-lucide] { position: absolute; left: 10px; color: var(--ph-ink-3); }
.topbar-search input {
  width: 100%;
  border: 1px solid var(--ph-border);
  background: var(--ph-surface-muted);
  border-radius: var(--r-md);
  padding: 7px 10px 7px 32px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ph-ink);
  outline: none;
  transition: border-color .15s, background .15s;
}
.topbar-search input:focus { border-color: var(--ph-orange); background: var(--ph-surface); }
.topbar-search kbd {
  position: absolute; right: 8px;
  font-family: inherit; font-size: 10.5px;
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ph-ink-3);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-md);
  color: var(--ph-ink-2);
}
.hamburger:hover { background: var(--ph-surface-muted); }

.main-content {
  grid-column: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.main-canvas {
  flex: 1;
  padding: 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { grid-column: 1; }
  .hamburger { display: inline-flex; }
  .topbar-search { width: 160px; }
  .main-canvas { padding: 16px; }
}

/* ── Page header (in-canvas, when used) ──────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-header-content .page-title { font-size: 22px; font-weight: 800; color: var(--ph-ink); margin: 0; letter-spacing: -.005em; }
.page-header-content .page-subtitle { font-size: 13.5px; color: var(--ph-ink-3); margin: 4px 0 0; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Upload zone ─────────────────────────────────────────────── */
.upload-zone {
  border: 1.5px dashed var(--ph-border-strong);
  background: var(--ph-surface-elev);
  border-radius: var(--r-lg);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--ph-orange);
  background: var(--ph-orange-50);
}
.upload-zone-icon {
  width: 48px; height: 48px;
  border-radius: 9999px;
  background: var(--ph-orange-50);
  color: var(--ph-orange-600);
  display: inline-flex;
  align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.upload-zone-icon [data-lucide] { width: 22px; height: 22px; }

/* ── Filter bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px;
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  margin-bottom: 16px;
}
.filter-bar .search-wrap { min-width: 220px; flex: 1; }
.filter-select {
  border: 1px solid var(--ph-border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  color: var(--ph-ink-2);
  background: var(--ph-surface);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  min-width: 140px;
}
.filter-select:focus { border-color: var(--ph-orange); }
.filter-spacer { flex: 1; }

/* ── TomSelect overrides — filter bar ───────────────────────── */
.filter-cell .ts-wrapper {
  width: 100%;
}
.filter-cell .ts-wrapper .ts-control {
  border: none;
  padding: 6px 10px;
  min-height: auto;
  background: transparent;
  box-shadow: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ph-ink-2);
  cursor: pointer;
  flex-wrap: nowrap;
  gap: 4px;
}
.filter-cell .ts-wrapper.focus { border-color: var(--ph-orange); outline: none; }
.filter-cell .ts-wrapper .ts-control input { font-family: inherit; font-size: 13px; color: var(--ph-ink-2); }
.filter-cell .ts-dropdown {
  border: 1px solid var(--ph-border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  font-family: inherit;
  font-size: 13px;
  z-index: 9999;
}
.filter-cell .ts-dropdown .ts-dropdown-content { padding: 4px; }
.filter-cell .ts-dropdown .option { padding: 7px 10px; border-radius: var(--r-sm); color: var(--ph-ink-2); }
.filter-cell .ts-dropdown .option:hover,
.filter-cell .ts-dropdown .option.active { background: var(--ph-surface-muted); color: var(--ph-ink); }
.filter-cell .ts-dropdown .option.selected { color: var(--ph-orange); font-weight: 700; }
.filter-cell .ts-dropdown .optgroup-header { font-size: 10.5px; font-weight: 700; color: var(--ph-ink-4); text-transform: uppercase; letter-spacing: .06em; padding: 6px 10px 2px; }

/* ── Enhanced filter bar — labeled cells + row layout ────────── */
.filter-bar-v2 {
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  margin-bottom: 16px;
  padding: 14px 16px 10px;
  overflow: visible;
}
.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 120px;
}
.filter-cell.cell-search { flex: 1; min-width: 200px; }
.filter-cell.cell-grow   { flex: 1; }
.filter-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ph-ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding-top: 0;
}
.filter-divider { width: 100%; height: 1px; background: var(--ph-border); margin: 10px 0 0; }

/* Segmented button group for status filter */
.seg-btn-group {
  display: inline-flex;
  background: var(--ph-surface-muted);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.seg-btn-group button {
  background: transparent;
  border: none;
  border-right: 1px solid var(--ph-border);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ph-ink-3);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.seg-btn-group button:last-child { border-right: none; }
.seg-btn-group button:hover { background: var(--ph-surface); color: var(--ph-ink-2); }
.seg-btn-group button.seg-active { background: var(--ph-surface); color: var(--ph-ink); font-weight: 700; box-shadow: var(--sh-1); }

/* Date-range preset row */
.date-range-wrap { display: flex; flex-direction: column; gap: 5px; }
.date-preset-group {
  display: inline-flex;
  background: var(--ph-surface-muted);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.date-preset-group button {
  background: transparent;
  border: none;
  border-right: 1px solid var(--ph-border);
  padding: 7px 11px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ph-ink-3);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.date-preset-group button:last-child { border-right: none; }
.date-preset-group button:hover { background: var(--ph-surface); color: var(--ph-ink-2); }
.date-preset-group button.seg-active { background: var(--ph-surface); color: var(--ph-orange-600); font-weight: 700; box-shadow: var(--sh-1); }
.date-custom-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.date-custom-row input[type="date"] {
  border: 1px solid var(--ph-border-strong);
  border-radius: var(--r-md);
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--ph-ink-2);
  background: var(--ph-surface);
  outline: none;
  transition: border-color .15s;
}
.date-custom-row input[type="date"]:focus { border-color: var(--ph-orange); }
.date-custom-row span { font-size: 12px; color: var(--ph-ink-3); }

/* ── Flat grey icon button ────────────────────────────────────── */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--ph-ink-3);
  cursor: pointer;
  transition: background .12s, color .12s;
  padding: 0;
}
.btn-icon:hover { background: var(--ph-surface-muted); color: var(--ph-ink); }
.btn-icon [data-lucide], .btn-icon svg, .btn-icon * { pointer-events: none; }
.btn-icon [data-lucide] { width: 15px; height: 15px; stroke-width: 1.75; }

/* ── Action bar for detail pages ─────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 16px;
  flex-wrap: wrap;
}
.action-bar-left { display: flex; align-items: center; gap: 10px; }
.action-bar-right { display: flex; align-items: center; gap: 8px; }

/* ── Breadcrumbs ─────────────────────────────────────────────── */
.breadcrumb-nav { margin-bottom: 10px; }
.breadcrumb-list {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.breadcrumb-list li { display: flex; align-items: center; gap: 4px; }
.breadcrumb-list a {
  font-size: 12.5px;
  color: var(--ph-ink-3);
  text-decoration: none;
  font-weight: 500;
  transition: color .12s;
}
.breadcrumb-list a:hover { color: var(--ph-ink); }
.breadcrumb-list .bc-current {
  font-size: 12.5px;
  color: var(--ph-ink-2);
  font-weight: 600;
}
.breadcrumb-list .bc-sep {
  color: var(--ph-ink-4);
  font-size: 11px;
}

/* ── Pill toggles ────────────────────────────────────────────── */
.pill-group { display: inline-flex; gap: 4px; background: var(--ph-surface-muted); padding: 3px; border-radius: 9999px; }
.pill {
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--ph-ink-3);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.pill:hover { color: var(--ph-ink); }
.pill.active { background: var(--ph-surface); color: var(--ph-ink); box-shadow: var(--sh-1); }

/* ── Chips ───────────────────────────────────────────────────── */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  color: var(--ph-ink-2);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  font-family: inherit;
}
.chip:hover { border-color: var(--ph-orange); color: var(--ph-orange-600); }
.chip.active { background: var(--ph-orange); border-color: var(--ph-orange); color: white; }
.chip [data-lucide] { width: 13px; height: 13px; }

/* ── Combobox ────────────────────────────────────────────────── */
.combobox { position: relative; }
.combobox-input {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: var(--ph-surface);
  border: 1px solid var(--ph-border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .15s;
}
.combobox-input:focus-within, .combobox-input.open { border-color: var(--ph-orange); box-shadow: 0 0 0 3px rgba(247,124,11,.16); }
.combobox-input input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 14px; color: var(--ph-ink);
  min-width: 0;
}
.combobox-input input::placeholder { color: var(--ph-ink-4); }
.combobox-popover {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 320px; overflow-y: auto;
  background: var(--ph-surface);
  border: 1px solid var(--ph-border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  z-index: 50;
  display: none;
}
.combobox-popover.open { display: block; }
.combobox-group { padding: 6px 0; }
.combobox-group-label {
  padding: 6px 14px 4px;
  font-size: 10.5px; font-weight: 700;
  color: var(--ph-ink-3);
  text-transform: uppercase; letter-spacing: .07em;
}
.combobox-item {
  display: flex; flex-direction: column;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s;
}
.combobox-item:hover, .combobox-item.focused { background: var(--ph-surface-muted); }
.combobox-item .item-title { font-size: 13.5px; font-weight: 600; color: var(--ph-ink); }
.combobox-item .item-sub   { font-size: 11.5px; color: var(--ph-ink-3); }
.combobox-empty {
  padding: 16px; text-align: center; color: var(--ph-ink-4); font-size: 13px;
}

/* ── Toast ───────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 13.5px;
  color: white;
  box-shadow: var(--sh-3);
  transition: opacity .3s, transform .3s;
  max-width: 320px;
  display: flex; align-items: center; gap: 8px;
}
#toast.hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }

/* ── Timeline ────────────────────────────────────────────────── */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--ph-border);
}
.timeline-item {
  display: flex;
  gap: 14px;
  padding-bottom: 14px;
  position: relative;
}
.timeline-dot {
  width: 28px; height: 28px;
  border-radius: 9999px;
  background: var(--ph-surface);
  border: 1px solid var(--ph-border-strong);
  color: var(--ph-ink-3);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center; justify-content: center;
  position: relative;
  z-index: 1;
}
.timeline-dot [data-lucide] { width: 13px; height: 13px; }
.timeline-dot.is-success { background: var(--ph-success-bg); border-color: var(--ph-success); color: var(--ph-success); }
.timeline-dot.is-danger  { background: var(--ph-danger-bg);  border-color: var(--ph-danger);  color: var(--ph-danger); }
.timeline-dot.is-brand   { background: var(--ph-orange-50);  border-color: var(--ph-orange);  color: var(--ph-orange-600); }
.timeline-content .timeline-title { font-size: 13.5px; font-weight: 700; color: var(--ph-ink); }
.timeline-content .timeline-meta  { font-size: 12px; color: var(--ph-ink-3); }

/* ── Amount box ──────────────────────────────────────────────── */
.amount-box {
  background: var(--ph-orange-50);
  border: 1px solid var(--ph-orange-100);
  border-radius: var(--r-md);
  padding: 16px 18px;
}

/* ── Detail row ──────────────────────────────────────────────── */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--ph-border);
  font-size: 13.5px;
  gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--ph-ink-3); font-weight: 600; flex-shrink: 0; }
.detail-value { font-weight: 700; text-align: right; color: var(--ph-ink); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-state-icon {
  width: 56px; height: 56px;
  border-radius: 9999px;
  background: var(--ph-orange-50);
  color: var(--ph-orange-600);
  display: inline-flex; align-items: center; justify-content: center;
}
.empty-state-icon [data-lucide] { width: 24px; height: 24px; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--ph-ink); }
.empty-state-text  { font-size: 13px; color: var(--ph-ink-3); max-width: 320px; }

/* ── Notice (printable) ──────────────────────────────────────── */
.notice-page {
  max-width: 480px;
  margin: 0 auto 40px;
  background: white;
  padding: 36px 32px;
  border: 1px solid var(--ph-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
}
.notice-divider { height: 2px; background: var(--ph-ink); margin: 18px auto; max-width: 240px; }
.notice-section-label {
  font-size: 14px; font-weight: 800; color: var(--ph-ink);
  letter-spacing: .04em; margin: 18px 0 12px;
}
.notice-field {
  display: flex; align-items: baseline; gap: 12px;
  padding: 6px 0;
  font-size: 14px;
}
.notice-field-label { font-weight: 700; color: var(--ph-ink); white-space: nowrap; min-width: 120px; }
.notice-field-value {
  flex: 1; border-bottom: 1.5px solid var(--ph-ink);
  padding-bottom: 2px; min-height: 18px;
  font-family: inherit; font-weight: 600;
}
.notice-footnote {
  margin-top: 24px;
  text-align: center;
  color: var(--ph-orange);
  font-size: 13px; font-weight: 600; line-height: 1.5;
}
.notice-photo-block {
  border: 1px dashed var(--ph-border-strong);
  border-radius: var(--r-md);
  padding: 12px;
  background: var(--ph-surface-muted);
  margin-bottom: 18px;
}

@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .sidebar, .topbar, .sidebar-overlay { display: none !important; }
  .app-shell { display: block; }
  .main-content { grid-column: 1; }
  .main-canvas { padding: 0; max-width: none; }
  .notice-page { box-shadow: none; border: none; max-width: 100%; padding: 12mm; margin: 0; }
  .notice-page + .notice-page { page-break-before: always; }
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-list {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--ph-border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 600;
  color: var(--ph-ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--ph-ink); }
.tab.active { color: var(--ph-orange-600); border-bottom-color: var(--ph-orange); }

/* Vertical tabs (settings) */
.tabs-vertical { display: grid; grid-template-columns: 200px 1fr; gap: 24px; }
.tabs-vertical .tab-list { flex-direction: column; border: none; gap: 2px; }
.tabs-vertical .tab {
  text-align: left;
  border-bottom: none;
  border-left: 3px solid transparent;
  padding: 9px 14px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.tabs-vertical .tab.active {
  border-left-color: var(--ph-orange);
  background: var(--ph-orange-50);
  color: var(--ph-orange-600);
}
@media (max-width: 768px) {
  .tabs-vertical { grid-template-columns: 1fr; }
  .tabs-vertical .tab-list { flex-direction: row; border-bottom: 1px solid var(--ph-border); }
  .tabs-vertical .tab { border-left: none; border-bottom: 2px solid transparent; border-radius: 0; }
  .tabs-vertical .tab.active { border-bottom-color: var(--ph-orange); border-left-color: transparent; }
}

/* ── Grid helpers ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
@media (max-width: 1100px) {
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}

/* ── Misc utility ────────────────────────────────────────────── */
.text-muted   { color: var(--ph-ink-3); }
.text-mute-2  { color: var(--ph-ink-4); }
.text-success { color: var(--ph-success); }
.text-warn    { color: var(--ph-warn); }
.text-danger  { color: var(--ph-danger); }
.text-brand   { color: var(--ph-orange-600); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.divider { height: 1px; background: var(--ph-border); margin: 16px 0; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--ph-surface-muted);
  color: var(--ph-ink-3);
}
.row-link { color: inherit; text-decoration: none; }
.row-flex { display: flex; align-items: center; gap: 10px; }
.col-flex { display: flex; flex-direction: column; gap: 4px; }

/* Mini bar chart */
.minibar-list { display: flex; flex-direction: column; gap: 10px; }
.minibar-row { display: grid; grid-template-columns: 1fr 60px; align-items: center; gap: 10px; }
.minibar-row .minibar-label { font-size: 13px; color: var(--ph-ink-2); font-weight: 600; }
.minibar-row .minibar-track {
  background: var(--ph-surface-muted); border-radius: 9999px; height: 8px; overflow: hidden;
  grid-column: 1 / span 2;
}
.minibar-row .minibar-fill { display: block; height: 100%; background: var(--ph-orange); border-radius: 9999px; }
.minibar-row .minibar-value { font-size: 12.5px; font-weight: 700; color: var(--ph-ink); text-align: right; }
.minibar-row.has-value { grid-template-columns: 1fr 60px; }
.minibar-row.has-value .minibar-track { grid-column: 1; }
.minibar-row.has-value .minibar-value { grid-column: 2; }

/* Scrollable table wrapper */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Slide-down form panel (kept for backwards-compat; new code should use slide-over) */
.slide-form { overflow: hidden; max-height: 0; transition: max-height .3s ease; }
.slide-form.open { max-height: 800px; }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--ph-border);
  border-top-color: var(--ph-orange);
  border-radius: 9999px;
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Run pills (sightings day cards) ─────────────────────────── */
.run-pill {
  min-width: 96px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--ph-border);
  background: var(--ph-surface-muted);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.run-pill:hover { border-color: var(--ph-orange); box-shadow: var(--sh-2); }
.run-pill--empty { cursor: default; opacity: .5; border-style: dashed; }
.run-pill--empty:hover { border-color: var(--ph-border); box-shadow: none; }
.run-pill--am { border-top: 3px solid var(--ph-info); }
.run-pill--pm { border-top: 3px solid var(--ph-warn); }
.run-pill--violations { border-top-color: var(--ph-danger) !important; }
.run-pill__label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ph-ink-3); }
.run-pill__time  { font-size: 13.5px; font-weight: 700; color: var(--ph-ink); }
.run-pill__meta  { font-size: 11.5px; color: var(--ph-ink-4); }
.run-pill__stats { display: flex; gap: 8px; margin-top: 4px; font-size: 11.5px; font-weight: 600; color: var(--ph-ink-3); }
.run-pill__stats [data-lucide] { width: 11px; height: 11px; vertical-align: middle; }

/* ── Responsive: narrow-screen listings ──────────────────────── */
@media (max-width: 900px) { .col-hide-md { display: none; } }
@media (max-width: 640px) { .col-hide-sm { display: none; } }

@media (max-width: 640px) {
  .admin-table th,
  .admin-table td { padding: 8px 10px; font-size: 12.5px; }
  .admin-table th { font-size: 10.5px; letter-spacing: .04em; }
  .admin-table td .row-sub { font-size: 11px; }
  .filter-bar { padding: 10px; gap: 8px; }
  .filter-bar .search-wrap { min-width: 0; flex-basis: 100%; }
  .filter-select { min-width: 0; flex: 1 1 calc(50% - 4px); }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; }
}

/* ── Semantic state tokens ───────────────────────────────────── */
:root {
  --state-success: var(--ph-success);
  --state-warning: var(--ph-warn);
  --state-danger:  var(--ph-danger);
}

/* ── Alert banners ───────────────────────────────────────────── */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.alert-banner [data-lucide] { flex-shrink: 0; }
.alert-banner span { flex: 1; }
.alert-banner__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.35);
  transition: background .15s;
}
.alert-banner__link:hover { background: rgba(255,255,255,.55); }
.alert-banner--repeat  { background: var(--ph-warn-bg);   color: var(--ph-warn);    border: 1px solid #e9c97a; }
.alert-banner--dispute { background: var(--ph-danger-bg); color: var(--ph-danger);  border: 1px solid #e8b4ad; }
.alert-banner--escalate{ background: var(--ph-orange-50); color: var(--ph-orange-600); border: 1px solid var(--ph-orange-100); }
.alert-banners-stack { margin-bottom: 4px; }

/* ── Escalation ladder ───────────────────────────────────────── */
.ladder {
  display: flex;
  align-items: center;
  gap: 0;
}
.ladder--sm .ladder-step-label { display: none; }
.ladder-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 56px;
}
.ladder-step-dot {
  width: 26px; height: 26px;
  border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--ph-border-strong);
  background: var(--ph-surface-muted);
  color: var(--ph-ink-4);
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
}
.ladder-step-label {
  font-size: 10.5px; font-weight: 700; color: var(--ph-ink-4);
  white-space: nowrap;
}
.ladder-step--done .ladder-step-dot {
  background: var(--ph-success-bg); border-color: var(--ph-success); color: var(--ph-success);
}
.ladder-step--done .ladder-step-label { color: var(--ph-success); }
.ladder-step--current .ladder-step-dot {
  background: var(--ph-orange-50); border-color: var(--ph-orange); color: var(--ph-orange-600);
  box-shadow: 0 0 0 3px var(--ph-orange-100);
}
.ladder-step--current .ladder-step-label { color: var(--ph-orange-600); font-weight: 800; }
.ladder-step--future .ladder-step-dot { opacity: .4; }
.ladder-step--future .ladder-step-label { opacity: .4; }
.ladder-connector {
  flex: 1; height: 2px; min-width: 16px; max-width: 32px;
  background: var(--ph-border); margin-bottom: 14px;
}

/* ── Offender chip ───────────────────────────────────────────── */
.offender-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 4px;
  border-radius: var(--r-sm);
  background: var(--ph-surface-muted);
  border: 1px solid var(--ph-border);
  font-size: 12.5px;
}
.offender-chip__dot {
  width: 8px; height: 8px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.offender-chip__dot--grey     { background: #9A958C; }
.offender-chip__dot--amber    { background: var(--ph-warn); }
.offender-chip__dot--red      { background: var(--ph-danger); }
.offender-chip__dot--red-ring {
  background: var(--ph-danger);
  box-shadow: 0 0 0 2px rgba(192,57,43,.35);
  outline: 2px dashed var(--ph-danger);
  outline-offset: 2px;
}
.offender-chip__name {
  font-size: 12px; color: var(--ph-ink-3); font-weight: 600;
}

/* ── Issuance wizard ─────────────────────────────────────────── */
.wizard {
  border: 1px solid var(--ph-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--ph-surface);
}
.wizard-header {
  display: flex;
  gap: 0;
  background: var(--ph-surface-muted);
  border-bottom: 1px solid var(--ph-border);
  padding: 0 20px;
}
.wizard-step-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ph-ink-4);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.wizard-step-tab.is-active  { color: var(--ph-orange-600); border-bottom-color: var(--ph-orange); }
.wizard-step-tab.is-done    { color: var(--ph-success); }
.wizard-step-num {
  width: 20px; height: 20px;
  border-radius: 9999px;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  background: var(--ph-border);
  color: var(--ph-ink-3);
}
.wizard-step-tab.is-active  .wizard-step-num { background: var(--ph-orange); color: white; }
.wizard-step-tab.is-done    .wizard-step-num { background: var(--ph-success); color: white; }
.wizard-body { padding: 24px 20px; }
.wizard-nav {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--ph-border);
}

/* ── Helper popover ──────────────────────────────────────────── */
.popover-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ph-ink-4);
  padding: 2px;
  border-radius: 9999px;
  transition: color .15s;
}
.popover-trigger:hover,
.popover-trigger:focus { color: var(--ph-orange-600); outline: 2px solid var(--ph-orange-100); }
.popover-content {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  background: var(--ph-ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--r-md);
  z-index: 400;
  pointer-events: none;
  box-shadow: var(--sh-3);
}
.popover-content .popover-learn {
  display: block;
  margin-top: 6px;
  color: var(--ph-orange-100);
  font-weight: 700;
  text-decoration: underline;
}
.popover-trigger:hover .popover-content,
.popover-trigger:focus .popover-content { display: block; pointer-events: auto; }

/* ── Violation cards ─────────────────────────────────────────── */
.violation-card {
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
  transition: box-shadow .15s;
}
.violation-card:hover { box-shadow: var(--sh-2); }
.violation-card.is-repeat { border-left: 3px solid var(--ph-danger); }
.violation-card.is-warning { border-left: 3px solid var(--ph-warn); }
.violation-card__photo {
  width: 80px; height: 60px;
  border-radius: var(--r-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.violation-card__photo img { width: 100%; height: 100%; object-fit: cover; }
.violation-card__body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.violation-card__plate { font-size: 14px; font-weight: 800; }
.violation-card__meta  { font-size: 12.5px; color: var(--ph-ink-3); }
.violation-card__actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.violation-cards-list { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 640px) {
  .violation-card { grid-template-columns: 1fr; }
  .violation-card__photo { width: 100%; height: 120px; }
}

/* ── Fine cards ──────────────────────────────────────────────── */
.fine-card {
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 16px;
  align-items: start;
  transition: box-shadow .15s;
  cursor: pointer;
}
.fine-card:hover { box-shadow: var(--sh-2); }
.fine-card.is-repeat    { border-left: 3px solid var(--ph-danger); }
.fine-card.is-disputed  { border-left: 3px solid var(--ph-warn); }
.fine-card__dispute-callout {
  grid-column: 1 / -1;
  background: var(--ph-warn-bg);
  border: 1px solid #e9c97a;
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ph-warn);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fine-card__amount { text-align: right; }
.fine-card__amount-base { font-size: 20px; font-weight: 800; color: var(--ph-ink); }
.fine-card__amount-admin { font-size: 12px; color: var(--ph-warn); font-weight: 700; }
.fine-cards-list { display: flex; flex-direction: column; gap: 12px; }

/* ── Dispute tab form ────────────────────────────────────────── */
.dispute-form { display: flex; flex-direction: column; gap: 14px; }
.dispute-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) {
  .dispute-form .form-row { grid-template-columns: 1fr; }
}
.dispute-card {
  background: var(--ph-warn-bg);
  border: 1px solid #e9c97a;
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.dispute-card__meta { font-size: 12px; color: var(--ph-ink-3); margin-top: 4px; }
.dispute-resolution { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.dispute-resolution textarea {
  width: 100%; resize: vertical; min-height: 70px;
  padding: 8px 10px; font-family: inherit; font-size: 13px;
  border: 1px solid var(--ph-border-strong); border-radius: var(--r-sm);
}
.dispute-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Escalation funnel ───────────────────────────────────────── */
.funnel {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
  border-radius: var(--r-md);
  border: 1px solid var(--ph-border);
}
.funnel-step {
  flex: 1;
  padding: 14px 12px;
  text-align: center;
  border-right: 1px solid var(--ph-border);
  position: relative;
  background: var(--ph-surface);
}
.funnel-step:last-child { border-right: none; }
.funnel-step__count { font-size: 22px; font-weight: 800; color: var(--ph-ink); }
.funnel-step__label { font-size: 11.5px; color: var(--ph-ink-3); font-weight: 600; margin-top: 2px; }
.funnel-step--paid   .funnel-step__count { color: var(--ph-success); }
.funnel-step--unpaid .funnel-step__count { color: var(--ph-danger); }
.funnel-step--warn   .funnel-step__count { color: var(--ph-warn); }
.funnel-arrow {
  position: absolute; right: -8px; top: 50%; transform: translateY(-50%);
  z-index: 2; color: var(--ph-border-strong);
}
@media (max-width: 760px) {
  .funnel { flex-direction: column; }
  .funnel-step { border-right: none; border-bottom: 1px solid var(--ph-border); }
  .funnel-step:last-child { border-bottom: none; }
  .funnel-arrow { display: none; }
}

/* ── ph-dialog: custom confirmation/alert dialog ─────────────── */
.ph-dialog-backdrop {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(29, 29, 29, .5);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-4);
  animation: ph-fade-in .15s ease;
}
.ph-dialog {
  background: var(--ph-surface-elev);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  width: 100%; max-width: 440px;
  animation: ph-slide-up .18s ease;
  overflow: hidden;
}
.ph-dialog-header {
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--ph-border);
}
.ph-dialog-title {
  font-size: 16px; font-weight: 700; color: var(--ph-ink); margin: 0 0 4px;
}
.ph-dialog-subtitle {
  font-size: 13px; color: var(--ph-ink-3); margin: 0;
}
.ph-dialog-body {
  padding: 16px 22px;
  font-size: 14px; color: var(--ph-ink-2); line-height: 1.55;
}
.ph-dialog-footer {
  padding: 12px 22px 18px;
  display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--ph-border);
}
.ph-dialog-footer .ph-btn-cancel {
  background: transparent; border: 1px solid var(--ph-border-strong);
  color: var(--ph-ink-2); border-radius: var(--r-md);
  padding: 8px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.ph-dialog-footer .ph-btn-cancel:hover { background: var(--ph-surface-muted); }
.ph-dialog-footer .ph-btn-confirm {
  background: var(--ph-orange); border: none; color: #fff;
  border-radius: var(--r-md); padding: 8px 18px;
  font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.ph-dialog-footer .ph-btn-confirm:hover { background: var(--ph-orange-600); }
.ph-dialog-footer .ph-btn-confirm.is-danger { background: var(--ph-danger); }
.ph-dialog-footer .ph-btn-confirm.is-danger:hover { background: #a93226; }
.ph-dialog--summary {
  background: var(--ph-surface-muted);
  border: 1px solid var(--ph-border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.ph-dialog--summary-row {
  font-size: 13px; color: var(--ph-ink-2);
  display: flex; gap: 6px; align-items: baseline;
}
.ph-dialog--summary-row strong { color: var(--ph-ink); font-weight: 700; }
@keyframes ph-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes ph-slide-up { from { transform: translateY(10px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* ── Grid / list view toggle ─────────────────────────────────── */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--s-4);
}
.resource-list { display: flex; flex-direction: column; gap: var(--s-3); }
.view-toggle { display: flex; gap: 4px; }
.view-toggle-btn {
  background: transparent; border: 1px solid var(--ph-border);
  border-radius: var(--r-sm); padding: 5px 8px; cursor: pointer;
  color: var(--ph-ink-3); display: flex; align-items: center;
  font-size: 0; line-height: 1;
}
.view-toggle-btn:hover { background: var(--ph-surface-muted); }
.view-toggle-btn.active {
  background: var(--ph-orange-50); border-color: var(--ph-orange-100);
  color: var(--ph-orange-600);
}

/* ── View container: data-view="grid"|"list" ─────────────────── */
[data-view="grid"]  { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-4); }
[data-view="list"]  { display: flex; flex-direction: column; gap: 10px; }
.ph-card-link       { display: block; text-decoration: none; color: inherit; }
.ph-card-link:hover .panel { border-color: var(--ph-border-strong); box-shadow: var(--sh-2); }
[data-view="grid"] .panel { height: 100%; box-sizing: border-box; }

/* ── Detail page stat row ────────────────────────────────────── */
.detail-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }

/* ── Evidence photo strip ────────────────────────────────────── */
.evidence-strip {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.evidence-photo {
  position: relative; border-radius: var(--r-md); overflow: hidden;
  background: var(--ph-surface-muted); border: 1px solid var(--ph-border);
  min-height: 120px;
}
.evidence-photo img {
  width: 100%; display: block; cursor: zoom-in;
}
.evidence-photo__label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 18px 8px 6px; letter-spacing: .03em;
}
.evidence-photo__ts {
  font-size: 10px; font-weight: 400; opacity: .85;
  font-family: 'Courier New', monospace;
}
.evidence-photo__placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--ph-ink-4); font-size: 12px;
  min-height: 120px; padding: var(--s-4);
}

/* ── Vacancy ring ────────────────────────────────────────────── */
.vacancy-card { display: flex; align-items: center; gap: 12px; }
.vacancy-card .ring-label { font-size: 13px; font-weight: 700; }
.vacancy-ring--low  .ring-value { stroke: var(--ph-warn); }
.vacancy-ring--high .ring-value { stroke: var(--ph-danger); }
.vacancy-ring--healthy .ring-value { stroke: var(--ph-success); }
.vacancy-ring--unknown .ring-value { stroke: var(--ph-border-strong); }
.vacancy-alert {
  border-left: 3px solid var(--ph-orange);
  background: var(--ph-warn-bg);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: var(--s-4);
  font-size: 13.5px; color: var(--ph-ink-2);
}

/* ── Patrol layer: touch-optimised sizes ─────────────────────── */
/* For tablet/iPhone field use — min 48px touch targets           */
.ph-btn-lg   { padding: 13px 22px; font-size: 14px; min-height: 48px; touch-action: manipulation; }
.btn-ghost-lg { padding: 12px 16px; font-size: 14px; min-height: 48px; touch-action: manipulation; }

.btn-warn {
  background: var(--ph-warn-bg);
  border: 1px solid #d4a84b;
  color: var(--ph-warn);
  font-family: inherit; font-weight: 700; font-size: 13px;
  border-radius: var(--r-md); padding: 8px 14px;
  cursor: pointer; display: inline-flex; align-items: center;
  gap: 8px; transition: background .15s, border-color .15s;
  touch-action: manipulation;
}
.btn-warn:hover { background: #f0dab0; }
.btn-warn-lg  { padding: 13px 18px; font-size: 14px; min-height: 48px; }

/* Sticky bottom action strip — patrol confirm actions */
.patrol-action-strip {
  position: sticky; bottom: 0; left: 0; right: 0;
  background: var(--ph-surface);
  border-top: 1px solid var(--ph-border);
  padding: 12px 20px;
  display: flex; gap: 10px; align-items: center;
  z-index: 40;
  box-shadow: 0 -4px 16px rgba(29,29,29,.09);
}
.patrol-action-strip > form,
.patrol-action-strip > a { flex: 1; }
.patrol-action-strip .ph-btn,
.patrol-action-strip .btn-warn,
.patrol-action-strip .btn-ghost,
.patrol-action-strip .btn-danger { width: 100%; justify-content: center; }

/* Upload drag / drop zone */
.upload-dropzone {
  position: relative; border: 2px dashed var(--ph-border-strong);
  border-radius: var(--r-lg); padding: 36px 24px;
  text-align: center; background: var(--ph-surface-muted);
  cursor: pointer; transition: border-color .2s, background .2s;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.upload-dropzone.drag-over,
.upload-dropzone:focus-within { border-color: var(--ph-orange); background: var(--ph-orange-50); }
.upload-dropzone input[type=file] {
  position: absolute; opacity: 0; inset: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-dropzone__icon { color: var(--ph-ink-4); margin-bottom: 12px; }
.upload-dropzone__icon [data-lucide] { width: 40px; height: 40px; stroke-width: 1.25; }
.upload-dropzone__label { font-size: 15px; font-weight: 700; color: var(--ph-ink-2); margin-bottom: 4px; }
.upload-dropzone__sub   { font-size: 13px; color: var(--ph-ink-4); }

/* Upload step indicators */
.upload-steps { display: flex; gap: 0; margin-bottom: 24px; align-items: flex-start; }
.upload-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.upload-step__num {
  width: 32px; height: 32px; border-radius: 9999px;
  background: var(--ph-surface-muted); border: 2px solid var(--ph-border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--ph-ink-3);
}
.upload-step.is-active .upload-step__num {
  background: var(--ph-orange); border-color: var(--ph-orange); color: white;
}
.upload-step__label { font-size: 11px; font-weight: 700; color: var(--ph-ink-3); text-align: center; text-transform: uppercase; letter-spacing: .05em; }
.upload-step.is-active .upload-step__label { color: var(--ph-orange-600); }
.upload-step-connector { flex: none; width: 40px; height: 2px; background: var(--ph-border); margin-top: 15px; }

/* Bigger filter-select on touch devices */
@media (max-width: 1024px) {
  .filter-select { min-height: 42px; font-size: 14px; }
}
