/* ==========================================================================
   Machine Ops theme — layered on Bootstrap 5.3
   ========================================================================== */
:root,
[data-bs-theme="light"] {
  --app-bg: #f4f6f9;
  --app-surface: #ffffff;
  --app-surface-2: #f8f9fb;
  --app-border: #e4e7ec;
  --app-text: #1a2230;
  --app-muted: #667085;
  --app-accent: #257de0;
  --app-accent-strong: #1b64be;
  --app-accent-soft: #e9f2fd;
  --app-side: #0f1726;
  --app-side-text: #aab3c2;
  --app-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --app-shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);

  /* data viz roles (validated reference palette) */
  --viz-assigned: #257de0;
  --viz-covered: #00b894;
  --viz-short: #dc3c3d;
  --viz-track: #eef1f5;
  --stage-1: #84b9f3; --stage-2: #519ced; --stage-3: #257de0; --stage-4: #1b64be; --stage-5: #0f4a96;

  /* status (fixed) */
  --st-good: #0a8a1f; --st-good-soft: #e5f5e8;
  --st-warn: #a86a00; --st-warn-soft: #fff4dc;
  --st-crit: #c4302f; --st-crit-soft: #fdecec;
  --st-info: #1b64be; --st-info-soft: #e9f2fd;

  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-border-color: var(--app-border);
  --bs-secondary-color: var(--app-muted);
  --bs-primary: #257de0;
  --bs-primary-rgb: 37, 125, 224;
  --bs-link-color: #1b64be;
  --bs-link-color-rgb: 27, 100, 190;
  --bs-link-hover-color: #0f4a96;
  --bs-tertiary-bg: var(--app-surface-2);
}
[data-bs-theme="dark"] {
  --app-bg: #0d1117;
  --app-surface: #161b22;
  --app-surface-2: #1c222b;
  --app-border: #2b333e;
  --app-text: #e6e9ee;
  --app-muted: #98a2b3;
  --app-accent: #338ced;
  --app-accent-strong: #6aabf1;
  --app-accent-soft: #15253b;
  --app-side: #090c11;
  --app-side-text: #a1abba;
  --app-shadow: none;
  --app-shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, .6);

  --viz-assigned: #338ced;
  --viz-covered: #00a888;
  --viz-short: #dc3c3d;
  --viz-track: #232a34;
  --stage-1: #2370cd; --stage-2: #338ced; --stage-3: #519ced; --stage-4: #6aabf1; --stage-5: #84b9f3;

  --st-good: #4ac36a; --st-good-soft: #12301b;
  --st-warn: #fbb315; --st-warn-soft: #33270b;
  --st-crit: #ff7b72; --st-crit-soft: #3a1717;
  --st-info: #6aabf1; --st-info-soft: #15253b;

  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-border-color: var(--app-border);
  --bs-secondary-color: var(--app-muted);
  --bs-primary: #338ced;
  --bs-primary-rgb: 51, 140, 237;
  --bs-link-color: #6aabf1;
  --bs-link-color-rgb: 106, 171, 241;
  --bs-link-hover-color: #9dc8f7;
  --bs-tertiary-bg: var(--app-surface-2);
}

