/* =====================================================
   FAMILIFOOD SALES PORTAL — Global Styles
   Colour palette matched to www.familifood.com
   ===================================================== */

:root {
  --ff-red:        #C0272D;
  --ff-red-dark:   #8B0000;
  --ff-red-light:  #E53935;
  --ff-black:      #0D0D0D;
  --ff-dark:       #1A1A1A;
  --ff-dark2:      #242424;
  --ff-dark3:      #2E2E2E;
  --ff-mid:        #3A3A3A;
  --ff-border:     #3D3D3D;
  --ff-text:       #F0F0F0;
  --ff-text-muted: #A0A0A0;
  --ff-white:      #FFFFFF;
  --ff-cream:      #F8F4EF;
  --ff-success:    #2E7D32;
  --ff-warning:    #E65100;
  --ff-info:       #1565C0;
  --ff-btn-text:   #FFFFFF;
  --radius:        8px;
  --shadow:        0 4px 20px rgba(0,0,0,0.5);
  --transition:    all 0.2s ease;
}

/* Light theme — swaps the same palette variables everything else already
   uses, so it applies portal-wide without touching individual components.
   Toggled by setting data-theme="light" on <html> (see api.js applyBranding). */
:root[data-theme="light"] {
  --ff-black:      #F4F4F4;
  --ff-dark:       #FFFFFF;
  --ff-dark2:      #FFFFFF;
  --ff-dark3:      #F0F0F0;
  --ff-mid:        #E0E0E0;
  --ff-border:     #DADADA;
  --ff-text:       #1A1A1A;
  --ff-text-muted: #6B6B6B;
  --ff-white:      #111111;
  --shadow:        0 4px 20px rgba(0,0,0,0.1);
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--ff-black);
  color: var(--ff-text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--ff-red-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--ff-dark); }
::-webkit-scrollbar-thumb { background: var(--ff-mid); border-radius: 3px; }

/* ===================== LAYOUT ===================== */
.app-shell {
  display: flex;
  /* Pinned to the visible screen on all four sides. iPhone Safari sizes 100vh/100dvh/innerHeight differently while its toolbars move, which
     left the bottom of the scrolling area underneath the toolbar (reps could not scroll to the end of a page). A fixed box always matches
     what is really visible. */
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--ff-dark);
  border-right: 1px solid var(--ff-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--ff-border);
  text-align: center;
}

.sidebar-logo img {
  max-width: 140px;
  height: auto;
}

.sidebar-logo .portal-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ff-red-light);
  margin-top: 6px;
}

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ff-border);
}

.sidebar-user .user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ff-white);
}

.sidebar-user .user-role {
  font-size: 12px;
  color: var(--ff-text-muted);
  text-transform: capitalize;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ff-text-muted);
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--ff-text-muted);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: var(--transition);
  font-size: 14px;
}

.nav-item:hover {
  background: var(--ff-dark2);
  color: var(--ff-white);
}

.nav-item.active {
  background: rgba(192, 39, 45, 0.12);
  color: var(--ff-red-light);
  border-left-color: var(--ff-red);
}

.nav-item .nav-icon { font-size: 17px; }

.nav-badge {
  margin-left: auto;
  background: var(--ff-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--ff-border);
}

.btn-logout {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1px solid var(--ff-border);
  color: var(--ff-text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.btn-logout:hover {
  border-color: var(--ff-red);
  color: var(--ff-red-light);
}

.main-area {
  flex: 1;
  min-width: 0;
  min-height: 0;   /* without this Safari lets a flex child grow to its content instead of scrolling inside it */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ff-black);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  border-bottom: 1px solid var(--ff-border);
  background: var(--ff-dark);
  flex-shrink: 0;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--ff-white);
}

.content {
  flex: 1 1 auto;
  min-height: 0;   /* see .main-area */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;   /* smooth, reliable touch scrolling on older iPhones */
  overscroll-behavior-y: contain;
  padding: 28px;
}

/* ===================== CARDS ===================== */
.card {
  background: var(--ff-dark2);
  border: 1px solid var(--ff-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ff-white);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .card-icon { color: var(--ff-red-light); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--ff-dark2);
  border: 1px solid var(--ff-border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--ff-red-light);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--ff-text-muted);
  margin-top: 4px;
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--ff-red);
  color: var(--ff-btn-text);
}

.btn-primary:hover { background: var(--ff-red-dark); }

