/* ============================================================
   v05 SHELL — shared by Orders list, Order detail, Place order
   and the Calendar month (which has its own variant inline).

   Locked-in defaults (cohesive across pages):
     • Ink sidebar (.hf-side, --sidebar-bg = ink-900)
     • Ink topbar (.hf-header, --topbar-bg = ink-900)
     • Warm canvas (--page-bg = #E8EAE6)
     • Dark-white active sidebar pill
     • Page title sits at top of sidebar (not in content)
     • Account block pinned to bottom of sidebar

   Per-page Tweaks can override these via :root inside the page.
   ============================================================ */

:root {
  /* Sidebar */
  --sidebar-bg: var(--enroute-ink-900);
  --sidebar-fg: rgba(255,255,255,0.65);
  --sidebar-fg-mute: rgba(255,255,255,0.40);
  --sidebar-fg-strong: #fff;
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-border: #000;
  --sidebar-icon-opacity: 0.7;

  /* Topbar */
  --topbar-bg: var(--enroute-ink-900);
  --topbar-fg: rgba(255,255,255,0.55);
  --topbar-fg-strong: #fff;
  --topbar-fg-mute: rgba(255,255,255,0.50);
  --topbar-border: #000;

  /* Canvas */
  --page-bg: #E8EAE6;

  /* Motion */
  --dur-fast: 120ms;
  --dur-base: 220ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

html, body { background: var(--page-bg); }
body { font-family: var(--font-sans); }

/* ---------- Shell grid ---------- */
.hf-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 55px 1fr;
  min-height: 100vh;
  background: var(--page-bg);
}

/* ---------- Header (top chrome) ---------- */
.hf-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr max-content 1fr;
  align-items: center;
  gap: 28px;
  padding: 0 28px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  position: sticky; top: 0; z-index: 30;
  height: 55px;
}
.hf-header__title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--topbar-fg-strong);
  line-height: 1.05;
  margin: 0;
  text-decoration: none;
}
.hf-header__title .dot { color: var(--enroute-green-400); }
.hf-header__center {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: center;
  min-width: 0;
  max-width: 100%;
}
.hf-header__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
}

/* Header utility label ("SHOW BY", "ROLE", etc.) */
.hf-hlabel {
  color: var(--topbar-fg);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  white-space: nowrap;
}

/* Header primary action (lives in topbar right cluster) */
.hf-hbtn {
  appearance: none;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
  background: var(--brand);
  color: #fff;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.hf-hbtn:hover { background: var(--brand-hover); }
.hf-hbtn svg { width: 14px; height: 14px; }

.hf-hbtn--ghost {
  background: rgba(255,255,255,0.06);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}
.hf-hbtn--ghost:hover { background: rgba(255,255,255,0.12); }

/* Header search (used by Orders list + Order detail) */
.hf-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
  min-width: 320px;
  max-width: 100%;
}
.hf-search:focus-within {
  background: rgba(255,255,255,0.10);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
}
.hf-search svg { width: 14px; height: 14px; color: rgba(255,255,255,0.5); flex: none; }
.hf-search input {
  background: transparent;
  border: 0;
  outline: 0;
  color: #fff;
  font: inherit;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}
.hf-search input::placeholder { color: rgba(255,255,255,0.45); }

/* Breadcrumb / title cluster in header center for non-calendar pages */
.hf-bc {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  color: var(--topbar-fg);
  font-size: 13px;
  font-weight: 600;
}
.hf-bc strong {
  color: var(--topbar-fg-strong);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.hf-bc .sep { color: var(--topbar-fg-mute); font-weight: 400; }

/* ---------- Sidebar ---------- */
.hf-side {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 0 10px 14px;
  display: flex; flex-direction: column;
  gap: 2px;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.hf-side__logo {
  height: 55px;
  display: flex; align-items: center;
  padding: 0 8px;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--sidebar-fg-strong);
  text-decoration: none;
  margin-bottom: 4px;
}
.hf-side__logo .dot { color: var(--enroute-green-400); }
.hf-side__pagetitle { font-size: 20px; }
.hf-side__pagetitle small {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-fg-mute);
  margin-top: -1px;
}