html, body { background: var(--app-bg); }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--app-text);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; color: inherit; }
.text-muted, .muted { color: var(--app-muted) !important; }
.small, small { font-size: 12.5px; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- page fade */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.app-main { animation: fadeUp .35s ease both; transition: opacity .18s ease, transform .18s ease; }
body.leaving .app-main { opacity: 0; transform: translateY(4px); }
.stagger > * { animation: fadeUp .4s ease both; }
.stagger > *:nth-child(2) { animation-delay: .04s; }
.stagger > *:nth-child(3) { animation-delay: .08s; }
.stagger > *:nth-child(4) { animation-delay: .12s; }
.stagger > *:nth-child(5) { animation-delay: .16s; }
.stagger > *:nth-child(6) { animation-delay: .20s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.app-side {
  background: var(--app-side); color: var(--app-side-text);
  position: sticky; top: 0; height: 100vh; padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.app-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 15px; padding: 2px 10px 18px; }
.app-brand .logo {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #338ced, #1b64be); color: #fff; font-size: 15px;
}
.app-brand small { display: block; color: var(--app-side-text); font-weight: 500; font-size: 11px; }
.app-nav-label { text-transform: uppercase; letter-spacing: .08em; font-size: 10.5px; font-weight: 600; color: #6b7686; padding: 14px 12px 6px; }
.app-nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  color: var(--app-side-text); font-weight: 500; transition: background .15s ease, color .15s ease;
}
.app-nav a i { font-size: 16px; opacity: .85; }
.app-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.app-nav a.active { background: rgba(51, 140, 237, .16); color: #fff; }
.app-nav a.active i { color: #6aabf1; opacity: 1; }
.app-nav .count { margin-left: auto; font-size: 11px; background: rgba(255, 255, 255, .1); color: #fff; border-radius: 999px; padding: 1px 7px; }
.app-side .foot { margin-top: auto; padding: 10px 6px 0; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; gap: 6px; align-items: center; }
.app-side .foot .btn { color: var(--app-side-text); border-color: transparent; }
.app-side .foot .btn:hover { color: #fff; background: rgba(255, 255, 255, .06); }

.app-main { padding: 22px 30px 64px; min-width: 0; }
.app-top { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.app-top .titles { flex: 1; min-width: 220px; }
.app-top h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.app-top .crumbs { color: var(--app-muted); font-size: 12.5px; margin-bottom: 2px; }
.app-top .crumbs a { color: var(--app-muted); }
.app-search { position: relative; }
.app-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--app-muted); }
.app-search input { padding-left: 32px; width: 250px; }

/* ---------------------------------------------------------------- surfaces */
.card {
  --bs-card-bg: var(--app-surface); --bs-card-border-color: var(--app-border);
  --bs-card-cap-bg: transparent; border-radius: 12px; box-shadow: var(--app-shadow);
}
.card-header { padding: 14px 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--app-border); }
.card-header h2, .card-header .h2 { font-size: 14.5px; font-weight: 650; margin: 0; flex: 1; }
.card-header .hint { color: var(--app-muted); font-size: 12px; font-weight: 400; }
.card-body { padding: 16px 18px; }
.card + .card { margin-top: 0; }
.section-gap > * + * { margin-top: 20px; }

/* ---------------------------------------------------------------- stat tiles */
.stat {
  display: block; height: 100%; color: var(--app-text); padding: 16px 18px; border-radius: 12px;
  background: var(--app-surface); border: 1px solid var(--app-border); box-shadow: var(--app-shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
a.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--app-shadow-lg); border-color: var(--app-accent); color: var(--app-text); }
.stat .label { color: var(--app-muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat .label i {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 14px;
  background: var(--app-accent-soft); color: var(--app-accent);
}
.stat .value { font-size: 28px; font-weight: 700; line-height: 1.1; margin-top: 10px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .value .unit { font-size: 14px; font-weight: 600; color: var(--app-muted); margin-left: 3px; }
.stat .context { color: var(--app-muted); font-size: 12px; margin-top: 4px; }
.stat.is-critical .label i { background: var(--st-crit-soft); color: var(--st-crit); }
.stat.is-good .label i { background: var(--st-good-soft); color: var(--st-good); }

/* ---------------------------------------------------------------- journey strip (overview) */
.journey-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
.journey-stage {
  position: relative; padding: 16px 18px 16px 26px; color: var(--app-text); display: block;
  border-right: 1px solid var(--app-border); transition: background .15s ease;
}
.journey-stage:first-child { padding-left: 18px; }
.journey-stage:last-child { border-right: 0; }
.journey-stage:hover { background: var(--app-surface-2); text-decoration: none; color: var(--app-text); }
.journey-stage:not(:last-child)::after {
  content: ""; position: absolute; right: -7px; top: 50%; width: 12px; height: 12px; z-index: 1;
  background: var(--app-surface); border-top: 1px solid var(--app-border); border-right: 1px solid var(--app-border);
  transform: translateY(-50%) rotate(45deg);
}
.journey-stage .num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #fff; margin-right: 6px; vertical-align: 1px;
}
.journey-stage .name { font-weight: 600; font-size: 13px; }
.journey-stage .big { font-size: 26px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.journey-stage .meta { color: var(--app-muted); font-size: 12px; }
.seg-bar { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; background: var(--viz-track); }
.seg-bar > span { display: block; height: 100%; transition: filter .15s ease; }
.seg-bar > span:hover { filter: brightness(1.12); }
.seg-bar > span:first-child { border-radius: 999px 0 0 999px; }
.seg-bar > span:last-child { border-radius: 0 999px 999px 0; }
.seg-bar > span:only-child { border-radius: 999px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--app-muted); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------------------------------------------------------------- supply bars */
.supply-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(0, 2fr) auto; gap: 14px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--app-border); }
.supply-row:last-child { border-bottom: 0; }
.supply-row .type { font-weight: 600; font-size: 13px; }
.supply-row .type small { display: block; color: var(--app-muted); font-weight: 400; }
.tall-bar { display: flex; gap: 2px; height: 24px; }
.tall-bar > span {
  display: flex; align-items: center; padding: 0 8px; border-radius: 4px; font-size: 11.5px; font-weight: 600;
  color: #fff; white-space: nowrap; overflow: hidden; min-width: 0; transition: filter .15s ease;
}
.tall-bar > span:hover { filter: brightness(1.1); }
.tall-bar .assigned { background: var(--viz-assigned); }
.tall-bar .covered { background: var(--viz-covered); color: #0b2a22; }
.tall-bar .short { background: transparent; color: var(--viz-short); border: 1.5px dashed var(--viz-short); }
.tall-bar .none { background: var(--viz-track); color: var(--app-muted); flex: 1; font-weight: 500; }

/* ---------------------------------------------------------------- pills / badges */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6;
  background: var(--app-surface-2); color: var(--app-muted); border: 1px solid var(--app-border);
}
.pill i { font-size: 11px; }
.pill.good { background: var(--st-good-soft); color: var(--st-good); border-color: transparent; }
.pill.warn { background: var(--st-warn-soft); color: var(--st-warn); border-color: transparent; }
.pill.crit { background: var(--st-crit-soft); color: var(--st-crit); border-color: transparent; }
.pill.info { background: var(--st-info-soft); color: var(--st-info); border-color: transparent; }
.pill.stage { background: var(--app-accent-soft); color: var(--app-accent-strong); border-color: transparent; }

/* ---------------------------------------------------------------- tables */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--app-surface-2); --bs-table-color: var(--app-text); margin: 0; }
.table > :not(caption) > * > * { padding: 10px 14px; border-bottom-color: var(--app-border); vertical-align: middle; }
.table thead th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--app-muted);
  font-weight: 600; background: var(--app-surface-2); white-space: nowrap;
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.flash-row > td { animation: rowFlash 2.2s ease; }
@keyframes rowFlash { 0%, 40% { background: var(--app-accent-soft); } 100% { background: transparent; } }
.empty-state { text-align: center; padding: 36px 16px; color: var(--app-muted); }
.empty-state i { font-size: 28px; display: block; margin-bottom: 8px; opacity: .6; }

/* ---------------------------------------------------------------- lists */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list > li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--app-border); }
.item-list > li:last-child { border-bottom: 0; }
.item-list .grow { flex: 1; min-width: 0; }
.item-list .title { font-weight: 600; }
.item-list .sub { color: var(--app-muted); font-size: 12px; }
.icon-chip {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; font-size: 15px;
  background: var(--app-accent-soft); color: var(--app-accent);
}
.icon-chip.critical { background: var(--st-crit-soft); color: var(--st-crit); }
.icon-chip.warning { background: var(--st-warn-soft); color: var(--st-warn); }
.icon-chip.ready { background: var(--st-good-soft); color: var(--st-good); }
.date-chip { width: 44px; flex: none; text-align: center; border: 1px solid var(--app-border); border-radius: 9px; overflow: hidden; background: var(--app-surface); }
.date-chip .m { background: var(--app-accent); color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 0; }
.date-chip .d { font-size: 16px; font-weight: 700; padding: 2px 0 3px; line-height: 1.2; }
.date-chip.today .m { background: var(--st-crit); }

