/* RobotLAB Dispatcher — shared console styles */
* { box-sizing: border-box; }
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #16202e;
  --muted: #5b6b7f;
  --line: #dde4ec;
  --brand: #12325c;
  --brand-2: #1c4d8f;
  --accent: #2a6fd6;
  --ok: #1e7a3d;
  --ok-bg: #e2f4e8;
  --warn: #9a6200;
  --warn-bg: #fdf1d8;
  --bad: #b3261e;
  --bad-bg: #fbe3e1;
  --info: #1c4d8f;
  --info-bg: #e2ecfa;
  --open: #6b3fa0;
  --open-bg: #efe6fa;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(22, 32, 46, .08), 0 4px 14px rgba(22, 32, 46, .06);
}
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }

/* Header */
.topbar {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .logo { font-weight: 700; letter-spacing: .4px; font-size: 16px; }
.topbar .logo small { display: block; font-weight: 400; opacity: .75; font-size: 11px; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }
.topbar .station-chip {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  padding: 4px 12px; border-radius: 999px; font-size: 13px;
}
.topbar button { font-size: 13px; }
.mode-chip { font-size: 11px; padding: 3px 10px; border-radius: 999px; background: #ffd966; color: #4a3800; font-weight: 600; }
.mode-chip.live { background: #7be0a2; color: #0b3f20; }
.mode-chip.test { background: #ffb457; color: #5c3200; animation: pulse 2.2s ease-in-out infinite; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #f0b429; display: inline-block; }
.conn-dot.on { background: #4ade80; }
.conn-dot.off { background: #f87171; }

/* Layout */
.wrap { max-width: 1380px; margin: 0 auto; padding: 18px 20px 60px; }
.grid { display: grid; gap: 16px; }
@media (min-width: 1024px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.main-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.card h2 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--brand); }
.card h2 .count { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* Buttons */
button, .btn {
  font: inherit; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 8px;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-2); }
.btn-good { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 12px 22px; font-size: 16px; border-radius: 10px; }
.btn-block { display: block; width: 100%; }

/* Forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .4px; }
input, select, textarea {
  font: inherit; width: 100%;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(42,111,214,.35); border-color: var(--accent); }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.dispatched { background: var(--info-bg); color: var(--info); }
.badge.arrived { background: var(--warn-bg); color: var(--warn); }
.badge.opened { background: var(--open-bg); color: var(--open); }
.badge.accepted { background: var(--ok-bg); color: var(--ok); }
.badge.exception { background: var(--bad-bg); color: var(--bad); }
.badge.resolved { background: #d9f2ef; color: #0f6b60; }
.badge.cancelled { background: #e8ebf0; color: var(--muted); }
.badge.undelivered { background: var(--warn-bg); color: var(--warn); }
.badge.idle { background: #e8ebf0; color: var(--muted); }
.badge.enroute { background: var(--info-bg); color: var(--info); }
.badge.at_stop { background: var(--warn-bg); color: var(--warn); }
.badge.returning { background: var(--open-bg); color: var(--open); }
.badge.offline { background: #e8ebf0; color: #8a94a3; }
.badge.busy { background: var(--warn-bg); color: var(--warn); }

/* Tables */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f6f9fd; }

/* Robot cards */
.robot-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: #fbfcfe; }
.robot-card .robot-head { display: flex; align-items: center; gap: 10px; }
.robot-card .robot-name { font-weight: 700; font-size: 15px; }
.robot-card .meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.battery { display: inline-flex; align-items: center; gap: 5px; }
.battery .bar { width: 34px; height: 9px; border: 1px solid var(--muted); border-radius: 3px; position: relative; }
.battery .bar i { position: absolute; inset: 1px; border-radius: 2px; background: var(--ok); display: block; }
.progress { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .8s linear; }

/* Notifications */
.notif { border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.notif.high { border-left-color: var(--bad); background: #fff7f6; }
.notif .n-title { font-weight: 600; font-size: 13.5px; }
.notif .n-body { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.notif .n-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.notif.high .n-title { color: var(--bad); }

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 25, 40, .5);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
.modal { background: #fff; border-radius: 12px; box-shadow: var(--shadow); max-width: 640px; width: 100%; max-height: 88vh; overflow: auto; padding: 20px; }
.modal h3 { margin: 0 0 12px; color: var(--brand); }
.hidden { display: none !important; }

/* Toasts (kept above the help bubble) */
#toasts { position: fixed; right: 16px; bottom: 84px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1d2a3d; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; max-width: 380px; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* Teller focus panel */
.focus-panel { text-align: center; padding: 34px 20px; }
.focus-panel .big { font-size: 26px; font-weight: 700; margin: 8px 0; }
.focus-panel .sub { color: var(--muted); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.arrival-banner {
  background: var(--warn-bg); border: 1px solid #ecd9a8; color: var(--warn);
  border-radius: 10px; padding: 12px 16px; font-weight: 700; font-size: 17px; margin-bottom: 14px;
}
.exception-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.exception-grid button { border-color: #e6b6b2; color: var(--bad); font-weight: 600; padding: 12px; }
.exception-grid button:hover { background: var(--bad-bg); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); margin-left: 8px; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid #fff;
}
.timeline .t-type { font-weight: 600; font-size: 13.5px; }
.timeline .t-meta { font-size: 12px; color: var(--muted); }

/* Tabs (admin) */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: none; background: none; border-radius: 8px 8px 0 0;
  padding: 10px 16px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs button.active { color: var(--brand-2); border-bottom-color: var(--accent); background: #fff; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filter-bar > div { min-width: 130px; flex: 0 1 auto; }
.filter-bar label { margin-top: 0; }

/* Site footer */
.site-footer {
  text-align: center; color: var(--muted);
  font-size: 12px; letter-spacing: .2px;
  padding: 20px 20px 28px;
}
.site-footer.on-login {
  position: absolute; left: 0; right: 0; bottom: 0;
  color: rgba(255, 255, 255, .7);
}

/* Login */
.login-page { position: relative; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0e2547, #1c4d8f); }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); padding: 34px; width: 380px; max-width: 92vw; }
.login-card h1 { margin: 0; font-size: 22px; color: var(--brand); }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 18px; }
.login-err { color: var(--bad); font-size: 13.5px; margin-top: 10px; min-height: 18px; }
.login-err.locked {
  background: var(--bad-bg); border: 1px solid #e6b6b2; border-radius: 8px;
  padding: 8px 10px; font-weight: 600;
}
.login-card input:disabled { background: #eef1f5; color: var(--muted); cursor: not-allowed; }

kbd.fob { background: #eef2f7; border: 1px solid var(--line); padding: 2px 8px; border-radius: 6px; font-family: ui-monospace, monospace; }

/* In-app help ("?" bubble + manual drawer) */
.help-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 50;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 24px; font-weight: 700; line-height: 1;
  border: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 4px 16px rgba(14, 37, 71, .35);
  display: flex; align-items: center; justify-content: center;
}
.help-fab:hover { transform: scale(1.07); border-color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--accent)); }
.help-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(15, 25, 40, .45);
  display: flex; justify-content: flex-end;
}
.help-drawer {
  width: min(440px, 94vw); height: 100%;
  background: var(--panel); box-shadow: -8px 0 30px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
  animation: help-slide .22s ease-out;
}
@keyframes help-slide { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.help-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 16px 18px 12px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff;
}
.help-head h3 { margin: 2px 0 0; font-size: 18px; }
.help-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .75; }
.help-close {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); color: #fff;
  width: 32px; height: 32px; border-radius: 8px; font-size: 18px; line-height: 1; padding: 0; flex: 0 0 auto;
}
.help-close:hover { background: rgba(255,255,255,.28); }
.help-body { padding: 14px 18px 24px; overflow-y: auto; font-size: 14px; }
.help-body > p { margin: 0 0 10px; }
.help-sec { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fbfcfe; }
.help-sec summary {
  cursor: pointer; padding: 10px 12px; font-weight: 600; color: var(--brand-2);
  list-style-position: inside;
}
.help-sec[open] summary { border-bottom: 1px solid var(--line); }
.help-sec > div { padding: 10px 14px; }
.help-sec ul, .help-sec ol { margin: 6px 0; padding-left: 20px; }
.help-sec li { margin-bottom: 6px; }
.help-sec h4 { margin: 12px 0 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.help-legend { list-style: none; padding-left: 0 !important; }
.help-legend li { display: flex; align-items: baseline; gap: 8px; }
.help-legend .badge { flex: 0 0 auto; }
.help-note { background: var(--info-bg); border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--info); }
.help-foot { margin-top: 14px; text-align: center; font-size: 12px; color: var(--muted); }