.hf-side__spacer { flex: 1 1 auto; min-height: 12px; }

.hf-side__account {
  display: flex; flex-direction: column;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--sidebar-hover-bg);
  margin-top: 6px;
}
.hf-side__user {
  padding: 8px 10px 0 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sidebar-fg-strong);
  line-height: 1.3;
  letter-spacing: -0.005em;
  word-break: break-all;
}
.hf-side__signout {
  padding: 2px 10px 6px 10px;
  font-size: 11.5px;
  color: var(--sidebar-fg-mute);
  text-decoration: none;
  display: inline-block;
  width: fit-content;
}
.hf-side__signout:hover { color: var(--sidebar-fg-strong); text-decoration: underline; }

.hf-side__label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--sidebar-fg-mute); font-weight: 700;
  padding: 14px 10px 6px;
}
.hf-side__label:first-child { padding-top: 4px; }
.hf-side__item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  color: var(--sidebar-fg);
  text-decoration: none;
  white-space: nowrap;
  transition: background 100ms, color 100ms;
}
.hf-side__item:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-fg-strong); }
.hf-side__item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: var(--sidebar-icon-opacity); }
.hf-side__item:hover svg { opacity: 1; }
.hf-side__item--active,
.hf-side__item--active:hover {
  background: #fff;
  color: var(--enroute-ink-900);
  font-weight: 700;
}
.hf-side__item--active svg { opacity: 1; }
.hf-side__item__count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,0.10);
  color: var(--sidebar-fg-strong);
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.hf-side__item--active .hf-side__item__count {
  background: rgba(10,13,11,0.08);
  color: var(--enroute-ink-900);
}

/* ---------- Main content shell ---------- */
.hf-main { padding: 18px; min-width: 0; }

/* ---------- Status pill (3-bucket palette, locked) ---------- */
.st-pill {
  display: inline-flex; align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  background: var(--st-bg);
  color: var(--st-fg);
  white-space: nowrap;
  --st-bg: var(--enroute-ink-100);
  --st-fg: var(--enroute-ink-700);
}
.st-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--st-dot);
  --st-dot: var(--enroute-ink-400);
}
.st-pill.s-pending,
.st-pill.s-accepted   { --st-bg: var(--enroute-amber-50); --st-fg: var(--enroute-amber-800); --st-dot: var(--enroute-amber-500); }
.st-pill.s-loading,
.st-pill.s-transit    { --st-bg: var(--enroute-green-50); --st-fg: var(--enroute-green-800); --st-dot: var(--enroute-green-500); }
.st-pill.s-delivered,
.st-pill.s-invoiced   { --st-bg: var(--enroute-ink-100); --st-fg: var(--enroute-ink-700); --st-dot: var(--enroute-ink-400); }
.st-pill.s-cancelled  { --st-bg: var(--enroute-rose-100); --st-fg: var(--enroute-rose-700); --st-dot: var(--enroute-rose-500); }

/* Quiet inline status (used in tables): just dot + label, no chip background */
.st-inline {
  display: inline-flex; align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-1);
  white-space: nowrap;
}
.st-inline .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--enroute-ink-400);
  flex: none;
}
.st-inline.s-pending .dot,
.st-inline.s-accepted .dot   { background: var(--enroute-amber-500); }
.st-inline.s-loading .dot,
.st-inline.s-transit .dot    { background: var(--enroute-green-500); }
.st-inline.s-delivered .dot,
.st-inline.s-invoiced .dot   { background: var(--enroute-ink-400); }
.st-inline.s-cancelled .dot  { background: var(--enroute-rose-500); }