/* ---------------------------------------------------------------- kanban pipeline */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(205px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.lane { background: var(--app-surface-2); border: 1px solid var(--app-border); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 210px); min-height: 200px; }
.lane-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--app-border); }
.lane-head .t { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.lane-head .t .n { margin-left: auto; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 999px; font-size: 12px; padding: 0 8px; font-variant-numeric: tabular-nums; }
.lane-head .bar { height: 3px; border-radius: 2px; margin-top: 10px; }
.lane-head .meta { color: var(--app-muted); font-size: 11.5px; margin-top: 6px; }
.lane-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.deal {
  background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 10px; padding: 11px 12px;
  box-shadow: var(--app-shadow); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, opacity .25s ease;
}
.deal:hover { transform: translateY(-2px); box-shadow: var(--app-shadow-lg); border-color: var(--app-accent); }
.deal.overdue { border-left: 3px solid var(--st-crit); }
.deal .name { font-weight: 650; color: var(--app-text); }
.deal .name:hover { color: var(--app-accent); }
.deal .meta { color: var(--app-muted); font-size: 12px; margin-top: 2px; }
.deal .foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.deal .act { margin-top: 10px; }
.deal .act .btn { width: 100%; justify-content: center; white-space: nowrap; }
.btn { white-space: nowrap; }
.deal.hide { display: none; }
.lane-empty { color: var(--app-muted); font-size: 12.5px; text-align: center; padding: 22px 8px; border: 1px dashed var(--app-border); border-radius: 10px; }

/* ---------------------------------------------------------------- journey stepper (order page) */
.stepper { display: flex; position: relative; padding: 6px 0 2px; }
.stepper .step { flex: 1; text-align: center; position: relative; padding: 0 6px; min-width: 0; }
.stepper .step::before {
  content: ""; position: absolute; top: 19px; left: calc(-50% + 22px); right: calc(50% + 22px); height: 3px;
  background: var(--viz-track); border-radius: 2px;
}
.stepper .step:first-child::before { display: none; }
.stepper .step.done::before, .stepper .step.current::before { background: var(--app-accent); }
.stepper .dot {
  width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center; font-size: 17px;
  background: var(--app-surface); border: 2px solid var(--app-border); color: var(--app-muted); position: relative; z-index: 1;
  transition: transform .2s ease;
}
.stepper .step.done .dot { background: var(--app-accent); border-color: var(--app-accent); color: #fff; }
.stepper .step.current .dot { border-color: var(--app-accent); color: var(--app-accent); box-shadow: 0 0 0 5px var(--app-accent-soft); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 5px var(--app-accent-soft); } 50% { box-shadow: 0 0 0 9px var(--app-accent-soft); } }
.stepper .lbl { font-weight: 600; font-size: 12.5px; }
.stepper .step.upcoming .lbl { color: var(--app-muted); }
.stepper .when { font-size: 11.5px; color: var(--app-muted); }
.stepper .det { font-size: 11.5px; color: var(--app-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-step {
  border: 1px solid color-mix(in srgb, var(--app-accent) 40%, transparent);
  background: linear-gradient(135deg, var(--app-accent-soft), var(--app-surface) 70%);
  border-radius: 12px; padding: 16px 18px;
}
.next-step .eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--app-accent); }
.next-step h3 { font-size: 17px; font-weight: 700; margin: 2px 0 12px; }

dl.kv { display: grid; grid-template-columns: 120px 1fr; gap: 9px 14px; margin: 0; }
dl.kv dt { color: var(--app-muted); font-weight: 500; }
dl.kv dd { margin: 0; min-width: 0; }

.timeline { list-style: none; margin: 0; padding: 4px 18px 8px; }
.timeline li { position: relative; padding: 8px 0 8px 22px; border-left: 2px solid var(--app-border); margin-left: 5px; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--app-surface); border: 2px solid var(--app-accent);
}
.timeline li:last-child { border-left-color: transparent; }
.timeline .what { font-weight: 600; }
.timeline .when { color: var(--app-muted); font-size: 12px; }

/* ---------------------------------------------------------------- forms & buttons */
.form-label { font-size: 12.5px; font-weight: 600; color: var(--app-muted); margin-bottom: 5px; }
.form-control, .form-select {
  background-color: var(--app-surface); border-color: var(--app-border); color: var(--app-text);
  border-radius: 8px; font-size: 14px; padding: 7px 11px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus { border-color: var(--app-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-accent) 22%, transparent); background-color: var(--app-surface); color: var(--app-text); }
