/* Surge Delivery Tracking V2 — the whole stylesheet, in sections. */


/* ---- tokens --------------------------------------------------------------- */

:root {
  --ink: #1e293b;
  --ink-soft: #475569;
  --muted: #64748b;
  --line: rgba(255, 255, 255, 0.4);
  --line-strong: rgba(255, 255, 255, 0.6);
  --panel: rgba(255, 255, 255, 0.55);
  --bg: #e2e8f0;

  --brand: #3b82f6;
  --brand-dark: #2563eb;
  --brand-ink: #1e40af;
  --soft: rgba(255, 255, 255, 0.8);

  --good-bg: rgba(16, 185, 129, 0.2);    --good-ink: #047857;   --good-border: rgba(16, 185, 129, 0.4);
  --moving-bg: rgba(245, 158, 11, 0.2);  --moving-ink: #b45309; --moving-border: rgba(245, 158, 11, 0.4);
  --stopped-bg: rgba(239, 68, 68, 0.2);  --stopped-ink: #b91c1c;--stopped-border: rgba(239, 68, 68, 0.4);
  --open-bg: rgba(59, 130, 246, 0.15);   --open-ink: #2563eb;   --open-border: rgba(59, 130, 246, 0.3);
  --flat-bg: rgba(255, 255, 255, 0.5);   --flat-ink: #475569;   --flat-border: rgba(255, 255, 255, 0.7);

  --danger: #e11d48;
  --danger-bg: rgba(225, 29, 72, 0.15);
  --danger-line: rgba(225, 29, 72, 0.3);

  --rail: rgba(255, 255, 255, 0.6);
  --rail-line: rgba(255, 255, 255, 0.4);
  --rail-ink: #475569;
  --rail-ink-strong: #1e293b;
  --rail-active: rgba(59, 130, 246, 0.15);
  --rail-group: #94a3b8;
  --rail-width: 260px;

  --text-xxs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 19px;
  --text-lg: 23px;
  --text-xl: 28px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow-panel: 0 8px 32px 0 rgba(31, 38, 135, 0.05), 0 1px 2px 0 rgba(255, 255, 255, 0.6) inset;
  --shadow-lift: 0 12px 48px 0 rgba(31, 38, 135, 0.1), 0 1px 2px 0 rgba(255, 255, 255, 0.6) inset;

  --quick: .2s ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}


/* ---- foundation ----------------------------------------------------------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: var(--text-base);
  line-height: 1.45;
  color: var(--ink);
  background-color: #f4f7fb; /* Ultra light slate/silver base */
  background-image:
    radial-gradient(at 0% 0%, hsla(215, 25%, 90%, 0.8) 0px, transparent 50%),
    radial-gradient(at 100% 100%, hsla(215, 15%, 85%, 0.8) 0px, transparent 50%),
    radial-gradient(at 100% 0%, hsla(215, 30%, 95%, 0.8) 0px, transparent 50%),
    radial-gradient(at 0% 100%, hsla(215, 20%, 88%, 0.8) 0px, transparent 50%);
  background-attachment: fixed;
}

h1 { font-size: var(--text-xl); line-height: 1.15; margin: var(--space-1) 0 var(--space-2); font-weight: 700; }
h2 { font-size: var(--text-md); font-weight: 600; }

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:where(a, button, input, select, textarea):focus:not(:focus-visible) { outline: none; }


/* ---- top nav -------------------------------------------------------------- */

.shell { display: flex; flex-direction: column; min-height: 100vh; max-width: 1600px; margin: 0 auto; width: 100%; }
.shell.shell-wide { max-width: 1600px; }
.shell.shell-medium { max-width: 1400px; }
.shell.shell-narrow { max-width: 1100px; }

.top-nav {
  position: sticky; top: 0; z-index: 50;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  padding: 12px 32px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.brand {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 18px; font-weight: 800; color: var(--brand-dark);
  letter-spacing: -.02em; text-transform: uppercase;
}
.brand small {
  font-size: 11px; color: var(--brand); font-weight: 700; letter-spacing: 0.1em;
}
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: var(--radius-md); background: var(--brand); color: #fff;
}

