/* ═══════════════════════════════════════════════════════
   AAA Automation — Admin panel
   Mobile-first: base rules target phones; min-width queries
   progressively add sidebar/columns/density for larger screens.
   Reuses design tokens from ../css/style.css (loaded first).
   ═══════════════════════════════════════════════════════ */

.admin-body {
  /* Tells the browser to render native controls (checkboxes, <select>
     dropdown popups, date pickers, scrollbars) in their dark variants. */
  color-scheme: dark;

  /* Dark theme — overrides the light-surface tokens defined in
     ../css/style.css for everything scoped under .admin-body. The public
     site keeps its own light theme untouched; only the admin panel is dark. */
  --bg-page:    #0B0C0E;
  --bg-surface: #1A1C20;
  --bg-sunken:  #121316;
  --text-strong: #F5F6F7;
  --text-body:   #C7CCD1;
  --text-muted:  var(--steel-400);
  --border-subtle:  #2A2E33;
  --border-default: #3A3F45;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.4);
  --shadow-md: 0 6px 20px rgba(0,0,0,.5);

  background: var(--bg-page);
  font-family: var(--font-body);
  color: var(--text-body);
  min-height: 100vh;
  overflow-x: hidden;
}

.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;
}

.admin-body button,
.admin-body a,
.admin-body input,
.admin-body select,
.admin-body textarea {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── Shell layout ──────────────────────────────────────
   Mobile: sidebar is an off-canvas drawer (fixed, slides in).
   Desktop (≥900px): sidebar becomes a static sticky column. ── */
.admin-shell { display: flex; min-height: 100vh; }

.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 11, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out);
  z-index: 55;
}
.admin-overlay.is-open { opacity: 1; pointer-events: auto; }

.admin-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(280px, 82vw);
  height: 100vh;
  height: 100dvh;
  background: var(--aaa-black);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 240ms var(--ease-out);
  z-index: 60;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.admin-sidebar.is-open { transform: translateX(0); }

.admin-sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-4);
  flex-shrink: 0;
}

.admin-logo { height: 32px; }

.admin-sidebar__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--steel-300);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.admin-sidebar__close:active { background: var(--steel-900); }

/* ── Current-user chip (top of sidebar, links to profile.php) ────── */
.admin-user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 var(--space-3) var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--dur) var(--ease-out);
}
.admin-user-chip:hover, .admin-user-chip.is-active { background: var(--steel-900); }
.admin-user-chip__text { min-width: 0; }
.admin-user-chip__greeting {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-user-chip__link { color: var(--steel-400); font-size: 0.78rem; }

/* Avatar: used both as an <img> and as a lettered placeholder <div>.
   max-width: none overrides the global `img { max-width: 100% }` rule
   (css/style.css) — without it, a real <table>'s auto column-width
   algorithm can shrink the avatar column below 36px (e.g. once a wide
   sibling column like the worker phone/call button needs the room),
   squishing the circle into an oval instead of just reserving space. */
.admin-avatar {
  max-width: none;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--steel-700);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
}
.admin-avatar--sm { width: 36px; height: 36px; font-size: 0.95rem; }
.admin-avatar--md { width: 48px; height: 48px; font-size: 1.1rem; }
.admin-avatar--lg { width: 72px; height: 72px; font-size: 1.6rem; }

.admin-profile-row { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-2); }

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: 0 var(--space-3);
  flex: 1;
}

.admin-nav__link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--steel-300);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

