/* ==========================================================================
   ParcelTrack Lite · shared design (Task 1)
   Sleek app-dashboard style with light and dark mode.
   One stylesheet for every module: reuse these classes and the macros in
   templates/_macros.html. Don't add colours or <style> blocks in pages.
   ========================================================================== */

/* ---------- Fonts (bundled, works offline · SIL Open Font License) ---------- */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

/* ---------- Tokens: light (default) ---------- */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;          /* hover, table head, inputs */
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #0f172a;
  --text-2: #475467;             /* secondary */
  --text-3: #6b7486;             /* hints, labels */
  --primary: #0d9488;            /* teal */
  --primary-hover: #0f766e;
  --primary-soft: #e7f8f4;
  --primary-text: #ffffff;
  --ring: rgba(13, 148, 136, 0.35);
  --sidebar: #ffffff;

  --st-registered: #a16207;  --st-registered-bg: #fef6d8;
  --st-assigned: #0f766e;    --st-assigned-bg: #ccfbf1;
  --st-out: #b54708;         --st-out-bg: #fff4e5;
  --st-delivered: #067647;   --st-delivered-bg: #e9f7ef;
  --st-failed: #c01048;      --st-failed-bg: #fdecf1;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, 0.18);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "IBM Plex Mono", Consolas, "Courier New", monospace;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --tap: 44px;
  --sidebar-w: 248px;
}

/* ---------- Tokens: dark ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #191d26;
  --border: #232836;
  --border-strong: #303749;
  --text: #e8eaf0;
  --text-2: #a7afc0;
  --text-3: #8790a3;
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --primary-soft: #0f2e2b;
  --primary-text: #0b0d12;
  --ring: rgba(45, 212, 191, 0.45);
  --sidebar: #0f1218;

  --st-registered: #fcd34d;  --st-registered-bg: #3a2f0b;
  --st-assigned: #5eead4;    --st-assigned-bg: #0f2e2b;
  --st-out: #fdb022;         --st-out-bg: #3a2a12;
  --st-delivered: #47cd89;   --st-delivered-bg: #11301f;
  --st-failed: #fd6f8e;      --st-failed-bg: #3a1621;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
h1, h2, h3 { color: var(--text); margin: 0 0 .5em; letter-spacing: -0.02em; }
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.125rem; font-weight: 650; line-height: 1.3; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--text-2); }
.small { font-size: .8125rem; }
.mono { font-family: var(--mono); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 22px; height: 22px; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* Theme-dependent icons (sun shows in dark mode, moon in light mode) */
:root[data-theme="dark"] .theme-light-only,
:root:not([data-theme="dark"]) .theme-dark-only { display: none; }
.theme-dark-only, .theme-light-only { display: inline-flex; }
.sidebar-foot .button-block { justify-content: flex-start; gap: .7rem; padding: 0 .7rem; font-weight: 520; }
.sidebar-foot .button-block::after { content: "Dark mode"; }
:root[data-theme="dark"] .sidebar-foot .button-block::after { content: "Light mode"; }

/* ---------- App shell (logged in): sidebar + content ---------- */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  /* sidebar colour runs the full height of long pages */
  background: linear-gradient(90deg, var(--sidebar) calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px) var(--sidebar-w), transparent var(--sidebar-w));
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: .25rem;
  background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 1.1rem .9rem;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .35rem .6rem 1.1rem; color: var(--text); font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff;
  box-shadow: 0 4px 12px rgba(13, 148, 136, .35);
}
.brand-mark .icon { width: 17px; height: 17px; stroke-width: 2.2; }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--text-3); letter-spacing: 0; }

.nav-label { font-size: .72rem; font-weight: 600; color: var(--text-3); padding: .9rem .7rem .35rem; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .7rem; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 520; min-height: 40px;
  transition: background-color .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: .65rem; padding: .4rem .5rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 650; font-size: .8rem;
}
.user-card .name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.user-card .role { font-size: .75rem; color: var(--text-3); text-transform: capitalize; }
.user-card form { margin-left: auto; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 2rem; min-height: 64px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .greeting { font-weight: 600; }
.topbar .date { color: var(--text-3); font-size: .8125rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.content { padding: 1.75rem 2rem 3rem; max-width: 1180px; width: 100%; animation: rise .35s ease-out both; }
.content-narrow { max-width: 640px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar .menu-button { display: none; }
.scrim { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; background: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); z-index: 50;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 12, 18, .45); z-index: 40; }
  .topbar .menu-button { display: inline-flex; }
  .topbar { padding: .75rem 1rem; }
  .content { padding: 1.25rem 1rem 2.5rem; }
  .topbar .date { display: none; }
}