/* ---------- Primary surface (cards / panels) ---------- */
.surface {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 1px rgba(10,13,11,0.03);
}
.surface--quiet {
  background: #FAFBF9;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--border-1);
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 0;
  background: var(--enroute-ink-100);
  color: var(--enroute-ink-900);
  text-decoration: none;
  white-space: nowrap;
  transition: background 100ms;
  min-height: 36px;
}
.btn:hover { background: var(--enroute-ink-200); }
.btn svg { width: 14px; height: 14px; }
.btn--primary {
  background: var(--brand);
  color: #fff;
}
.btn--primary:hover { background: var(--brand-hover); }
.btn--outline {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--border-2);
  color: var(--fg-1);
}
.btn--outline:hover { background: var(--enroute-ink-100); box-shadow: inset 0 0 0 1px var(--border-3); }
.btn--danger {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--enroute-rose-200);
  color: var(--enroute-rose-700);
}
.btn--danger:hover { background: var(--enroute-rose-50); box-shadow: inset 0 0 0 1px var(--enroute-rose-400); }
.btn--ghost {
  background: transparent;
  color: var(--fg-2);
}
.btn--ghost:hover { background: var(--enroute-ink-100); color: var(--fg-1); }
.btn--lg { padding: 12px 18px; font-size: 14px; min-height: 44px; }
.btn--block { width: 100%; justify-content: center; }

/* ---------- Form atoms ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld__lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--fg-3);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.fld__lbl em {
  font-style: normal;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--fg-4);
}
.fld__hint {
  font-size: 12px;
  color: var(--fg-3);
}
.fld__ctrl,
.fld input[type="text"],
.fld input[type="number"],
.fld input[type="date"],
.fld input[type="time"],
.fld input[type="email"],
.fld input[type="tel"],
.fld input[type="search"],
.fld input[type="password"],
.fld input[type="url"],
.fld select,
.fld textarea {
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 0;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--border-2);
  color: var(--fg-1);
  outline: 0;
  min-height: 40px;
  min-width: 0;
  width: 100%;
}
.fld textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.fld select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%23232825' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
.fld input:focus,
.fld select:focus,
.fld textarea:focus {
  box-shadow: inset 0 0 0 1px var(--enroute-ink-700), 0 0 0 3px rgba(10,13,11,0.06);
}
.fld--inline { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 12px 16px; align-items: center; }
.fld--inline .fld__lbl { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--fg-1); }

/* Inline composite control: two inputs glued together (eg "R/L" prefix) */
.fld__ctrl--combo {
  display: flex; align-items: stretch;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--border-2);
  border-radius: 8px;
  overflow: hidden;
  min-height: 40px;
}
.fld__ctrl--combo > input {
  border: 0; outline: 0; background: transparent;
  padding: 10px 12px;
  font-size: 14px;
  flex: 1;
  min-width: 0;
}
.fld__ctrl--combo > .fld__affix {
  display: inline-flex; align-items: center; padding: 0 12px;
  background: #F2F4F1;
  color: var(--fg-3);
  font-size: 12.5px; font-weight: 600;
  border-left: 1px solid var(--border-1);
  font-family: var(--font-mono);
}
.fld__ctrl--combo > .fld__affix--lead {
  border-left: 0; border-right: 1px solid var(--border-1);
}

