/* ============================================================
   VMI Platform — design system
   Dark "control tower" theme · ArcelorMittal orange accent
   ============================================================ */

:root {
  --bg: #0b1220;
  --bg-2: #0e1628;
  --panel: #121b30;
  --panel-2: #16203a;
  --panel-3: #1b2745;
  --line: #223052;
  --line-soft: #1a2540;
  --text: #e8edf7;
  --text-dim: #93a0bd;
  --text-faint: #5d6a8a;

  --accent: #f26522;        /* ArcelorMittal orange */
  --accent-soft: #ff8a4d;
  --accent-glow: rgba(242, 101, 34, 0.16);

  --sap: #21b8a6;           /* SAP teal */
  --sap-soft: rgba(33, 184, 166, 0.14);
  --ai: #a78bfa;            /* AI violet */
  --ai-soft: rgba(167, 139, 250, 0.14);

  --good: #3bb273;
  --warn: #e8c53a;
  --bad: #ef5d60;
  --blue: #4d9de0;

  --st-available: #3bb273;
  --st-reserved: #4d9de0;
  --st-inspection: #e8c53a;
  --st-ready: #21b8a6;
  --st-dispatched: #ff8a4d;
  --st-consumed: #7c88a5;
  --st-returned: #b48ce8;
  --st-repair: #e8843a;
  --st-scrap: #ef5d60;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 32px rgba(3, 8, 20, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(242, 101, 34, 0.07), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(77, 157, 224, 0.06), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app { display: flex; height: 100vh; position: relative; z-index: 1; }

/* ---------------- sidebar ---------------- */
.sidebar {
  width: 236px; flex: 0 0 236px;
  background: linear-gradient(180deg, #0d1526 0%, #0a111f 100%);
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  padding: 20px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; color: var(--text-faint); margin-top: 1px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-faint); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px;
  color: var(--text-dim); text-decoration: none;
  font-weight: 500; font-size: 13.5px;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(242, 101, 34, 0.14), rgba(242, 101, 34, 0.04));
  border-color: rgba(242, 101, 34, 0.25);
  color: var(--text);
}
.nav-item.active .nav-icon { color: var(--accent-soft); }
.nav-icon { display: inline-flex; width: 20px; color: var(--text-faint); }

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--line-soft); }
.sync-pill {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--text-dim);
  background: var(--sap-soft); border: 1px solid rgba(33, 184, 166, 0.25);
  padding: 6px 10px; border-radius: 20px;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sap); box-shadow: 0 0 8px var(--sap); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.sync-time { margin-left: auto; color: var(--text-faint); font-size: 10.5px; }
.reset-btn {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: 11.5px; font-weight: 650;
  background: var(--panel); border: 1px solid var(--line-soft); color: var(--text-dim);
  padding: 7px 11px; border-radius: 10px; cursor: pointer; transition: all 0.15s;
}
.reset-btn:hover { color: var(--text); border-color: var(--line); }
.reset-btn.armed {
  background: rgba(239, 93, 96, 0.12); border-color: rgba(239, 93, 96, 0.45);
  color: var(--bad); animation: pulse 1.2s infinite;
}
.reset-btn:disabled { opacity: 0.5; cursor: wait; }
.powered { font-size: 11px; color: var(--text-faint); padding-left: 4px; }
.powered strong { color: var(--text-dim); }

/* hamburger + drawer backdrop — hidden on desktop, shown via media query */
.hamburger { display: none; }
.drawer-backdrop { display: none; }

/* ---------------- topbar ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; flex: 0 0 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; border-bottom: 1px solid var(--line-soft);
  background: rgba(11, 18, 32, 0.7); backdrop-filter: blur(8px);
}
.page-heading h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; }
.page-heading p { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.role-switch { display: flex; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 22px; padding: 3px; }
.role-btn {
  border: none; background: transparent; color: var(--text-dim);
  font-family: var(--font); font-size: 12px; font-weight: 600;
  padding: 5px 13px; border-radius: 18px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.role-btn.active { background: var(--accent); color: #fff; box-shadow: 0 2px 10px rgba(242, 101, 34, 0.4); }
.role-btn:not(.active):hover { color: var(--text); }
.date-chip { font-size: 12px; color: var(--text-dim); background: var(--panel); border: 1px solid var(--line-soft); padding: 6px 12px; border-radius: 20px; white-space: nowrap; }

/* ---------------- content ---------------- */
.content { flex: 1; overflow-y: auto; padding: 24px 26px 60px; }
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 6px; border: 2px solid var(--bg); }