.btn-secondary {
  background: var(--ff-dark3);
  color: var(--ff-text);
  border: 1px solid var(--ff-border);
}

.btn-secondary:hover { background: var(--ff-mid); }

.btn-success {
  background: var(--ff-success);
  color: var(--ff-white);
}

.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===================== TABLE ===================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead tr {
  background: var(--ff-dark3);
  border-bottom: 2px solid var(--ff-border);
}

thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--ff-text-muted);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--ff-border);
  transition: background .15s;
}

tbody tr:hover { background: var(--ff-dark3); }

tbody td { padding: 11px 14px; color: var(--ff-text); }

/* ===================== FORMS ===================== */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 13px;
  color: var(--ff-text-muted);
  margin-bottom: 5px;
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--ff-dark3);
  border: 1px solid var(--ff-border);
  border-radius: var(--radius);
  color: var(--ff-text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .2s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--ff-red);
}

input::placeholder { color: var(--ff-text-muted); }

select option { background: var(--ff-dark3); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ===================== BADGES ===================== */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green  { background: rgba(46,125,50,.25);  color: #66BB6A; }
.badge-red    { background: rgba(192,39,45,.25);  color: #EF5350; }
.badge-orange { background: rgba(230,81,0,.25);   color: #FFA726; }
.badge-gray   { background: rgba(100,100,100,.25);color: #9E9E9E; }
.badge-blue   { background: rgba(21,101,192,.25); color: #42A5F5; }
.badge-purple { background: rgba(142,36,170,.25); color: #CE93D8; }

/* ===================== PIN COLOURS ===================== */
.pin-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.pin-red    { background: #E53935; }
.pin-green  { background: #2E7D32; }
.pin-orange { background: #E65100; }
.pin-black  { background: #757575; }
.pin-purple { background: #8E24AA; }

/* ===================== MODAL ===================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--ff-dark2);
  border: 1px solid var(--ff-border);
  border-radius: 12px;
  width: min(560px, 95vw);
  max-height: 90vh;
  max-height: calc(var(--app-h, 100vh) * 0.9);
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--ff-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ff-white);
}

.modal-close {
  background: none;
  border: none;
  color: var(--ff-text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--ff-white); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ff-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===================== ALERTS ===================== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error   { background: rgba(192,39,45,.2);  border: 1px solid var(--ff-red);    color: #EF9A9A; }
.alert-success { background: rgba(46,125,50,.2);  border: 1px solid var(--ff-success); color: #A5D6A7; }
.alert-info    { background: rgba(21,101,192,.2); border: 1px solid var(--ff-info);   color: #90CAF9; }

/* ===================== INVENTORY BARS ===================== */
.inv-bar-wrap {
  background: var(--ff-dark3);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-top: 4px;
  width: 120px;
  display: inline-block;
}

.inv-bar-fill {
  height: 100%;
  background: var(--ff-red);
  border-radius: 4px;
  transition: width .4s;
}

.inv-bar-fill.mid  { background: var(--ff-warning); }
.inv-bar-fill.high { background: var(--ff-success); }

/* ===================== LOADING ===================== */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--ff-border);
  border-top-color: var(--ff-red);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== BLINKING PIN ===================== */
@keyframes blink-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(1.4); }
}

.blink-marker { animation: blink-pulse 1.2s ease-in-out infinite; }

/* Attention button: flips between white-on-black and black-on-white */
@keyframes promo-flash {
  0%, 49%   { background: #000; color: #fff; border-color: #fff; }
  50%, 100% { background: #fff; color: #000; border-color: #000; }
}
.btn.promo-blink { animation: promo-flash 1s steps(1, end) infinite; border: 2px solid #fff; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .btn.promo-blink { animation: none; background: #fff; color: #000; } }

/* ===================== MAP PAGE ===================== */
#map { width: 100%; height: 100%; }

.map-layout {
  display: flex;
  height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
  height: calc(var(--app-h, 100dvh) - 60px);
  overflow: hidden;
}

.map-sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--ff-dark2);
  border-right: 1px solid var(--ff-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.map-sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--ff-border);
}

.map-sidebar-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--ff-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.map-container { flex: 1; position: relative; }

.legend-fab { position: absolute; bottom: 16px; left: 16px; z-index: 15; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--ff-border); background: var(--ff-dark2); color: var(--ff-text); font-size: 20px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.45); }
.legend-panel { position: absolute; bottom: 64px; left: 16px; z-index: 16; width: 270px; max-width: calc(100% - 32px); max-height: 60%; overflow: auto; background: var(--ff-dark2); border: 1px solid var(--ff-border); border-radius: 12px; padding: 12px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.55); }
@media (max-width: 768px) { .legend-fab { width: 44px; height: 44px; } }
.locate-fab {
  display: none; /* shown only on mobile, where the sidebar's own button is hidden */
  position: absolute;
  bottom: 16px;
  left: 16px; /* right side is Google Maps' own zoom +/- controls — don't cover them */
  z-index: 15;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--ff-border);
  background: var(--ff-dark2);
  color: var(--ff-text);
  font-size: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.map-toolbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 8px;
  background: var(--ff-dark2);
  border: 1px solid var(--ff-border);
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.pin-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pin-btn {
  flex: 1 1 calc(50% - 6px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: grab;
  transition: var(--transition);
  color: #fff;
  touch-action: none; /* so pointerdown-drag isn't hijacked by page scroll */
}

.pin-btn:active { cursor: grabbing; }
.pin-btn.active { border-color: #fff; }

.pin-btn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  flex-shrink: 0;
}

.pin-btn-red    { background: #C62828; }
.pin-btn-green  { background: #2E7D32; }
.pin-btn-orange { background: #E65100; }
.pin-btn-black  { background: #424242; }
.pin-btn-purple { background: #6A1B9A; }

/* ===================== MY CUSTOMERS LIST ===================== */
.cust-list { display: flex; flex-direction: column; gap: 8px; }

.cust-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--ff-dark3);
  border: 1px solid var(--ff-border);
  border-radius: var(--radius);
}

.cust-main { flex: 1; min-width: 0; }
.cust-name { font-weight: 600; color: var(--ff-white); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-town { font-weight: 400; color: var(--ff-text-muted); }
.cust-sub { font-size: 12px; color: var(--ff-text-muted); margin-top: 2px; }

.cust-card.deleted { border-style: dashed; opacity: 0.7; }
.cust-deleted-note { font-size: 12px; color: var(--ff-warning); margin-top: 2px; }

.cust-actions { display: flex; gap: 6px; flex-shrink: 0; }

.cust-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--ff-border);
  background: var(--ff-dark2);
  font-size: 17px;
  text-decoration: none;
  cursor: pointer;
}
.cust-act:hover { border-color: var(--ff-red); text-decoration: none; }
.cust-act.disabled { opacity: 0.25; cursor: not-allowed; filter: grayscale(1); }

@media (max-width: 480px) {
  .cust-card { flex-wrap: wrap; }
  .cust-actions { width: 100%; justify-content: space-between; }
  .cust-act { flex: 1; border-radius: var(--radius); }
}

.voice-wrap { position: relative; display: block; }

.voice-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--ff-border);
  background: var(--ff-dark3);
  color: var(--ff-text);
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}

/* Multi-line notes: keep the mic in the bottom corner, not mid-height */
.voice-wrap.is-textarea .voice-btn { top: auto; bottom: 8px; transform: none; }

.voice-btn.listening {
  background: var(--ff-red);
  border-color: var(--ff-red);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.drag-ghost {
  position: fixed;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 500;
}

.visit-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 320px;
  max-width: calc(100vw - 32px);
  overflow-y: auto;
  background: var(--ff-dark2);
  border: 1px solid var(--ff-border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  z-index: 20;
}

/* ===================== LOGIN PAGE ===================== */
.login-page {
  min-height: 100vh;
  min-height: var(--app-h, 100vh);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ff-black);
  background-image: radial-gradient(ellipse at 30% 20%, rgba(192,39,45,.15) 0%, transparent 60%);
}

.login-box {
  width: min(420px, 95vw);
  background: var(--ff-dark2);
  border: 1px solid var(--ff-border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { max-width: 160px; }
.login-logo p { color: var(--ff-text-muted); font-size: 13px; margin-top: 8px; }

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ff-white);
  margin-bottom: 24px;
  text-align: center;
}

/* ===================== MOBILE NAV ===================== */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--ff-border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0;
}

.hamburger-btn span {
  display: block;
  width: 16px;
  height: 2px;
  margin: 0 auto;
  background: var(--ff-text);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .hamburger-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop.open { display: block; }

  .main-area { width: 100%; }

  .topbar { padding: 0 16px; gap: 12px; }

  .content { padding: 16px; }

  .form-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Canvassing map: the sidebar becomes a bottom bar of just the pin-drop
     buttons (the reason a rep opens this page); Options/Recent Visits move
     out of the way, and the floating recentre button takes over from the
     one that lived in the now-hidden Options section. */
  .map-layout { flex-direction: column; position: relative; }
  /* The pin buttons float over the map, well ABOVE the bottom edge. On iPhone the bottom edge is the swipe-up "go home" gesture and on
     Android the gesture bar sits there: dragging a pin from a button flush with the edge closed the app. */
  .map-sidebar {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    z-index: 12;
    width: auto;
    min-width: 0;
    max-height: none;
    overflow: visible;
    background: rgba(38, 38, 38, .94);
    border: 1px solid var(--ff-border);
    border-radius: 26px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .55);
  }
  .map-sidebar-section { border-bottom: none; }
  .map-container { order: 1; flex: 1; min-height: 0; }
  .map-sidebar-pins { padding: 7px 8px; }
  .map-sidebar-pins h3, .pins-hint { display: none; }
  .pin-btn-row { flex-wrap: nowrap; gap: 4px; }
  /* Icon-only on phones — a colour dot with no label, so all 5 fit in one
     row without pushing the map down or needing a scroll. */
  .pin-btn {
    flex: 1 1 0;
    justify-content: center;
    padding: 13px 4px;   /* a little taller than before: an easier target now that the bar floats */
    min-width: 0;
  }
  .pin-btn-label { display: none; }
  .pin-btn-dot { width: 18px; height: 18px; }
  .map-sidebar-extra { display: none; }
  /* the round buttons that used to sit at the bottom now sit above the floating pin bar */
  .locate-fab { display: flex; align-items: center; justify-content: center; bottom: calc(116px + env(safe-area-inset-bottom, 0px)); }
  .legend-fab { bottom: calc(172px + env(safe-area-inset-bottom, 0px)); }
  .legend-panel { bottom: calc(224px + env(safe-area-inset-bottom, 0px)); }

  .visit-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 75vh;
    max-height: calc(var(--app-h, 100vh) * 0.75);
    border-radius: 16px 16px 0 0;
  }
}

/* Native date/time picker icons: follow the theme so they stay visible on dark inputs */
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: 1; filter: none; width: 20px; height: 20px; padding: 3px; border-radius: 6px;
  background-repeat: no-repeat; background-position: center; background-size: 20px 20px;
}
/* Our own bright icons (the browser's default one is a dim grey on dark inputs): light on the dark theme, dark on the light theme */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFB74D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
}
input[type="time"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFB74D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");
}
:root[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="light"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23C0272D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
}
:root[data-theme="light"] input[type="time"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23C0272D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover { background-color: rgba(255,152,0,.18); }

/* Checkboxes & radios: the global input rule stretches inputs to 100% width, which pushed
   these to the middle of their rows. Keep them small, left-aligned and lined up with their text. */
input[type="checkbox"], input[type="radio"] {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  padding: 0;
  margin: 0;
  accent-color: var(--ff-red);
  cursor: pointer;
}
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  line-height: 1.35;
}

/* Rearrangeable dashboard tiles */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; row-gap: 0; }
.dash-grid > [data-tile] { grid-column: 1 / -1; min-width: 0; }
.dash-grid > [data-tile][data-size="half"] { grid-column: auto; }
@media (max-width: 800px) { .dash-grid > [data-tile][data-size="half"] { grid-column: 1 / -1; } }
#dashToolbar { text-align: right; margin-bottom: 10px; }
.dash-editing { outline: 2px dashed var(--ff-border); outline-offset: 4px; border-radius: 10px; position: relative; margin-bottom: 14px; }
.dash-dragging { opacity: .4; }
.dash-ctl { display: flex; justify-content: space-between; align-items: center; background: var(--ff-dark3); border-radius: 8px;
  padding: 6px 10px; margin-bottom: 8px; font-size: 12px; color: var(--ff-text-muted); cursor: grab; user-select: none; }
.dash-ctl button { background: var(--ff-dark2); border: 1px solid var(--ff-border); color: var(--ff-text); border-radius: 6px;
  width: 34px; height: 28px; margin-left: 6px; cursor: pointer; }