/* ---------- Drawer (slide-in) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,13,11,0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
  z-index: 80;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0;
  height: 100vh;
  width: 380px;
  max-width: 100vw;
  background: #fff;
  box-shadow: -12px 0 32px rgba(10,13,11,0.18);
  transform: translateX(100%);
  transition: transform var(--dur-base) var(--ease-out);
  z-index: 90;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer__hd {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-1);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer__hd h2 { margin: 0; font-size: 16px; font-weight: 700; }
.drawer__close {
  appearance: none; background: transparent; border: 0; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-2);
}
.drawer__close:hover { background: var(--enroute-ink-100); color: var(--fg-1); }
.drawer__body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.drawer__ft {
  padding: 14px 18px;
  border-top: 1px solid var(--border-1);
  display: flex; gap: 10px;
  background: #FAFBF9;
}
.drawer__ft .btn { flex: 1; justify-content: center; }

/* ============================================================
   FORM SHELL — used by Request location / Import orders / Export
   orders / Document upload / Accept / Amend / Cancel pages.
   Single centered card for "context-free" forms; +sticky right rail
   for order-scoped forms.
   ============================================================ */

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
  max-width: 1100px;
  margin: 0 auto;
}
.form-grid--solo {
  display: block;
  max-width: 720px;
  margin: 0 auto;
}
.form-intro {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px;
  padding: 0 24px 14px 24px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.form-intro--solo { max-width: 720px; }
.form-intro__copy h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 4px;
}
.form-intro__copy p {
  font-size: 13.5px;
  color: var(--fg-3);
  margin: 0;
  max-width: 64ch;
}
.form-intro__actions { display: flex; gap: 8px; }

.form-card {
  background: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 1px 1px rgba(10,13,11,0.03);
  display: flex; flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.form-card__hd {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  margin-bottom: -2px;
}
.form-card__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg-1);
  letter-spacing: -0.01em;
  margin: 0;
  display: inline-flex; align-items: baseline; gap: 8px;
}
.form-card__title .step {
  display: inline-flex;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--enroute-ink-900);
  color: #fff;
  font-size: 11px; font-weight: 700;
  align-items: center; justify-content: center;
  letter-spacing: 0;
}
.form-card__sub {
  font-size: 12px;
  color: var(--fg-3);
  font-weight: 500;
}
.form-card__actions {
  display: flex; gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}
.form-card__actions .btn { min-height: 44px; }

.form-row { display: grid; gap: 14px 18px; grid-template-columns: 1fr; }
.form-row--2 { grid-template-columns: 1fr 1fr; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }

/* Context card (sticky right rail, parent-order summary etc.) */
.ctx-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 1px rgba(10,13,11,0.03);
  display: flex; flex-direction: column;
  gap: 4px;
  position: sticky; top: 73px;
}
.ctx-card__lbl {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--fg-3);
  margin: 0 0 6px;
}
.ctx-card__id {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--fg-1);
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.ctx-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-1);
  gap: 12px;
  font-size: 12.5px;
}
.ctx-row:last-of-type { border-bottom: 0; }
.ctx-row .lbl { color: var(--fg-3); font-weight: 500; }
.ctx-row .val { color: var(--fg-1); font-weight: 600; text-align: right; max-width: 60%; }
.ctx-row .val.mono { font-family: var(--font-mono); }

/* ============================================================
   ROLE-SCOPED HIDING (shared so every page can use it)
   Add .role-internal-only, .role-client-only, .role-transporter-only,
   or the inverse hide-* utilities to any element. The page's <body>
   needs data-role="internal" | "client" | "transporter".
   ============================================================ */
[data-role="client"]      .role-hide-client      { display: none !important; }
[data-role="transporter"] .role-hide-transporter { display: none !important; }
[data-role="internal"]    .role-hide-internal    { display: none !important; }

.role-internal-only { display: none; }
[data-role="internal"] .role-internal-only { display: revert; }

.role-client-only { display: none; }
[data-role="client"] .role-client-only { display: revert; }

.role-transporter-only { display: none; }
[data-role="transporter"] .role-transporter-only { display: revert; }

/* Role pill (e.g. shown next to a field that's role-gated) */
.role-pill {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
  white-space: nowrap;
}
.role-pill--internal   { background: var(--enroute-cobalt-100); color: var(--enroute-cobalt-700); }
.role-pill--client     { background: var(--enroute-amber-100);  color: var(--enroute-amber-800); }
.role-pill--transporter{ background: #E6DDFF;                    color: #4A2E99; }
