/* Colours taken from the Daniels logo (dan.png): teal #006060 lettering, silver #AEAEB4 lion. */
:root {
  --bg: #f1f4f4;
  --card: rgba(255, 255, 255, 0.86);
  --ink: #12302f;
  --muted: #5b6b6b;
  --line: #d9e1e1;
  --brand: #006060;
  --brand-dark: #004545;
  --brand-ink: #ffffff;
  --brand-tint: #e6f1f0;
  --brand-tint-2: #f0f7f6;
  --silver: #aeaeb4;
  --silver-dark: #8e8e95;
  --accent: var(--silver);
  --accent-ink: #003a3a;
  --good: #1e7d4f;
  --bad: #c62828;
  --warn-bg: #fff4e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 64, 64, 0.06), 0 4px 16px rgba(0, 64, 64, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  position: relative;
  isolation: isolate;
}

/* The Daniels logo as a faint watermark behind every page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("/assets/dan-logo.png") center 58% / min(88vw, 760px) auto no-repeat;
  opacity: 0.22;
}

a { color: var(--brand); }

/* ---------- header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: 0.2px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: #fff;
  display: grid; place-items: center; color: var(--brand); font-weight: 800; font-size: 0.95rem;
  box-shadow: inset 0 -3px 0 var(--silver);
}
.topbar { box-shadow: 0 2px 0 var(--silver); }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button.link { color: var(--brand-ink); text-decoration: none; font-size: 0.9rem; opacity: 0.92; }
.topbar button.link { background: none; border: 0; padding: 6px 4px; cursor: pointer; font: inherit; }

/* ---------- layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 16px; }

.card {
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.card .sub { margin: 0 0 12px; color: var(--muted); font-size: 0.9rem; }
.step {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff;
  display: inline-grid; place-items: center; font-size: 0.85rem; font-weight: 700; flex: none;
}

/* ---------- form controls ---------- */
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 10px 0 4px; }
input[type="text"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* stops iOS zooming into inputs */
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }

.row { display: flex; gap: 8px; align-items: stretch; }
.row > input { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.accent { background: linear-gradient(180deg, #d3d4d8 0%, var(--silver) 100%); color: var(--brand-dark); border-color: var(--silver-dark); }
.btn.primary:active { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.small { min-height: 36px; padding: 0 10px; font-size: 0.85rem; }

.upload-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.toggle:first-of-type { border-top: 0; }
.toggle span small { display: block; color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.toggle input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }

.modes { display: grid; gap: 8px; margin: 10px 0 8px; }
.mode {
  display: flex; gap: 10px; align-items: flex-start; margin: 0; font-weight: 400; cursor: pointer;
  border: 2px solid var(--line); border-radius: 12px; padding: 12px; background: #fff;
  -webkit-tap-highlight-color: transparent;
}
.mode:has(input:checked) { border-color: var(--brand); background: var(--brand-tint-2); }
@media (min-width: 560px) { .modes { grid-template-columns: 1fr 1fr; } }
.mode input { margin-top: 3px; accent-color: var(--brand); }
.mode strong { display: block; }
.mode small { color: var(--muted); }

/* ---------- messages ---------- */
.msg { border-radius: 10px; padding: 10px 12px; font-size: 0.92rem; margin: 10px 0 0; }
.msg.error { background: #fdecea; color: var(--bad); }
.msg.ok { background: #e7f4ea; color: var(--good); }
.msg.info { background: var(--warn-bg); color: #7a4b00; }
.hidden { display: none !important; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.45); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
.btn:not(.primary) .spinner { border-color: rgba(0, 96, 96, 0.25); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- stops editor ---------- */
.preview { width: 100%; max-height: 220px; object-fit: contain; border-radius: 10px; background: #e9edf2; margin-top: 12px; }
.stops { list-style: none; margin: 12px 0 0; padding: 0; }
.stop {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: start;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.stop:first-child { border-top: 0; }
.stop .num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand-tint); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; margin-top: 6px;
}
.stop.bad .num { background: #fdecea; color: var(--bad); }
.stop.bad input.addr { border-color: var(--bad); }
.stop input { padding: 9px 10px; }
.stop .fields { display: grid; gap: 6px; }
.stop .remove { border: 0; background: none; color: var(--muted); font-size: 1.4rem; line-height: 1; padding: 6px 8px; cursor: pointer; }
.count { color: var(--muted); font-size: 0.9rem; }

/* ---------- results ---------- */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.summary div { background: var(--brand-tint-2); border-radius: 10px; padding: 10px; text-align: center; }
.summary b { display: block; font-size: 1.15rem; }
.summary span { color: var(--muted); font-size: 0.8rem; }

#map { width: 100%; height: 340px; border-radius: 12px; background: #e9edf2; margin-bottom: 12px; z-index: 0; }

/* numbered stop pins on the OpenStreetMap map */
.map-pin {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 0.85rem;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.map-pin.home { background: var(--good); }
.map-pin.first { background: var(--silver); color: var(--accent-ink); }

.route { list-style: none; margin: 0; padding: 0; }
.route li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.route li:first-child { border-top: 0; }
.route .badge {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.route .badge.home { background: var(--good); }
.route .badge.first { background: var(--silver); color: var(--accent-ink); }
.route .name { font-weight: 700; }
.route .addr { color: var(--ink); font-size: 0.92rem; }
.route .meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.route .notes { font-size: 0.85rem; background: var(--warn-bg); border-radius: 8px; padding: 4px 8px; margin-top: 6px; display: inline-block; }
.route .warn { color: #7a4b00; font-size: 0.8rem; }

.links { display: grid; gap: 8px; margin-top: 12px; }
.fineprint { color: var(--muted); font-size: 0.8rem; margin-top: 12px; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(0, 96, 96, 0.14) 100%);
}
.login-card { width: 100%; max-width: 380px; border-top: 5px solid var(--brand); }
.login-logo { display: block; width: 72%; max-width: 240px; height: auto; margin: 6px auto 10px; }
.login-title { text-align: center; color: var(--brand); font-weight: 800; font-size: 1.2rem; margin: 0; }
.login-card .brand { color: var(--ink); justify-content: center; margin-bottom: 4px; font-size: 1.25rem; }
.login-card .tag { text-align: center; color: var(--muted); margin: 0 0 12px; }

/* ---------- admin ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; border-top: 0; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: 0.75rem; background: var(--brand-tint); color: var(--brand); border-radius: 999px; padding: 2px 8px; font-weight: 600; }

@media (min-width: 640px) {
  main { padding: 24px 16px; }
  #map { height: 420px; }
}

@media print {
  .topbar, .no-print, #map { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; padding: 0; }
}
