:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1e293b;
    --border: #1f2937;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --danger: #f87171;
    --danger-bg: rgba(220, 38, 38, 0.14);
    --danger-border: rgba(248, 113, 113, 0.35);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem;
}

.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-shell {
  min-height: 100dvh;
  justify-content: center;
  max-width: 420px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.brand-row h1 {
  margin: 0;
  font-size: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 650;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.row-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

@media (max-width: 560px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
}

input, select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

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

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.btn-full {
  width: 100%;
}

.muted {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.83rem;
  word-break: break-all;
}

.alert {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.alert-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.pkg-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.pkg-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}

.pkg-card:hover {
  border-color: var(--accent);
}

.pkg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.pkg-title {
  font-weight: 650;
  font-size: 1rem;
  margin: 0;
}

.pkg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.pkg-event {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-delivered {
  background: rgba(22, 163, 74, 0.16);
  color: #15803d;
}

.badge-pickup {
  background: rgba(2, 132, 199, 0.16);
  color: #0369a1;
}

.badge-transit {
  background: rgba(234, 179, 8, 0.2);
  color: #a16207;
}

.badge-exception {
  background: rgba(220, 38, 38, 0.16);
  color: #b91c1c;
}

.badge-pending, .badge-muted {
  background: var(--surface-2);
  color: var(--muted);
}

@media (prefers-color-scheme: dark) {
  .badge-delivered { color: #4ade80; }
  .badge-pickup { color: #38bdf8; }
  .badge-transit { color: #facc15; }
  .badge-exception { color: #f87171; }
}

.timeline {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0 0 0 1.15rem;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.48rem;
  top: 0.35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.timeline-date {
  font-size: 0.8rem;
  color: var(--muted);
}

.timeline-detail {
  font-size: 0.93rem;
  font-weight: 500;
}

.timeline-loc {
  font-size: 0.82rem;
  color: var(--muted);
}