.form-control-sm { font-size: 13px; padding: 4px 9px; }
.btn { border-radius: 8px; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; transition: all .15s ease; }
.btn-sm { font-size: 12.5px; padding: 4px 10px; border-radius: 7px; }
.btn-primary { --bs-btn-bg: var(--app-accent); --bs-btn-border-color: var(--app-accent); --bs-btn-hover-bg: var(--app-accent-strong); --bs-btn-hover-border-color: var(--app-accent-strong); --bs-btn-active-bg: var(--app-accent-strong); }
[data-bs-theme="dark"] .btn-primary { --bs-btn-hover-bg: #2370cd; --bs-btn-hover-border-color: #2370cd; }
.btn-light-soft { background: var(--app-surface); border: 1px solid var(--app-border); color: var(--app-text); }
.btn-light-soft:hover { background: var(--app-surface-2); border-color: color-mix(in srgb, var(--app-accent) 45%, var(--app-border)); color: var(--app-text); }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn-soft-danger { background: transparent; border: 1px solid var(--app-border); color: var(--st-crit); }
.btn-soft-danger:hover { background: var(--st-crit-soft); color: var(--st-crit); border-color: transparent; }

/* segmented tabs */
.seg { display: inline-flex; background: var(--app-surface-2); border: 1px solid var(--app-border); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a { padding: 5px 12px; border-radius: 7px; color: var(--app-muted); font-weight: 600; font-size: 13px; transition: all .15s ease; }
.seg a:hover { color: var(--app-text); text-decoration: none; }
.seg a.active { background: var(--app-surface); color: var(--app-text); box-shadow: var(--app-shadow); }
[data-bs-theme="dark"] .seg a.active { background: #262e39; }
.seg a .c { font-size: 11px; color: var(--app-muted); margin-left: 4px; }

/* ---------------------------------------------------------------- Bootstrap dropdowns (animated) */
.dropdown-menu {
  --bs-dropdown-bg: var(--app-surface); --bs-dropdown-border-color: var(--app-border);
  --bs-dropdown-link-color: var(--app-text); --bs-dropdown-link-hover-bg: var(--app-accent-soft);
  --bs-dropdown-link-hover-color: var(--app-accent-strong); --bs-dropdown-link-active-bg: var(--app-accent);
  --bs-dropdown-font-size: 13.5px; --bs-dropdown-item-padding-y: 7px;
  border-radius: 10px; box-shadow: var(--app-shadow-lg); padding: 6px;
}
.dropdown-menu.show { animation: menuIn .16s ease-out; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.dropdown-item { border-radius: 7px; display: flex; align-items: center; gap: 9px; }
.dropdown-item i { width: 16px; color: var(--app-muted); }
.dropdown-item:hover i { color: inherit; }
.dropdown-item.text-danger:hover { background: var(--st-crit-soft); color: var(--st-crit) !important; }
.dropdown-divider { border-color: var(--app-border); margin: 5px 0; }

/* ---------------------------------------------------------------- Tom Select (themed dropdowns) */
.ts-wrapper { min-width: 0; }
.ts-wrapper.form-select, .ts-wrapper.single { padding: 0 !important; background-image: none !important; border: 0; }
.ts-wrapper .ts-control, .ts-wrapper.single .ts-control, .ts-wrapper.single.input-active .ts-control {
  background: var(--app-surface) !important; border: 1px solid var(--app-border); color: var(--app-text);
  border-radius: 8px; padding: 7px 34px 7px 11px; min-height: 37px; box-shadow: none; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ts-wrapper.form-select-sm .ts-control { min-height: 31px; padding: 4px 30px 4px 9px; font-size: 13px; }
.ts-wrapper.single .ts-control::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 1.8px solid var(--app-muted); border-bottom: 1.8px solid var(--app-muted);
  transform: rotate(45deg); transition: transform .2s ease, margin-top .2s ease; border-color: var(--app-muted) !important;
  border-top: 0 !important; border-left: 0 !important;
}
.ts-wrapper.single.dropdown-active .ts-control::after { transform: rotate(-135deg); margin-top: -2px; }
.ts-wrapper.focus .ts-control { border-color: var(--app-accent) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-accent) 22%, transparent) !important; }
.ts-control > input { color: var(--app-text) !important; }
.ts-control .item { color: var(--app-text); }
.ts-dropdown {
  background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 10px; color: var(--app-text);
  box-shadow: var(--app-shadow-lg); margin-top: 6px; padding: 5px; z-index: 1080;
  animation: menuIn .16s ease-out;
}
.ts-dropdown .ts-dropdown-content { max-height: 260px; }
.ts-dropdown .option, .ts-dropdown .no-results, .ts-dropdown .optgroup-header { border-radius: 7px; padding: 7px 10px; }
.ts-dropdown .option.active { background: var(--app-accent-soft); color: var(--app-accent-strong); }
.ts-dropdown .option.selected { font-weight: 600; }
.ts-dropdown .option.selected::after { content: "\F26E"; font-family: "bootstrap-icons"; float: right; color: var(--app-accent); }
.ts-dropdown .opt-sub { display: block; font-size: 11.5px; color: var(--app-muted); }
.ts-dropdown .dropdown-input-wrap { padding: 2px 2px 6px; }
.ts-dropdown .dropdown-input { border: 1px solid var(--app-border); border-radius: 7px; background: var(--app-surface-2); color: var(--app-text); padding: 6px 9px; }
.ts-dropdown .no-results { color: var(--app-muted); }

/* ---------------------------------------------------------------- modals, toasts, tooltips */
.modal-content { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 14px; box-shadow: var(--app-shadow-lg); }
.modal-header { border-bottom-color: var(--app-border); padding: 16px 20px; }
.modal-header .modal-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.modal-header .modal-title .icon-chip { width: 32px; height: 32px; }
.modal-body { padding: 18px 20px; }
.modal-footer { border-top-color: var(--app-border); padding: 12px 20px; }
.modal.fade .modal-dialog { transform: translateY(12px) scale(.98); transition: transform .22s ease-out, opacity .22s ease-out; }
.modal.show .modal-dialog { transform: none; }
.modal-backdrop.show { opacity: .45; }
.toast-container { z-index: 1100; }
.toast { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 12px; box-shadow: var(--app-shadow-lg); color: var(--app-text); overflow: hidden; }
.toast .toast-body { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; }
.toast .toast-body i { font-size: 18px; }
.toast.ok .toast-body i { color: var(--st-good); }
.toast.error .toast-body i { color: var(--st-crit); }
.toast .bar { height: 3px; background: var(--st-good); animation: shrink 4.5s linear forwards; transform-origin: left; }
.toast.error .bar { background: var(--st-crit); }
@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.tooltip { --bs-tooltip-bg: #1a2230; --bs-tooltip-font-size: 12px; }
[data-bs-theme="dark"] .tooltip { --bs-tooltip-bg: #e6e9ee; --bs-tooltip-color: #0d1117; }
.collapse-card .chev { transition: transform .25s ease; }
.collapse-card [aria-expanded="true"] .chev { transform: rotate(180deg); }
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-cards input { position: absolute; opacity: 0; }
.choice-cards label {
  display: block; border: 1px solid var(--app-border); border-radius: 10px; padding: 10px 12px; cursor: pointer;
  transition: all .15s ease; color: var(--app-text); font-weight: 600; font-size: 13px; margin: 0;
}
.choice-cards label small { display: block; font-weight: 400; color: var(--app-muted); }
.choice-cards input:checked + label { border-color: var(--app-accent); background: var(--app-accent-soft); box-shadow: 0 0 0 1px var(--app-accent) inset; }
.choice-cards input:focus-visible + label { outline: 2px solid var(--app-accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; animation: fadeUp .4s ease both; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1200px) {
  .journey-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .journey-stage { border-bottom: 1px solid var(--app-border); }
  .journey-stage::after { display: none; }
}
@media (max-width: 860px) {
  .app-search input { width: 100%; }
  .app-search { flex: 1; }
  .journey-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .supply-row { grid-template-columns: 1fr; gap: 6px; }
  .stepper { flex-direction: column; gap: 10px; }
  .stepper .step { display: grid; grid-template-columns: 40px 1fr; text-align: left; gap: 0 12px; }
  .stepper .step::before { display: none; }
  .stepper .dot { grid-row: span 3; margin: 0; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .kanban { grid-template-columns: repeat(5, 82vw); }
}

/* ---------------------------------------------------------------- machine map */
.machine-map { height: 560px; border-radius: 0 0 12px 12px; background: var(--app-surface-2); z-index: 0; }
.machine-map.compact { height: 340px; }
.map-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 640px; }
.map-layout .machine-map { height: 100%; min-height: 640px; border-radius: 0 12px 12px 0; }
.map-list { border-right: 1px solid var(--app-border); display: flex; flex-direction: column; min-height: 0; max-height: 720px; }
.map-list .tools { padding: 12px; border-bottom: 1px solid var(--app-border); display: grid; gap: 8px; }
.map-list .rows { overflow-y: auto; flex: 1; }
.map-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--app-border); cursor: pointer; transition: background .15s ease; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; color: var(--app-text); }
.map-row:hover, .map-row:focus-visible { background: var(--app-surface-2); outline: none; }
.map-row.active { background: var(--app-accent-soft); }
.map-row .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; }
.map-row .dot.live { background: var(--st-good); }
.map-row .dot.removal { background: var(--st-warn); }
.map-row .dot.removed { background: var(--app-muted); }
.map-row .t { font-weight: 600; }
.map-row .s { color: var(--app-muted); font-size: 12px; }
.map-legend { position: absolute; left: 12px; bottom: 26px; z-index: 500; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 10px; padding: 8px 12px; box-shadow: var(--app-shadow-lg); font-size: 12px; display: grid; gap: 4px; }
.map-legend .k { display: flex; align-items: center; gap: 7px; }
.map-legend .sw { width: 12px; height: 12px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.map-wrap { position: relative; }

.map-pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  display: grid; place-items: center; color: #fff; border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35); transition: transform .15s ease;
}
.map-pin i { transform: rotate(45deg); font-size: 13px; }
.map-pin.live { background: #0a8a1f; }
.map-pin.removal { background: #c77700; }
.map-pin.removed { background: #667085; }
.map-pin.selected { background: var(--app-accent); }
.leaflet-marker-icon:hover .map-pin { transform: rotate(-45deg) scale(1.12); }
[data-bs-theme="dark"] .map-pin { border-color: #0d1117; }

.leaflet-container { font-family: inherit; font-size: 13px; background: var(--app-surface-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--app-surface); color: var(--app-text); box-shadow: var(--app-shadow-lg); }
.leaflet-popup-content-wrapper { border-radius: 12px; border: 1px solid var(--app-border); }
.leaflet-popup-content { margin: 14px 16px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--app-muted); top: 6px; right: 6px; }
.map-popup .btn-primary { color: #fff; }
.map-pop dl.kv { grid-template-columns: 82px 1fr; gap: 3px 10px; }
.leaflet-tooltip.map-tip { background: var(--app-surface); color: var(--app-text); border: 1px solid var(--app-border); border-radius: 8px; box-shadow: var(--app-shadow-lg); }
.leaflet-tooltip-top.map-tip::before { border-top-color: var(--app-surface); }
.leaflet-bar a { background: var(--app-surface); color: var(--app-text); border-bottom-color: var(--app-border); }
.leaflet-bar a:hover { background: var(--app-surface-2); color: var(--app-text); }
.leaflet-bar { border: 1px solid var(--app-border) !important; box-shadow: var(--app-shadow) !important; border-radius: 9px !important; overflow: hidden; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--app-surface) 85%, transparent) !important; color: var(--app-muted); font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--app-accent-strong); }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: color-mix(in srgb, var(--app-accent) 28%, transparent); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: var(--app-accent); color: #fff; font-weight: 700; font-family: inherit; }
.leaflet-fade-anim .leaflet-popup { transition: opacity .2s ease; }

.loc-status { font-size: 12.5px; margin-top: 6px; display: flex; align-items: center; gap: 6px; min-height: 18px; }
.loc-status.ok i { color: var(--st-good); }
.loc-status.warn i, .loc-status.warn { color: var(--st-warn); }
.loc-status.err { color: var(--st-crit); }
.loc-preview-map { height: 170px; border-radius: 10px; border: 1px solid var(--app-border); margin-top: 8px; overflow: hidden; animation: fadeIn .3s ease; }

@media (max-width: 860px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-list { border-right: 0; border-bottom: 1px solid var(--app-border); max-height: 260px; }
  .map-layout .machine-map { min-height: 420px; border-radius: 0 0 12px 12px; }
}

/* ---------------------------------------------------------------- route planner */
.route-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; align-items: start; }
.route-main { position: sticky; top: 16px; }
.route-map-card { position: relative; overflow: hidden; }
.route-map { height: 520px; border-radius: 12px; z-index: 0; }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--app-accent); color: #fff; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.route-addon { background: var(--app-surface-2); border-color: var(--app-border); color: var(--app-accent); }
.stop-list { max-height: 340px; overflow-y: auto; }
.stop-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 16px; border-bottom: 1px solid var(--app-border); cursor: pointer; margin: 0; transition: background .15s ease; }
.stop-row:hover { background: var(--app-surface-2); }
.stop-row.on { background: var(--app-accent-soft); }
.stop-row .form-check-input { margin-top: 3px; flex: none; }
.stop-row .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: none; }
.stop-row .dot.live { background: var(--st-good); }
.stop-row .dot.removal { background: var(--st-warn); }
.stop-row .t { font-weight: 600; font-size: 13px; }
.stop-row .s { color: var(--app-muted); font-size: 12px; }
.min-w-0 { min-width: 0; }
.custom-stops { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.custom-stops li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border: 1px solid var(--app-border); border-radius: 9px; background: var(--app-surface-2); animation: fadeUp .25s ease; min-width: 0; }
.custom-stops li i.bi-geo-alt-fill { color: #6941c6; }
.map-pin.start { background: var(--app-accent); }
.map-pin.picked { box-shadow: 0 0 0 3px var(--app-accent), 0 3px 8px rgba(0, 0, 0, .35); }
.map-pin.custom { background: #6941c6; }
.route-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--app-text); color: var(--app-surface);
  display: grid; place-items: center; font-weight: 700; font-size: 12.5px; border: 2px solid var(--app-surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3); animation: fadeIn .3s ease;
}
.fade-in { animation: fadeUp .4s ease both; }
.route-link .form-control { font-size: 12px; }
.itinerary { list-style: none; margin: 0; padding: 8px 18px 16px; }
.itinerary li { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; }
.itinerary .it-dot {
  width: 30px; height: 30px; border-radius: 50%; background: var(--app-accent); color: #fff; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.itinerary .it-start .it-dot { background: var(--app-text); color: var(--app-surface); }
.itinerary .t { font-weight: 600; }
.itinerary .s { color: var(--app-muted); font-size: 12.5px; }
.itinerary .it-leg { margin-left: 14px; padding: 2px 0 2px 26px; border-left: 2px dashed var(--app-border); color: var(--app-muted); font-size: 12px; }
@media (max-width: 1100px) {
  .route-layout { grid-template-columns: 1fr; }
  .route-main { position: static; }
  .route-map { height: 420px; }
}

/* ==========================================================================
   Mobile & tablet
   ========================================================================== */
.mbar, .mbar-search, .tabbar, .mobile-only, .route-dock { display: none; }
.app-toasts { top: 0; right: 0; }
.app-drawer { --bs-offcanvas-width: 290px; --bs-offcanvas-bg: var(--app-side); --bs-offcanvas-color: var(--app-side-text); }
.app-drawer .offcanvas-header { padding: 18px 16px 8px; }
.app-drawer .offcanvas-body { display: flex; flex-direction: column; padding: 4px 12px calc(16px + env(safe-area-inset-bottom)); }
.app-drawer .app-brand { color: #fff; }
.app-drawer .app-nav a { padding: 11px 12px; font-size: 15px; }
.app-drawer .foot { margin-top: auto; padding: 12px 4px 0; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; gap: 6px; }
.app-drawer .foot .btn { color: var(--app-side-text); }
.app-brand .logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(135deg, #338ced, #1b64be); color: #fff; font-size: 15px; flex: none; }

@media (max-width: 860px) {
  .desktop-only, .app-side { display: none !important; }
  .mobile-only { display: flex; }
  .app { display: block; min-height: 0; }

  /* top bar */
  .mbar {
    display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 1020;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px 14px;
    background: color-mix(in srgb, var(--app-side) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    color: #fff;
  }
  .mbar-brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 700; font-size: 16px; margin-right: auto; }
  .mbar-brand:hover { color: #fff; text-decoration: none; }
  .mbar-brand .logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(135deg, #338ced, #1b64be); font-size: 15px; }
  .mbar-btn { width: 42px; height: 42px; border: 0; border-radius: 10px; background: transparent; color: #dfe5ee; font-size: 20px; display: grid; place-items: center; }
  .mbar-btn:active, .mbar-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .1); }
  .mbar-new { background: var(--app-accent); color: #fff; width: 38px; height: 38px; margin-right: 2px; }
  .mbar-new::after { display: none; }
  .mbar-search { display: block; position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 1019; background: var(--app-side); padding: 0 12px; }
  .mbar-search.show, .mbar-search.collapsing { padding-bottom: 10px; }
  .mbar-search .app-search input { width: 100%; }

  /* bottom tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: color-mix(in srgb, var(--app-surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--app-border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0 4px; position: relative;
    color: var(--app-muted); font-size: 10.5px; font-weight: 600; background: none; border: 0; border-radius: 10px; text-decoration: none;
    transition: color .15s ease;
  }
  .tabbar i { font-size: 21px; line-height: 1.1; transition: transform .2s ease; }
  .tabbar .active { color: var(--app-accent); }
  .tabbar .active i { transform: translateY(-1px) scale(1.06); }
  .tabbar .active::before { content: ""; position: absolute; top: -5px; width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--app-accent); }
  .tabbar .dot-count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--st-crit); color: #fff; font-size: 10px; line-height: 17px; text-align: center; }

  .app-toasts { top: auto; right: 0; left: 0; bottom: calc(64px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; }
  .app-toasts .toast { width: min(100%, 420px); }

  /* page frame */
  .app-main { padding: 16px 14px calc(92px + env(safe-area-inset-bottom)); }
  .app-top { margin-bottom: 16px; gap: 10px; }
  .app-top .titles { min-width: 0; flex: 1 1 100%; }
  .app-top h1 { font-size: 21px; }
  .app-top .crumbs { font-size: 12px; }
  .app-top > .dropdown { margin-left: auto; }

  /* iOS zooms into inputs under 16px */
  .form-control, .form-select, .ts-control, .ts-control > input, .ts-dropdown .dropdown-input { font-size: 16px !important; }
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; }
  .btn-icon { width: 38px; height: 38px; }

  /* cards & headers */
  .card { border-radius: 14px; }
  .card-header { flex-wrap: wrap; padding: 12px 14px; }
  .card-header h2 { flex: 1 1 auto; }
  .card-header .hint { display: block; margin: 2px 0 0 !important; }
  .card-header > form, .card-header > .seg { flex: 1 1 100%; }
  .card-header .form-control[style*="width"], .card-header form > div[style*="width"] { width: auto !important; flex: 1 1 140px; }
  .card-header .ms-auto { margin-left: 0 !important; }
  .card-body { padding: 14px; }
  .seg { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg a { white-space: nowrap; }

  /* stat tiles */
  .stat { padding: 13px 14px; }
  .stat .value { font-size: 23px; margin-top: 8px; }
  .stat .label { font-size: 12px; }
  .stat .label i { width: 26px; height: 26px; font-size: 13px; }
  .stat .context { font-size: 11.5px; }
  a.stat:hover { transform: none; }

  /* lists: action buttons drop under the text */
  .item-list > li { flex-wrap: wrap; padding: 12px 14px; }
  .item-list > li > .grow { flex: 1 1 calc(100% - 50px); }
  .item-list > li > .btn, .item-list > li > form { margin-left: 46px; }
  .item-list > li > .date-chip + .grow { flex-basis: calc(100% - 60px); }
  .supply-row { padding: 12px 14px; }
  .supply-row > .text-end { text-align: left !important; min-width: 0 !important; }
  .journey-stage { padding: 14px; }
  .journey-stage .big { font-size: 22px; }

  /* tables become labelled cards */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr { display: block; width: 100%; }
  .table-stack tr { padding: 12px 14px; border-bottom: 1px solid var(--app-border); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 4px 0 !important;
    border: 0 !important; text-align: right; max-width: none !important; white-space: normal !important;
  }
  .table-stack td::before { content: attr(data-label); color: var(--app-muted); font-size: 12.5px; font-weight: 600; text-align: left; flex: none; padding-top: 1px; }
  .table-stack td:empty { display: none; }
  .table-stack td.td-primary { display: block; text-align: left; font-size: 15px; padding-bottom: 6px !important; }
  .table-stack td.td-primary::before, .table-stack td.td-actions::before { display: none; }
  .table-stack td.td-actions { justify-content: flex-start; flex-wrap: wrap; padding-top: 10px !important; text-align: left !important; }
  .table-stack td.td-actions:not(:has(*)) { display: none; }
  .table-stack td.td-actions .dropdown { margin-left: auto; }
  .table-stack tbody tr:hover > * { background: transparent; }
  .table-responsive:has(.table-stack) { overflow: visible; }

  /* pipeline: swipe between stages */
  .pipe-filters > * { flex: 1 1 100% !important; width: auto !important; min-width: 0 !important; }
  .pipe-filters > span.ms-auto { display: none; }
  .lane-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px 2px; scrollbar-width: none; }
  .lane-tabs::-webkit-scrollbar { display: none; }
  .lane-tabs button {
    flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
    background: var(--app-surface); border: 1px solid var(--app-border); color: var(--app-muted); transition: all .15s ease;
  }
  .lane-tabs button .n { width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 10.5px; display: grid; place-items: center; }
  .lane-tabs button b { font-variant-numeric: tabular-nums; color: var(--app-text); }
  .lane-tabs button.active { background: var(--app-accent-soft); border-color: var(--app-accent); color: var(--app-accent-strong); }
  .kanban {
    grid-template-columns: repeat(5, 88%) !important; gap: 10px; margin: 0 -14px; padding: 0 14px 10px;
    scroll-snap-type: x mandatory; scroll-padding: 0 14px; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none;
  }
  .kanban::-webkit-scrollbar { display: none; }
  .lane { scroll-snap-align: start; max-height: none; }
  .lane-body { overflow: visible; }
  .deal:hover { transform: none; }

  /* order page */
  .next-step { padding: 14px; }
  .next-step > div:last-child, .next-step .btn { width: 100%; justify-content: center; }
  .stepper .dot { width: 34px; height: 34px; font-size: 15px; }
  .stepper .step { grid-template-columns: 34px 1fr; }

  /* map page: map first */
  .map-layout { display: flex; flex-direction: column; min-height: 0; }
  .map-layout .map-wrap { order: -1; }
  .map-layout .machine-map { height: 58vh; min-height: 320px; border-radius: 0; }
  .map-list { max-height: none; border-bottom: 0; }
  .map-list .rows { max-height: none; }
  .machine-map.compact { height: 260px; }
  .map-legend { left: 8px; bottom: 22px; padding: 6px 9px; font-size: 11px; }
  .leaflet-control-attribution { font-size: 9px; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .leaflet-control-zoom a { width: 36px !important; height: 36px !important; line-height: 36px !important; }

  /* route planner */
  .route-map { height: 52vh; min-height: 300px; }
  .route-link .form-control { display: none; }
  .route-link .input-group { display: flex; gap: 8px; flex-wrap: nowrap; }
  .route-link .input-group > .btn { flex: 1; justify-content: center; border-radius: 9px !important; margin: 0 !important; min-height: 44px; }
  .route-link .input-group > .btn-primary { flex: 2; }
  .stop-list { max-height: 46vh; }
  .stop-row { padding: 11px 14px; }
  .stop-row .form-check-input { width: 20px; height: 20px; margin-top: 1px; }
  .route-dock {
    display: flex; align-items: center; gap: 10px; position: fixed; left: 10px; right: 10px; z-index: 1025;
    bottom: calc(66px + env(safe-area-inset-bottom)); padding: 10px 10px 10px 14px; border-radius: 14px;
    background: var(--app-surface); border: 1px solid var(--app-border); box-shadow: var(--app-shadow-lg);
    animation: fadeUp .3s ease both;
  }
  .route-dock .btn { flex: none; min-height: 42px; }
  body:has(.route-dock) .app-main { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }
  .itinerary { padding: 6px 12px 14px; }

  /* modals: full-screen sheets on phones */
  .modal-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-footer .btn { flex: 1; justify-content: center; min-height: 44px; }
  .choice-cards { grid-template-columns: 1fr; }
  .dropdown-menu { --bs-dropdown-item-padding-y: 10px; --bs-dropdown-font-size: 15px; }
}
@media (max-width: 575.98px) {
  .modal-fullscreen-sm-down .modal-content { border-radius: 0; border: 0; }
}

@media (min-width: 861px) and (max-width: 1100px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .app-side { padding: 14px 8px; align-items: center; }
  .app-side .app-brand div, .app-side .app-nav-label, .app-side .app-nav a span.t, .app-side .app-nav .count, .app-side .foot form { display: none; }
  .app-side .app-brand { padding: 2px 0 14px; justify-content: center; }
  .app-side .app-nav a { justify-content: center; padding: 10px; }
  .app-side .app-nav a i { font-size: 18px; }
  .app-side .foot { justify-content: center; }
  .app-main { padding: 20px 22px 56px; }
}

@media (max-width: 860px) {
  .stage-dist-head { flex-direction: column; align-items: flex-start !important; gap: 6px; }
  .map-alert { flex-wrap: wrap; }
  .map-alert > form, .map-alert > form .btn { width: 100%; justify-content: center; }
  .map-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; right: 56px; }
  .pipe-filters > div[style*="width"] { flex: 1 1 calc(50% - 4px) !important; }
}

/* ---------------------------------------------------------------- users & account */
.account-menu { width: 100%; }
.account-chip {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); color: #fff; text-align: left;
  transition: background .15s ease;
}
.account-chip:hover, .account-chip[aria-expanded="true"] { background: rgba(255, 255, 255, .09); }
.account-chip .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.account-chip .n { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-chip .r { font-size: 11.5px; color: var(--app-side-text); }
.account-chip > i { color: var(--app-side-text); }
.account-menu .dropdown-menu { min-width: 220px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff; background: #5b6b82;
}
.account-chip .avatar { background: linear-gradient(135deg, #338ced, #1b64be); }
.avatar.admin { background: linear-gradient(135deg, #338ced, #1b64be); }
.role-matrix td:first-child { font-weight: 500; }
.role-matrix td i { font-size: 16px; }
.auth-body { background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--app-accent) 16%, transparent), transparent 60%), var(--app-bg); min-height: 100vh; }
.login-card { max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; margin: 0 0 18px 4px; color: var(--app-text); }
.auth-brand .logo { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, #338ced, #1b64be); color: #fff; font-size: 19px; }
.auth-brand small { display: block; font-weight: 500; font-size: 12.5px; color: var(--app-muted); }
@media (min-width: 861px) and (max-width: 1100px) {
  .app-side .account-chip { justify-content: center; padding: 6px; }
  .app-side .account-chip .who, .app-side .account-chip > i { display: none; }
}
@media (max-width: 860px) {
  .login-wrap { align-items: start; padding-top: 12vh; }
  .app-drawer .foot { padding-top: 14px; }
}
