/* ============================================================
   VELTRAX - main stylesheet
   ============================================================ */

:root {
  --purple:        #4d148c;
  --purple-dark:   #3a0f6b;
  --purple-light:  #ede4f7;
  --orange:        #ff6600;
  --orange-dark:   #d95400;

  --ink:           #16233a;
  --ink-2:         #33415c;
  --muted:         #6b7a99;
  --line:          #e3e6ec;
  --line-2:        #eef1f6;
  --bg:            #f4f6fa;
  --card:          #ffffff;

  --green:         #0f8a4d;
  --green-bg:      #e6f6ed;
  --blue:          #1667c2;
  --blue-bg:       #e7f1fc;
  --amber:         #a86a00;
  --amber-bg:      #fdf3e0;
  --red:           #c62b2b;
  --red-bg:        #fdecec;
  --violet:        #6b21a8;
  --violet-bg:     #f1e8fb;

  --radius:        14px;
  --radius-sm:     9px;
  --shadow:        0 6px 26px rgba(22, 35, 58, .08);
  --shadow-lg:     0 18px 50px rgba(22, 35, 58, .13);
  --font:          'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.public { background: var(--bg); }

h1, h2, h3, h4, h5 { margin: 0 0 .5em; line-height: 1.25; font-weight: 700; color: var(--ink); }
h1 { font-size: 30px; }
h2 { font-size: 23px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }
p  { margin: 0 0 1em; }

a { color: var(--purple); text-decoration: none; overflow-wrap: anywhere; }
a:hover { text-decoration: underline; }

/* Long unbroken strings (emails, tracking numbers, IBANs, URLs) otherwise set
   a min-content width wider than a phone screen and push the page sideways. */
.card-body, .card-head, p, li, dd, dt, .charge-panel, .stat, .field { overflow-wrap: anywhere; }

img { max-width: 100%; display: block; }
svg { max-width: 100%; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.mono { font-family: 'Consolas', 'Courier New', monospace; letter-spacing: .04em; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right  { text-align: right; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt1 { margin-top: 10px; } .mt2 { margin-top: 20px; } .mt3 { margin-top: 30px; }
.mb1 { margin-bottom: 10px; } .mb2 { margin-bottom: 20px; } .mb3 { margin-bottom: 30px; }

.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 18px; }
.site-main { flex: 1 0 auto; }

.hidden { display: none !important; }

/* ============================================================
   Header
   ============================================================ */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 60;
  box-shadow: 0 1px 3px rgba(22, 35, 58, .05);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
}

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--purple), var(--purple-dark));
  border-radius: 11px;
  box-shadow: 0 4px 12px rgba(77, 20, 140, .3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 20px; color: var(--ink); letter-spacing: -.4px; }