/* ---------- Public layout (home, track, login) ---------- */
.public-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem; padding: .85rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.public-top .brand { padding: 0; }
.public-top nav { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.public-top nav a.link { color: var(--text-2); font-weight: 520; padding: .5rem .75rem; border-radius: var(--r-sm); }
.public-top nav a.link:hover, .public-top nav a.link[aria-current="page"] { background: var(--surface-2); color: var(--text); text-decoration: none; }
.public-main { padding: 2.5rem 1rem 4rem; animation: rise .35s ease-out both; }
.public-main > .wrap { max-width: 1080px; margin: 0 auto; }
.public-main > .wrap-narrow { max-width: 460px; margin: 0 auto; }
.public-main > .wrap-mid { max-width: 640px; margin: 0 auto; }
.site-foot { text-align: center; color: var(--text-3); font-size: .8125rem; padding: 2rem 1rem 2.5rem; }
.site-foot p { margin: 0 auto; }

/* Subtle dotted grid behind the home hero */
.hero {
  position: relative; text-align: center; padding: 4rem 1rem 3rem;
}
.hero::before {
  /* dotted grid that fades out softly on every side, so it has no visible edges */
  content: ""; position: absolute; inset: -40px -10%; z-index: -1;
  background: radial-gradient(circle at 1px 1px, var(--border-strong) 1px, transparent 0) 0 0 / 22px 22px;
  mask-image: radial-gradient(ellipse 60% 55% at 50% 45%, #000 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 45%, #000 35%, transparent 100%);
}
.pill-note {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .3rem .75rem; border-radius: 999px; font-size: .8rem; font-weight: 550;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}
.pill-note .dot { width: 7px; height: 7px; border-radius: 50%; background: #12b76a; box-shadow: 0 0 0 3px rgba(18, 183, 106, .2); }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 750; letter-spacing: -0.035em; line-height: 1.08; margin-bottom: .75rem; }
.hero p { margin: 0 auto 2rem; font-size: 1.075rem; color: var(--text-2); }
.search-hero {
  display: flex; gap: .5rem; max-width: 560px; margin: 0 auto;
  padding: .45rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
}
.search-hero .field-icon { flex: 1; }
.search-hero .input { border: 0; box-shadow: none; background: transparent; min-height: 48px; font-size: 1rem; }
.search-hero .input:focus { box-shadow: none; }
.search-hero .button { min-height: 48px; padding: 0 1.4rem; }
@media (max-width: 520px) { .search-hero { flex-direction: column; } }

.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 3rem; }
.feature { padding: 1.4rem; }
.feature .chip-icon { margin-bottom: .9rem; }
.feature h3 { margin-bottom: .35rem; }
.feature p { color: var(--text-2); font-size: .9rem; margin-bottom: .75rem; }
@media (max-width: 760px) { .features { grid-template-columns: 1fr; } }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .25rem 0 0; color: var(--text-2); }
.back-link { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: 1rem; color: var(--text-2); font-size: .85rem; font-weight: 520; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 40px; padding: 0 1rem; white-space: nowrap;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--primary); color: var(--primary-text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 1px 0 rgba(255, 255, 255, .12);
  cursor: pointer; transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.button:hover { background: var(--primary-hover); color: var(--primary-text); text-decoration: none; }
.button:active { transform: translateY(1px); }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.button-secondary:hover { background: var(--surface-2); color: var(--text); }
.button-ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.button-ghost:hover { background: var(--surface-2); color: var(--text); }
.button-icon { width: 38px; min-height: 38px; padding: 0; }
.button-small { min-height: 34px; padding: 0 .75rem; font-size: .82rem; }
.button-lg { min-height: 46px; padding: 0 1.3rem; font-size: .95rem; }
.button-block { width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 560; font-size: .875rem; margin-bottom: .4rem; }
.field .hint { font-size: .8rem; color: var(--text-3); margin: .35rem 0 0; }
.input, .select, .textarea {
  display: block; width: 100%; min-height: var(--tap); padding: .6rem .8rem;
  font: inherit; font-size: .925rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm); transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 6rem; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.select {
  appearance: none; padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238790a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
}
.input-mono { font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.input[type="file"] { padding: .45rem .55rem; cursor: pointer; color: var(--text-2); }
.input[type="file"]::file-selector-button {
  margin-right: .75rem; padding: .5rem .9rem; font: inherit; font-weight: 600; font-size: .875rem;
  color: var(--primary-hover); background: var(--primary-soft); border: 1px solid var(--ring); border-radius: var(--r-sm); cursor: pointer;
}
.input[type="file"]:hover::file-selector-button { filter: brightness(.95); }
.field-icon { position: relative; }
.field-icon > .icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.field-icon > .input { padding-left: 2.4rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-form .input, .inline-form .field-icon { flex: 1; min-width: 0; }
.inline-form .select { flex: 1; min-width: 10rem; min-height: 38px; padding-top: .4rem; padding-bottom: .4rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  color: var(--text);   /* override Bootstrap's own .card colour so dark mode works */
}
.card-pad { padding: 1.5rem; }
.content > .card + .card, .wrap-mid > .card + .card { margin-top: 1.25rem; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 1rem; }
.card-head .inline-form { flex: 1; max-width: 440px; }
.card-head .count { font-size: .78rem; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: .15rem .55rem; border-radius: 999px; }
.card-body { padding: 1.4rem; }
.card-title { display: flex; align-items: center; gap: .55rem; font-size: 1rem; margin-bottom: 1.1rem; }
.card-title .icon { color: var(--text-3); }

.chip-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }

.facts { display: grid; grid-template-columns: 1fr; gap: .1rem; margin: 0; }
.fact { display: flex; gap: .85rem; align-items: flex-start; padding: .7rem 0; border-bottom: 1px dashed var(--border); }
.fact:last-child { border-bottom: 0; padding-bottom: 0; }
.fact:first-child { padding-top: 0; }
.fact > .icon { margin-top: .15rem; color: var(--text-3); }
.fact .k { font-size: .78rem; color: var(--text-3); font-weight: 520; }
.fact .v { font-weight: 520; }

/* ---------- Notices ---------- */
.notice {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .85rem 1rem; margin-bottom: 1.1rem;
  border-radius: var(--r); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-sm); font-size: .9rem;
}
.notice > .icon { margin-top: .1rem; }
.notice-success { border-color: color-mix(in srgb, var(--st-delivered) 35%, transparent); background: var(--st-delivered-bg); color: var(--st-delivered); }
.notice-danger  { border-color: color-mix(in srgb, var(--st-failed) 35%, transparent); background: var(--st-failed-bg); color: var(--st-failed); }
.notice-warning { border-color: color-mix(in srgb, var(--st-out) 35%, transparent); background: var(--st-out-bg); color: var(--st-out); }
.notice-info    { border-color: color-mix(in srgb, var(--st-assigned) 30%, transparent); background: var(--st-assigned-bg); color: var(--st-assigned); }

/* ---------- Status pill (status_badge macro) ---------- */
.status {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .2rem .6rem .2rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  color: var(--st-registered); background: var(--st-registered-bg);
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-assigned { color: var(--st-assigned); background: var(--st-assigned-bg); }
.status-out-for-delivery { color: var(--st-out); background: var(--st-out-bg); }
.status-out-for-delivery::before { animation: pulse 1.6s ease-in-out infinite; }
.status-delivered { color: var(--st-delivered); background: var(--st-delivered-bg); }
.status-failed { color: var(--st-failed); background: var(--st-failed-bg); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Tracking code (waybill macro) ---------- */
.tracking { display: inline-flex; align-items: center; gap: .55rem; }
.tracking .box { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.tracking .box .icon { width: 15px; height: 15px; }
.tracking .code { font-family: var(--mono); font-weight: 600; font-size: .85rem; letter-spacing: .04em; white-space: nowrap; }
.tracking-lg .box { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.tracking-lg .box .icon { width: 21px; height: 21px; }
.tracking-lg .code { font-size: 1.15rem; }
.tracking-lg .sub { display: block; font-size: .75rem; color: var(--text-3); font-weight: 500; font-family: var(--font); letter-spacing: 0; }

/* ---------- Route timeline (route macro) ---------- */
.route { list-style: none; margin: 0; padding: 0; }
.route li { position: relative; display: grid; grid-template-columns: 32px 1fr auto; gap: 0 .85rem; align-items: start; padding-bottom: 1.4rem; }
.route li:last-child { padding-bottom: 0; }
.route li::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--border); border-radius: 2px; }
.route li:last-child::before { display: none; }
.route .stop {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-3);
}
.route .stop .icon { width: 15px; height: 15px; stroke-width: 2.2; }
.route .label { font-weight: 600; padding-top: .3rem; }
.route .label small { display: block; font-weight: 450; color: var(--text-3); font-size: .8rem; }
.route .when { color: var(--text-3); font-size: .8rem; padding-top: .4rem; text-align: right; white-space: nowrap; }
.route .is-done .stop { background: var(--st-delivered); border-color: var(--st-delivered); color: var(--surface); }
.route .is-done::before { background: var(--st-delivered); }
.route .is-current .stop { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 5px var(--ring); }
.route .is-failed .stop { background: var(--st-failed); border-color: var(--st-failed); color: #fff; }
.route .is-delivered .stop { background: var(--st-delivered); border-color: var(--st-delivered); color: #fff; box-shadow: 0 0 0 5px color-mix(in srgb, var(--st-delivered) 25%, transparent); }
.route .is-upcoming .label { color: var(--text-3); font-weight: 500; }

/* ---------- Progress bar ---------- */
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 1rem 0 1.5rem; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #14b8a6, #10b981); }

/* ---------- Tables ---------- */
.table-wrap { position: relative; overflow-x: auto; }
.data-table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: .9rem; }
.data-table th {
  text-align: left; font-weight: 560; font-size: .78rem; color: var(--text-3);
  padding: .7rem 1.4rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: .85rem 1.4rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { transition: background-color .12s ease; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .person { display: flex; align-items: center; gap: .6rem; }
.data-table .person .avatar { width: 28px; height: 28px; font-size: .7rem; }
.empty { text-align: center; color: var(--text-2); padding: 3rem 1.5rem !important; }
.empty .chip-icon { margin: 0 auto .8rem; }
.empty strong { display: block; color: var(--text); margin-bottom: .2rem; }

/* ---------- Stat cards (dashboard) ---------- */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { padding: 1.15rem 1.2rem; transition: transform .15s ease, box-shadow .15s ease; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.stat .name { font-size: .82rem; color: var(--text-2); font-weight: 520; }
.stat .chip-icon { width: 32px; height: 32px; border-radius: 9px; }
.stat .chip-icon .icon { width: 16px; height: 16px; }
.stat .value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat-registered .chip-icon { color: var(--st-registered); background: var(--st-registered-bg); }
.stat-assigned .chip-icon { color: var(--st-assigned); background: var(--st-assigned-bg); }
.stat-out-for-delivery .chip-icon { color: var(--st-out); background: var(--st-out-bg); }
.stat-delivered .chip-icon { color: var(--st-delivered); background: var(--st-delivered-bg); }
.stat-failed .chip-icon { color: var(--st-failed); background: var(--st-failed-bg); }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Job list (rider) ---------- */
.job-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.job {
  display: flex; flex-direction: row; align-items: center; gap: .9rem; padding: 1rem 1.1rem; color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.job:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.job .info { flex: 1; min-width: 0; }
.job .who { display: flex; align-items: center; gap: .35rem; color: var(--text-2); font-size: .85rem; margin-top: .3rem; }
.job .who .icon { width: 14px; height: 14px; }
.job .chev { color: var(--text-3); }
.job .info .mono { white-space: nowrap; }
@media (max-width: 480px) {
  .job { display: grid; grid-template-columns: auto 1fr; row-gap: .6rem; }
  .job .status { grid-column: 2; justify-self: start; }
  .job .chev { display: none; }
}

/* ---------- Auth pages ---------- */
.auth-card { padding: 2rem; }
.auth-card .chip-icon { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 1.1rem; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: .3rem; }
.auth-card > p { color: var(--text-2); margin-bottom: 1.5rem; }
.auth-foot { text-align: center; margin-top: 1.25rem; color: var(--text-2); font-size: .875rem; }

/* ---------- Error page ---------- */
.error-wrap { text-align: center; padding: 3rem 1rem; }
.error-code { font-size: 4.5rem; font-weight: 800; letter-spacing: -0.05em; line-height: 1; background: linear-gradient(135deg, #14b8a6, #10b981); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: .75rem; }
.error-wrap p { margin-left: auto; margin-right: auto; }

/* ==========================================================================
   Richer elements (banners, charts, activity, summaries)
   ========================================================================== */

/* ---------- Gradient banner (welcome / summary) ---------- */
.banner {
  position: relative; overflow: hidden;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.25rem;
  padding: 1.6rem 1.75rem; margin-bottom: 1.5rem; border-radius: var(--r-lg);
  color: #fff; background: linear-gradient(120deg, #0d9488 0%, #059669 55%, #65a30d 120%);
  box-shadow: 0 14px 32px -12px rgba(13, 148, 136, .55);
}
.banner::after {   /* soft route lines in the background */
  content: ""; position: absolute; right: -40px; top: -60px; width: 320px; height: 320px; border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .22); box-shadow: 0 0 0 40px rgba(255, 255, 255, .05), 0 0 0 80px rgba(255, 255, 255, .04);
  pointer-events: none;
}
.banner h2 { color: #fff; font-size: 1.35rem; margin: 0 0 .3rem; }
.banner p { color: rgba(255, 255, 255, .85); margin: 0; }
.banner .actions { display: flex; flex-wrap: wrap; gap: .5rem; position: relative; z-index: 1; }
.banner .button { background: #fff; color: #115e59; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }
.banner .button:hover { background: #e7f8f4; color: #134e4a; }
.banner .button-glass { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .35); box-shadow: none; }
.banner .button-glass:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.banner-warm { background: linear-gradient(120deg, #f59e0b 0%, #f97316 55%, #ef4444 120%); box-shadow: 0 18px 36px -14px rgba(249, 115, 22, .6); }
.banner-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: rgba(255, 255, 255, .18); color: #fff; position: relative; z-index: 1; }
.banner .big { font-size: 2.4rem; font-weight: 750; letter-spacing: -0.04em; line-height: 1; }
.banner .meter { flex-basis: 100%; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .22); overflow: hidden; position: relative; z-index: 1; }
.banner .meter > span { display: block; height: 100%; border-radius: inherit; background: #fff; }

/* ---------- Share bar inside stat cards ---------- */
.stat .share { margin-top: .85rem; height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.stat .share > span { display: block; height: 100%; border-radius: inherit; background: currentColor; }
.stat .foot { margin-top: .45rem; font-size: .75rem; color: var(--text-3); }
.stat-registered .share { color: var(--st-registered); }
.stat-assigned .share { color: var(--st-assigned); }
.stat-out-for-delivery .share { color: var(--st-out); }
.stat-delivered .share { color: var(--st-delivered); }
.stat-failed .share { color: var(--st-failed); }

/* ---------- Dashboard grid ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1.15fr); gap: 1.25rem; margin-bottom: 1.5rem; align-items: start; }
@media (max-width: 1150px) { .dash-grid { grid-template-columns: 1fr 1fr; } .dash-grid > :last-child { grid-column: 1 / -1; } }
@media (max-width: 720px) { .dash-grid { grid-template-columns: 1fr; } }

/* ---------- Donut chart (status share) ---------- */
.donut-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.donut {
  --size: 150px; width: var(--size); height: var(--size); flex: none; border-radius: 50%;
  display: grid; place-items: center; position: relative;
}
.donut::before { content: ""; position: absolute; inset: 20px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.donut .center { position: relative; text-align: center; }
.donut .center b { display: block; font-size: 1.7rem; letter-spacing: -0.03em; line-height: 1; }
.donut .center span { font-size: .75rem; color: var(--text-3); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; flex: 1; min-width: 150px; }
.legend li { display: flex; align-items: center; gap: .55rem; font-size: .85rem; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .n { margin-left: auto; font-weight: 600; color: var(--text); }
.legend li { color: var(--text-2); }

/* ---------- Rider workload ---------- */
.workload { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.workload li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; }
.workload .name { font-weight: 560; font-size: .9rem; }
.workload .sub { font-size: .75rem; color: var(--text-3); }
.workload .bar { grid-column: 2 / 4; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: -.35rem; }
.workload .bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #14b8a6, #10b981); }
.workload .num { font-weight: 650; font-size: .9rem; }

/* ---------- Activity feed ---------- */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 30px 1fr; gap: .75rem; padding: .7rem 0; border-bottom: 1px dashed var(--border); }
.activity li:first-child { padding-top: 0; }
.activity li:last-child { border-bottom: 0; padding-bottom: 0; }
.activity .dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.activity .dot .icon { width: 15px; height: 15px; }
.activity .what { font-size: .85rem; line-height: 1.45; }
.activity .what .mono { font-weight: 600; font-size: .8rem; }
.activity .meta { font-size: .75rem; color: var(--text-3); margin-top: .1rem; }
.dot-registered { background: var(--st-registered-bg); color: var(--st-registered); }
.dot-assigned { background: var(--st-assigned-bg); color: var(--st-assigned); }
.dot-out-for-delivery { background: var(--st-out-bg); color: var(--st-out); }
.dot-delivered { background: var(--st-delivered-bg); color: var(--st-delivered); }
.dot-failed { background: var(--st-failed-bg); color: var(--st-failed); }
.card-empty { text-align: center; color: var(--text-3); font-size: .85rem; padding: 1.5rem 0; }

/* ---------- Summary strip (seller and rider) ---------- */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.summary .card { display: flex; flex-direction: row; align-items: center; gap: .85rem; padding: 1rem 1.1rem; }
.summary .value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.summary .name { font-size: .78rem; color: var(--text-2); }
@media (max-width: 900px) { .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chip-registered { color: var(--st-registered); background: var(--st-registered-bg); }
.chip-assigned { color: var(--st-assigned); background: var(--st-assigned-bg); }
.chip-out { color: var(--st-out); background: var(--st-out-bg); }
.chip-delivered { color: var(--st-delivered); background: var(--st-delivered-bg); }
.chip-failed { color: var(--st-failed); background: var(--st-failed-bg); }

/* ---------- Home: illustration and how it works ---------- */
.hero-art { display: block; width: min(560px, 100%); height: auto; margin: 2.75rem auto 0; }
.how { margin-top: 3.5rem; }
.how > h2 { text-align: center; font-size: 1.5rem; margin-bottom: .35rem; }
.how > p { text-align: center; color: var(--text-2); margin: 0 auto 1.75rem; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; counter-reset: step; }
.steps li { position: relative; padding: 1.3rem; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; top: 1.1rem; right: 1.1rem; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: .75rem; font-weight: 700;
  background: var(--surface-2); color: var(--text-2);
}
.steps h3 { margin: .9rem 0 .3rem; font-size: .95rem; }
.steps p { font-size: .85rem; color: var(--text-2); margin: 0; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .steps { grid-template-columns: 1fr; } }

/* ==========================================================================
   Colour layer: gradient sidebar, colourful background, filled stat tiles
   ========================================================================== */
:root {
  /* bright, vivid gradients */
  --grad-primary: linear-gradient(135deg, #0d9488 0%, #10b981 55%, #84cc16 100%);
  --grad-gold: linear-gradient(135deg, #eab308 0%, #b45309 100%);
  --grad-teal: linear-gradient(135deg, #2dd4bf 0%, #0d9488 100%);
  --grad-orange: linear-gradient(135deg, #fb923c 0%, #ea580c 100%);
  --grad-green: linear-gradient(135deg, #4ade80 0%, #16a34a 100%);
  --grad-rose: linear-gradient(135deg, #fb7185 0%, #e11d48 100%);
  --grad-lime: linear-gradient(135deg, #84cc16 0%, #3f6212 100%);
  --sidebar-grad: linear-gradient(180deg, #134e4a 0%, #0f766e 55%, #059669 100%);
  --card-line: linear-gradient(90deg, #eab308, #14b8a6, #10b981, #84cc16);
  --mesh:
    radial-gradient(760px 480px at 0% 0%, rgba(45, 212, 191, .42), transparent 70%),
    radial-gradient(700px 460px at 100% 0%, rgba(250, 204, 21, .38), transparent 70%),
    radial-gradient(820px 560px at 75% 100%, rgba(52, 211, 153, .36), transparent 70%),
    radial-gradient(620px 420px at 10% 95%, rgba(253, 186, 116, .38), transparent 70%);
}
:root[data-theme="dark"] {
  --sidebar-grad: linear-gradient(180deg, #0a2e2a 0%, #0b3b36 55%, #14532d 100%);
  --mesh:
    radial-gradient(760px 480px at 0% 0%, rgba(20, 184, 166, .34), transparent 70%),
    radial-gradient(700px 460px at 100% 0%, rgba(234, 179, 8, .18), transparent 70%),
    radial-gradient(820px 560px at 75% 100%, rgba(16, 185, 129, .26), transparent 70%),
    radial-gradient(620px 420px at 10% 95%, rgba(132, 204, 22, .16), transparent 70%);
}

/* Colourful page background */
body { background: var(--mesh), var(--bg); background-attachment: fixed; }
.app { background: none; }

/* Gradient sidebar with white text */
.sidebar { background: var(--sidebar-grad); border-right: 0; color: #fff; box-shadow: 4px 0 24px -12px rgba(19, 78, 74, .5); }
.sidebar .brand, .sidebar .brand:hover { color: #fff; }
.sidebar .brand small { color: rgba(255, 255, 255, .65); }
.sidebar .brand-mark { background: #fff; color: #0d9488; box-shadow: 0 6px 16px rgba(0, 0, 0, .2); }
.sidebar .nav-label { color: rgba(255, 255, 255, .55); }
.sidebar .nav-item { color: rgba(255, 255, 255, .82); }
.sidebar .nav-item:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.sidebar .nav-item[aria-current="page"] { background: #fff; color: #0f766e; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .35); }
:root[data-theme="dark"] .sidebar .nav-item[aria-current="page"] { background: rgba(255, 255, 255, .16); color: #fff; }
.sidebar-foot { border-top-color: rgba(255, 255, 255, .16); }
.sidebar .button-ghost { color: rgba(255, 255, 255, .85); }
.sidebar .button-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.sidebar .user-card { background: rgba(255, 255, 255, .1); border-radius: var(--r); padding: .55rem .6rem; }
.sidebar .user-card .role { color: rgba(255, 255, 255, .65); }
.sidebar .avatar { background: rgba(255, 255, 255, .2); color: #fff; }

/* Glassy top bars over the colourful background */
.topbar, .public-top { background: color-mix(in srgb, var(--bg) 55%, transparent); }

/* Gradient main buttons */
.button:not(.button-secondary):not(.button-ghost):not(.button-glass) { background: var(--grad-primary); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -6px rgba(20, 184, 166, .6), inset 0 1px 0 rgba(255, 255, 255, .2); }
.button:not(.button-secondary):not(.button-ghost):not(.button-glass):hover { filter: brightness(1.07); }
.banner .actions > .button:not(.button-glass):not(.button-secondary):not(.button-ghost) { background: #fff; color: #115e59; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }

/* Filled colour tiles: dashboard stat cards and seller summary cards */
.stat, .summary .tile { color: #fff; border: 0; position: relative; overflow: hidden; }
.stat::after, .summary .tile::after {   /* soft light shape for depth */
  content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255, 255, 255, .14); pointer-events: none;
}
.stat .name, .stat .foot, .summary .tile .name { color: rgba(255, 255, 255, .88); }
.stat .chip-icon, .summary .tile .chip-icon { background: rgba(255, 255, 255, .2) !important; color: #fff !important; }
.stat .share { background: rgba(255, 255, 255, .25); color: #fff !important; }
.stat-registered, .tile-gold { background: var(--grad-gold); box-shadow: 0 12px 24px -12px rgba(161, 98, 7, .6); }
.stat-assigned, .tile-teal { background: var(--grad-teal); box-shadow: 0 12px 24px -12px rgba(13, 148, 136, .6); }
.stat-out-for-delivery, .tile-orange { background: var(--grad-orange); box-shadow: 0 12px 24px -12px rgba(249, 115, 22, .6); }
.stat-delivered, .tile-green { background: var(--grad-green); box-shadow: 0 12px 24px -12px rgba(5, 150, 105, .6); }
.stat-failed, .tile-rose { background: var(--grad-rose); box-shadow: 0 12px 24px -12px rgba(225, 29, 72, .6); }
.tile-lime { background: var(--grad-lime); box-shadow: 0 12px 24px -12px rgba(124, 58, 237, .6); }

/* Card titles get a coloured icon chip */
.card-title > .icon { width: 30px; height: 30px; padding: 7px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); }

/* Tinted table head */
.data-table th { background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface)); color: var(--text-2); }

/* Rider delivery cards: coloured edge by status */
.job { border-left: 4px solid var(--border-strong); }
.job-assigned { border-left-color: #14b8a6; }
.job-out-for-delivery { border-left-color: #f59e0b; }
.job-delivered { border-left-color: #10b981; }
.job-failed { border-left-color: #f43f5e; }

/* Home: colourful feature and step cards */
.feature { position: relative; overflow: hidden; }
.feature::before, .steps li.card::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; }
.feature-gold::before { background: var(--grad-gold); }
.feature-orange::before { background: var(--grad-orange); }
.feature-green::before { background: var(--grad-green); }
.feature .chip-icon { color: #fff; }
.feature-gold .chip-icon { background: var(--grad-gold); }
.feature-orange .chip-icon { background: var(--grad-orange); }
.feature-green .chip-icon { background: var(--grad-green); }
.steps li.card { overflow: hidden; }
.steps li:nth-child(1)::after { background: var(--grad-gold); }
.steps li:nth-child(2)::after { background: var(--grad-teal); }
.steps li:nth-child(3)::after { background: var(--grad-orange); }
.steps li:nth-child(4)::after { background: var(--grad-green); }
.hero h1 { background: linear-gradient(135deg, var(--text) 30%, #14b8a6 75%, #10b981 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Log in / register: gradient strip on top of the card */
.auth-card { position: relative; overflow: hidden; }
.auth-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: linear-gradient(90deg, #facc15, #14b8a6, #10b981, #84cc16); }
.auth-card .chip-icon { background: var(--grad-primary); color: #fff; box-shadow: 0 8px 18px -8px rgba(20, 184, 166, .7); }

/* ---------- Brighter, less blank light theme ---------- */
.content > .card, .dash-grid > .card, .wrap-mid > .card, .content-narrow > .card { position: relative; overflow: hidden; }
.content > .card::before, .dash-grid > .card::before, .wrap-mid > .card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--card-line);
}
.card-head { background: linear-gradient(90deg, color-mix(in srgb, #14b8a6 7%, var(--surface)), color-mix(in srgb, #eab308 7%, var(--surface))); }
.page-head h1 { background: linear-gradient(120deg, var(--text) 35%, #14b8a6 80%, #84cc16 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar { background: linear-gradient(90deg, color-mix(in srgb, #e7f8f4 70%, transparent), color-mix(in srgb, #fefce8 70%, transparent)); }
:root[data-theme="dark"] .topbar { background: color-mix(in srgb, var(--bg) 55%, transparent); }
.data-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--primary-soft) 35%, transparent); }
.stat .value, .summary .tile .value { text-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
.stat, .summary .tile { box-shadow: 0 16px 30px -14px rgba(20, 184, 166, .55); }
.banner { background: var(--grad-primary); box-shadow: 0 18px 36px -14px rgba(16, 185, 129, .65); }
.banner-warm { background: linear-gradient(120deg, #f59e0b 0%, #f97316 55%, #ef4444 120%); box-shadow: 0 18px 36px -14px rgba(249, 115, 22, .6); }
.progress > span, .workload .bar > span { background: var(--grad-primary); }
.brand-mark { background: var(--grad-primary); }

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