.admin-nav__link:hover { background: var(--steel-900); color: #fff; }
.admin-nav__link:active { background: var(--steel-800); }
.admin-nav__link.is-active { background: var(--aaa-red); color: #fff; }

.admin-nav__logout {
  display: flex;
  align-items: center;
  min-height: 48px;
  margin: var(--space-4) var(--space-3) var(--space-6);
  padding: var(--space-3) var(--space-4);
  color: var(--steel-400);
  text-decoration: none;
  font-size: 0.95rem;
  border-top: 1px solid var(--steel-800);
  padding-top: var(--space-4);
  flex-shrink: 0;
}
.admin-nav__logout:hover { color: #fff; }

.admin-main { flex: 1; min-width: 0; width: 100%; }

/* Topbar: sticky, hamburger + title, always one row */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.admin-menu-toggle {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 44px; height: 44px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  cursor: pointer;
}
.admin-menu-toggle span { display: block; width: 18px; height: 2px; background: var(--text-strong); border-radius: 1px; }
.admin-menu-toggle:active { background: var(--bg-sunken); }

.admin-topbar h1 {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 4vw, 1.6rem);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-view-site {
  flex-shrink: 0;
  color: var(--aaa-red);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}
@media (max-width: 400px) {
  .admin-view-site__label { display: none; }
}

.admin-content { padding: var(--space-4); max-width: 1440px; }

@media (min-width: 640px) { .admin-content { padding: var(--space-6); } }
@media (min-width: 900px) { .admin-content { padding: var(--space-8); } }

/* Desktop: static sidebar, no drawer chrome */
@media (min-width: 900px) {
  .admin-menu-toggle,
  .admin-sidebar__close,
  .admin-overlay { display: none; }

  .admin-sidebar {
    position: sticky;
    top: 0;
    left: auto;
    transform: none;
    width: 220px;
    height: 100vh;
    flex-shrink: 0;
    box-shadow: none;
  }
  .admin-sidebar__brand { padding: var(--space-6) var(--space-5); }
  .admin-logo { height: 36px; }
  .admin-topbar { padding: var(--space-6) var(--space-8); }
}

/* ── Dashboard tiles ─────────────────────────────────── */
.admin-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
@media (min-width: 560px) {
  .admin-tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); }
}

.admin-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-top: 3px solid var(--aaa-red);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: box-shadow var(--dur) var(--ease-out);
}
.admin-tile:hover { box-shadow: var(--shadow-md); }
.admin-tile:active { background: var(--bg-sunken); }

.admin-tile__value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-strong);
}
@media (min-width: 560px) { .admin-tile__value { font-size: 2rem; } }
.admin-tile__label { color: var(--text-muted); font-size: 0.85rem; }

.admin-hint { color: var(--text-muted); max-width: 60ch; }

/* ── Login / setup card ──────────────────────────────── */
.admin-body--login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.admin-login-card {
  background: var(--bg-surface);
  border-top: 4px solid var(--aaa-red);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  width: 100%;
  max-width: 380px;
}
@media (min-width: 480px) { .admin-login-card { padding: var(--space-8); } }

.admin-login-logo { height: 40px; margin-bottom: var(--space-5); }

.admin-login-card h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  text-transform: uppercase;
  margin: 0 0 var(--space-5);
}

/* ── Forms (shared across admin) ─────────────────────── */
.admin-form { display: flex; flex-direction: column; gap: var(--space-4); }

.admin-field { display: flex; flex-direction: column; gap: var(--space-1); }
.admin-field label { font-weight: 600; font-size: 0.9rem; color: var(--text-strong); }
.admin-field .admin-field__hint { font-size: 0.8rem; color: var(--text-muted); }

.admin-field input[type="text"],
.admin-field input[type="email"],
.admin-field input[type="tel"],
.admin-field input[type="password"],
.admin-field input[type="number"],
.admin-field input[type="date"],
.admin-field input[type="file"],
.admin-field select,
.admin-field textarea {
  font-family: inherit;
  font-size: 1rem;
  min-height: 44px;
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-strong);
}
.admin-field input::placeholder, .admin-field textarea::placeholder { color: var(--text-muted); opacity: 1; }
.admin-field textarea { resize: vertical; min-height: 90px; }

.admin-field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 640px) {
  .admin-field-row { grid-template-columns: 1fr 1fr; }
}

.admin-lang-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
}
@media (min-width: 640px) {
  .admin-lang-pair { grid-template-columns: 1fr 1fr; }
}
.admin-lang-pair .admin-field label::after { content: ""; }
.admin-lang-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-left: var(--space-1);
}

