/* MMW Agent Portal — Styles */

/* ── File attachment zones ───────────────────────────────────── */
.attach-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.attach-zone:hover { border-color: var(--brand); background: #fffdf0; }
.attach-zone input[type=file] { display: none; }
.attach-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.attach-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px;
}
.attach-item .attach-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item .attach-remove { cursor: pointer; color: var(--red); font-size: 16px; flex-shrink: 0; line-height: 1; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:      #2563eb;
  --blue-lt:   #3b82f6;
  --teal:      #0891b2;
  --green:     #059669;
  --amber:     #d97706;
  --red:       #dc2626;
  --purple:    #7c3aed;
  /* Brand accent — defaults to MMW gold, overridden per-company at runtime
     (nav.js samples the logged-in company's logo for a dominant color and
     injects --brand/--brand-rgb on :root; falls back to gold for logos with
     no clearly vivid color, e.g. plain black & white). Everything below
     that used to be a literal gold hex/rgb now derives from these two. */
  --brand:     #FFD700;
  --brand-rgb: 255,215,0;
  --gold:      var(--brand);
  --gold-dk:   #b8860b;
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  /* Sidebar — black / brand accent */
  --sb-bg:     #111111;
  --sb-gold:   var(--brand);
  --sb-dim:    rgba(var(--brand-rgb),.48);
  --sb-hover:  rgba(var(--brand-rgb),.09);
  --sb-active: rgba(var(--brand-rgb),.16);
  --sidebar-w: 220px;
  --topbar-h:  60px;
  --bottom-nav-h: 62px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  /* Fixed to the window, so it must scroll itself: with 14 links plus the
     footer it is ~820px tall, and on a laptop the Sign Out / Change my PIN
     buttons were below the bottom edge with no way to reach them (2026-11-30). */
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  border-right: 1px solid rgba(var(--brand-rgb),.10);
}