.loading-splash { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; gap: 16px; color: var(--text-faint); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--panel-3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- generic panels & grids ---------------- */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }

.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-title { font-size: 13px; font-weight: 700; letter-spacing: 0.3px; display: flex; align-items: center; gap: 8px; }
.panel-title .t-icon { color: var(--accent-soft); display: inline-flex; }
.panel-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.section-gap { margin-top: 16px; }

/* ---------------- KPI cards ---------------- */
.kpi {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--kpi-color, var(--accent)), transparent 70%);
  opacity: 0.8;
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 27px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.kpi-value small { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.kpi-foot { font-size: 11.5px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.kpi-foot.good { color: var(--good); }
.kpi-foot.bad { color: var(--bad); }
.kpi-foot.warn { color: var(--warn); }

/* ---------------- chips & badges ---------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
  border: 1px solid transparent;
}
.chip-sap { background: var(--sap-soft); color: var(--sap); border-color: rgba(33, 184, 166, 0.3); }
.chip-ai { background: var(--ai-soft); color: var(--ai); border-color: rgba(167, 139, 250, 0.3); }
.chip-neutral { background: var(--panel-2); color: var(--text-dim); border-color: var(--line-soft); }

.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px;
  padding: 3px 10px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  text-transform: capitalize; white-space: nowrap;
}
.status-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--sc, var(--text-faint)); box-shadow: 0 0 6px var(--sc, transparent); }
.st-available { --sc: var(--st-available); color: var(--st-available); }
.st-reserved { --sc: var(--st-reserved); color: var(--st-reserved); }
.st-under-inspection { --sc: var(--st-inspection); color: var(--st-inspection); }
.st-ready { --sc: var(--st-ready); color: var(--st-ready); }
.st-dispatched { --sc: var(--st-dispatched); color: var(--st-dispatched); }
.st-consumed { --sc: var(--st-consumed); color: var(--st-consumed); }
.st-returned { --sc: var(--st-returned); color: var(--st-returned); }
.st-repair { --sc: var(--st-repair); color: var(--st-repair); }
.st-scrap { --sc: var(--st-scrap); color: var(--st-scrap); }
.st-received { --sc: var(--blue); color: var(--blue); }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: 13px; font-weight: 650;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  transition: all 0.15s;
}
.btn:hover { background: var(--panel-3); border-color: var(--line); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, #ff7a3a, var(--accent));
  border-color: rgba(255, 138, 77, 0.5); color: #fff;
  box-shadow: 0 4px 16px rgba(242, 101, 34, 0.35);
}
.btn-primary:hover { background: linear-gradient(180deg, #ff8a4d, #f97230); }
.btn-ai {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.22), rgba(167, 139, 250, 0.08));
  border-color: rgba(167, 139, 250, 0.4); color: #c9b8fc;
}
.btn-ai:hover { background: linear-gradient(180deg, rgba(167, 139, 250, 0.3), rgba(167, 139, 250, 0.14)); }
.btn-sap { background: var(--sap-soft); border-color: rgba(33, 184, 166, 0.35); color: var(--sap); }
.btn-ghost { background: transparent; border-color: var(--line-soft); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { font-size: 12px; padding: 6px 12px; border-radius: 8px; }
.btn-good { background: linear-gradient(180deg, rgba(59,178,115,.25), rgba(59,178,115,.1)); border-color: rgba(59,178,115,.4); color: #6fdca4; }

/* ---------------- tables ---------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-faint); font-weight: 700; padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.tbl .num { text-align: right; }
.tbl-scroll { overflow-x: auto; }
.cell-changed { background: var(--accent-glow); border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(242, 101, 34, 0.4); animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: rgba(242, 101, 34, 0.45); } 100% { background: var(--accent-glow); } }
.delta-up { color: var(--accent-soft); font-weight: 700; }
.delta-down { color: var(--blue); font-weight: 700; }

/* ---------------- alerts ---------------- */
.alert-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft); background: var(--panel-2);
  cursor: pointer; transition: all 0.14s; margin-bottom: 8px;
}
.alert-row:hover { border-color: var(--line); transform: translateX(2px); }
.alert-ico { flex: 0 0 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.alert-high .alert-ico { background: rgba(239, 93, 96, 0.15); color: var(--bad); }
.alert-med .alert-ico { background: rgba(232, 197, 58, 0.12); color: var(--warn); }
.alert-low .alert-ico { background: rgba(77, 157, 224, 0.12); color: var(--blue); }
.alert-title { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-detail { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---------------- AI digest ---------------- */
.ai-digest {
  border: 1px solid rgba(167, 139, 250, 0.3);
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.1), rgba(167, 139, 250, 0.03) 60%);
  border-radius: var(--radius); padding: 16px 18px;
}
.ai-digest-head { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 13px; color: #cabdfb; margin-bottom: 10px; }
.ai-digest li { margin-left: 18px; padding: 3px 0; font-size: 13px; color: var(--text); }
.ai-digest li::marker { color: var(--ai); }

/* ---------------- stepper (demand page) ---------------- */
.stepper { display: flex; gap: 0; margin-bottom: 18px; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line-soft); position: relative; }
.step:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.step:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.step + .step { border-left: none; }
.step-num {
  width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%;
  background: var(--panel-3); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 800;
  border: 1px solid var(--line);
}
.step.done .step-num { background: var(--good); color: #06130c; border-color: var(--good); }
.step.active .step-num { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 0 12px rgba(242, 101, 34, 0.5); }
.step-label { font-size: 12px; font-weight: 650; color: var(--text-dim); line-height: 1.25; }
.step.active .step-label, .step.done .step-label { color: var(--text); }
.step-tag { font-size: 10px; color: var(--text-faint); }

/* ---------------- agent console ---------------- */
.agent-console {
  background: #0a0f1c; border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: var(--radius-sm); padding: 14px 16px;
  font-family: var(--mono); font-size: 12px; min-height: 132px;
}
.agent-line { display: flex; align-items: center; gap: 9px; padding: 4px 0; color: var(--text-dim); opacity: 0; animation: lineIn 0.3s forwards; }
@keyframes lineIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.agent-line .li-icon { color: var(--ai); display: inline-flex; flex: 0 0 16px; }
.agent-line.ok .li-icon { color: var(--good); }
.agent-line.warn .li-icon { color: var(--warn); }
.agent-cursor { display: inline-block; width: 8px; height: 14px; background: var(--ai); animation: pulse 0.8s infinite; vertical-align: middle; }

/* ---------------- calc trace ---------------- */
.calc-flow { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; }
.calc-node { flex: 1; min-width: 130px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 11px 13px; }
.calc-node .cn-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-faint); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.calc-node .cn-value { font-size: 19px; font-weight: 750; margin-top: 3px; font-variant-numeric: tabular-nums; }
.calc-node .cn-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.calc-op { display: flex; align-items: center; color: var(--text-faint); font-size: 17px; font-weight: 700; }
.calc-node.hl { border-color: rgba(242, 101, 34, 0.45); background: linear-gradient(180deg, rgba(242, 101, 34, 0.12), rgba(242, 101, 34, 0.04)); }
.calc-node.ai-node { border-color: rgba(167, 139, 250, 0.4); background: linear-gradient(180deg, rgba(167, 139, 250, 0.12), rgba(167, 139, 250, 0.03)); }
.calc-node.sap-node { border-color: rgba(33, 184, 166, 0.35); background: linear-gradient(180deg, rgba(33, 184, 166, 0.1), rgba(33, 184, 166, 0.02)); }

/* ---------------- charts ---------------- */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; }
.legend-line { width: 16px; height: 3px; border-radius: 2px; }