/* ── Buttons ──────────────────────────────────────────── */
.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-strong);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), transform 100ms var(--ease-out);
}
.admin-btn:hover { background: var(--bg-sunken); }
.admin-btn:active { transform: scale(0.97); }

.admin-btn--primary { background: var(--aaa-red); border-color: var(--aaa-red); color: #fff; }
.admin-btn--primary:hover { background: var(--aaa-red-600); }

.admin-btn--danger { color: #FF6B5E; border-color: var(--fault-red); background: var(--bg-surface); }
.admin-btn--danger:hover { background: rgba(217,45,32,.15); }

.admin-btn--sm { min-height: 40px; padding: var(--space-2) var(--space-3); font-size: 0.85rem; }
.admin-btn--block { width: 100%; }

/* ── Alerts ───────────────────────────────────────────── */
.admin-alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.admin-alert--error   { background: rgba(217,45,32,.15); color: #FF6B5E; border: 1px solid var(--fault-red); }
.admin-alert--success { background: rgba(31,168,90,.15); color: #4FD383; border: 1px solid var(--live-green); }

/* ── Cards / lists (services, gallery, clients) ──────── */
.admin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}
@media (min-width: 640px) { .admin-card { padding: var(--space-6); margin-bottom: var(--space-6); } }

.admin-card h2 {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 1.05rem;
  margin: 0 0 var(--space-4);
}

.admin-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-body);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}
.admin-tab.is-active { background: var(--aaa-red); border-color: var(--aaa-red); color: #fff; }

.admin-list { display: flex; flex-direction: column; gap: var(--space-3); }

.admin-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.admin-list-item__drag {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.2rem;
  user-select: none;
}

.admin-list-item__icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  color: var(--aaa-red);
  flex-shrink: 0;
}

.admin-list-item__thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--bg-sunken);
}
@media (min-width: 480px) {
  .admin-list-item__thumb { width: 64px; height: 64px; }
}

.admin-list-item__body { flex: 1; min-width: 160px; }
.admin-list-item__title { font-weight: 700; color: var(--text-strong); }
.admin-list-item__sub { font-size: 0.85rem; color: var(--text-muted); }

.admin-list-item__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); flex-shrink: 0; width: 100%; }
@media (min-width: 560px) {
  .admin-list-item__actions { width: auto; margin-left: auto; }
}

/* Icon picker */
.admin-icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: var(--space-2);
  max-width: 460px;
}
.admin-icon-swatch {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1;
  min-height: 48px;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-body);
  cursor: pointer;
  position: relative;
}
.admin-icon-swatch.is-selected { border-color: var(--aaa-red); color: var(--aaa-red); background: rgba(255,47,25,.15); }
.admin-icon-swatch input { position: absolute; opacity: 0; pointer-events: none; }