.sidebar-logo {
  flex-shrink: 0;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(var(--brand-rgb),.10);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.logo-mark {
  background: var(--sb-gold);
  color: #111;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1px;
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-img  { width: 100%; max-width: 160px; height: auto; border-radius: 6px; display: block; margin-bottom: 4px; }
.logo-name { color: #ffffff; font-weight: 700; font-size: 13px; line-height: 1.2; }
.logo-sub  { color: rgba(255,255,255,.45); font-size: 10px; letter-spacing: .3px; }
.logo-agent-name {
  color: rgba(255,255,255,.8);
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
  letter-spacing: .2px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
  position: relative;
}
.nav-link:hover  { background: var(--sb-hover); color: #ffffff; text-decoration: none; }
.nav-link.active { background: var(--sb-active); color: #ffffff; border-left-color: var(--sb-gold); }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: #dc2626;
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 10px 8px 14px;
  border-top: 1px solid rgba(var(--brand-rgb),.10);
}
.btn-signout {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid rgba(var(--brand-rgb),.22);
  background: transparent;
  color: var(--sb-dim);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: center;
  text-decoration: none;
}
.btn-signout:hover { background: rgba(220,38,38,.15); color: #fca5a5; border-color: rgba(220,38,38,.3); text-decoration: none; }

/* ── Layout ───────────────────────────────────────────────── */
#nav-sidebar    { width: var(--sidebar-w); flex-shrink: 0; }
.main-content   {
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: #111111;
  border-bottom: 2px solid rgba(var(--brand-rgb),.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
/* Title and the SYNC button (nav.js, every page) used the per-company
   brand color here, which on some companies' branding is too close to the
   #111 topbar background to read easily — pinned to white instead. */
.topbar-title   { font-size: 17px; font-weight: 900; color: #fff; letter-spacing: -.2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.topbar .text-muted,
.topbar .text-small { color: rgba(var(--brand-rgb),.55); }
.topbar .btn-secondary {
  background: rgba(var(--brand-rgb),.10);
  color: var(--brand);
  border: 1px solid rgba(var(--brand-rgb),.25);
}
.topbar .btn-secondary:hover { background: rgba(var(--brand-rgb),.18); opacity: 1; }
.topbar .btn-ghost   { color: rgba(255,255,255,.85); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }

.page-body { padding: 24px; flex: 1; }

/* ── A faint rule between columns ─────────────────────────────────────
   These order tables run to a dozen columns and more. Without a divider the
   eye loses which value belongs to which heading halfway across. Deliberately
   very light — it should separate, not draw attention. The expanded detail row
   spans the whole table, so it is exempt. */
.table-wrap table > thead th:not(:last-child),
.table-wrap table > tbody > tr > td:not(:last-child) { border-right: 1px solid rgba(0,0,0,.08); }
.table-wrap table > tbody > tr.order-detail-row > td { border-right: 0; }

/* The message bubble is an icon, not a value — centred under its heading it
   reads as something to aim at, rather than clinging to the column's left edge.
   Only this column: everything either side keeps the alignment it had. */
.table-wrap table > thead th.col-msg,
.table-wrap table > tbody > tr > td.col-msg { text-align: center; }


/* ── Promised orders ──────────────────────────────────────────────────
   An order MMW has committed to a date on is solid baby blue everywhere it
   appears, until it is completed — the whole point is that it cannot be
   scrolled past. !important is needed because these rows carry their own
   inline backgrounds; status badges keep their own colours. */
tr.promised-row > td { background: #89cff0 !important; color: #08344a !important; border-bottom-color: #5bb8e0 !important; }
tr.promised-row > td :not(.badge):not(.badge *) { color: #08344a !important; }
tr.promised-row > td:first-child { box-shadow: inset 3px 0 0 #1e6f96; }
.promised-badge { display:inline-block; padding:2px 9px; border-radius:10px; background:#89cff0; color:#08344a !important; font-weight:800; font-size:11px; white-space:nowrap; }


/* ── Notification banner ──────────────────────────────────── */
.notif-banner {
  background: #1e3a5f;
  border-bottom: 2px solid #3b82f6;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #bfdbfe;
}
.notif-banner strong { color: #fff; }
.notif-banner .notif-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #93c5fd;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.notif-banner .notif-close:hover { background: rgba(59,130,246,.2); color: #fff; }
.notif-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(59,130,246,.15);
  font-size: 13px;
}
.notif-item:last-child { border-bottom: none; }

/* ── Stat cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 16px 18px;
  border-top: 3px solid var(--border);
}
.stat-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat-card.blue   { border-top-color: var(--blue);   } .stat-card.blue   .stat-value { color: var(--blue);   }
.stat-card.green  { border-top-color: var(--green);  } .stat-card.green  .stat-value { color: var(--green);  }
.stat-card.amber  { border-top-color: var(--amber);  } .stat-card.amber  .stat-value { color: var(--amber);  }
.stat-card.teal   { border-top-color: var(--teal);   } .stat-card.teal   .stat-value { color: var(--teal);   }
.stat-card.red    { border-top-color: var(--red);    } .stat-card.red    .stat-value { color: var(--red);    }
.stat-card.gold   { border-top-color: #d4a017;       } .stat-card.gold   .stat-value { color: #b8860b;       }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.card + .card { margin-top: 18px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.card-body  { padding: 18px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #f8fafc;
  padding: 9px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 10px 14px; vertical-align: middle; }
tbody tr.expandable { cursor: pointer; }
.td-actions { white-space: nowrap; text-align: right; }
.table-empty { text-align: center; color: var(--muted); padding: 40px; font-size: 13px; }

/* ── Accordion row expansion ──────────────────────────────── */
.order-detail-row td {
  padding: 0;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}
.order-detail-inner {
  padding: 18px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  font-size: 13px;
}
.detail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.detail-value { color: var(--text); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary   { background: #111; color: var(--brand); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-success   { background: var(--green); color: #fff; }
.btn-ghost     { background: transparent; color: var(--muted); padding: 6px 10px; }
.btn-ghost:hover { background: var(--border); color: var(--text); opacity: 1; }
.btn-sm   { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; }
.btn svg  { width: 14px; height: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Badges / Status ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #d1fae5; color: #047857; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-teal   { background: #cffafe; color: #0e7490; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gold   { background: #fef9c3; color: #713f12; }

/* ── Forms ────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }
label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=password], select, textarea {
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17,17,17,.08);
}
textarea { resize: vertical; min-height: 70px; }
.input-prefix {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}
.input-prefix span {
  padding: 8px 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  border-right: 1.5px solid var(--border);
  white-space: nowrap;
}
.input-prefix input { border: none; border-radius: 0; box-shadow: none; }
.input-prefix input:focus { box-shadow: none; }
.input-prefix:focus-within { border-color: #111; box-shadow: 0 0 0 3px rgba(17,17,17,.08); }
.input-readonly {
  background: #f8fafc;
  color: var(--muted);
  cursor: default;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 36px 16px;
  z-index: 200;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
  margin: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 22px; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body   { padding: 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 0 0 12px 12px;
}

/* ── Toolbar / search bar ─────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 300px; }
.search-wrap input { padding-left: 34px; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search-icon svg { width: 14px; height: 14px; display: block; }
select.select-input, select {
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

/* ── Completion photo ─────────────────────────────────────── */
.completion-photo {
  border: 2px solid #6ee7b7;
  border-radius: 10px;
  overflow: hidden;
  background: #f0fdf4;
}
.completion-photo-header {
  background: #d1fae5;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #047857;
  display: flex;
  align-items: center;
  gap: 6px;
}
.completion-photo img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #fff;
  display: block;
}

/* Detail row split: text fields on the left, a tall thumbnail on the right
   that fills whatever height the dropdown ends up being. */
.order-detail-flex { display: flex; align-items: stretch; flex-wrap: wrap; }
/* flex-basis, not plain flex:1 — on a tablet the visible width can be less
   than the fields plus the 280px photo column, and with flex:1 the fields
   squeezed down to a few pixels wide instead of the photo dropping below
   them. The basis is what flex-wrap measures against, so the two now wrap
   onto separate lines before either gets unreadable. */
/* And a ceiling, so the photo sits NEXT TO the text rather than against the
   far edge of the screen. Pinning the row to the visible width stopped the
   photo being off the page, but the fields then stretched to fill whatever
   was left and pushed it back out to the margin on a wide monitor — right
   answer, wrong distance. The fields stop at a readable width and the photo
   follows immediately after them. */
.order-detail-flex .order-detail-inner { flex: 1 1 340px; min-width: 0; max-width: 720px; }
/* Notes, Company Notes and the hold reason run the full width of the row.
   Left to it, a paragraph typed in the Office System stretches across the
   whole screen — hard to read, and it was what shoved the completion photo
   out past the right edge. Cap it at a readable line instead; the photo
   column keeps its place beside the fields either way. */
.detail-note-block { max-width: 68ch; }
.detail-note-block .detail-value { overflow-wrap: break-word; }
.order-detail-photo-col {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 2px solid #6ee7b7;
  background: #f0fdf4;
}
.order-detail-photo-col .completion-photo-header {
  justify-content: center;
  text-align: center;
  font-size: 10px;
  padding: 6px 8px;
}
.order-detail-photo-col img {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 120px;
  object-fit: cover;
  cursor: pointer;
  display: block;
  transition: opacity .15s;
}
.order-detail-photo-col img:hover { opacity: .85; }

/* ── Completion photo lightbox ────────────────────────────── */
#completion-photo-lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
}
/* One scrollable panel — an order can have more than one completion photo,
   so they stack here rather than opening as separate files. */
#completion-photo-lightbox .cpl-img-wrap {
  max-width: 900px; width: 100%; max-height: 75vh; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
#completion-photo-lightbox img {
  max-width: 100%; max-height: 75vh; object-fit: contain;
  border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); flex-shrink: 0;
}
#completion-photo-lightbox .cpl-actions {
  display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; justify-content: center;
}

/* ── Misc helpers ─────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-small  { font-size: 12px; }
.font-bold   { font-weight: 700; }
.text-right  { text-align: right; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.flex-gap    { display: flex; gap: 8px; align-items: center; }
.divider     { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.no-data     { text-align: center; color: var(--muted); font-size: 14px; padding: 48px 20px; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Period tabs ──────────────────────────────────────────── */
.period-tabs { display: flex; gap: 4px; background: #f1f5f9; border-radius: 8px; padding: 3px; }
.period-tab {
  flex: 1; padding: 6px 12px; border-radius: 6px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--muted); background: transparent; transition: all .15s;
}
.period-tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ── Filter tabs ──────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: var(--muted);
  transition: all .15s;
}
.filter-tab:hover { border-color: #111; color: var(--text); }
.filter-tab.active { background: #111; color: var(--brand); border-color: #111; }

/* ══════════════════════════════════════════════════════
   AGENT PORTAL EXTENSIONS
══════════════════════════════════════════════════════ */

/* ── Login / PIN page ─────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #111111 0%, #1a1a2e 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 40px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,.4);
  text-align: center;
}
.login-logo-mark {
  width: 64px; height: 64px;
  background: #111;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.login-logo-mark span {
  color: var(--brand);
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 1px;
}
/* The company's own logo (on its own address): most are wide letterheads, so
   the mark widens to fit it rather than squeezing it into a square. */
.login-logo-mark.has-logo {
  width: auto; max-width: 260px; height: 84px;
  background: #fff; padding: 10px 16px;
}
.login-logo-mark.has-logo img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 32px;
}

/* ── 6-box PIN input ──────────────────────────────────────── */
.pin-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 28px;
}
.pin-input {
  width: 48px; height: 56px;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -moz-appearance: textfield;
  appearance: textfield;
  caret-color: var(--brand);
}
.pin-input::-webkit-outer-spin-button,
.pin-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.pin-input:focus {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17,17,17,.1);
  background: #fff;
}
.pin-input.filled { border-color: #111; background: #fff; }
.login-name-input {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 14px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-name-input:focus {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17,17,17,.1);
  background: #fff;
}
.login-btn {
  width: 100%;
  padding: 13px;
  background: #111;
  color: var(--brand);
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  letter-spacing: .3px;
}
.login-btn:hover { opacity: .88; }
.login-btn:disabled { opacity: .45; cursor: not-allowed; }
.login-error {
  margin-top: 14px;
  padding: 10px 14px;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  display: none;
}
.login-spinner {
  display: none;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-ring {
  width: 18px; height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: #111;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Commission cards ─────────────────────────────────────── */
.commission-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 22px 24px;
  text-align: center;
}
.commission-card .comm-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 10px;
}
.commission-card .comm-amount {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}
.comm-pending  { color: var(--amber); }
.comm-paid     { color: var(--green); }
.comm-available {
  color: var(--gold-dk);
  font-size: 38px !important;
}
.comm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

/* ── Draw button ─────────────────────────────────────────────*/
.draw-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--brand), #f59e0b);
  color: #111;
  font-size: 15px;
  font-weight: 800;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  letter-spacing: .2px;
  text-align: center;
  text-decoration: none;
  margin-top: 8px;
}
.draw-btn:hover { opacity: .88; text-decoration: none; transform: translateY(-1px); }
.draw-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* ── Stat strip ───────────────────────────────────────────── */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 22px;
}
.stat-strip-item {
  padding: 16px 20px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.stat-strip-item:last-child { border-right: none; }
.stat-strip-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-strip-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-strip-value.currency { font-size: 18px; }
.stat-strip-note {
  font-size: 10px; color: var(--muted); margin-top: 3px;
  line-height: 1.3; font-weight: 500;
}

/* ── Quick actions ────────────────────────────────────────── */
.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* ── Completed order grid ─────────────────────────────────── */
.completed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.completed-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.completed-card-photo {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f1f5f9;
  display: block;
}
.completed-card-photo-placeholder {
  width: 100%;
  height: 180px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}
.completed-card-body {
  padding: 14px 16px;
}
.completed-card-ref {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.completed-card-family {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0 2px;
}
.completed-card-cemetery {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.completed-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

/* ── Chart bar ────────────────────────────────────────────── */
.chart-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
}
.chart-bar-label { width: 80px; text-align: right; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.chart-bar-track {
  flex: 1;
  height: 20px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}
.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #f59e0b);
  border-radius: 4px;
  transition: width .5s ease;
  min-width: 4px;
}
.chart-bar-value { width: 70px; font-weight: 700; color: var(--text); }

/* ── Service checkbox grid ────────────────────────────────── */
.svc-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.svc-label:hover { border-color: #888; }
.svc-label.checked { border-color: #111; background: #f5f5f5; }
.svc-price {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}

/* ── Success screen ───────────────────────────────────────── */
.success-card {
  background: #d1fae5;
  border: 2px solid #059669;
  border-radius: 14px;
  padding: 40px;
  text-align: center;
  max-width: 520px;
  margin: 60px auto;
}
.success-icon { font-size: 52px; margin-bottom: 14px; }
.success-title { font-size: 24px; font-weight: 800; color: #047857; margin-bottom: 10px; }
.success-body { font-size: 14px; color: #065f46; line-height: 1.7; margin-bottom: 24px; }

/* ══════════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE — bottom nav
══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  body { flex-direction: column; }

  /* Hide desktop sidebar */
  #nav-sidebar { display: none !important; }

  .main-content { min-height: 100vh; padding-bottom: var(--bottom-nav-h); }

  .topbar { padding: 0 16px; }
  .topbar-title { font-size: 15px; }
  .page-body { padding: 16px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-group.span-2 { grid-column: span 1; }
  .form-group.span-3 { grid-column: span 1; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 20px; }

  .comm-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  /* Two per row on a phone: every even item ends its row, and everything
     past the first row gets a rule above it. Written by position rather
     than by index so the strip can grow without this going stale. */
  .stat-strip-item:nth-child(even) { border-right: none; }
  .stat-strip-item:nth-child(n+3) { border-top: 1px solid var(--border); }

  .completed-grid { grid-template-columns: 1fr; }

  .modal-overlay { padding: 16px; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-width: 100%; margin-bottom: 0; }

  table { font-size: 12px; }
  thead th { padding: 7px 10px; }
  tbody td { padding: 8px 10px; }

  .period-tabs .period-tab { font-size: 12px; padding: 5px 8px; }
  .filter-tabs .filter-tab { font-size: 11px; padding: 5px 10px; }

  /* Login card */
  .login-card { padding: 32px 24px 28px; }
  .pin-input { width: 42px; height: 50px; font-size: 20px; }
  .pin-row { gap: 7px; }
}

/* ── Bottom nav bar ───────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: #111111;
  border-top: 2px solid rgba(var(--brand-rgb),.18);
  z-index: 100;
  padding: 0;
}
.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 100%;
}
.bottom-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: rgba(var(--brand-rgb),.4);
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  padding: 8px 4px;
  transition: color .15s, background .15s;
  border-top: 3px solid transparent;
  position: relative;
}
.bottom-nav-link:hover { color: rgba(var(--brand-rgb),.75); text-decoration: none; }
.bottom-nav-link.active {
  color: var(--brand);
  border-top-color: var(--brand);
  background: rgba(var(--brand-rgb),.06);
}
.bottom-nav-link svg { width: 20px; height: 20px; }
.bottom-nav-badge {
  position: absolute;
  top: 6px; right: calc(50% - 18px);
  background: #dc2626;
  color: #fff;
  border-radius: 8px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 800;
}
.bottom-nav-more-panel {
  display: none;
  /* Phone held sideways: the More list is taller than the space above the
     bottom bar, so it scrolls instead of running off the top. */
  max-height: calc(100dvh - var(--bottom-nav-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  position: fixed;
  bottom: var(--bottom-nav-h);
  left: 0; right: 0;
  background: #111;
  border-top: 1px solid rgba(var(--brand-rgb),.15);
  padding: 12px 0;
  z-index: 99;
}
.bottom-nav-more-panel.open { display: block; }
.bottom-nav-more-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(var(--brand-rgb),.6);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.bottom-nav-more-link:hover { background: rgba(var(--brand-rgb),.08); color: var(--brand); text-decoration: none; }
.bottom-nav-more-link svg { width: 18px; height: 18px; flex-shrink: 0; }

@media (max-width: 768px) {
  .bottom-nav { display: block; }
}

/* Cancelled: black, white lettering — kept on the list so it can be looked
   up, with the reason under the badge. */
.badge-black  { background: #000; color: #fff; }
tr.cancelled-row > td { background: #000 !important; color: #fff !important; border-bottom-color: #333 !important; }
tr.cancelled-row > td * { color: #fff !important; }
tr.cancelled-row > td .badge { background: #fff !important; color: #000 !important; }
tr.cancelled-row:hover > td { background: #111 !important; }