/* ---------------- yard ---------------- */
.yard-svg-wrap { background: #0a1120; border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px; overflow: hidden; }
.yard-zone { fill: rgba(255, 255, 255, 0.02); stroke: var(--line); stroke-width: 1.2; rx: 10; }
.yard-zone.gate { stroke-dasharray: 5 4; }
.yard-zone-label { fill: var(--text-dim); font-size: 11px; font-weight: 700; letter-spacing: 0.6px; font-family: var(--font); }
.yard-zone-sub { fill: var(--text-faint); font-size: 9px; font-family: var(--font); }
.yard-bin { stroke: rgba(255, 255, 255, 0.07); stroke-width: 1; rx: 4; cursor: pointer; transition: filter 0.15s; }
.yard-bin:hover { filter: brightness(1.5); }
.yard-bin-label { fill: rgba(232, 237, 247, 0.55); font-size: 7.5px; font-family: var(--mono); pointer-events: none; }
.yard-bin-count { fill: #e8edf7; font-size: 9px; font-weight: 700; font-family: var(--font); pointer-events: none; }
.bin-highlight { stroke: var(--accent); stroke-width: 2.5; fill: none; rx: 5; filter: drop-shadow(0 0 6px rgba(242, 101, 34, 0.8)); animation: binPulse 1.4s infinite; }
@keyframes binPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.flow-dot { filter: drop-shadow(0 0 5px currentColor); }

.wf-card { border: 1px solid var(--line-soft); background: var(--panel-2); border-radius: var(--radius-sm); padding: 13px 14px; margin-bottom: 10px; }
.wf-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wf-id { font-weight: 750; font-size: 13.5px; }
.wf-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.wf-track { display: flex; gap: 4px; margin: 10px 0; }
.wf-seg { flex: 1; height: 5px; border-radius: 3px; background: var(--panel-3); position: relative; }
.wf-seg.done { background: var(--good); box-shadow: 0 0 6px rgba(59, 178, 115, 0.5); }
.wf-seg.doing { background: var(--accent); box-shadow: 0 0 6px rgba(242, 101, 34, 0.6); animation: pulse 1.6s infinite; }
.wf-steps-label { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--text-faint); margin-top: -4px; margin-bottom: 8px; }
.wf-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.disposition-box { border: 1px solid rgba(167, 139, 250, 0.35); background: var(--ai-soft); border-radius: var(--radius-sm); padding: 11px 13px; margin-top: 9px; }
.disp-split { display: flex; gap: 8px; margin: 8px 0; }
.disp-pill { flex: 1; text-align: center; border-radius: 8px; padding: 7px 4px; font-size: 11px; font-weight: 700; }
.disp-reuse { background: rgba(59, 178, 115, 0.15); color: var(--good); border: 1px solid rgba(59, 178, 115, 0.3); }
.disp-repair { background: rgba(232, 132, 58, 0.14); color: var(--st-repair); border: 1px solid rgba(232, 132, 58, 0.3); }
.disp-scrap { background: rgba(239, 93, 96, 0.13); color: var(--bad); border: 1px solid rgba(239, 93, 96, 0.3); }
.disp-pill .n { display: block; font-size: 18px; }
.disp-rationale { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; }
.disp-rationale li { margin-left: 16px; padding: 2px 0; }

/* capacity bars */
.cap-row { margin-bottom: 13px; }
.cap-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; margin-bottom: 5px; }
.cap-name { font-weight: 650; }
.cap-nums { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.cap-bar { height: 14px; background: var(--panel-3); border-radius: 7px; position: relative; overflow: visible; }
.cap-fill { height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--cf, var(--good)), var(--cf2, var(--good))); transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.cap-safety { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--warn); box-shadow: 0 0 5px rgba(232, 197, 58, 0.7); }
.cap-safety::after { content: 'safety'; position: absolute; top: -13px; left: -14px; font-size: 8.5px; color: var(--warn); letter-spacing: 0.5px; }