.nav-links { display: flex; gap: 8px; align-items: center; }
.nav-links a {
  padding: 8px 16px; border-radius: 100px;
  color: var(--ink-soft); font-weight: 600; font-size: 14px;
  transition: all var(--quick);
}
.nav-links a:hover { background: rgba(255, 255, 255, 0.8); color: var(--brand); text-decoration: none; }
.nav-links a.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,0.3); text-decoration: none; }

.dropdown { position: relative; display: inline-block; }
.dropbtn {
  background: none; border: none; padding: 8px 16px; border-radius: 100px;
  color: var(--ink-soft); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: all var(--quick); font-family: inherit;
}
.dropdown:hover .dropbtn { background: rgba(255, 255, 255, 0.8); color: var(--brand); }
.dropdown-content {
  display: none; position: absolute; top: 100%; left: 0; margin-top: 8px;
  background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  min-width: 160px; box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
  border-radius: var(--radius-md); border: 1px solid rgba(255, 255, 255, 0.6);
  z-index: 100; overflow: hidden;
}
.dropdown-content a {
  color: var(--ink); padding: 12px 16px; text-decoration: none; display: block;
  border-radius: 0; font-weight: 500;
}
.dropdown-content a:hover { background: var(--soft); color: var(--brand); }
.dropdown:hover .dropdown-content { display: block; }
.dropdown::after { content: ""; position: absolute; top: 100%; left: 0; right: 0; height: 10px; display: none; }
.dropdown:hover::after { display: block; }
.user-menu { display: flex; align-items: center; gap: 16px; }
.user-menu form { margin: 0; }
.who { display: flex; flex-direction: column; line-height: 1.25; color: var(--ink); min-width: 0; text-align: right;}
.who span { font-size: 14px; font-weight: 600; }
.who small { font-size: 11px; color: var(--muted); }
.link-button {
  border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 0; font-family: inherit; transition: color var(--quick);
}
.link-button:hover { color: var(--danger) !important; text-decoration: underline; }

/* ---- page scaffolding ----------------------------------------------------- */

.page { flex: 1 1 auto; min-width: 0; padding: var(--space-4) var(--space-5); }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-4); }
.page-heading .eyebrow { margin-bottom: 6px; }
.eyebrow { letter-spacing: .12em; font-size: var(--text-xs); font-weight: 700; color: var(--brand); margin: 0; text-transform: uppercase; }
.muted { color: var(--muted); margin: 0; }
.title-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.title-row h1 { margin: 0; }

.heading-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; flex: 0 0 auto; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); font-weight: 600; color: var(--muted);
  margin-bottom: var(--space-2); transition: color var(--quick);
}
.back-link::before { content: "←"; font-size: var(--text-base); line-height: 1; }
.back-link:hover { color: var(--brand); text-decoration: none; }

.panel {
  background: var(--panel);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  overflow: hidden; margin-bottom: 24px; transition: box-shadow var(--quick), transform var(--quick);
}
.panel:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.form-panel { padding: 16px; }
.narrow { max-width: 600px; margin: 24px auto; padding: var(--space-5); }
.panel:not(.form-panel) > h2 { margin: 0; padding: 18px var(--space-5) var(--space-3); }
.panel:not(.form-panel) > .stats,
.panel:not(.form-panel) > p,
.panel:not(.form-panel) > .actions,
.panel:not(.form-panel) > form > p,
.panel:not(.form-panel) > form > .actions { padding-left: var(--space-5); padding-right: var(--space-5); }
.panel:not(.form-panel) > p,
.panel:not(.form-panel) > form > p { padding-bottom: var(--space-4); }
.panel:not(.form-panel) > .actions,
.panel:not(.form-panel) > form > .actions { padding-bottom: 18px; }
.panel:not(.form-panel) > .stats { padding-bottom: 6px; }
.panel:not(.form-panel) > .file-grid + form { padding: 0 var(--space-5) var(--space-5); }

