/* ---------------------------------------------------------------------------------------
   Own The Field — app design system. Default shell is the blue-and-white office look
   (cobalt actions, pale canvas, readable sans). Tenant theme_preset still retints
   --brand / --brand-dark / --brand-tint / --bg only.
   --------------------------------------------------------------------------------------- */
:root {
  --brand-dark: #153F9C;
  --brand: #1D4ED8;
  --brand-light: #3B6EF0;
  --brand-tint: #EEF4FF;
  --bg: #F3F6FC;
  --card: #ffffff;
  --input-bg: #ffffff;
  --border: #DEE6F2;
  --text: #14213D;
  --muted: #58677E;
  --danger: #AB392F;
  --warn: #805714;
  --sent: #1D4ED8;
  --ok: #256342;
  --featured: #153F9C;
}

/* ---------- Preset themes (Settings > Theme) — override the brand variables only ---------- */
body[data-theme="forge"] {
  --brand-dark: #9A3412; --brand: #C2410C; --brand-light: #F59E42; --brand-tint: rgba(194,65,12,0.08); --bg: #FAF7F5;
}
body[data-theme="copper"] {
  --brand-dark: #7C3A0A; --brand: #B45309; --brand-light: #E3A854; --brand-tint: rgba(180,83,9,0.08); --bg: #FBF8F3;
}
body[data-theme="slate"] {
  --brand-dark: #1E293B; --brand: #334155; --brand-light: #64748B; --brand-tint: rgba(51,65,85,0.08); --bg: #F5F6F8;
}
body[data-theme="emerald"] {
  --brand-dark: #14532D; --brand: #15803D; --brand-light: #4ADE80; --brand-tint: rgba(21,128,61,0.08); --bg: #F5F9F4;
}
body[data-theme="night"] {
  --brand-dark: #9BB0F5;
  --brand: #6B86E8;
  --brand-light: #9BB0F5;
  --brand-tint: rgba(107,134,232,0.16);
  --bg: #12141A;
  --card: #1C1F28;
  --input-bg: #16181F;
  --border: rgba(255,255,255,0.12);
  --text: #E8EAED;
  --muted: rgba(232,234,237,0.62);
  --danger: #f07167;
  --warn: #e8b84a;
  --ok: #4ecb7f;
}
body[data-theme="night"] .error-text { color: #f07167; }
body[data-theme="night"] .success-text { color: #4ecb7f; }
body[data-theme="night"] .badge.paid,
body[data-theme="night"] .badge.completed,
body[data-theme="night"] .badge.approved,
body[data-theme="night"] .badge.won,
body[data-theme="night"] .badge.sent,
body[data-theme="night"] .badge.in_progress,
body[data-theme="night"] .badge.contacted {
  color: #12141A;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--card);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 12px 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar .brand {
  display: flex; align-items: center; gap: 8px; margin-right: 16px;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-weight: 700; font-size: 16px;
  letter-spacing: 0.02em; color: var(--text);
}
.topbar .brand img { width: 26px; height: 26px; border-radius: 4px; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: var(--muted); padding: 8px 11px; border-radius: 5px; font-size: 13.5px; font-weight: 500; }
.topbar nav a svg { margin-right: 7px; vertical-align: -3px; flex: 0 0 auto; }
.nav-group { display: inline-block; width: 1px; align-self: stretch; margin: 6px 6px; background: var(--border); }
.nav-group:first-child { display: none; }
.nav-group-label { display: none; }
.topbar nav a.active {
  color: var(--brand); background: var(--brand-tint); font-weight: 600;
}
.topbar nav a:hover { color: var(--text); background: var(--brand-tint); text-decoration: none; }
.topbar .user { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.topbar form { margin: 0; }
.topbar button.linklike { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px 8px; }
.topbar button.linklike:hover { color: var(--brand-dark); }

.container { max-width: 1100px; margin: 0 auto; padding: 22px 16px 60px; }
.container.narrow { max-width: 720px; }

h1 {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-weight: 700; text-transform: none;
  letter-spacing: -0.02em; font-size: 30px; margin: 4px 0 18px; color: var(--text);
}
h2 {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-weight: 600; text-transform: none;
  letter-spacing: -0.01em; font-size: 18px; color: var(--text);
}

.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(20,33,61,0.04); }

.btn {
  display: inline-block; background: var(--brand); color: white; border: none;
  padding: 10px 18px; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background 0.12s ease; min-height: 44px;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: var(--card); color: var(--brand-dark); border: 1px solid var(--brand-dark); }
.btn.secondary:hover { background: var(--brand-tint); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 13px; min-height: 36px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.tech-actions .btn { min-height: 44px; }

body.glove .btn { min-height: 56px; padding: 14px 20px; font-size: 16px; }
body.glove .btn.small { min-height: 48px; padding: 10px 14px; font-size: 14px; }
body.glove .btn-row.tech-actions .btn { min-height: 56px; }
body.glove .topbar nav a { min-height: 44px; padding: 10px 12px; display: inline-flex; align-items: center; }
body.glove .card { padding: 22px; }

.charge-info { display: inline-block; position: relative; vertical-align: middle; margin-left: 6px; font-weight: 400; }
.charge-info > summary { list-style: none; cursor: pointer; }
.charge-info > summary::-webkit-details-marker { display: none; }
.charge-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--brand); color: var(--brand); background: var(--card);
  border-radius: 999px; padding: 8px 14px 8px 10px;
  font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: 0; line-height: 1;
}
.charge-i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--brand); color: var(--brand);
  font-size: 13px; font-weight: 700; font-style: italic; font-family: Georgia, 'Times New Roman', serif;
  line-height: 1; text-transform: none; letter-spacing: 0;
}
.charge-info[open] .charge-trigger { background: var(--brand); color: #fff; }
.charge-info[open] .charge-i { background: #fff; color: var(--brand); border-color: #fff; }
.charge-pop {
  position: absolute; z-index: 40; left: 0; top: calc(100% + 8px);
  width: min(620px, calc(100vw - 48px));
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
  padding: 14px 14px 12px; box-shadow: 0 10px 28px rgba(32,36,44,0.12);
  color: var(--text); font-family: Inter, sans-serif; text-transform: none; letter-spacing: 0; font-weight: 400;
}
.charge-pop-title { font-size: 13px; font-weight: 600; margin: 0 0 10px; }
.charge-pop-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.charge-pop table { width: 100%; border-collapse: collapse; font-size: 12px; }
.charge-pop th, .charge-pop td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.charge-pop th { font-size: 11px; color: var(--muted); font-weight: 600; }
.charge-pop-note { font-size: 12px; color: var(--muted); margin: 10px 0 0; line-height: 1.45; }
@media (max-width: 800px) {
  .charge-pop { left: auto; right: 0; }
}

table.data { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 6px; overflow: visible; }
table.data th {
  background: var(--brand-tint); text-align: left; padding: 11px 12px; font-size: 12px; font-weight: 600;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif; text-transform: none; letter-spacing: 0;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover { background: var(--brand-tint); }

.portal-ico { display: inline-block; vertical-align: -1px; margin-right: 4px; }
@media (max-width: 640px) {
  table.data.stack,
  .portal-page table.portal-list {
    border: 0;
    background: transparent;
    overflow: visible;
  }
  table.data.stack thead,
  .portal-page table.portal-list thead { display: none; }
  table.data.stack tbody,
  table.data.stack tr,
  table.data.stack td,
  .portal-page table.portal-list tbody,
  .portal-page table.portal-list tr,
  .portal-page table.portal-list td {
    display: block;
    width: 100%;
  }
  table.data.stack tr,
  .portal-page table.portal-list tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
  }
  table.data.stack tr:hover,
  .portal-page table.portal-list tr:hover { background: var(--card); }
  table.data.stack td,
  .portal-page table.portal-list td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 0;
    padding: 6px 0;
  }
  table.data.stack td::before,
  .portal-page table.portal-list td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    flex: 0 0 38%;
  }
  table.data.stack td:not([data-label])::before,
  table.data.stack td[data-label=""]::before,
  .portal-page table.portal-list td:not([data-label])::before,
  .portal-page table.portal-list td[data-label=""]::before { display: none; }
  table.data.stack td.stack-actions,
  table.data.stack td.portal-list-actions,
  .portal-page table.portal-list td.portal-list-actions {
    display: block;
    padding-top: 10px;
  }
  table.data.stack .btn,
  .portal-page table.portal-list .btn { margin: 4px 6px 0 0; }
}

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 10.5px; font-weight: 700;
  font-family: 'Space Mono', monospace; letter-spacing: 0.04em; text-transform: uppercase; color: white; background: #8a8f99;
}
.badge.paid, .badge.completed, .badge.approved { background: var(--ok); }
.badge.overdue, .badge.declined { background: var(--danger); }
.badge.sent { background: var(--sent); }
.badge.draft, .badge.void { background: #7a7f89; }
.badge.scheduled { background: var(--sent); }
.badge.in_progress { background: var(--brand); }
.badge.cancelled { background: #7a7f89; }
.badge.new { background: var(--sent); }
.badge.contacted { background: var(--sent); }
.badge.quoted { background: var(--brand); }
.badge.won { background: var(--ok); }
.badge.lost { background: var(--danger); }

/* ---------- Lead pipeline board (see routes/leads.js, views/leads/board.ejs) ---------- */
.pipeline-board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.pipeline-col { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; min-height: 80px; }
.pipeline-col h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-family: 'Space Mono', monospace; color: var(--muted); display: flex; justify-content: space-between; }
.pipeline-card { background: var(--card); border: 1px solid var(--border); border-radius: 5px; padding: 10px; margin-bottom: 8px; font-size: 13px; display: block; color: var(--text); }
.pipeline-card:hover { border-color: var(--brand); text-decoration: none; box-shadow: 0 2px 8px rgba(20,20,30,0.06); }
.pipeline-card .name { font-weight: 700; display: block; color: var(--text); text-decoration: none; }
.pipeline-card .muted { display: block; margin-top: 2px; }
.pipeline-card.overdue { border-left: 3px solid var(--danger); }
.pipeline-card .followup.overdue-text { color: var(--danger); font-weight: 700; }
@media (max-width: 900px) {
  .pipeline-board { grid-template-columns: 1fr; }
}

.settings-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 8px 0 18px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.settings-tabs button {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 12px; cursor: pointer; min-height: 40px;
}
.settings-tabs button:hover { color: var(--text); background: var(--brand-tint); }
.settings-tabs button.active {
  color: var(--brand-dark); border-color: var(--brand-dark); background: var(--card);
}
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.settings-danger {
  border: 1px solid var(--danger);
  background: #fdf4f3;
  background: color-mix(in srgb, var(--danger) 6%, var(--card));
}

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; margin-top: 12px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 10px 11px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px;
  font-family: inherit; background: var(--input-bg); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.install-app-card { display: none; }
@media (max-width: 900px) {
  .install-app-card { display: block; }
}

.nav-toggle {
  display: none;
  background: var(--card);
  color: var(--brand-dark);
  border: 1px solid var(--brand-dark);
  border-radius: 3px;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  min-height: 44px;
  cursor: pointer;
}
.phone-dock { display: none; }

@media (max-width: 1280px) {
  .nav-toggle { display: inline-flex; align-items: center; }
  .topbar nav {
    display: none;
    width: 100%;
    flex-direction: column;
    flex-basis: 100%;
  }
  .topbar nav.is-open { display: flex; }
  .topbar nav a { min-height: 44px; display: flex; align-items: center; }
}
@media (max-width: 900px) {
  .phone-dock {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
    gap: 4px;
  }
  .phone-dock a {
    flex: 1;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 10px 4px;
    min-height: 44px;
    text-decoration: none;
  }
  .phone-dock a.active { color: var(--brand-dark); }
  .container { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .truck-rail {
    position: sticky;
    bottom: calc(64px + env(safe-area-inset-bottom));
    z-index: 5;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  }
  table.data:not(.stack), .items-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 640px) {
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .topbar nav a { padding: 7px 8px; font-size: 13px; }
  /* Bigger, thumb-friendly tap targets for technicians using a phone in the field. */
  .btn { padding: 13px 18px; font-size: 15px; min-height: 44px; }
  .btn.small { padding: 10px 14px; font-size: 13.5px; min-height: 38px; }
  .btn-row.tech-actions { flex-direction: column; }
  .btn-row.tech-actions .btn { width: 100%; text-align: center; }
  /* iOS zooms inputs under 16px */
  input, select, textarea { font-size: 16px; }
}

@media print {
  body.printing-office-sheet .topbar,
  body.printing-office-sheet .container > *:not(#officeSheet) { display: none !important; }
  body.printing-office-sheet .phone-dock { display: none !important; }
}

.section-title {
  color: var(--muted); font-family: 'Space Mono', monospace; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em; padding-bottom: 8px; margin: 28px 0 14px;
  border-bottom: 1px solid var(--border);
}

table.readings-input { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
table.readings-input th { background: var(--brand-tint); color: var(--text); font-size: 11.5px; padding: 6px 8px; text-align: left; }
table.readings-input td { border: 1px solid var(--border); padding: 4px; }
table.readings-input td.item-label { font-weight: 600; font-size: 12.5px; width: 30%; }
table.readings-input td.remove { width: 34px; text-align: center; border: none; }
table.readings-input input { border: none; font-size: 12.5px; padding: 6px; width: 100%; }
table.readings-input td.item-label input { font-weight: 600; }

.items-table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.items-table th { text-align: left; font-size: 11px; font-family: 'Space Mono', monospace; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 4px 6px; }
.items-table td { padding: 4px 6px; }
.items-table input { font-size: 13px; padding: 6px 8px; }
.items-table td.qty, .items-table td.price, .items-table td.remove { width: 100px; }
.items-table td.remove { width: 40px; text-align: center; }
.totals-box { max-width: 320px; margin-left: auto; margin-top: 10px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.totals-box .row.total { font-weight: 700; font-size: 18px; color: var(--brand-dark); border-top: 2px solid var(--brand-dark); margin-top: 4px; padding-top: 8px; }

.photo-upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.photo-upload-cell { border: 1px dashed var(--border); border-radius: 5px; padding: 10px; text-align: center; }
.photo-upload-cell img { max-width: 100%; max-height: 140px; border-radius: 4px; margin-bottom: 6px; }
.photo-upload-cell input[type=file] { font-size: 12px; }
.photo-upload-cell input[type=text] { margin-top: 6px; font-size: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 16px 14px; text-align: center; }
.stat-card .num { font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand); line-height: 1; }
.stat-card.featured { background: var(--featured); color: #fff; }
.stat-card.featured .num,
.stat-card.featured .label,
.stat-card.featured .muted { color: #fff; }
.row-menu { position: relative; display: inline-block; vertical-align: middle; }
.row-menu[open] { z-index: 40; }
.row-menu > summary {
  list-style: none; cursor: pointer; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); min-height: 36px;
}
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu-list {
  position: absolute; right: 0; top: 100%; z-index: 40; margin-top: 4px;
  min-width: 168px; padding: 8px; display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 20px rgba(20,33,61,0.08);
}
table.data tbody tr:last-child .row-menu-list {
  top: auto; bottom: calc(100% + 4px); margin-top: 0; margin-bottom: 4px;
}
.stat-card .label { font-size: 11.5px; color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.muted { color: var(--muted); font-size: 13px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.card.notice { background: color-mix(in srgb, var(--warn) 12%, var(--card)); border-left: 4px solid var(--warn); }
.card.notice-brand { background: var(--brand-tint); border-left: 4px solid var(--brand); }

body.request-page { background: var(--bg); }
body.request-embed { background: transparent; }
.request-split {
  display: flex; max-width: 980px; margin: 40px auto; background: var(--card);
  border-radius: 18px; overflow: hidden; min-height: 560px;
  box-shadow: 0 12px 40px rgba(20,33,61,0.08);
}
.request-split.embed { margin: 8px auto; min-height: 0; box-shadow: none; border: 1px solid var(--border); }
.request-rail {
  width: 340px; flex: 0 0 340px; background: var(--featured); color: #fff; padding: 36px 28px;
}
.request-rail img { max-height: 40px; max-width: 180px; margin-bottom: 16px; }
.request-rail-name { font-weight: 700; margin: 0 0 24px; }
.request-rail h1 { color: #fff; font-size: 28px; margin: 0 0 12px; }
.request-rail p { color: rgba(255,255,255,0.82); }
.request-rail-foot { margin-top: 32px; font-size: 13px; }
.request-main { flex: 1; padding: 32px 36px 40px; }
.request-main-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.job-ico { display: inline-block; vertical-align: -3px; margin-right: 6px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.filter-chips a {
  padding: 8px 14px; border-radius: 999px; color: var(--muted); text-decoration: none;
  font-weight: 600; font-size: 14px;
}
.filter-chips a.on { background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.command-bar {
  display: flex; align-items: center; gap: 12px; justify-content: flex-end;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--border);
}
.command-bar input[type="search"], .command-bar input[type="text"] { width: 280px; margin: 0; }
@media (max-width: 800px) {
  .request-split { flex-direction: column; margin: 12px; min-height: 0; }
  .request-rail { width: auto; flex: none; }
  .command-bar { justify-content: stretch; }
  .command-bar input[type="search"], .command-bar input[type="text"] { width: 100%; }
}
.sms-choice-label { font-weight: 600; margin: 10px 0 6px; }
.sms-optional-note, .sms-legal-line { margin: 8px 0 0; }
.sms-consent {
  display: flex; align-items: flex-start; gap: 8px; font-weight: 400;
  margin: 6px 0 8px;
}
.sms-consent input { width: auto; margin-top: 3px; flex: 0 0 auto; }
.sms-consent span { font-size: 13px; line-height: 1.45; color: var(--muted); }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--card); padding: 36px 32px; border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 8px 28px rgba(20,33,61,0.06); width: 340px; text-align: center; }
.login-card img { width: 56px; height: 56px; margin-bottom: 10px; border-radius: 8px; }
.login-card h1 { font-size: 24px; font-weight: 700; text-transform: none; letter-spacing: -0.02em; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }
.success-text { color: var(--ok); font-size: 13px; margin-top: 8px; }

.email-note { position: relative; }
.email-note summary { list-style: none; }
.email-note summary::-webkit-details-marker { display: none; }
.email-note-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 12px; width: 280px; box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.email-note-form textarea { min-height: 70px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 700; }

.calendar-dow-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.calendar-dow { font-family: 'Space Mono', monospace; font-size: 10.5px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 0; text-transform: uppercase; letter-spacing: 0.05em; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 20px; }
.calendar-day { background: var(--card); border: 1px solid var(--border); border-radius: 5px; min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.calendar-day.other-month { background: var(--bg); }
.calendar-day.other-month .calendar-day-num { color: var(--muted); }
.calendar-day.today { border-color: var(--brand); border-width: 2px; }
.calendar-day-num { font-size: 12px; font-weight: 700; }
.calendar-day-num a { color: inherit; }
.cal-job { font-size: 10.5px; padding: 2px 5px; border-radius: 4px; background: var(--brand-tint); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; border-left: 3px solid #999; }
.cal-job:hover { text-decoration: none; filter: brightness(0.97); }
.cal-job.status-scheduled { border-left-color: #4a7fb5; }
.cal-job.status-in_progress { border-left-color: var(--warn); }
.cal-job.status-completed { border-left-color: var(--ok); }
.cal-job.status-cancelled { border-left-color: #888; }
.cal-job.cal-maint { background: #f6efe0; border-left-color: var(--warn); }
.cal-job.cal-maint:hover { background: #efe4cc; }
.cal-more { font-size: 10px; color: var(--muted); }
@media (max-width: 640px) {
  .calendar-day { min-height: 60px; padding: 4px; }
  .cal-job { font-size: 9.5px; }
  .calendar-dow { font-size: 9.5px; }
}

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar { width: 100%; background: var(--brand); border-radius: 2px 2px 0 0; min-height: 2px; }
.bar-chart .bar-amount { font-size: 9px; color: var(--muted); margin-bottom: 2px; }
.bar-chart .bar-month { font-size: 9.5px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.aging-bar { display: flex; height: 28px; border-radius: 4px; overflow: hidden; margin: 10px 0; }
.aging-bar .seg { display: flex; align-items: center; justify-content: center; color: white; font-size: 11px; font-weight: 700; }
.aging-key { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.aging-key .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.watchlist-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.watchlist-item:last-child { border-bottom: none; }

/* ---------- Theme preset swatch picker (Settings > Theme) ---------- */
.theme-swatch-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.theme-swatch { cursor: pointer; text-align: center; }
.theme-swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-swatch .dot {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 6px; border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06); transition: border-color 0.12s ease;
}
.theme-swatch input:checked + .dot { border-color: var(--text); }
.theme-swatch input:focus-visible + .dot {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-color: var(--text);
}
.theme-swatch .name { font-size: 12px; color: var(--muted); }
.theme-swatch input:checked ~ .name { color: var(--text); font-weight: 700; }

body[data-theme="night"] .cal-job.cal-maint { background: rgba(209,154,31,0.18); }
body[data-theme="night"] .cal-job.cal-maint:hover { background: rgba(209,154,31,0.28); }

/* Left-side tabs — desktop. Phones keep the wrapping top bar. */
@media (min-width: 901px) {
  body[data-nav="left"] { display: flex; flex-wrap: wrap; min-height: 100vh; align-items: stretch; }
  body[data-nav="left"] > .app-banner { flex: 0 0 100%; width: 100%; }
  body[data-nav="left"] > .topbar {
    flex-direction: column;
    align-items: stretch;
    width: 220px;
    flex: none;
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: 18px 14px 24px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    min-height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    gap: 14px;
  }
  body[data-nav="left"] > .topbar .brand { margin-right: 0; margin-bottom: 6px; }
  body[data-nav="left"] > .topbar nav { flex-direction: column; flex-wrap: nowrap; }
  body[data-nav="left"] > .topbar nav a { display: block; }
  body[data-nav="left"] > .topbar nav a.active { box-shadow: inset 3px 0 0 var(--brand); }
  body[data-nav="left"] > .app-main {
    flex: 1 1 calc(100% - 220px);
    width: calc(100% - 220px);
    max-width: none;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  body[data-nav="left"] > .app-main > .container { max-width: none; width: 100%; }
  body[data-nav="left"] > .topbar nav .nav-group {
    display: block; width: auto; background: none; align-self: auto; margin: 0; padding: 12px 11px 4px;
  }
  body[data-nav="left"] > .topbar nav .nav-group:first-child { display: block; padding-top: 0; }
  body[data-nav="left"] > .topbar nav .nav-group-label {
    display: inline; font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted);
  }
  body[data-nav="left"] > .topbar form { margin-left: 0 !important; }
  body[data-nav="left"] > .topbar form input[name="q"] { width: 100% !important; }
  body[data-nav="left"] > .topbar .user { flex-wrap: wrap; }
  body[data-nav="left"] > .container { flex: 1; min-width: 0; }
}

.help-video { display: block; width: 100%; max-height: 420px; background: #111; }
.help-lesson h1 { font-size: 1.35rem; margin-top: 0; }
.help-lesson h2 { font-size: 1.1rem; margin-top: 22px; }
.help-lesson ol, .help-lesson ul { margin: 0 0 12px; padding-left: 22px; }
.help-lesson li { margin-bottom: 6px; }
.help-lesson table.data { margin: 12px 0; }
.help-es { display: none; }
html[data-help-lang="es"] .help-en { display: none; }
html[data-help-lang="es"] .help-es { display: revert; }

@media (min-width: 901px) {
  .truck-rail {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  }
}

.cal-board { display: flex; gap: 8px; overflow-x: auto; align-items: flex-start; }
.cal-times { flex: 0 0 52px; padding-top: 36px; }
.cal-hour { height: 48px; box-sizing: border-box; font-size: 11px; color: var(--muted); }
.cal-cols { display: flex; gap: 8px; flex: 1; }
.cal-col { flex: 1 0 168px; min-width: 168px; }
.cal-col h3 { height: 36px; margin: 0; padding: 0 8px; font-size: 14px; line-height: 36px; white-space: nowrap; overflow: hidden; }
.cal-body {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  background-image: repeating-linear-gradient(to bottom, transparent, transparent 47px, var(--border) 48px);
}
.cal-block {
  position: absolute;
  display: block;
  overflow: hidden;
  box-sizing: border-box;
  background: var(--brand-tint);
  border-left: 3px solid var(--brand);
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.3;
  padding: 2px 6px;
  color: var(--text);
}
.cal-block:hover { text-decoration: none; background: #e2ebff; }
.cal-untimed { margin: 0 0 12px; }
