:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --border: #d3dbe6;
  --border-strong: #b6c2d2;
  --text: #0f172a;
  --muted: #55637a;
  --faint: #7b879b;
  --accent: #0369a1;
  --accent-soft: #e0f2fe;
  --ok: #047857;
  --ok-soft: #d1fae5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --tap: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  /* Room for the fixed bottom navigation and the phone's home indicator. */
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

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

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1rem;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.mono {
  font-family: var(--mono);
  font-size: 0.85em;
}

.small {
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------ header */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: #0c4a6e;
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(12, 74, 110, 0.25);
}

.appbar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #ffffff;
  text-decoration: none;
  font-weight: 650;
}

.appbar .brand img {
  width: 24px;
  height: 24px;
  display: block;
}

.appbar .brand small {
  display: block;
  font-size: 0.7rem;
  font-weight: 450;
  opacity: 0.8;
  letter-spacing: 0.04em;
}

.appbar .spacer {
  flex: 1;
}

.appbar .who {
  font-size: 0.82rem;
  opacity: 0.9;
  text-align: right;
}

/* ------------------------------------------------------------------- layout */

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.card-head .grow {
  flex: 1;
}

.section-title {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}

.page-title {
  margin-bottom: 14px;
}

.page-title h1 {
  font-size: 1.3rem;
}

.page-title p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

/* -------------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 13px 14px;
}

.stat .k {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}

.stat .v {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.55;
  pointer-events: none;
}

.btn-sm {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions .btn {
  flex: 1;
  min-width: 140px;
}

/* -------------------------------------------------------------------- forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

input[type='text'],
input[type='email'],
input[type='tel'],
input[type='password'],
input[type='number'],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 3px solid #7dd3fc;
  outline-offset: 1px;
}

/* -------------------------------------------------------------------- lists */

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  color: inherit;
  text-decoration: none;
}

.item.collected {
  border-left-color: var(--ok);
}

.item.cancelled {
  border-left-color: var(--danger);
  opacity: 0.75;
}

.item .top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.item .top .grow {
  flex: 1;
}

.item .name {
  font-weight: 650;
  font-size: 1rem;
}

.item .sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 3px;
}

.item .row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.kv {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--surface-2);
  font-size: 0.92rem;
}

.kv:last-child {
  border-bottom: 0;
}

.kv .k {
  flex: 0 0 42%;
  color: var(--muted);
}

.kv .v {
  flex: 1;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-scheduled,
.pill-assigned,
.pill-pending,
.pill-in_progress {
  color: var(--warn);
  background: var(--warn-soft);
}

.pill-en_route {
  color: var(--accent);
  background: var(--accent-soft);
}

.pill-collected,
.pill-completed {
  color: var(--ok);
  background: var(--ok-soft);
}

.pill-cancelled,
.pill-failed {
  color: var(--danger);
  background: var(--danger-soft);
}

.pill-normal,
.pill-low,
.pill-high,
.pill-urgent {
  color: var(--muted);
  background: var(--surface-2);
}

.empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.notice-info {
  background: var(--accent-soft);
  color: #075985;
}

.notice-warn {
  background: var(--warn-soft);
  color: #7c2d12;
}

.notice-error {
  background: var(--danger-soft);
  color: #7f1d1d;
}

.problems {
  margin: 0;
  padding-left: 18px;
  color: var(--danger);
  font-size: 0.88rem;
}

.problems:empty {
  display: none;
}

/* --------------------------------------------------------------- bottom nav */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.07);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 60px;
  color: var(--faint);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.tabbar a[aria-current='page'] {
  color: var(--accent);
  box-shadow: inset 0 3px 0 var(--accent);
}

.tabbar .glyph {
  font-size: 1.15rem;
  line-height: 1;
}

/* -------------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px;
}

.login-card .logo {
  width: 46px;
  height: 46px;
  display: block;
  margin-bottom: 14px;
}

.login-card h1 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.login-card > p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.login-card .btn {
  width: 100%;
  margin-top: 6px;
}

.error-text {
  color: var(--danger);
  font-size: 0.88rem;
  margin-top: 12px;
}

/* -------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  z-index: 40;
  max-width: min(92vw, 460px);
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  background: #0f172a;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-ok {
  background: var(--ok);
}

.toast-error {
  background: var(--danger);
}

/* -------------------------------------------------------------- large text */

@media (min-width: 560px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
  .btn:active {
    transform: none;
  }
}

/* ------------------------------------------------------------ login steps */

.login-card section > p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 16px;
}

.login-card section .btn {
  width: 100%;
  margin-bottom: 10px;
}

.login-card section .btn:last-of-type {
  margin-bottom: 0;
}

/* A quiet button: an alternative route, not a competing action. */
.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  font-weight: 600;
}

.btn-quiet:active {
  transform: none;
  background: var(--accent-soft);
}

/* --------------------------------------------------------------- security */

.credential {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--surface-2);
}

.credential:last-child {
  border-bottom: 0;
}

.credential .grow {
  flex: 1;
  min-width: 0;
}

.credential .name {
  font-weight: 650;
}

.credential .meta {
  color: var(--faint);
  font-size: 0.82rem;
}

.step-list {
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.step-list li {
  margin-bottom: 4px;
}
