:root {
  color-scheme: light dark;
  --background: #f4f6f9;
  --surface: #fff;
  --surface-muted: #e9edf3;
  --text: #172033;
  --text-muted: #5e687a;
  --border: #cbd2de;
  --accent: #2357c6;
  --accent-strong: #183f98;
  --on-accent: #fff;
  --success: #18724b;
  --warning: #946200;
  --danger: #b52a35;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--background); font-size: 15px; line-height: 1.45; }
a { color: inherit; }
button, input, select { font: inherit; }
button, input, select, summary { min-height: 44px; border-radius: 12px; }
button, input, select { border: 1px solid var(--border); }
button { padding: 9px 14px; color: var(--text); background: var(--surface); cursor: pointer; font-weight: 650; }
button:hover { border-color: var(--accent); }
input, select { width: 100%; padding: 10px 12px; color: var(--text); background: var(--surface); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.75rem, 5vw, 2.25rem); line-height: 1.2; }
h2 { font-size: 1.1rem; }
dl, dd { margin: 0; }
.page-shell { width: min(1120px, 100%); margin: 0 auto; padding: 0 16px 48px; }
.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 72px; }
.wordmark { font-size: 1.1rem; font-weight: 750; text-decoration: none; }
.text-button { border: 0; background: transparent; }
.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.tabs a { flex: 1; min-height: 44px; padding: 11px 12px; border-radius: 10px; text-align: center; text-decoration: none; font-weight: 650; }
.tabs a[aria-current="page"] { color: var(--on-accent); background: var(--accent); }
main { padding-top: 28px; }
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.eyebrow { margin-bottom: 5px; color: var(--text-muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.muted { color: var(--text-muted); }
.primary { border-color: var(--accent); color: var(--on-accent); background: var(--accent); }
.primary:hover { background: var(--accent-strong); }
.add-panel { position: relative; }
.add-panel summary { display: grid; place-items: center; padding: 0 16px; list-style: none; cursor: pointer; font-weight: 700; }
.add-panel summary::-webkit-details-marker { display: none; }
.add-panel[open] { width: min(100%, 420px); }
.add-panel[open] summary { margin-bottom: 10px; }
.form-grid, .filters { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.form-grid label, .filters span { display: block; margin-bottom: 5px; font-weight: 650; }
.optional { color: var(--text-muted); font-weight: 400; }
.form-actions { margin-top: 4px; }
.filters { margin: 18px 0; padding: 12px; }
.filters button { align-self: end; }
.parcel-grid { display: grid; gap: 12px; }
.parcel-card, .summary-card, .timeline, .empty { padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.parcel-card h2 { margin-bottom: 5px; }
.parcel-card h2 a { text-decoration: none; }
.parcel-card h2 a::after { content: ""; position: absolute; inset: 0; }
.parcel-card { position: relative; }
.card-top, .detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.badge { flex: none; padding: 5px 9px; border-radius: 999px; background: var(--surface-muted); font-size: .78rem; font-weight: 750; }
.badge.success { color: var(--success); }
.badge.danger { color: var(--danger); }
.badge.accent { color: var(--accent); }
.tracking { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }
.warning, .form-error { color: var(--warning); font-weight: 700; }
.form-error { color: var(--danger); }
.card-data, .summary-data { display: grid; gap: 10px; margin-top: 16px; }
.card-data { grid-template-columns: repeat(3, 1fr); }
dt { color: var(--text-muted); font-size: .78rem; font-weight: 650; }
dd { margin-top: 3px; font-weight: 600; overflow-wrap: anywhere; }
.empty { padding: 44px 20px; text-align: center; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 390px); padding: 28px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); }
.login-card form { display: grid; gap: 10px; margin-top: 24px; }
.back { display: inline-block; margin-bottom: 18px; color: var(--accent); font-weight: 650; }
.detail-head { margin-bottom: 18px; }
.tracking.full { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.copy-button { min-height: 34px; padding: 5px 9px; font-size: .78rem; }
.detail-grid { display: grid; gap: 14px; }
.summary-data > div { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.carrier-link { display: inline-block; margin-top: 14px; color: var(--accent); font-weight: 650; }
.progress { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.progress span { padding: 5px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: .78rem; font-weight: 700; }
.edit-panel { margin-top: 18px; }
.edit-panel summary { display: flex; align-items: center; font-weight: 700; cursor: pointer; }
.edit-panel .form-grid { margin-top: 10px; padding: 12px; }
.timeline ol { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding-bottom: 20px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 12px; bottom: 0; width: 2px; background: var(--border); }
.dot { width: 12px; height: 12px; margin-top: 4px; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent); outline: 1px solid var(--accent); z-index: 1; }
.event-title { margin-bottom: 3px; font-weight: 700; }
.flash { position: sticky; top: 8px; z-index: 10; width: min(560px, calc(100% - 32px)); margin: 8px auto -8px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.flash.success { color: var(--success); }
.flash.error { color: var(--danger); }

@media (min-width: 700px) {
  .filters { grid-template-columns: 2fr 1fr auto; }
  .parcel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr); align-items: start; }
}

@media (max-width: 480px) {
  .title-row { align-items: stretch; flex-direction: column; }
  .add-panel[open] { width: 100%; }
  .card-data { grid-template-columns: 1fr; }
  .detail-head { flex-direction: column; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #111722;
    --surface: #192231;
    --surface-muted: #222d3e;
    --text: #edf2fa;
    --text-muted: #aab5c6;
    --border: #3a4659;
    --accent: #7da2ff;
    --accent-strong: #a9c0ff;
    --on-accent: #111722;
    --success: #63d6a0;
    --warning: #f0c15a;
    --danger: #ff8a93;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
