/* ============================================================
   Bus ministry app - shared stylesheet
   Brand colours are injected at runtime by common.js from config.js.
   ============================================================ */
:root {
  --primary: #1F3A5F;
  --secondary: #C89B3C;
  --accent: #2F8F83;
  --bg: #F7F5F2;
  --text: #141821;
  --surface: #ffffff;
  --surface-2: #f4f1ec;
  --line: #e4dfd6;
  --muted: #6d7480;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 12px 32px -22px rgba(20, 24, 33, 0.55);
}
html[data-theme="dark"] {
  --surface: #161b22;
  --surface-2: #1d232c;
  --line: #2b333e;
  --muted: #99a3b1;
  --bg: #0f1319;
  --text: #eef1f5;
  --shadow: 0 12px 32px -22px rgba(0, 0, 0, 0.8);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; letter-spacing: -0.01em; }
a { color: inherit; }
button { font: inherit; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  display: none; width: 262px; flex: 0 0 262px; background: var(--primary); color: #fff;
  padding: 20px 16px; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; background: #fff; object-fit: contain; padding: 3px; }
.brand .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--secondary); color: #1a1a1a; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.brand .name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.brand .sub { font-size: 11.5px; opacity: 0.75; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 10px 12px; border-radius: 10px; text-decoration: none; font-size: 14px; color: rgba(255, 255, 255, 0.82); }
.nav a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav a.active { background: var(--secondary); color: #1b1b1b; font-weight: 600; }
.sidebar .foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.16); padding-top: 14px; font-size: 11.5px; opacity: 0.75; line-height: 1.6; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.title-block { flex: 1; min-width: 0; }
.title-block h1 { font-size: 18px; }
.title-block .sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 16px 14px 96px; max-width: 1180px; width: 100%; margin: 0 auto; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { border-color: var(--secondary); }
.icon-btn .dot {
  position: absolute; top: -5px; right: -5px; background: var(--secondary); color: #1b1b1b;
  border-radius: 999px; font-size: 10px; font-weight: 700; padding: 1px 5px;
}
.user-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drawer {
  position: fixed; inset: 0 auto 0 0; width: 274px; background: var(--primary); color: #fff; padding: 18px 16px;
  transform: translateX(-105%); transition: transform 0.25s ease; z-index: 60; display: flex; flex-direction: column; gap: 16px;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head .icon-btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 16, 0.45); z-index: 50; }
.mobile-only { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- cards, layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; }
.card-head .grow { flex: 1; }
.card-body { padding: 16px; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: 1fr; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat .value { font-family: Georgia, serif; font-size: 26px; margin-top: 4px; }
.stat .hint { font-size: 12px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- buttons, tabs, pills ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); padding: 9px 15px; cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: var(--secondary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.gold { background: var(--secondary); border-color: var(--secondary); color: #1b1b1b; font-weight: 600; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.tab { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; cursor: pointer; white-space: nowrap; font-size: 13.5px; }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pill { border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.yes, .pill.submitted, .pill.ok { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--accent); }
.pill.no, .pill.needs { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); color: var(--danger); }
.pill.progress { background: color-mix(in srgb, var(--secondary) 26%, var(--surface)); color: #8a6417; }
.badge { border-radius: 6px; padding: 2px 7px; font-size: 11px; background: var(--surface-2); color: var(--muted); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 12px; }
.field .label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--secondary) 55%, transparent); border-color: var(--secondary); }
textarea { min-height: 92px; resize: vertical; }
input[type="color"] { padding: 3px; height: 42px; }
input[type="checkbox"] { width: auto; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch .switch-text { font-size: 13.5px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1 1 180px; margin-bottom: 0; }

/* ---------- streets + riders ---------- */
.street { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); margin-top: 10px; }
.street.done { opacity: 0.72; }
.street-head {
  width: 100%; display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 0;
  padding: 12px 14px; cursor: pointer; text-align: left; color: inherit;
}
.street-head .chev { display: inline-block; transition: transform 0.2s ease; color: var(--muted); }
.street-head.open .chev { transform: rotate(90deg); }
.street-name { font-weight: 600; flex: 1; }
.street-count { font-size: 12px; color: var(--muted); }
.street-head .tick { color: var(--accent); font-weight: 700; }
.street-body { padding: 8px 12px 12px; }
.rider { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.rider:last-child { border-bottom: 0; }
.rider-main { flex: 1 1 210px; min-width: 0; }
.rider-name { font-weight: 600; }
.rider-meta { font-size: 12.5px; color: var(--muted); }
.status-group { display: flex; gap: 6px; flex-wrap: wrap; }
.status-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 11px;
  cursor: pointer; font-size: 13px;
}
.status-btn[aria-pressed="true"][data-status="yes"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.status-btn[aria-pressed="true"][data-status="no"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.status-btn[aria-pressed="true"][data-status="na"] { background: var(--secondary); border-color: var(--secondary); color: #1b1b1b; }
.status-btn[aria-pressed="true"][data-status="on"], .status-btn[aria-pressed="true"][data-status="off"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.area-block { margin-top: 18px; }
.area-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.area-head h2 { font-size: 17px; }
.visitor-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; font-size: 14px; }

/* ---------- lists + tables ---------- */
.list { display: flex; flex-direction: column; }
.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 12.5px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.photo { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.thumb { width: 78px; height: 58px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }

/* ---------- states ---------- */
.loading, .empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 46px 18px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 19px; }
.empty-art { width: 46px; height: 46px; border-radius: 14px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: var(--surface-2); border-radius: 10px; height: 76px; animation: pulse 1.4s ease-in-out infinite; }
.skel + .skel { margin-top: 12px; }
@keyframes pulse { 50% { opacity: 0.55; } }
.banner { border-left: 4px solid var(--secondary); background: color-mix(in srgb, var(--secondary) 12%, var(--surface)); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.banner.info { border-color: var(--primary); background: var(--surface-2); }
.banner.ok { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.banner.warn { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.banner .banner-title { font-weight: 600; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(12, 15, 20, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 80; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.6); }
.modal.small { max-width: 400px; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--primary); color: #fff; border-radius: 11px; padding: 11px 13px; display: flex; gap: 10px;
  align-items: center; font-size: 13.5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: 0.25s ease;
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast.ok { background: var(--accent); }
.toast.warn { background: var(--danger); }
.toast button { border: 0; background: transparent; color: inherit; cursor: pointer; }

/* ---------- auth ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 22px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand img { width: 46px; height: 46px; object-fit: contain; border-radius: 12px; background: #fff; padding: 4px; border: 1px solid var(--line); }
.auth-brand .mark { width: 46px; height: 46px; border-radius: 12px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.auth-brand h1 { font-size: 20px; }
.auth-brand .sub { font-size: 12.5px; color: var(--muted); }
.auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }

@media (min-width: 960px) {
  .sidebar { display: flex; }
  .mobile-only { display: none; }
  .topbar { padding: 14px 26px; }
  .content { padding: 22px 26px 80px; }
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
  .title-block h1 { font-size: 21px; }
}
