/* ============================================================
   Delivery Helper — "Fleet" theme
   Navy topbar · blue primary · amber accent · soft blue-gray canvas
   ============================================================ */

:root {
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #17202b;
  --ink-soft: #4a5a6b;
  --ink-faint: #77879a;
  --line: #dfe6ef;
  --primary: #2563eb;
  --primary-deep: #1d4ed8;
  --primary-tint: #e8effd;
  --navy: #0f1e33;
  --navy-2: #16294a;
  --accent: #f59e0b;
  --accent-deep: #d97706;
  --success: #16a34a;
  --success-tint: #e4f6ea;
  --success-ink: #14683a;
  --danger: #dc2626;
  --danger-tint: #fdeaea;
  --danger-ink: #8f1f1f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 30, 51, 0.05), 0 4px 14px rgba(15, 30, 51, 0.06);
  --shadow-lift: 0 6px 22px rgba(15, 30, 51, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; margin: 0.4rem 0 1.1rem; }
h1 small { font-weight: 500; }
h2 { font-size: 1.12rem; margin: 0.4rem 0 0.7rem; }
h3 { font-size: 1rem; margin: 1.3rem 0 0.4rem; }
.muted { color: var(--ink-faint); font-size: 0.9em; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.83em; word-break: break-all; }

.container { max-width: 1120px; margin: 0 auto; padding: 1.3rem 1.1rem 3rem; }

/* ---------- top navigation ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff; padding: 0.55rem 1.2rem;
  box-shadow: 0 2px 12px rgba(8, 16, 30, 0.35);
}
.brand { display: flex; align-items: center; gap: 0.55rem; margin-right: auto; }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.12); border-radius: 9px; font-size: 1.05rem;
}
.brand-name { color: #fff; font-weight: 800; letter-spacing: -0.01em; }
.topnav .links { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.topnav .links > a {
  color: #b9c8dd; padding: 0.42rem 0.85rem; border-radius: 999px;
  font-weight: 600; font-size: 0.92rem; transition: background 0.15s, color 0.15s;
}
.topnav .links > a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.topnav .links > a.active { color: #fff; background: rgba(255, 255, 255, 0.16); }
.topnav .links > a.btn { color: #fff; }
.topnav form { margin-left: 0.4rem; }
.linklike {
  background: none; border: 1px solid rgba(255, 255, 255, 0.25); color: #b9c8dd;
  cursor: pointer; font: inherit; font-size: 0.85rem; font-weight: 600;
  padding: 0.3rem 0.8rem; border-radius: 999px; transition: all 0.15s;
}
.linklike:hover { color: #fff; border-color: rgba(255, 255, 255, 0.6); }
.inline { display: inline; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; background: var(--primary); color: #fff !important; border: none;
  padding: 0.55rem 1.15rem; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-weight: 700; font-size: 0.95rem;
  transition: background 0.15s, box-shadow 0.15s, transform 0.08s;
}
.btn:hover { background: var(--primary-deep); text-decoration: none; box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35); }
.btn:active { transform: scale(0.98); }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.85rem; }
.btn-lg { padding: 0.75rem 1.7rem; font-size: 1.05rem; margin-top: 1rem; }
.btn-ghost { background: transparent; color: var(--primary) !important; border: 1.5px solid #bccdea; }
.btn-ghost:hover { background: var(--primary-tint); box-shadow: none; }
.btn-accent { background: var(--accent); color: #201200 !important; }
.btn-accent:hover { background: var(--accent-deep); color: #fff !important; box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3); }
.btn-map { background: var(--success); }
.btn-map:hover { background: #12813b; box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3); }
.btn-visit { background: var(--accent); color: #201200 !important; }
.btn-visit:hover { background: var(--accent-deep); color: #fff !important; }
.btn-close { background: var(--success); width: 100%; margin-top: 0.7rem; }

/* ---------- flash messages ---------- */
.flash {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem;
  font-weight: 500; border: 1px solid; animation: fade-in 0.25s ease-out;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.flash-success { background: var(--success-tint); color: var(--success-ink); border-color: #b5e4c6; }
.flash-error { background: var(--danger-tint); color: var(--danger-ink); border-color: #f3bcbc; }

/* ---------- dashboard cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin: 1.1rem 0 1.6rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1rem; text-align: center; color: inherit;
  box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
a.card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--primary); }
.card-num { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em; color: var(--navy); }
.card-label { color: var(--ink-faint); font-weight: 600; font-size: 0.88rem; }

/* ---------- panels & forms ---------- */
.panel-row { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; margin-bottom: 1.2rem; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.1rem; box-shadow: var(--shadow);
}
.panel summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.panel summary:hover { color: var(--primary); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.8rem; margin: 0.9rem 0; }
label { display: flex; flex-direction: column; font-size: 0.85rem; font-weight: 600; gap: 0.25rem; color: var(--ink-soft); }
label.checkline { flex-direction: row; align-items: center; gap: 0.5rem; }
input, select {
  padding: 0.55rem 0.7rem; border: 1.5px solid #c9d4e3; border-radius: var(--radius-sm);
  font: inherit; font-size: 0.95rem; width: 100%; background: var(--surface);
  color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14); }
input[type="checkbox"] { width: auto; accent-color: var(--primary); }
input[type="file"] { border: 1.5px dashed #c9d4e3; background: var(--surface-2); padding: 0.8rem; cursor: pointer; }
.searchbar { display: flex; gap: 0.5rem; margin: 1.1rem 0; }
.searchbar input { max-width: 400px; }

/* ---------- tables ---------- */
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid #eaeff6; font-size: 0.92rem; }
th {
  background: var(--surface-2); font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 700;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: #f4f7fc; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-visited { background: var(--success-tint); }
.row-visited:hover { background: #d9f0e2 !important; }

/* ---------- badges & progress ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: #e7ecf4; color: var(--ink-soft); border-radius: 999px;
  padding: 0.14rem 0.65rem; font-size: 0.78rem; font-weight: 700; white-space: nowrap;
}
.badge-done { background: var(--success-tint); color: var(--success-ink); }
.progress { height: 6px; background: #e2e9f2; border-radius: 999px; overflow: hidden; min-width: 90px; margin: 0.35rem 0; }
.progress-cell { display: flex; align-items: center; gap: 0.5rem; }
.card-icon { font-size: 1.4rem; margin-bottom: 0.15rem; }
.route-card-status { margin-top: 0.4rem; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #4f8bf7); border-radius: 999px; transition: width 0.3s; }
.progress-fill.full { background: linear-gradient(90deg, var(--success), #34c46b); }

/* ---------- pager ---------- */
.pager { margin: 1.1rem 0; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.page {
  padding: 0.3rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font-weight: 600; font-size: 0.88rem;
}
.page:hover { border-color: var(--primary); text-decoration: none; }
.page.current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- map ---------- */
.map {
  width: 100%; height: 420px; border-radius: var(--radius);
  border: 1px solid var(--line); margin: 1rem 0; box-shadow: var(--shadow);
}

/* ---------- driver pages (mobile-first) ---------- */
.route-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.route-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; color: inherit; display: block; box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.route-card:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--primary); box-shadow: var(--shadow-lift); }
.route-card-name { font-weight: 800; font-size: 1.06rem; color: var(--navy); }
.route-card-meta { color: var(--ink-faint); font-size: 0.85rem; margin: 0.15rem 0 0.55rem; }

.stop-list { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1rem; }
.stop-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 0.95rem 1rem; box-shadow: var(--shadow);
}
.stop-visited { background: #f4fbf6; border-left-color: var(--success); }
.stop-head { display: flex; gap: 0.75rem; align-items: flex-start; }
.stop-seq {
  background: var(--navy); color: #fff; border-radius: 50%;
  width: 1.9rem; height: 1.9rem; display: flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0; font-size: 0.85rem;
}
.stop-visited .stop-seq { background: var(--success); }
.stop-info { flex: 1; min-width: 0; }
.stop-name { font-weight: 800; color: var(--navy); }
.stop-meta { font-size: 0.86rem; color: var(--ink-soft); }
.stop-actions { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.stop-actions .btn { flex: 1; text-align: center; }
.visit-form { display: none; border-top: 1px dashed #c9d4e3; margin-top: 0.9rem; padding-top: 0.7rem; }
.visit-form.open { display: block; animation: fade-in 0.2s ease-out; }
.pay-choice { display: flex; gap: 0.6rem; }
.pay-option {
  flex: 1; flex-direction: row; justify-content: center; align-items: center; gap: 0.45rem;
  border: 2px solid #c9d4e3; border-radius: var(--radius-sm); padding: 0.65rem;
  cursor: pointer; font-weight: 800; font-size: 1rem; background: var(--surface);
  transition: all 0.12s; color: var(--ink-soft);
}
.pay-option input { width: auto; accent-color: var(--primary); }
.pay-option:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); color: var(--primary-deep); }
.stop-collected { margin-top: 0.65rem; font-size: 0.9rem; color: var(--success-ink); font-weight: 700; }

/* ---------- login screen ---------- */
.auth-body {
  min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #0d1b2e 0%, #14335c 55%, var(--primary) 135%);
  padding: 1rem;
}
.auth-wrap { width: 100%; max-width: 380px; }
.auth-card {
  background: var(--surface); border-radius: 18px; padding: 2.2rem 1.8rem;
  box-shadow: 0 18px 50px rgba(4, 16, 32, 0.45);
  animation: auth-in 0.35s ease-out;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-logo {
  width: 64px; height: 64px; margin: 0 auto 0.8rem; font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-tint); border-radius: 18px;
}
.auth-title { text-align: center; margin: 0; font-size: 1.45rem; color: var(--navy); letter-spacing: -0.01em; }
.auth-sub { text-align: center; margin: 0.2rem 0 1.5rem; color: var(--ink-faint); font-size: 0.9rem; }
.auth-error {
  background: var(--danger-tint); color: var(--danger-ink); border: 1px solid #f3bcbc;
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; font-size: 0.9rem; margin-bottom: 1rem;
}
.auth-field { position: relative; margin-bottom: 0.9rem; }
.auth-icon {
  position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%);
  font-size: 1rem; pointer-events: none; opacity: 0.75;
}
.auth-field input {
  width: 100%; padding: 0.8rem 2.6rem 0.8rem 2.5rem; font-size: 1rem;
  border: 1.5px solid #c9d4e3; border-radius: 10px; background: var(--surface-2);
}
.auth-field input:focus { background: var(--surface); }
.auth-eye {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 1.05rem; cursor: pointer; padding: 0.3rem; line-height: 1;
}
.auth-submit {
  width: 100%; margin-top: 0.4rem; padding: 0.85rem; font-size: 1.05rem; font-weight: 800;
  color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  border: none; border-radius: 10px; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.auth-submit:hover { box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45); }
.auth-submit:active { transform: scale(0.985); }
.auth-foot { text-align: center; color: rgba(255, 255, 255, 0.65); font-size: 0.82rem; margin-top: 1.2rem; }

/* ---------- mobile / small screens ---------- */
@media (max-width: 820px) {
  .container { padding: 0.8rem 0.8rem 2.5rem; }
  h1 { font-size: 1.28rem; }

  .topnav { padding: 0.5rem 0.8rem; gap: 0.4rem; }
  .brand { width: 100%; }
  .topnav .links { gap: 0.15rem; width: 100%; font-size: 0.9rem; }

  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  th, td { padding: 0.5rem 0.65rem; }

  .btn { padding: 0.65rem 1.05rem; }
  .btn-sm { padding: 0.42rem 0.7rem; }
  input, select { padding: 0.65rem 0.75rem; }

  .searchbar { flex-wrap: wrap; }
  .searchbar input { max-width: none; flex: 1 1 200px; }

  .map { height: 300px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
  .card { padding: 0.95rem 0.6rem; }
  .card-num { font-size: 1.65rem; }
  .grid-form { grid-template-columns: 1fr; }
  .panel-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stop-actions { flex-direction: column; }
  .pay-choice { flex-direction: row; }
  .pager .page { padding: 0.4rem 0.8rem; }
  .auth-card { padding: 1.7rem 1.2rem; }
}