/* Gallery grid thumbnails */
.admin-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-3);
}
@media (min-width: 480px) {
  .admin-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
.admin-gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.admin-gallery-item img { width: 100%; height: 120px; object-fit: cover; display: block; }
.admin-gallery-item__cat {
  position: absolute; top: 6px; left: 6px;
  background: rgba(10,10,11,.75); color: #fff;
  font-size: 0.7rem; padding: 2px 6px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.admin-gallery-item__del {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(217,45,32,.9);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

/* ── Tables (quotes list, quote-edit items) ──────────────
   Desktop (≥900px, matches the sidebar breakpoint): normal
   table, horizontal scroll as a safety net if still too wide.
   Phone/tablet (<900px): each row collapses into a card; cells
   get their column header re-attached via data-label. ── */
.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table, .admin-table--form { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th, .admin-table--form th {
  text-align: left;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid var(--border-default);
  white-space: nowrap;
}
.admin-table td, .admin-table--form td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.admin-table tbody tr:hover, .admin-table--form tbody tr:hover { background: var(--bg-sunken); }

/* Inputs living directly inside table cells (quote items editor) aren't
   wrapped in .admin-field, so they need their own full-width styling —
   otherwise the browser falls back to a fixed ~20-char default width,
   ignoring the column's percentage width and forcing the table wider
   than it needs to be. */
.admin-table td input, .admin-table td select,
.admin-table--form td input, .admin-table--form td select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-strong);
}

/* Action-button group used inside table cells and list items:
   constrained width forces a tidy 2-col wrap instead of one
   long unreadable row of 4-5 buttons (was the main desktop bug). */
.admin-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  max-width: 250px;
}
.admin-action-group form { display: contents; }
.admin-action-group .admin-btn { flex: 1 1 calc(50% - var(--space-2)); }

/* Reserve enough column width so the 2-up button grid above actually
   renders as 2 columns instead of the table's auto-layout squeezing
   it down to a narrow single-button-per-row stack. */
@media (min-width: 900px) {
  .admin-table__actions { min-width: 250px; }
  /* Avatar-only column (workers list): fixed width so the table's
     auto-layout can't squeeze the circular photo when other columns
     (e.g. phone + call button) need more room. */
  .admin-table__avatar-cell { width: 52px; }
}

.admin-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.admin-tag--gray { background: var(--steel-800); color: var(--text-muted); }
.admin-tag--green { background: rgba(31,168,90,.15); color: #4FD383; }
.admin-tag--blue { background: rgba(44,123,229,.15); color: #6FA8F5; }
.admin-tag--orange { background: rgba(255,184,0,.15); color: var(--safety-yellow); }

/* ── Quotes list: filters + status select ────────────────── */
.admin-quote-filters {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.admin-quote-filters select,
.admin-quote-filters input[type="text"],
.admin-quote-filters input[type="date"] {
  font-family: inherit;
  font-size: 1rem;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-strong);
}
.admin-quote-filters input[type="text"] { flex: 1; min-width: 160px; }
@media (max-width: 559px) {
  .admin-quote-filters { flex-direction: column; align-items: stretch; }
  .admin-quote-filters select,
  .admin-quote-filters input[type="text"],
  .admin-quote-filters input[type="date"],
  .admin-quote-filters button,
  .admin-quote-filters a { width: 100%; }
}

.admin-status-form { display: inline-block; }
.admin-status-select {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
}
.admin-status-select--draft { background: var(--steel-800); color: var(--text-muted); }
.admin-status-select--sent { background: rgba(44,123,229,.15); color: #6FA8F5; }
.admin-status-select--paid { background: rgba(31,168,90,.15); color: #4FD383; }

/* ── Checkbox labels (quote-edit toggles) ────────────────── */
.admin-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-strong);
  margin-bottom: var(--space-2);
  cursor: pointer;
  min-height: 32px;
}
.admin-checkbox-label input { width: 20px; height: 20px; flex-shrink: 0; }

/* ── Live totals preview (quote-edit) ─────────────────────── */
.admin-totals-line {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: 0.9rem;
}
.admin-totals-line span:last-child { font-family: var(--font-mono); font-weight: 600; }
.admin-totals-line--grand { font-size: 1.05rem; color: var(--aaa-red); border-top: 1px solid var(--border-default); margin-top: var(--space-1); padding-top: var(--space-3); }

/* Toggle switch (WhatsApp on/off) */
.admin-switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.admin-switch input { display: none; }
.admin-switch__track {
  width: 46px; height: 26px;
  background: var(--steel-700);
  border-radius: 999px;
  position: relative;
  transition: background var(--dur) var(--ease-out);
  flex-shrink: 0;
}
.admin-switch__track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur) var(--ease-out);
}
.admin-switch input:checked + .admin-switch__track { background: var(--live-green); }
.admin-switch input:checked + .admin-switch__track::after { transform: translateX(20px); }

/* ── Mobile card-ified tables (<900px) ──────────────────────
   Two flavors:
   .admin-table         → label-left / value-right rows (read-only data, e.g. quotes list)
   .admin-table--form    → label-above / full-width field (editable inputs, e.g. quote items)
   Both need <td data-label="..."> in the markup; a td with
   data-label="" is treated as unlabeled (actions/remove cell). ── */
@media (max-width: 899px) {
  .admin-table-wrap { overflow-x: visible; }

  .admin-table, .admin-table--form { display: block; width: 100%; }
  .admin-table thead, .admin-table--form thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .admin-table tbody, .admin-table--form tbody { display: block; }

  .admin-table tr, .admin-table--form tr {
    display: block;
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    padding: var(--space-4);
  }

  /* row-style: label left, value right */
  .admin-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-subtle);
    text-align: right;
  }
  .admin-table td:last-child { border-bottom: none; padding-bottom: 0; }
  .admin-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
  }
  .admin-table td[data-label=""]::before { content: none; }
  .admin-table td[data-label=""] { justify-content: flex-start; }

  /* cells that need to stack fully (status select, action buttons) */
  .admin-table td.admin-table__cell--stack {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .admin-table td.admin-table__cell--stack::before { margin-bottom: var(--space-2); }
  .admin-table td.admin-table__cell--stack .admin-action-group { max-width: none; }
  .admin-table td.admin-table__cell--stack .admin-action-group .admin-btn { flex: 1 1 calc(50% - var(--space-2)); }

  /* column-style: label above, input fills width */
  .admin-table--form td {
    display: block;
    padding: var(--space-2) 0;
  }
  .admin-table--form td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
  .admin-table--form td[data-label=""]::before { content: none; }

  /* quote line-item cards: float the remove button as a corner chip */
  .quote-item-row { padding-right: var(--space-12) !important; }
  .quote-item-row td:last-child {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    padding: 0;
  }
  .quote-item-row td:last-child .admin-btn {
    min-height: 32px; min-width: 32px;
    padding: 0;
    border-radius: 50%;
  }
}