.brand-text strong span { color: var(--orange); }
.brand-text em {
  font-style: normal; font-size: 11px; color: var(--muted);
  letter-spacing: .9px; text-transform: uppercase;
}

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  padding: 8px 14px; border-radius: 8px;
  color: var(--ink-2); font-weight: 600; font-size: 14.5px; text-decoration: none;
  transition: background .15s, color .15s;
}
.site-nav a:hover { background: var(--purple-light); color: var(--purple); text-decoration: none; }
.site-nav a.on { background: var(--purple); color: #fff; }
.site-nav a.nav-admin {
  margin-left: 6px; background: var(--ink); color: #fff;
}
.site-nav a.nav-admin:hover { background: var(--purple); color: #fff; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 42px; height: 38px; padding: 0 10px;
  background: var(--line-2); border: 0; border-radius: 9px; cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: .2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   Alerts
   ============================================================ */

.alert {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 15px; margin: 16px 0 0;
  border-radius: var(--radius-sm); font-size: 14.5px; font-weight: 500;
  border: 1px solid transparent;
}
.alert-ico {
  flex: 0 0 auto; width: 21px; height: 21px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff;
}
.alert > span:nth-child(2) { flex: 1; }
.alert-x {
  background: none; border: 0; font-size: 20px; line-height: 1;
  color: inherit; opacity: .5; cursor: pointer; padding: 0 2px;
}
.alert-x:hover { opacity: 1; }

.alert-success { background: var(--green-bg); border-color: #bfe8d2; color: #14663c; }
.alert-success .alert-ico { background: var(--green); }
.alert-error   { background: var(--red-bg);   border-color: #f3c6c6; color: #a11b1b; }
.alert-error .alert-ico   { background: var(--red); }
.alert-info    { background: var(--blue-bg);  border-color: #c2dcf7; color: #0f4c8f; }
.alert-info .alert-ico    { background: var(--blue); }
.alert-warning { background: var(--amber-bg); border-color: #f0d99b; color: #7a5a06; }
.alert-warning .alert-ico { background: var(--amber); }

/* ============================================================
   Hero + tracking box
   ============================================================ */

.hero {
  position: relative;
  background:
    radial-gradient(900px 380px at 88% -12%, rgba(255, 102, 0, .22), transparent 62%),
    linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 58%, #2b0a52 100%);
  color: #fff;
  padding: 62px 0 74px;
  overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; inset: auto 0 -1px 0; height: 70px;
  background: var(--bg);
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
}
.hero h1 { color: #fff; font-size: 40px; letter-spacing: -.9px; margin-bottom: 10px; }
.hero .lede { font-size: 17.5px; color: rgba(255, 255, 255, .87); max-width: 620px; margin-bottom: 26px; }
.hero-eyebrow {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 1.4px;
  text-transform: uppercase; color: #ffc899;
  background: rgba(255, 255, 255, .1); padding: 5px 12px; border-radius: 20px; margin-bottom: 16px;
}

.track-box {
  background: #fff;
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  position: relative; z-index: 2;
}
.track-box .field { flex: 1 1 240px; margin: 0; }
.track-box .field label { color: var(--ink); }
.track-box .btn { flex: 0 0 auto; height: 47px; padding: 0 30px; }
.track-hint { width: 100%; font-size: 12.5px; color: var(--muted); margin: 0; }
.track-hint a { font-weight: 600; }

.hero-stats {
  display: flex; gap: 30px; flex-wrap: wrap; margin-top: 30px; position: relative; z-index: 2;
}
.hero-stats div { color: #fff; }
.hero-stats b { display: block; font-size: 24px; line-height: 1.2; }
.hero-stats span { font-size: 12.5px; color: rgba(255, 255, 255, .72); letter-spacing: .4px; }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 17px; }
.card-head .card-sub { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.card-body { padding: 20px; }
.card-foot {
  padding: 14px 20px; border-top: 1px solid var(--line-2);
  background: #fbfcfe; border-radius: 0 0 var(--radius) var(--radius);
}

.section { padding: 40px 0; }
.section-tight { padding: 26px 0; }

/* ============================================================
   Forms
   ============================================================ */

.field { margin-bottom: 15px; }
.field label, .lbl {
  display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  margin-bottom: 5px; letter-spacing: .2px;
}
.field label .req, .lbl .req { color: var(--red); }

input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=number], input[type=date], input[type=datetime-local], input[type=search],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: #fff;
  border: 1px solid #ccd3e0;
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(77, 20, 140, .12);
}
input:disabled, select:disabled, textarea:disabled { background: #f4f6fa; color: var(--muted); }
textarea { min-height: 84px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7a99' d='M4.5 6.5 8 10l3.5-3.5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }

.grid { display: grid; gap: 0 16px; }
/* minmax(0, 1fr) rather than a bare 1fr: a bare 1fr is minmax(auto, 1fr),
   whose floor is the content's min-content width, so one long unbroken string
   pushes the whole grid wider than the viewport. */
.grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.fieldset-title {
  font-size: 12.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  color: var(--purple); padding-bottom: 8px; margin: 4px 0 14px;
  border-bottom: 2px solid var(--purple-light);
}
.fieldset-title + .fieldset-title { margin-top: 22px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--purple); }

.help { font-size: 12px; color: var(--muted); margin-top: 4px; }

input[type=file] {
  width: 100%; padding: 9px; font-size: 13.5px;
  border: 1px dashed #c2cbd9; border-radius: var(--radius-sm); background: #fbfcfe;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px;
  font-family: inherit; font-size: 14.5px; font-weight: 700; line-height: 1.2;
  color: #fff; background: var(--purple);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  /* a long label must not set a min-content floor wider than the screen */
  max-width: 100%; min-width: 0; text-align: center;
  transition: background .15s, box-shadow .15s, transform .06s;
}
/* On narrow screens let button labels wrap instead of forcing a scrollbar. */
@media (max-width: 560px) {
  .btn { white-space: normal; overflow-wrap: anywhere; hyphens: auto; }
}
.btn:hover { background: var(--purple-dark); text-decoration: none; color: #fff; box-shadow: 0 4px 12px rgba(77, 20, 140, .25); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(77, 20, 140, .3); outline-offset: 2px; }

.btn-lg { padding: 13px 28px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-orange { background: var(--orange); }
.btn-orange:hover { background: var(--orange-dark); box-shadow: 0 4px 12px rgba(255, 102, 0, .3); }

.btn-ghost { background: #fff; color: var(--purple); border-color: #ccd3e0; }
.btn-ghost:hover { background: var(--purple-light); color: var(--purple); border-color: var(--purple); box-shadow: none; }

.btn-dark { background: var(--ink); }
.btn-dark:hover { background: #0c1526; box-shadow: 0 4px 12px rgba(22, 35, 58, .28); }

.btn-danger { background: var(--red); }
.btn-danger:hover { background: #a11b1b; box-shadow: 0 4px 12px rgba(198, 43, 43, .3); }

.btn-success { background: var(--green); }
.btn-success:hover { background: #0b6b3c; box-shadow: 0 4px 12px rgba(15, 138, 77, .3); }

.btn-grey { background: #eef1f6; color: var(--ink-2); }
.btn-grey:hover { background: #e0e5ee; color: var(--ink); box-shadow: none; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Keeps a small form (e.g. a delete button) aligned with sibling buttons. */
form.inline { display: inline-flex; margin: 0; }
form.inline .btn { margin: 0; }

/* ============================================================
   Badges / tones
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 20px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green  { background: var(--green-bg);  color: var(--green);  border-color: #bfe8d2; }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);   border-color: #c2dcf7; }
.badge-amber  { background: var(--amber-bg);  color: var(--amber);  border-color: #f0d99b; }
.badge-red    { background: var(--red-bg);    color: var(--red);    border-color: #f3c6c6; }
.badge-violet { background: var(--violet-bg); color: var(--violet); border-color: #ddd0ee; }
.badge-grey   { background: #eef1f6;          color: var(--muted); border-color: #dde3ec; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--purple-light); color: var(--purple);
  font-size: 12px; font-weight: 700;
}

/* ============================================================
   Tracking result page
   ============================================================ */

.track-head {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 26px 0;
}
.track-head-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.trk-number-label {
  font-size: 11.5px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.trk-number {
  font-size: 27px; font-weight: 800; letter-spacing: 1.4px; color: var(--ink);
  font-family: 'Consolas', 'Courier New', monospace;
}
.trk-refs { display: flex; gap: 26px; flex-wrap: wrap; }
.trk-refs div span {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted);
}
.trk-refs div b { font-size: 14.5px; color: var(--ink-2); }

.status-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center;
  padding: 22px 24px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow);
}
.status-hero .sh-icon {
  width: 56px; height: 56px; border-radius: 15px;
  display: grid; place-items: center; font-size: 26px;
}
.status-hero h1 { font-size: 25px; margin: 0 0 4px; }
.status-hero .sh-meta { color: var(--muted); font-size: 14.5px; margin: 0; }
.status-hero .sh-right { text-align: right; }
.sh-eta { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.sh-eta b { display: block; font-size: 22px; color: var(--purple); letter-spacing: -.3px; }

/* tone helpers for the status hero */
.tone-green  { background: var(--green-bg);  }
.tone-blue   { background: var(--blue-bg);   }
.tone-amber  { background: var(--amber-bg);  }
.tone-red    { background: var(--red-bg);    }
.tone-violet { background: var(--violet-bg); }
.tone-grey   { background: #eef1f6;          }

/* progress bar */
.progress {
  display: flex; gap: 0; margin: 4px 0 0;
  counter-reset: step;
}
.progress .step {
  flex: 1; position: relative; text-align: center; padding: 0 4px;
}
.progress .step::before {
  content: ''; position: absolute; top: 15px; left: -50%; right: 50%;
  height: 3px; background: var(--line);
}
.progress .step:first-child::before { display: none; }
.progress .dot {
  position: relative; z-index: 2;
  width: 32px; height: 32px; margin: 0 auto 8px;
  border-radius: 50%; background: #fff;
  border: 3px solid var(--line);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800; color: var(--muted);
}
.progress .step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.progress .step.done::before { background: var(--green); }
.progress .step.current .dot {
  background: var(--purple); border-color: var(--purple); color: #fff;
  box-shadow: 0 0 0 5px rgba(77, 20, 140, .16);
  transform: scale(1.12);
}
.progress .step.current::before { background: var(--green); }
.progress .step.fail .dot { background: var(--red); border-color: var(--red); color: #fff; }
.progress .lbl { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0; line-height: 1.35; }
.progress .step.done .lbl, .progress .step.current .lbl { color: var(--ink-2); }
.progress .step.current .lbl { font-weight: 800; color: var(--purple); }
.progress .step.skip { opacity: .42; }

/* timeline */
.timeline { position: relative; padding-left: 4px; }
.tl-item { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding-bottom: 20px; position: relative; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: 19px; top: 34px; bottom: -4px;
  width: 2px; background: var(--line);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 17px;
  background: var(--line-2); border: 2px solid var(--line); z-index: 2;
}
.tl-item.is-latest .tl-dot { background: var(--purple); border-color: var(--purple); box-shadow: 0 0 0 4px rgba(77, 20, 140, .13); }
.tl-item.is-done .tl-dot { background: var(--green-bg); border-color: #bfe8d2; }
.tl-item.is-fail .tl-dot { background: var(--red-bg); border-color: #f3c6c6; }
/* min-width: 0 lets this grid item shrink below its content's min-content
   width; without it the whole grid is forced wider than the viewport. */
.tl-body { padding-top: 2px; min-width: 0; overflow-wrap: anywhere; }
.tl-title { font-weight: 700; font-size: 15px; color: var(--ink); margin: 0 0 2px; }
.tl-meta { font-size: 13px; color: var(--muted); margin: 0; }
.tl-loc {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: var(--line-2); padding: 3px 9px; border-radius: 6px;
  /* inline-flex defaults to nowrap, which would pin a long location to one
     line and set a huge min-content floor. */
  flex-wrap: wrap; min-width: 0; max-width: 100%; overflow-wrap: anywhere;
}

/* detail definition lists */
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0; margin: 0; font-size: 14.5px; }
.dl dt {
  padding: 8px 0; font-weight: 600; color: var(--muted); font-size: 13.5px;
  border-bottom: 1px solid var(--line-2);
}
.dl dd { padding: 8px 0; margin: 0; color: var(--ink); border-bottom: 1px solid var(--line-2); min-width: 0; overflow-wrap: anywhere; }
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }

.addr-box {
  background: #fbfcfe; border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 13px 15px;
  font-size: 14.5px; line-height: 1.7; white-space: pre-line;
  min-width: 0; overflow-wrap: anywhere;
}
.addr-box .who {
  font-weight: 800; font-size: 12px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--purple); margin-bottom: 5px;
}

.party-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.party-grid > * { min-width: 0; }

/* charges panel */
.charge-panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fafbfe, #fff);
  border-radius: var(--radius);
  padding: 20px;
}
.pay-amount {
  font-size: 34px; font-weight: 800; color: var(--ink); letter-spacing: -1px; line-height: 1.1;
  overflow-wrap: anywhere;
}

/* ============================================================
   Tables
   ============================================================ */

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.data th {
  text-align: left; padding: 11px 14px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .9px; text-transform: uppercase;
  color: var(--muted); background: #f7f9fc;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:hover { background: #fafbfe; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.tight { width: 1%; white-space: nowrap; }
table.data .trk { font-family: 'Consolas', 'Courier New', monospace; font-weight: 700; letter-spacing: .5px; color: var(--purple); }
table.data tr.row-flag td { background: #fffdf5; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .empty-ico { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }

/* filters */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2); background: #fbfcfe;
}
.filters .field { margin: 0; min-width: 148px; }
.filters .field label { font-size: 11.5px; }
.pager { display: flex; gap: 6px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 36px; height: 36px; padding: 0 11px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink-2); font-size: 14px; font-weight: 600; text-decoration: none; background: #fff;
}
.pager a:hover { background: var(--purple-light); border-color: var(--purple); color: var(--purple); text-decoration: none; }
.pager .on { background: var(--purple); border-color: var(--purple); color: #fff; }
.pager .gap { border: 0; background: none; }

/* ============================================================
   Admin shell
   ============================================================ */

body.admin { background: #f4f6fa; }
body.admin .site-main { display: flex; align-items: stretch; min-height: calc(100vh - 0px); }

.admin-shell { display: flex; width: 100%; }

.admin-side {
  width: 236px; flex: 0 0 236px;
  background: linear-gradient(180deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: #fff; padding: 20px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-side .side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 20px; margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .16);
}
.admin-side .side-brand .brand-mark { background: rgba(255, 255, 255, .16); box-shadow: none; }
.admin-side .side-brand b { font-size: 17px; }
.admin-side .side-brand b span { color: #ffa257; }

.side-group { padding: 14px 20px 4px; font-size: 10.5px; font-weight: 800; letter-spacing: 1.3px; text-transform: uppercase; color: rgba(255, 255, 255, .48); }
.admin-side nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 20px; color: rgba(255, 255, 255, .88);
  font-size: 14.5px; font-weight: 600; text-decoration: none;
  border-left: 3px solid transparent; transition: .15s;
}
.admin-side nav a:hover { background: rgba(255, 255, 255, .09); color: #fff; text-decoration: none; }
.admin-side nav a.on { background: rgba(0, 0, 0, .2); border-left-color: var(--orange); color: #fff; }
.admin-side nav a .ico { width: 19px; text-align: center; font-size: 15px; }
.admin-side nav a .cnt {
  margin-left: auto; background: var(--orange); color: #fff;
  font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 10px;
}
.side-foot { padding: 16px 20px 0; margin-top: 14px; border-top: 1px solid rgba(255, 255, 255, .16); font-size: 12.5px; color: rgba(255, 255, 255, .7); }
.side-foot a { color: #ffc899; font-weight: 600; }

.admin-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Off-canvas nav toggle: hidden on desktop, shown by the <=1000px block. */
.admin-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 40px;
  margin-right: 2px; padding: 0;
  font-size: 20px; line-height: 1; color: var(--ink);
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer;
}
.admin-menu-btn:active { background: #f2f4f8; }
.admin-title { min-width: 0; }

.admin-top {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 13px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 40; flex-wrap: wrap;
}
.admin-top h1 { font-size: 20px; margin: 0; }
.admin-top .crumb { font-size: 12.5px; color: var(--muted); }
.admin-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--purple); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
}
.admin-user .who b { display: block; font-size: 13.5px; line-height: 1.3; }
.admin-user .who span { font-size: 12px; color: var(--muted); }

.admin-content { padding: 24px 26px 40px; flex: 1; }

/* stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  text-decoration: none; display: block;
}
.stat:hover { text-decoration: none; box-shadow: var(--shadow-lg); }
.stat::after { content: ''; position: absolute; right: -18px; top: -18px; width: 74px; height: 74px; border-radius: 50%; background: var(--purple-light); opacity: .55; }
.stat .s-ico { position: relative; z-index: 2; font-size: 19px; }
.stat b { display: block; font-size: 27px; line-height: 1.2; color: var(--ink); letter-spacing: -.7px; position: relative; z-index: 2; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; position: relative; z-index: 2; }
.stat.green::after  { background: var(--green-bg); }  .stat.green b  { color: var(--green); }
.stat.blue::after   { background: var(--blue-bg); }   .stat.blue b   { color: var(--blue); }
.stat.amber::after  { background: var(--amber-bg); }  .stat.amber b  { color: var(--amber); }
.stat.red::after    { background: var(--red-bg); }    .stat.red b    { color: var(--red); }

/* login page */
body.login-page {
  display: grid; place-items: center; min-height: 100vh; padding: 30px 18px;
  background:
    radial-gradient(800px 420px at 80% 0%, rgba(255, 102, 0, .18), transparent 60%),
    linear-gradient(140deg, var(--purple) 0%, var(--purple-dark) 100%);
}
.login-card {
  width: 100%; max-width: 400px;
  background: #fff; border-radius: 18px; padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.login-card .lc-brand { text-align: center; margin-bottom: 24px; }
.login-card .lc-brand .brand-mark { margin: 0 auto 12px; width: 52px; height: 52px; }
.login-card .lc-brand b { font-size: 23px; color: var(--ink); letter-spacing: -.5px; display: block; }
.login-card .lc-brand b span { color: var(--orange); }
.login-card .lc-brand em {
  font-style: normal; font-size: 11px; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--muted);
}
.login-card h2 { font-size: 18px; text-align: center; margin-bottom: 4px; }
.login-card .lc-sub { text-align: center; font-size: 13.5px; color: var(--muted); margin-bottom: 22px; }

/* tabs */
.tabs { display: flex; gap: 3px; border-bottom: 2px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a {
  padding: 9px 16px; font-size: 14px; font-weight: 700; color: var(--muted);
  text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs a:hover { color: var(--purple); text-decoration: none; }
.tabs a.on { color: var(--purple); border-bottom-color: var(--purple); }

/* sticky action bar on shipment detail */
.action-bar {
  position: sticky; bottom: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  padding: 12px 26px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  box-shadow: 0 -4px 18px rgba(22, 35, 58, .07);
}
.action-bar .spacer { flex: 1; }

/* misc */
.kv-inline { display: flex; gap: 8px; font-size: 13.5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--line-2); border-radius: 6px; padding: 4px 10px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}

.callout {
  border-left: 4px solid var(--purple); background: var(--purple-light);
  padding: 13px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; color: #2c1152;
}
.callout.warn { border-left-color: var(--amber); background: var(--amber-bg); color: #6b4a05; }
.callout.good { border-left-color: var(--green); background: var(--green-bg); color: #0f5a34; }
.callout.bad  { border-left-color: var(--red);   background: var(--red-bg);   color: #8f1d1d; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* The vertical rail cannot survive below 1000px: an icons-only 68px strip
     is unreadable, and once the shell stacks the rail's height:100vh becomes
     a full screen of purple. Turn it into an off-canvas drawer instead, so the
     whole viewport belongs to the content and every label stays reachable. */
  .admin-menu-btn { display: inline-flex; }
  .admin-side {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 264px; flex: none; height: 100vh; max-height: 100vh;
    padding: 16px 0; overflow-y: auto; z-index: 60;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: none;
  }
  .admin-side.open { transform: none; box-shadow: 0 0 44px rgba(20, 12, 45, .38); }

  .admin-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(20, 12, 45, .48);
  }
  .admin-backdrop[hidden] { display: none; }

  /* Everything the rail used to show has to come back inside the drawer. */
  .admin-side .side-brand b { display: block; }
  .admin-side .side-group { display: block; }
  .admin-side nav { display: block; }
  .admin-side nav a { min-height: 44px; padding: 12px 18px; }
  .admin-side nav a span.txt { display: inline; }
  .admin-side nav a .cnt { display: inline-block; }
  .admin-side .side-foot { display: block; padding: 12px 18px 16px; }
  .admin-side .side-foot a {
    display: inline-block; margin: 0 14px 6px 0;
    padding: 8px 0; min-height: 36px; line-height: 20px;
  }

  /* Below 1000px the pointer is a finger: 30px rows and 16px checkboxes are
     not reliably hittable, so grow every control to a usable size. */
  .btn, .btn-sm { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { padding: 0 12px; }
  table.data .btn, table.data .btn-sm { min-width: 40px; min-height: 40px; }
  table.data .trk { display: inline-block; padding: 7px 0; }
  .pager a, .pager span { min-width: 40px; height: 40px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .check { min-height: 40px; }
  select, input[type=text], input[type=search], input[type=date], input[type=number],
  input[type=email], input[type=password], input[type=tel], textarea { min-height: 42px; }

  .admin-body { width: 100%; }
  .admin-top { padding: 11px 15px; }
  .admin-content { padding: 18px 15px 34px; }
  .action-bar { padding: 10px 15px; }
}

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .site-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: #fff; border-bottom: 1px solid var(--line);
    padding: 8px 14px 14px; box-shadow: var(--shadow);
    display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 11px 14px; }
  .site-nav a.nav-admin { margin-left: 0; margin-top: 6px; text-align: center; }

  .hero { padding: 40px 0 56px; }
  .hero h1 { font-size: 28px; }
  .hero .lede { font-size: 15.5px; }
  .track-box { padding: 17px; }
  .track-box .btn { width: 100%; }

  h1 { font-size: 24px; }
  .status-hero { grid-template-columns: minmax(0, 1fr); text-align: center; }
  .status-hero .sh-right { text-align: center; }
  .status-hero .sh-icon { margin: 0 auto; }

  /* These overrides need !important: without it the multi-column base rules
     keep winning in Chrome, so the grids never actually collapse to one
     column on a phone and the desktop layout overflows sideways. */
  .party-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr) !important; }
  .status-hero { grid-template-columns: minmax(0, 1fr) !important; }
  .dl { grid-template-columns: 116px minmax(0, 1fr) !important; }
  .stat-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; gap: 11px; }
  .stat b { font-size: 22px; }
  .admin-content { padding: 18px 15px 34px; }
  .admin-top { padding: 11px 15px; }
  .action-bar { padding: 10px 15px; }

  .progress { flex-wrap: wrap; gap: 14px 0; }
  .progress .step { flex: 0 0 33.33%; }
  .progress .step::before { display: none; }
  .trk-number { font-size: 21px; }
  .trk-refs { gap: 16px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .track-box .field { flex: 1 1 100%; }
  .dl { grid-template-columns: minmax(0, 1fr) !important; }
  .dl dt { padding-bottom: 0; border-bottom: 0; }
  .dl dd { padding-top: 2px; }
}

/* ============================================================
   Phone: admin shell + data tables
   ============================================================ */

@media (max-width: 640px) {
  .admin-content { padding: 15px 13px 32px; }

  /* The sticky page-title bar now shares its row with the menu button. */
  .admin-top { padding: 10px 13px; gap: 10px; flex-wrap: nowrap; }
  .admin-top h1 { font-size: 17px; }
  .admin-user .who { display: none; }
  .admin-user .btn { display: none; }
  .admin-top .crumb { font-size: 12px; }

  /* Drawer links and touch targets are sized by the <=1000px block above. */

  /* Let headers wrap so far fewer columns are pushed off-screen, and shrink
     the padding that was forcing the table wider than the viewport. */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.data { font-size: 13px; }
  table.data th { padding: 9px 10px; white-space: normal; letter-spacing: .5px; }
  table.data td { padding: 10px; }
  table.data td.tight { white-space: normal; }

  /* Keep the row's identity in view while swiping across the rest. */
  table.data th:first-child,
  table.data td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: #fff;
    box-shadow: 1px 0 0 var(--line-2);
  }
  table.data th:first-child { background: #f7f9fc; z-index: 2; }
  table.data tr.row-flag td:first-child { background: #fffdf5; }
  table.data tbody tr:hover td:first-child { background: #fafbfe; }

  .filters { padding: 13px 12px; gap: 9px; }
  .filters .field { min-width: 128px; }
}

/* Explicit hint that a wide table scrolls sideways. */
@media (max-width: 640px) {
  .table-wrap { position: relative; }
  .table-wrap .swipe-hint {
    display: block; padding: 7px 12px;
    font-size: 11.5px; font-weight: 700; letter-spacing: .4px;
    color: var(--muted); background: #f7f9fc;
    border-bottom: 1px solid var(--line-2);
  }
}
@media (min-width: 641px) { .table-wrap .swipe-hint { display: none; } }

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  margin-top: auto;
  background:
    radial-gradient(820px 320px at 6% 0%, rgba(255, 102, 0, .16), transparent 60%),
    linear-gradient(180deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: rgba(255, 255, 255, .8);
  border-top: 4px solid var(--orange);
}

.footer-inner {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 40px;
  padding: 52px 18px 44px;
}

.footer-brand { max-width: 340px; }

.footer-logo {
  display: inline-flex; align-items: center; gap: 11px;
  text-decoration: none; margin-bottom: 15px;
}
.footer-logo:hover { text-decoration: none; }
.footer-mark {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 11px;
}
.footer-logo strong { font-size: 21px; color: #fff; letter-spacing: -.4px; }
.footer-logo strong span,
.footer-fine strong span { color: var(--orange); }

.footer-tag {
  color: #fff; font-weight: 700; font-size: 14.5px;
  letter-spacing: .2px; margin: 0 0 12px;
}
.footer-meta {
  color: rgba(255, 255, 255, .68);
  font-size: 13.5px; line-height: 1.65; margin: 0 0 6px;
}
.footer-meta a { color: rgba(255, 255, 255, .82); text-decoration: none; }
.footer-meta a:hover { color: #fff; text-decoration: underline; }
.footer-contact .dot { margin: 0 7px; opacity: .5; }

.footer-col h4 {
  color: #fff; font-size: 12.5px; font-weight: 800;
  letter-spacing: 1.1px; text-transform: uppercase;
  margin: 0 0 16px; padding-bottom: 10px; position: relative;
}
.footer-col h4::after {
  content: ''; position: absolute; left: 0; bottom: 0;
  width: 30px; height: 2px; border-radius: 2px; background: var(--orange);
}
.footer-col a {
  display: block; padding: 6px 0;
  color: rgba(255, 255, 255, .76);
  font-size: 14px; text-decoration: none;
  transition: color .15s, transform .15s;
}
.footer-col a:hover { color: #fff; text-decoration: none; transform: translateX(3px); }

.footer-base {
  background: rgba(0, 0, 0, .18);
  border-top: 1px solid rgba(255, 255, 255, .12);
  padding: 17px 0;
}
.footer-base-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px 24px; flex-wrap: wrap;
  font-size: 13px; color: rgba(255, 255, 255, .62);
}
.footer-fine { color: rgba(255, 255, 255, .5); }
.footer-fine strong { color: #fff; font-weight: 700; }

@media (max-width: 900px) {
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 34px 28px; padding: 44px 18px 36px; }
  .footer-brand { grid-column: 1 / -1; max-width: none; }
}
@media (max-width: 480px) {
  .footer-inner { grid-template-columns: 1fr; gap: 26px; }
  .footer-col a { padding: 9px 0; }
  .footer-col a:hover { transform: none; }
  .footer-base-inner { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Print
   ============================================================ */

@media print {
  .site-header, .site-footer, .action-bar, .btn, .alert-x, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
  a { text-decoration: none; color: inherit; }
}
