:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --line: #e4e4e0;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --err: #c0362c;
  --info: #2f6fde;
  --tint: 14%;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214; --card: #1c1c1f; --text: #ececee; --muted: #9a9aa0; --line: #2c2c31;
    --accent: #6b9cff; --accent-text: #0d1220; --ok: #4cc07e; --warn: #e3a33b; --err: #f0726a; --info: #6b9cff;
    --tint: 22%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121214; --card: #1c1c1f; --text: #ececee; --muted: #9a9aa0; --line: #2c2c31;
  --accent: #6b9cff; --accent-text: #0d1220; --ok: #4cc07e; --warn: #e3a33b; --err: #f0726a; --info: #6b9cff;
  --tint: 22%;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

header {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; margin: 0 auto; padding: 14px 16px;
}
.brand { font-weight: 650; color: var(--text); }
nav { display: flex; align-items: center; gap: 6px; }
nav a, nav button { font-size: 1.15rem; color: var(--muted); padding: 4px 8px; }
nav form { margin: 0; }

main { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin: 0 0 14px;
}
.card.narrow { max-width: 380px; margin: 8vh auto 0; }
label { display: block; margin: 0 0 12px; font-size: .9rem; color: var(--muted); }
label input { display: block; width: 100%; margin-top: 4px; }
input {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-width: 0;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 9px 16px;
  background: var(--accent); color: var(--accent-text); font-weight: 550;
}
button.ghost { background: transparent; color: var(--accent); padding: 6px 10px; font-weight: 500; }
nav button.ghost { color: var(--muted); }
button:disabled { opacity: .55; cursor: progress; }
form.busy { cursor: progress; }

.add { display: flex; gap: 8px; flex-wrap: wrap; }
.add input[name=number] { flex: 2 1 220px; }
.add input[name=name] { flex: 1 1 150px; }
.add + .small { margin: -6px 0 18px; }

.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; }
.flash.ok { background: color-mix(in srgb, var(--ok) var(--tint), transparent); }
.flash.err { background: color-mix(in srgb, var(--err) var(--tint), transparent); }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: inherit; }
.list a:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.list .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list .main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
.list .side { text-align: right; font-size: .85rem; white-space: nowrap; }
.today { color: var(--ok); font-weight: 650; }
.list .empty { padding: 20px 16px; }
.list .badge { width: 9.5em; flex: none; text-align: center; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  --c: var(--muted); color: var(--c); background: color-mix(in srgb, var(--c) var(--tint), transparent);
}
.badge.info_received, .badge.in_transit { --c: var(--info); }
.badge.out_for_delivery, .badge.available_for_pickup { --c: var(--warn); }
.badge.delivered { --c: var(--ok); }
.badge.failed_attempt, .badge.exception { --c: var(--err); }

.tag {
  display: inline-block; font-size: .72rem; font-weight: 600; padding: 0 6px; border-radius: 5px;
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 45%, transparent); color: var(--c, var(--muted));
  vertical-align: 1px;
}
.tag.info_received, .tag.in_transit { --c: var(--info); }
.tag.out_for_delivery, .tag.available_for_pickup { --c: var(--warn); }
.tag.delivered { --c: var(--ok); }
.tag.failed_attempt, .tag.exception { --c: var(--err); }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.head p { margin: 0; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 14px 0; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; }
form.inline { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 0; }
form.inline input { flex: 1 1 160px; padding: 6px 10px; }

.timeline { list-style: none; margin: 18px 0 0; padding: 0 0 0 20px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 18px 14px; display: flex; flex-direction: column; }
.timeline li::before {
  content: ""; position: absolute; left: -27px; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--line);
}
.timeline li.now::before { background: var(--accent); border-color: var(--accent); }
.timeline time { font-size: .8rem; color: var(--muted); }
.timeline strong { font-weight: 500; }
.timeline .muted { font-size: .88rem; }

@media (max-width: 520px) {
  .list a { flex-wrap: wrap; }
  .list .badge { width: auto; order: 2; }
  .list .main { flex-basis: 100%; }
  .list .side { order: 3; margin-left: auto; }
}