/* ── Finance dashboard (admin/finance.php) ───────────────────
   No SVG here on purpose — plain CSS bars/meters computed from a
   server-side percentage (via inline style), same tokens as the
   rest of the admin panel. Avoids the coordinate-math fragility
   the hand-drawn SVG US map ran into. ── */

.fin-kpi-delta { display: inline-block; margin-left: var(--space-2); font-size: 0.78rem; font-weight: 700; }
.fin-kpi-delta--up { color: #4FD383; }
.fin-kpi-delta--down { color: #FF6B5E; }

/* Monthly revenue bar chart */
.fin-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--space-1);
  height: 180px;
  padding-top: var(--space-5);
}
@media (min-width: 640px) { .fin-chart { gap: var(--space-2); height: 220px; } }

.fin-chart__col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
}

.fin-chart__value {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}
@media (max-width: 480px) { .fin-chart__value { display: none; } }

.fin-chart__bar {
  width: 100%;
  max-width: 34px;
  background: var(--aaa-red);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height var(--dur-slow) var(--ease-out);
}

.fin-chart__label {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Meter bars — category breakdown, revenue goal progress */
.fin-meter-row { margin-bottom: var(--space-4); }
.fin-meter-row:last-child { margin-bottom: 0; }
.fin-meter-row__head {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-strong);
  margin-bottom: var(--space-2);
}
.fin-meter {
  height: 10px;
  background: var(--bg-sunken);
  border-radius: 999px;
  overflow: hidden;
}
.fin-meter__fill {
  height: 100%;
  border-radius: 999px;
  transition: width var(--dur-slow) var(--ease-out);
}
.fin-meter__fill--industrial { background: var(--aaa-red); }
.fin-meter__fill--residential { background: #6FA8F5; }
.fin-meter__fill--uncategorized { background: var(--steel-600); }
.fin-meter__fill--goal { background: var(--live-green); }

/* Status funnel */
.fin-funnel {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
@media (min-width: 560px) { .fin-funnel { grid-template-columns: repeat(4, 1fr); gap: var(--space-4); } }

.fin-funnel__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  border-top: 3px solid var(--steel-600);
}
.fin-funnel__item--draft { border-top-color: var(--steel-600); }
.fin-funnel__item--sent { border-top-color: #6FA8F5; }
.fin-funnel__item--paid { border-top-color: var(--live-green); }
.fin-funnel__item--expired { border-top-color: var(--safety-yellow); }
.fin-funnel__amount { font-size: 0.85rem; color: var(--text-body); font-family: var(--font-mono); }