.highlight { border-color: var(--brand); box-shadow: 0 6px 24px rgba(11, 113, 137, .12); }
.highlight > h2:first-child, .panel.form-panel.highlight h2 { color: var(--brand); }

.grave { border-color: var(--danger-line); }
.grave > h2:first-child { color: var(--danger); }


/* ---- explanatory prose ---------------------------------------------------- */

.standing {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: var(--radius-md); padding: var(--space-4) 18px; margin: 0 0 18px;
  line-height: 1.6; max-width: 960px;
}
.standing.muted { border-left-color: var(--line); }
.standing.held { border-left-color: var(--danger); background: var(--danger-bg); }
.standing strong { font-weight: 600; }
.standing a { font-weight: 600; }

.alert, .notice {
  padding: 16px 20px; border-radius: var(--radius-md); margin-bottom: var(--space-4); border: 1px solid;
  display: flex; align-items: center; gap: 12px; font-weight: 500;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.alert { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); border-left: 4px solid var(--danger); }
.notice { background: var(--good-bg); border-color: #b9ddc6; color: var(--good-ink); border-left: 4px solid var(--good-ink); }


/* ---- controls ------------------------------------------------------------- */

.primary, .secondary, .danger-button, button {
  border: 1px solid transparent; border-radius: var(--radius-md); padding: 10px 20px;
  font: inherit; font-weight: 600; cursor: pointer; letter-spacing: 0.02em;
  transition: all var(--quick); display: inline-flex; justify-content: center; align-items: center; gap: 8px;
}
.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2); }
.primary:hover { background: var(--brand-dark); text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 10px -1px rgba(37, 99, 235, 0.3); }
.secondary { background: var(--panel); color: var(--ink-soft); border-color: var(--line-strong); box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.05); }
.secondary:hover { background: var(--soft); color: var(--brand); border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.danger-button { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.danger-button:hover { background: var(--danger); color: #fff; transform: translateY(-1px); }
button:disabled, .primary:disabled { opacity: .55; cursor: default; }
.button { display: inline-block; }
.full-width-btn { width: 100%; }
.compact { padding: 7px 12px; font-size: var(--text-sm); }

.actions { display: flex; justify-content: flex-end; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-actions { display: flex; gap: 7px; align-items: center; }
.row-actions form { margin: 0; }
.decision-actions { display: flex; flex-direction: column; gap: 18px; margin-top: var(--space-4); }
.decision-actions form { margin: 0; }

label {
  font-size: var(--text-sm); font-weight: 600; color: var(--ink-soft);
  display: flex; flex-direction: column; gap: 6px;
}
label small { font-weight: 400; color: var(--muted); }

input, select, textarea {
  width: 100%; border: 1px solid rgba(0, 0, 0, 0.12); border-radius: var(--radius-sm);
  padding: 10px 11px; background: rgba(255, 255, 255, 0.85); color: var(--ink); font: inherit;
  transition: all var(--quick);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02) inset;
}
input:hover, select:hover, textarea:hover { border-color: rgba(0, 0, 0, 0.25); background: #ffffff; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); background: #ffffff; outline: none; }
input[type="file"] { padding: 8px; }

/* Controlled widths for short inputs */
input[data-date], input[data-datetime] { width: 140px; }
input[type="tel"] { width: 180px; }
select { width: fit-content; min-width: 160px; max-width: 100%; }
.stepper-input input { width: 60px; flex: none; border-radius: 0; }
.date-wrap { position: relative; display: inline-block; width: fit-content; max-width: 100%; }

.stack { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.check {
  flex-direction: row; align-items: flex-start; gap: 10px;
  background: var(--soft); border: 1px solid #bcdde6; padding: var(--space-3);
  border-radius: var(--radius-sm);
}
.check input { width: auto; margin-top: 3px; }
.check label { flex-direction: column; align-items: flex-start; gap: 2px; }

.filters {
  display: flex; gap: 10px; padding: var(--space-4); border-bottom: 1px solid rgba(255,255,255,0.2);
  flex-wrap: wrap; align-items: center;
}
.filters input, .filters select { 
  width: auto; flex: 0 1 220px; 
  background: rgba(255,255,255,0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 100px; padding: 12px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02) inset; color: var(--ink);
}
.filters input:focus, .filters select:focus { background: #fff; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); border-color: var(--brand); outline: none; }
.filters input:first-child { flex: 1 1 260px; }
.filters button { flex: 0 0 auto; border-radius: 100px; padding: 12px 24px; }
.form-panel .filters { padding: 0 0 var(--space-3); border: 0; }
.form-panel .filters input { flex: 1; }
#material-count { white-space: nowrap; font-size: var(--text-sm); }

/* ---- material cards (Bento Grid) ---- */

.material-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; padding: 24px;
}
.material-card {
  background: rgba(255,255,255,0.6); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.8); border-radius: 20px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 4px 16px rgba(31,38,135,0.05); transition: transform var(--quick), box-shadow var(--quick);
}
.material-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(31,38,135,0.1); }
.material-card .card-header {
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.4);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.material-card .header-right { text-align: right; }
.material-card .header-right a { font-size: 16px; color: var(--ink); text-decoration: none; display: block; line-height: 1.1; }
.material-card .header-right a:hover { color: var(--brand); text-decoration: underline; }
.material-card .header-right small { font-size: 11px; color: var(--muted); font-weight: 600; }
.material-card .card-body { padding: 20px; flex: 1; }
.material-card h3 { font-size: 15px; font-weight: 700; margin: 0 0 4px; line-height: 1.3; }
.material-card h3 small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.material-card .project-info { font-size: 13px; color: var(--ink-soft); margin: 0 0 16px; font-weight: 500; }
.material-card .project-info small { color: var(--muted); }
.material-card .progress-section { background: rgba(255,255,255,0.5); padding: 12px; border-radius: 12px; }
.material-card .card-footer {
  padding: 12px 20px; background: rgba(255,255,255,0.4); border-top: 1px solid rgba(255,255,255,0.4);
  font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.material-card .footer-st { flex: 1; color: var(--muted); font-weight: 500; }
.material-card .footer-st a { font-weight: 700; color: var(--brand); }
.material-card .alert-hold { color: var(--danger); font-weight: 600; margin-top: 4px; }
.empty-state {
  grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px 20px; text-align: center; color: var(--muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; color: var(--ink-soft); margin: 0 0 8px; }

/* ---- Timeline Stepper ---- */
.timeline-stepper { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 600px; margin: 0 auto; }
.step { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; position: relative; z-index: 2; }
.step-icon { width: 32px; height: 32px; border-radius: 50%; background: #cbd5e1; color: #475569; display: grid; place-items: center; font-weight: 700; font-size: 14px; transition: all 0.3s; }
.step.active .step-icon { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.step.cancelled .step-icon { background: var(--danger); color: #fff; }
.step-text { font-size: 12px; font-weight: 600; color: #64748b; }
.step.active .step-text { color: var(--ink); }
.step-line { flex: 2; height: 4px; background: #cbd5e1; border-radius: 4px; margin: -20px 10px 0; z-index: 1; transition: background 0.3s; }
.step-line.active { background: var(--brand); }

/* ---- Receipt Grid Cards ---- */
.receipt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; padding: 16px; }
.receipt-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; box-shadow: 0 2px 8px rgba(0,0,0,0.02); }
.rc-header h4 { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.rc-header small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.rc-body p { margin: 0 0 4px; font-size: 12px; }
.rc-footer { margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); }
.stepper-input { display: inline-flex; align-items: center; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper-btn { background: none; border: none; padding: 8px 16px; cursor: pointer; font-weight: bold; font-size: 16px; color: var(--ink); transition: background 0.2s; }
.stepper-btn:hover { background: #e2e8f0; }
.stepper-input input { border: none; text-align: center; width: 60px; font-weight: 600; font-size: 14px; padding: 8px 0; border-radius: 0; background: transparent; }

/* ---- Horizontal Wizard Bar ---- */
.wizard-bar { display: flex; align-items: center; background: rgba(255,255,255,0.7); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.6); border-radius: 100px; padding: 6px; box-shadow: 0 4px 12px rgba(31,38,135,0.05); }
.wizard-step { padding: 10px 24px; border-radius: 100px; font-weight: 600; font-size: 14px; color: var(--muted); transition: all 0.3s; flex: 1; text-align: center; }
.wizard-step.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,0.2); }

/* ---- Request Group (Dashboard) ---- */
.request-group {
  margin-bottom: 16px; background: rgba(255,255,255,0.7); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.8); border-radius: 12px; box-shadow: 0 4px 12px rgba(31,38,135,0.03);
}
.request-group > summary {
  padding: 16px; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  list-style-type: none; outline: none; transition: background var(--quick);
  border-radius: 12px;
}
.request-group > summary::-webkit-details-marker { display: none; }
.request-group > summary:hover { background: rgba(255,255,255,0.9); }
.request-group[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 1px solid var(--line); }
.rg-header { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--ink); }
.rg-meta { color: var(--muted); font-size: 13px; }
.request-group > summary::after {
  content: ''; display: inline-block; width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 5px solid var(--ink-soft); transition: transform var(--quick); margin-left: 12px;
}
.request-group[open] > summary::after { transform: rotate(180deg); }

/* ---- Legend / Details ---- */
.legend {
  margin: 16px 24px 24px; background: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.8); border-radius: 12px; backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(31,38,135,0.02);
}
.legend summary {
  padding: 12px 16px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink);
  outline: none; list-style-type: none; display: flex; align-items: center; justify-content: space-between;
}
.legend[open] summary { border-bottom: 1px solid rgba(0,0,0,0.05); }
.legend summary::after {
  content: ''; display: inline-block; width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 5px solid var(--ink-soft); transition: transform var(--quick);
}
.legend[open] summary::after { transform: rotate(180deg); }
.legend summary::-webkit-details-marker { display: none; }
.legend dl {
  display: grid; grid-template-columns: max-content 1fr; gap: 12px 24px;
  margin: 0; padding: 16px; align-items: center;
}
.legend dt { margin: 0; }
.legend dd { margin: 0; font-size: 13px; color: var(--ink-soft); font-weight: 500; }

.step { margin: 0 0 14px; font-size: var(--text-base); color: var(--brand); font-weight: 600; }
.step-number {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--soft); color: var(--brand); font-size: var(--text-xs);
  margin-right: 9px; vertical-align: -4px;
}

button[aria-busy="true"] { opacity: .6; cursor: progress; }


/* ---- counters ------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin-bottom: 24px; }
.stat {
  background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px; padding: 24px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.stat strong { font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.1; margin-top: 8px; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: rgba(255, 255, 255, 1); background: rgba(255,255,255,0.9); box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.1); transform: translateY(-4px); }
a.stat.chosen { border-color: var(--brand); background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; box-shadow: 0 8px 24px rgba(37,99,235,0.3); }
a.stat.chosen span, a.stat.chosen strong { color: #fff; }

/* ---- progress bars -------------------------------------------------------- */

.progress-cell { min-width: 180px; }
.qty-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.progress-track {
  display: flex; height: 10px; background: rgba(226, 232, 240, 0.5); border-radius: 99px; overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.05);
}
.progress-bar { height: 100%; transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
.bar-assigned { background: var(--open-ink); }
.bar-delivered { background: var(--moving-ink); }
.bar-accepted { background: var(--good-ink); }


/* ---- tables --------------------------------------------------------------- */

.table-wrap { overflow: auto; max-height: 72vh; border: 1px solid rgba(255,255,255,0.6); border-radius: 20px; background: rgba(255,255,255,0.7); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
  background: var(--bg); color: var(--ink-soft); text-align: left; font-size: 11px;
  font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  position: sticky; top: 0; z-index: 1;
  padding: 14px var(--space-4); border-bottom: 1px solid var(--line-strong);
}
th small { display: block; font-weight: 500; color: var(--muted); font-size: 10px; letter-spacing: 0; margin-top: 4px; text-transform: none; }
th, td { padding: 14px var(--space-4); border-bottom: 1px solid var(--line); vertical-align: top; }
td { font-variant-numeric: tabular-nums; }
tbody td:first-child { font-weight: 600; }
tbody td:first-child small { font-weight: 400; }
td small { display: block; color: var(--muted); margin-top: 3px; font-size: var(--text-xs); }

tbody tr { transition: background var(--quick); }
tbody tr:hover { background: #f7fafc; }
.table-wrap td a { white-space: nowrap; }

tbody tr.being-edited { background: var(--soft); box-shadow: inset 3px 0 0 var(--brand); }
tbody tr.being-edited:hover { background: #ddeff4; }
.empty { text-align: center; color: var(--muted); padding: 42px; }
.empty:hover { background: transparent; }
.qty { min-width: 120px; font-variant-numeric: tabular-nums; }

.pager {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4);
  padding: 14px var(--space-5); border-top: 1px solid var(--line);
  font-size: var(--text-sm); color: var(--muted); flex-wrap: wrap;
}
.pager-links { display: flex; gap: 14px; }
.pager-links a { font-weight: 600; }


/* ---- badges --------------------------------------------------------------- */

.badge {
  display: inline-block; padding: 4px 10px; border-radius: 99px;
  background: var(--open-bg); color: var(--open-ink); border: 1px solid var(--open-border);
  font-size: var(--text-xs); font-weight: 700; white-space: nowrap; backdrop-filter: blur(4px);
}
.badge .kind {
  display: inline-block; font-weight: 800; font-size: 10px; letter-spacing: .07em;
  text-transform: uppercase; opacity: .7; margin-right: 6px;
}
.title-row .badge { font-size: var(--text-sm); padding: 6px var(--space-3); display: inline-flex; align-items: baseline; }

.badge.completed, .badge.issued, .badge.arrived, .badge.approved, .badge.released,
.badge.partial, .badge.on_delivery, .badge.waiting_approval,
.badge.assigned, .badge.in_preparation {
  background: var(--open-bg); color: var(--open-ink); border-color: var(--open-border);
}

.badge.cancelled, .badge.hold, .badge.held, .badge.rejected, .badge.recalled, .badge.not_complete,
.badge.draft, .badge.unassigned, .badge.not_started, .badge.withdrawn {
  background: var(--flat-bg); color: var(--flat-ink); border-color: var(--flat-border);
}



/* ---- definition lists ----------------------------------------------------- */

.facts {
  display: grid; grid-template-columns: minmax(150px, 200px) minmax(0, 1fr);
  gap: 10px var(--space-5); margin: 0; padding: 0 var(--space-5) var(--space-5);
}
.facts dt { font-size: var(--text-sm); font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.facts dt small { font-weight: 400; color: var(--muted); }
.facts dd { margin: 0; color: var(--ink); }
.facts dd .badge { margin-right: 6px; }
.facts dd small { display: block; color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }


/* ---- status legend --------------------------------------------------------- */

.legend {
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
}
.legend > summary {
  padding: var(--space-3) var(--space-5);
  color: var(--muted); font-weight: 600; cursor: pointer;
  list-style-position: inside;
}
.legend > summary:hover { color: var(--brand); }
.legend h3 {
  margin: var(--space-3) var(--space-5) 0;
  font-size: var(--text-xs); font-weight: 700; color: var(--muted);
  letter-spacing: .04em; text-transform: uppercase;
}
.legend dl {
  display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0; padding: 0 var(--space-5) var(--space-4);
}
.legend dt { margin: 0; }
.legend dd { margin: 0; color: var(--muted); }
.form-panel .legend { border: 1px solid var(--line); border-radius: var(--radius-sm); }

@media (max-width: 580px) {
  .legend dl { grid-template-columns: 1fr; gap: var(--space-1) 0; }
  .legend dd { margin-bottom: var(--space-3); }
}

.audit-detail { display: block; font-size: var(--text-sm); }
.audit-detail + .audit-detail { margin-top: 2px; }
.audit-detail b { font-weight: 600; color: var(--muted); margin-right: 5px; }


/* ---- layouts -------------------------------------------------------------- */

.editor-dialog {
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 24px;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto;
  /* opaque on purpose: --panel is 55% white, which lets the table underneath
     read through a dialog that floats over it */
  background: #ffffff; color: var(--ink);
  box-shadow: 0 24px 60px rgba(24, 59, 91, .28);
}
.editor-dialog::backdrop { background: rgba(23, 35, 49, .5); }

body:has(dialog[open]) { overflow: hidden; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.dialog-head h2 { margin: 0; }
.dialog-close {
  display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: var(--radius-sm); color: var(--muted); font-size: 22px; line-height: 1;
  text-decoration: none; transition: background var(--quick), color var(--quick);
}
.dialog-close:hover { background: var(--flat-bg); color: var(--ink); text-decoration: none; }

.detail-layout { display: flex; gap: 18px; align-items: flex-start; width: 100%; }
.detail-main { flex: 1 1 0%; min-width: 0; }
.detail-aside { flex: 0 1 340px; min-width: 280px; position: sticky; top: 92px; }
.detail-aside .facts { grid-template-columns: 1fr; gap: 0; }
.detail-aside .facts dd { margin-bottom: 14px; }
.detail-aside .facts dd:last-child { margin-bottom: 0; }
.detail-main .standing { max-width: none; }

.file-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; padding: var(--space-5); }
.file-card {
  border: 1px solid var(--line); border-radius: 10px; padding: var(--space-4);
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color var(--quick), box-shadow var(--quick);
}
.file-card:hover { border-color: var(--brand); box-shadow: var(--shadow-lift); text-decoration: none; }
.file-card span { color: var(--muted); font-size: var(--text-xs); }


/* ---- sign in and error pages ---------------------------------------------- */

.auth-page {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at top left, #dff3f4, transparent 38%), linear-gradient(145deg, #eff4f8, #e9eef4);
}
.auth-card {
  width: min(440px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--line);
  border-radius: 18px; padding: 36px; box-shadow: 0 20px 55px rgba(24, 59, 91, .15);
}
.auth-brand { margin-bottom: var(--space-6); }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 0; left: var(--space-4); z-index: 30;
  transform: translateY(-120%);
  background: var(--brand); color: #fff; font-weight: 600;
  padding: 10px 18px; border-bottom-left-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift); transition: transform var(--quick);
}
.skip-link:focus { transform: translateY(0); text-decoration: none; }

#main:focus { outline: none; }


/* ---- forms step wizard ---------------------------------------------------- */

.step { display: flex; align-items: center; gap: 12px; margin: 32px 0 20px; font-size: 20px; font-weight: 700; color: var(--ink-strong); letter-spacing: -0.02em; }
.step:first-of-type { margin-top: 0; }
.step-number {
  display: flex; justify-content: center; align-items: center; flex: 0 0 auto;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 4px rgba(37,99,235,0.25);
}


/* ---- narrower screens ------------------------------------------------------ */

@media (max-width: 1100px) {
  .detail-layout { flex-direction: column; }
  .detail-aside { position: static; }
}

@media (min-width: 901px) {
  .sidebar::details-content { content-visibility: visible; block-size: auto; overflow: visible; }
  .sidebar > *:not(summary) { display: revert; }
  .sidebar nav { display: flex; }
  .sidebar-foot { display: flex; }
}

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    width: auto; flex: none; max-height: none; position: sticky; top: 0; z-index: 20;
    padding: 0; gap: 0;
  }
  .sidebar > summary {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding: var(--space-3) 18px; min-height: 56px;
  }
  .sidebar > summary .brand { padding: 0; }
  .sidebar[open] > summary { border-bottom: 1px solid var(--rail-line); }
  .sidebar .burger {
    font-size: 20px; line-height: 1; color: var(--rail-ink-strong);
    border: 1px solid var(--rail-line); border-radius: var(--radius-sm);
    padding: 6px 11px; min-height: 44px; display: grid; place-items: center;
  }
  .sidebar > .brand { display: none; }
  .sidebar nav { padding-bottom: var(--space-3); }
  .sidebar-foot { margin-top: 0; padding: var(--space-3) 18px var(--space-4); }
  .page { padding: var(--space-4) var(--space-3); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .page-heading { align-items: flex-start; }

  .compact, .primary, .secondary, .danger-button, button, .button { min-height: 44px; padding: 11px var(--space-4); }
  .row-actions { gap: var(--space-2); }
  .sidebar nav a { padding: 12px 18px; }
  .link-button { min-height: 44px; }
}

@media (max-width: 700px) {
  .facts { grid-template-columns: 1fr; gap: var(--space-1) 0; }
  .facts dd { margin-bottom: 10px; }
}

@media (max-width: 580px) {
  input[data-date], input[data-datetime], input[type="tel"], select { width: 100%; }
  .date-wrap { width: 100%; display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters input, .filters select { flex: 1 1 auto; }
  .page-heading { flex-direction: column; }
  .page-heading .button { width: 100%; text-align: center; }
  .stat { flex: 1 1 100%; }
}

@media (max-width: 760px) {
  .table-wrap { max-height: none; overflow: visible; }

  .table-wrap thead { display: none; }
  .table-wrap :is(table, tbody, tr, td) { display: block; width: auto; }

  .table-wrap tr {
    border: 1px solid var(--line); border-radius: var(--radius-md);
    margin: 0 var(--space-3) var(--space-3); padding: var(--space-2) 0; background: var(--panel);
  }
  .table-wrap tr:hover { background: var(--panel); }
  .table-wrap tr.being-edited { background: var(--soft); }

  .table-wrap td {
    border: 0; padding: 6px var(--space-4);
    display: grid; grid-template-columns: minmax(90px, 36%) minmax(0, 1fr); gap: var(--space-3);
    align-items: baseline;
  }
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    color: var(--muted); font-size: var(--text-xs); font-weight: 600; line-height: 1.5;
  }

  .table-wrap td:not([data-label]) { grid-template-columns: minmax(0, 1fr); padding-top: var(--space-2); }
  .table-wrap td small { margin-top: 2px; }
  .table-wrap td .row-actions { flex-wrap: wrap; }

  .table-wrap td.empty { display: block; padding: var(--space-6) var(--space-4); }
  .table-wrap tr:has(td.empty) { border: 0; }
}


/* ---- pager ----------------------------------------------------------------- */

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 24px; background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  position: sticky; bottom: 0; z-index: 10;
  border-bottom-left-radius: inherit; border-bottom-right-radius: inherit;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.02);
}
.pager-info { display: flex; flex-direction: column; gap: 2px; }
.pager-info strong { color: var(--ink); font-weight: 700; }
.pager-info span { font-size: 14px; color: var(--ink-soft); }
.pager-info small { font-size: 12px; color: var(--muted); }
.pager-links { display: flex; gap: 8px; }
.pager-links .button { min-width: 110px; text-align: center; }

@media (max-width: 580px) {
  .pager { flex-direction: column; align-items: stretch; text-align: center; padding: 16px; }
  .pager-links { display: flex; justify-content: stretch; }
  .pager-links .button { flex: 1; }
}


/* ---- printing -------------------------------------------------------------- */

@media print {
  .shell { display: block; }
  .sidebar, .filters, .pager, .heading-actions, .actions, .row-actions,
  .form-panel, .stats, .legend { display: none !important; }

  .detail-aside { position: static; }
  body { background: #fff; font-size: 11pt; }
  .page { padding: 0; max-width: none; }
  .panel { border: 1px solid #444; box-shadow: none; break-inside: avoid; margin-bottom: 12pt; }
  .standing { border: 1px solid #444; border-left-width: 1px; max-width: none; }
  .detail-layout { display: block; }
  th { background: #e8e8e8 !important; color: #000; }
  th, td { border-bottom: 1px solid #999; padding: 5pt 6pt; }
  .badge { border: 1px solid #444; background: #fff !important; color: #000 !important; }
  a { color: #000; text-decoration: none; }
  .table-wrap { overflow: visible; max-height: none; }
}