/* movement feed */
.feed { display: flex; flex-direction: column; }
.feed-row { display: flex; gap: 11px; padding: 9px 2px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.feed-row:last-child { border-bottom: none; }
.feed-time { flex: 0 0 52px; color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.feed-body b { font-weight: 650; }
.feed-detail { color: var(--text-dim); font-size: 11.5px; margin-top: 1px; }

/* ---------------- tracking ---------------- */
.search-hero { max-width: 780px; margin: 0 auto; text-align: center; padding: 28px 0 6px; }
.search-hero h2 { font-size: 21px; font-weight: 750; letter-spacing: -0.2px; }
.search-hero p { color: var(--text-dim); font-size: 13px; margin-top: 5px; }
.search-box { display: flex; gap: 10px; margin: 20px auto 10px; max-width: 640px; }
.search-input {
  flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 18px; color: var(--text);
  font-family: var(--mono); font-size: 14.5px; outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-suggest { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.suggest-chip {
  font-size: 11px; font-family: var(--mono); color: var(--text-dim);
  background: var(--panel); border: 1px solid var(--line-soft);
  padding: 4px 10px; border-radius: 16px; cursor: pointer; transition: all 0.14s;
}
.suggest-chip:hover { color: var(--accent-soft); border-color: rgba(242, 101, 34, 0.4); }
.suggest-label { font-size: 11px; color: var(--text-faint); padding: 4px 2px; }

.pipe-card { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 16px; }
.pipe-attrs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.attr { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 9px 11px; }
.attr-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-faint); font-weight: 700; }
.attr-value { font-size: 13.5px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }

.timeline { position: relative; padding-left: 24px; margin-top: 6px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 8px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 7px 0 7px 6px; }
.tl-item::before {
  content: ''; position: absolute; left: -22px; top: 12px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--panel-3); border: 2px solid var(--text-faint);
}
.tl-item.sap::before { border-color: var(--sap); background: var(--sap-soft); }
.tl-item:first-child::before { border-color: var(--accent); background: var(--accent-glow); }
.tl-event { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.tl-meta { font-size: 11px; color: var(--text-faint); margin-top: 1px; font-variant-numeric: tabular-nums; }

/* ---------------- consumption ---------------- */
.well-list { display: flex; flex-direction: column; gap: 8px; max-height: 640px; overflow-y: auto; padding-right: 4px; }
.well-item {
  border: 1px solid var(--line-soft); background: var(--panel-2);
  border-radius: var(--radius-sm); padding: 11px 13px; cursor: pointer;
  transition: all 0.14s;
}
.well-item:hover { border-color: var(--line); }
.well-item.active { border-color: rgba(242, 101, 34, 0.5); background: linear-gradient(180deg, rgba(242, 101, 34, 0.1), rgba(242, 101, 34, 0.03)); }
.well-id { font-weight: 750; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.well-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.well-status { font-size: 10px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; padding: 2px 8px; border-radius: 12px; margin-left: auto; }
.ws-drilling { background: rgba(242, 101, 34, 0.14); color: var(--accent-soft); }
.ws-planned { background: rgba(77, 157, 224, 0.13); color: var(--blue); }
.ws-completed { background: rgba(59, 178, 115, 0.13); color: var(--good); }

.profile-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-sec { flex: 1; min-width: 118px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 9px 11px; border-top: 3px solid var(--pc, var(--line)); }
.profile-sec .ps-name { font-size: 10.5px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.profile-sec .ps-val { font-size: 15px; font-weight: 750; margin-top: 2px; }
.profile-sec .ps-sub { font-size: 10.5px; color: var(--text-dim); }

.link-banner {
  display: flex; align-items: center; gap: 10px;
  border: 1px dashed rgba(242, 101, 34, 0.4); background: var(--accent-glow);
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text); cursor: pointer; transition: background 0.15s;
}
.link-banner:hover { background: rgba(242, 101, 34, 0.22); }

/* ---------------- toasts ---------------- */
#toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; max-width: 380px; }
.toast {
  background: var(--panel-3); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 15px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  font-size: 13px;
}
.toast.sap { border-left-color: var(--sap); }
.toast.ai { border-left-color: var(--ai); }
.toast.good { border-left-color: var(--good); }
.toast-title { font-weight: 700; display: flex; align-items: center; gap: 7px; }
.toast-body { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut 0.3s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* ---------------- misc ---------------- */
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); font-size: 0.92em; }
.right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

.empty-note { text-align: center; color: var(--text-faint); padding: 30px 10px; font-size: 13px; }

.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------- guided tour ---------------- */
.tour-root { position: fixed; inset: 0; z-index: 300; pointer-events: none; opacity: 0; transition: opacity 0.35s; }
.tour-root.on { opacity: 1; }
.tour-root { --tour-dim: rgba(4, 8, 18, 0.55); }
.tour-spotlight {
  position: fixed; border-radius: 14px;
  border: 2px solid rgba(242, 101, 34, 0.85);
  box-shadow: 0 0 0 200vmax var(--tour-dim);
  transition: top 0.55s cubic-bezier(0.3, 0.9, 0.25, 1), left 0.55s cubic-bezier(0.3, 0.9, 0.25, 1),
              width 0.55s cubic-bezier(0.3, 0.9, 0.25, 1), height 0.55s cubic-bezier(0.3, 0.9, 0.25, 1),
              opacity 0.3s, box-shadow 0.35s;
  pointer-events: none;
}
.tour-spotlight::after {
  content: ''; position: absolute; inset: -5px; border-radius: 17px;
  border: 2px solid rgba(242, 101, 34, 0.5);
  animation: spotGlow 2.2s infinite;
  pointer-events: none;
}
@keyframes spotGlow {
  0%, 100% { opacity: 0.35; box-shadow: 0 0 12px rgba(242, 101, 34, 0.3); }
  50% { opacity: 1; box-shadow: 0 0 32px rgba(242, 101, 34, 0.55); }
}

/* secondary highlight — "the result appears HERE" — used on action steps */
.tour-watch {
  position: fixed; border-radius: 14px; pointer-events: none;
  border: 2px dashed rgba(33, 184, 166, 0.85);
  box-shadow: 0 0 20px rgba(33, 184, 166, 0.3), inset 0 0 24px rgba(33, 184, 166, 0.08);
  transition: top 0.55s cubic-bezier(0.3, 0.9, 0.25, 1), left 0.55s cubic-bezier(0.3, 0.9, 0.25, 1),
              width 0.55s cubic-bezier(0.3, 0.9, 0.25, 1), height 0.55s cubic-bezier(0.3, 0.9, 0.25, 1), opacity 0.3s;
  animation: watchPulse 1.8s infinite;
}
@keyframes watchPulse {
  0%, 100% { border-color: rgba(33, 184, 166, 0.85); box-shadow: 0 0 20px rgba(33, 184, 166, 0.3), inset 0 0 24px rgba(33, 184, 166, 0.08); }
  50% { border-color: rgba(33, 184, 166, 0.45); box-shadow: 0 0 34px rgba(33, 184, 166, 0.5), inset 0 0 24px rgba(33, 184, 166, 0.14); }
}
.tour-watch-label {
  position: absolute; top: -13px; left: 16px; transform: translateY(-100%);
  background: linear-gradient(180deg, #1a4d47, #123833);
  border: 1px solid rgba(33, 184, 166, 0.6); color: #7ee8da;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.3px;
  padding: 5px 12px; border-radius: 14px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; gap: 6px;
}
.tour-watch-label::before { content: '👁'; font-size: 12px; }
.tour-watch.below-fold .tour-watch-label { top: auto; bottom: -13px; transform: translateY(100%); }
.tour-card {
  position: fixed; width: 360px; pointer-events: auto;
  background: linear-gradient(180deg, #1b2745, #131d36);
  border: 1px solid rgba(242, 101, 34, 0.35);
  border-radius: 16px; padding: 16px 18px 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  transition: top 0.55s cubic-bezier(0.3, 0.9, 0.25, 1), left 0.55s cubic-bezier(0.3, 0.9, 0.25, 1), opacity 0.22s, transform 0.22s;
}
.tour-card.switching { opacity: 0; transform: translateY(8px) scale(0.985); }
.tour-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tour-step-count { font-size: 10.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--accent-soft); }
.tour-x { background: transparent; border: none; color: var(--text-faint); cursor: pointer; padding: 4px; border-radius: 6px; display: flex; }
.tour-x:hover { color: var(--text); background: var(--panel-3); }
.tour-title { font-size: 15.5px; font-weight: 750; letter-spacing: -0.1px; margin-bottom: 6px; }
.tour-body { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }
.tour-body b { color: var(--text); }
.tour-action-hint {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  background: var(--accent-glow); border: 1px dashed rgba(242, 101, 34, 0.5);
  border-radius: 9px; padding: 8px 11px; font-size: 12px; color: var(--accent-soft); font-weight: 650;
}
.tour-action-hint .tah-icon { display: inline-flex; animation: nudge 1.2s infinite; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
.tour-action-hint.done { border-color: rgba(59, 178, 115, 0.5); background: rgba(59, 178, 115, 0.12); color: #6fdca4; }
.tour-action-hint.done .tah-icon { animation: none; }
.tour-progress { height: 3px; background: var(--panel-3); border-radius: 2px; margin: 12px 0 10px; overflow: hidden; }
.tour-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); border-radius: 2px; transition: width 0.4s; }
.tour-controls { display: flex; align-items: center; gap: 8px; }
.tour-btn {
  font-family: var(--font); font-size: 12px; font-weight: 650; cursor: pointer;
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--line-soft);
  padding: 7px 12px; border-radius: 8px; display: inline-flex; align-items: center; gap: 5px;
  transition: all 0.15s;
}
.tour-btn:hover { color: var(--text); border-color: var(--line); }
.tour-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tour-btn-primary { background: linear-gradient(180deg, #ff7a3a, var(--accent)); color: #fff; border-color: rgba(255, 138, 77, 0.5); }
.tour-btn-primary:hover { color: #fff; }
.tour-skip-tour { background: transparent; border-color: transparent; color: var(--text-faint); padding-left: 2px; }
.tour-launch {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line-soft); color: var(--text-dim);
  font-family: var(--font); font-size: 12px; font-weight: 650;
  padding: 6px 13px; border-radius: 20px; cursor: pointer; transition: all 0.15s;
}
.tour-launch:hover { color: var(--accent-soft); border-color: rgba(242, 101, 34, 0.4); }

/* ---------------- filter chips & bars ---------------- */
.filter-bar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.filter-label { font-size: 11px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; display: inline-flex; align-items: center; gap: 5px; }
.fchip {
  font-family: var(--font); font-size: 12px; font-weight: 650; cursor: pointer;
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--line-soft);
  padding: 5px 12px; border-radius: 18px; transition: all 0.14s; display: inline-flex; align-items: center; gap: 6px;
}
.fchip:hover { color: var(--text); border-color: var(--line); }
.fchip.on { background: var(--accent-glow); border-color: rgba(242, 101, 34, 0.5); color: var(--accent-soft); }
.fchip .fdot { width: 8px; height: 8px; border-radius: 50%; }
.fsearch {
  background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 18px;
  color: var(--text); font-family: var(--font); font-size: 12px;
  padding: 6px 13px; outline: none; min-width: 150px; transition: border 0.15s;
}
.fsearch:focus { border-color: rgba(242, 101, 34, 0.5); }
.fselect {
  background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 18px;
  color: var(--text); font-family: var(--font); font-size: 12px; font-weight: 600;
  padding: 6px 11px; outline: none; cursor: pointer;
}

/* ---------------- tracking tabs, tree & lifecycle ---------------- */
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 12px; padding: 4px; gap: 4px; }
.tab-btn {
  font-family: var(--font); font-size: 13px; font-weight: 650; cursor: pointer;
  background: transparent; border: none; color: var(--text-dim);
  padding: 8px 18px; border-radius: 9px; display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.15s;
}
.tab-btn.on { background: linear-gradient(180deg, #ff7a3a, var(--accent)); color: #fff; box-shadow: 0 3px 12px rgba(242, 101, 34, 0.35); }
.tab-btn:not(.on):hover { color: var(--text); }

.loc-tree { max-height: 620px; overflow-y: auto; padding-right: 6px; }
.loc-node { user-select: none; }
.loc-row {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px;
  border-radius: 9px; cursor: pointer; border: 1px solid transparent;
  transition: background 0.13s;
}
.loc-row:hover { background: var(--panel-2); }
.loc-row.selected { background: linear-gradient(90deg, rgba(242, 101, 34, 0.16), rgba(242, 101, 34, 0.04)); border-color: rgba(242, 101, 34, 0.35); }
.loc-caret { display: inline-flex; color: var(--text-faint); transition: transform 0.22s; flex: 0 0 14px; }
.loc-node.open > .loc-row .loc-caret { transform: rotate(90deg); }
.loc-caret.leaf { visibility: hidden; }
.loc-ico { display: inline-flex; color: var(--text-faint); flex: 0 0 17px; }
.loc-row.selected .loc-ico { color: var(--accent-soft); }
.loc-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-count { margin-left: auto; font-size: 10.5px; font-weight: 750; color: var(--text-dim); background: var(--panel-3); padding: 1px 8px; border-radius: 12px; font-variant-numeric: tabular-nums; }
.loc-children { margin-left: 17px; border-left: 1px solid var(--line-soft); padding-left: 6px; overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.loc-node.open > .loc-children { max-height: 3000px; }
.loc-breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.loc-breadcrumb .crumb { color: var(--text-dim); cursor: pointer; font-weight: 600; }
.loc-breadcrumb .crumb:hover { color: var(--accent-soft); }
.loc-breadcrumb .crumb.last { color: var(--text); font-weight: 750; cursor: default; }
.loc-breadcrumb .sep { color: var(--text-faint); display: inline-flex; }

.lifecycle { display: flex; align-items: center; gap: 0; flex-wrap: wrap; row-gap: 8px; }
.lc-stage {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.2px;
  padding: 5px 11px; border-radius: 16px; white-space: nowrap;
  background: var(--panel-2); border: 1px solid var(--line-soft); color: var(--text-faint);
}
.lc-stage.done { color: var(--good); border-color: rgba(59, 178, 115, 0.35); background: rgba(59, 178, 115, 0.07); }
.lc-stage.now { color: #fff; background: linear-gradient(180deg, #ff7a3a, var(--accent)); border-color: rgba(255, 138, 77, 0.5); box-shadow: 0 0 14px rgba(242, 101, 34, 0.4); animation: pulse 2s infinite; }
.lc-stage.branch { color: var(--st-returned); border-color: rgba(180, 140, 232, 0.4); background: rgba(180, 140, 232, 0.08); }
.lc-arrow { color: var(--text-faint); margin: 0 4px; display: inline-flex; }

@media (max-width: 1200px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: repeat(2, 1fr); }
  .pipe-card { grid-template-columns: 1fr; }
}

/* =====================================================================
   MOBILE  (≤ 860px)  — sidebar becomes a slide-out drawer, everything
   stacks to one column. Desktop layout above is untouched.
   ===================================================================== */
@media (max-width: 860px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; }

  /* ---- sidebar → slide-out drawer ---- */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 220;
    width: 270px; flex-basis: 270px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.3, 0.9, 0.25, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
  body.drawer-open .sidebar { transform: translateX(0); }
  .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 210;
    background: rgba(4, 8, 18, 0.6);
    opacity: 0; pointer-events: none; transition: opacity 0.28s;
  }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

  /* ---- hamburger in the topbar ---- */
  .hamburger {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 38px; height: 38px; flex: 0 0 38px; margin-right: 4px;
    background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px;
    cursor: pointer; padding: 0 9px;
  }
  .hamburger span { display: block; height: 2px; border-radius: 2px; background: var(--text); transition: all 0.2s; }
  body.drawer-open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  body.drawer-open .hamburger span:nth-child(2) { opacity: 0; }
  body.drawer-open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* ---- topbar: tighter, wraps to two rows if needed ---- */
  .main { height: auto; }
  .topbar {
    height: auto; min-height: 58px; flex: none;
    padding: 8px 14px; gap: 10px;
    position: sticky; top: 0; z-index: 120; flex-wrap: wrap;
  }
  .page-heading { flex: 1; min-width: 0; }
  .page-heading h1 { font-size: 16px; }
  .page-heading p { display: none; }               /* subtitle lives in the tour instead */
  .topbar-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .date-chip { display: none; }
  .tour-launch-label { display: none; }            /* icon-only tour button */
  .tour-launch { padding: 8px; }
  .role-btn { padding: 6px 10px; font-size: 11.5px; }
  .content { padding: 16px 14px 80px; }

  /* ---- everything stacks ---- */
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .grid { gap: 12px; }
  .section-gap { margin-top: 12px; }
  .panel { padding: 14px; border-radius: 12px; }

  /* two-column page layouts → single column */
  .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* KPI + calc cards a touch smaller */
  .kpi-value { font-size: 23px; }
  .calc-flow { flex-direction: column; }
  .calc-op { transform: rotate(90deg); align-self: center; }

  /* demand stepper scrolls sideways instead of squishing */
  .stepper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .step { min-width: 148px; }

  /* wide tables scroll horizontally inside their own box */
  .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* the well list (consumption) and location tree cap their height */
  .well-list { max-height: 300px; }
  .loc-tree { max-height: 340px; }

  /* the yard map stays legible by scrolling sideways rather than shrinking */
  .yard-svg-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #yard-svg svg { min-width: 640px; }
  .yard-svg-wrap::after {
    content: 'swipe the map sideways →'; display: block;
    text-align: right; font-size: 10px; color: var(--text-faint);
    padding: 4px 6px 0;
  }

  /* header actions inside panels wrap */
  .panel-head { flex-wrap: wrap; }

  /* tracking search box stacks its button */
  .search-box { flex-direction: column; }
  .search-box .btn { width: 100%; justify-content: center; }
  .search-hero h2 { font-size: 18px; }

  /* tour card fits the screen and never overflows */
  .tour-card { width: calc(100vw - 24px); max-width: 360px; }

  /* toasts span the width */
  #toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* very narrow phones — role switcher takes its own full-width row */
@media (max-width: 520px) {
  .topbar-right { width: 100%; justify-content: space-between; }
  .role-switch { flex: 1; }
  .role-btn { flex: 1; justify-content: center; padding: 6px 4px; }
}
