:root {
  --bg: #121826; --panel: #1a2234; --panel2: #202a40; --line: #2c3750; --text: #e3e8f2; --muted: #8b97ad;
  --accent: #3d7bfd; --accent2: #2f63d6; --ok: #22b573; --warn: #f0a020; --bad: #e5484d; --violet: #9b59f6; --gray: #6b7489;
  --radius: 6px; --sidebar: 230px;
  font-size: 13px;
}
body.light {
  --bg: #f3f5f9; --panel: #ffffff; --panel2: #f7f8fb; --line: #dfe3ec; --text: #1c2333; --muted: #6a7487;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "Segoe UI", Inter, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ---------- layout ---------- */
#app { display: flex; height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar .brand { height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 16px; font-weight: 700; font-size: 17px; border-bottom: 1px solid var(--line); }
.sidebar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 14px 0 0 var(--ok); margin-right: 14px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-group > .nav-title { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; font-weight: 600; color: var(--text); user-select: none; }
.nav-group > .nav-title .chev { margin-left: auto; color: var(--muted); font-size: 10px; transition: transform .15s; }
.nav-group.closed > .nav-title .chev { transform: rotate(-90deg); }
.nav-group.closed .nav-items { display: none; }
.nav-items a, .nav-single { display: block; padding: 6px 16px 6px 42px; color: var(--muted); }
.nav-single { padding-left: 16px; color: var(--text); font-weight: 600; display: flex; gap: 10px; }
.nav-items a:hover, .nav-single:hover { background: var(--panel2); text-decoration: none; color: var(--text); }
.nav-items a.active, .nav-single.active { background: rgba(61, 123, 253, .18); color: var(--text); border-left: 3px solid var(--accent); padding-left: 39px; }
.nav-single.active { padding-left: 13px; }
.ico { width: 18px; text-align: center; opacity: .85; }
.sidebar .me { border-top: 1px solid var(--line); padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.me .who { flex: 1; min-width: 0; }
.me .who div:last-child { color: var(--muted); font-size: 11px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 48px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.crumbs { color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }
.search-wrap { position: relative; }
.search-wrap input { width: 300px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; }
.search-results { position: absolute; top: 34px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); z-index: 50; max-height: 360px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.search-results a { display: block; padding: 7px 10px; color: var(--text); }
.search-results a:hover { background: var(--panel2); text-decoration: none; }
.search-results small { color: var(--muted); margin-left: 6px; }
.content { flex: 1; overflow: auto; padding: 14px 16px; }

/* ---------- common ---------- */
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
input.inp, select.inp, textarea.inp { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; width: 100%; }
input.inp:focus, select.inp:focus, textarea.inp:focus { outline: none; border-color: var(--accent); }
textarea.inp { min-height: 70px; resize: vertical; }
.muted { color: var(--muted); }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.card + .card { margin-top: 12px; }
.card h3 { margin-bottom: 10px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.page-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.page-tabs a, .page-tabs button { padding: 9px 14px; color: var(--muted); border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.page-tabs .active { color: var(--text); border-bottom-color: var(--accent); }
.page-tabs .count { background: var(--panel2); border-radius: 10px; padding: 1px 7px; margin-left: 6px; font-size: 11px; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.page-head h1 { font-size: 18px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar input.inp, .toolbar select.inp { width: auto; }
.toolbar .search { width: 240px; }

.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { background: var(--panel2); color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; z-index: 1; cursor: default; }
.tbl th.sort { cursor: pointer; }
.tbl th.sort:hover { color: var(--text); }
.tbl tbody tr:hover { background: var(--panel2); }
.tbl tr.click { cursor: pointer; }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.wrap { white-space: normal; min-width: 200px; }
.tbl tfoot td { background: var(--panel2); font-weight: 600; }
.tbl .chk { width: 30px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.pager .totals { flex: 1; display: flex; gap: 16px; flex-wrap: wrap; color: var(--text); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; background: var(--gray); color: #fff; }
.b-available, .b-delivered, .b-active, .b-paid, .b-posted, .b-done, .b-closed, .b-on_time { background: var(--ok); }
.b-dispatched, .b-booked, .b-in_progress, .b-open, .b-partial { background: var(--accent); }
.b-in_transit, .b-unposted, .b-at_risk, .b-assigned, .b-todo { background: var(--warn); color: #222; }
.b-shop, .b-cancelled, .b-late, .b-short, .b-terminated, .b-inactive, .b-void, .b-high { background: var(--bad); }
.b-invoiced, .b-rest { background: var(--violet); }
.b-home, .b-offer, .b-yard, .b-archived { background: var(--gray); }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: 760px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal.wide { width: 1100px; }
.modal-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px; max-height: calc(100vh - 200px); overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.field.check { display: flex; align-items: center; gap: 8px; padding-top: 18px; }
.field.check label { margin: 0; text-transform: none; font-size: 13px; color: var(--text); letter-spacing: 0; }
.close-x { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 6px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 420px; }
.toast.err { border-left-color: var(--bad); }

/* ---------- dashboard ---------- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }
.big-links { display: flex; justify-content: space-around; text-align: center; padding: 12px 0; }
.big-links a { font-size: 26px; font-weight: 700; text-decoration: underline; }
.gauge { display: block; margin: 0 auto; }
.pnl-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.pnl-row.total { font-weight: 700; border-bottom: 0; font-size: 15px; }
.bar { height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }

/* ---------- load detail ---------- */
.load-head { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.load-head .kv { display: flex; gap: 28px; margin-top: 10px; flex-wrap: wrap; }
.kv div small { display: block; color: var(--muted); font-size: 11px; }
.kv div b { font-size: 14px; }
.load-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; }
@media (max-width: 1200px) { .load-layout { grid-template-columns: 1fr; } }
.stepper { display: flex; justify-content: space-between; position: relative; padding: 10px 10px 4px; }
.stepper::before { content: ''; position: absolute; left: 40px; right: 40px; top: 27px; height: 2px; background: var(--line); }
.step { position: relative; text-align: center; flex: 1; z-index: 1; cursor: pointer; }
.step .c { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; background: var(--panel2); border: 2px solid var(--line); font-weight: 700; }
.step.done .c { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.cur .c { background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(61,123,253,.25); }
.step .t { font-size: 12px; color: var(--muted); }
.step.done .t, .step.cur .t { color: var(--text); }
.activity { max-height: 520px; overflow: auto; }
.ev { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ev small { color: var(--muted); display: block; font-size: 11px; }
.ev.note { border-left: 3px solid var(--warn); padding-left: 8px; }
.ev.chat { border-left: 3px solid var(--accent); padding-left: 8px; }
.profit-box .pnl-row { padding: 5px 0; }
.pre { white-space: pre-wrap; }

/* ---------- dispatch board ---------- */
.board { display: grid; border: 1px solid var(--line); border-radius: 8px; overflow: auto; background: var(--panel); }
.board .cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; min-height: 74px; position: relative; }
.board .hd { background: var(--panel2); font-weight: 600; color: var(--muted); min-height: auto; text-align: center; position: sticky; top: 0; z-index: 2; }
.board .hd.today { color: var(--accent); }
.board .drv b { display: block; }
.board .tripbar { position: absolute; top: 24px; height: 30px; background: rgba(61,123,253,.22); border: 1px solid var(--accent); border-radius: 5px; font-size: 11px; padding: 2px 6px; overflow: hidden; white-space: nowrap; cursor: pointer; z-index: 1; }
.board .tripbar.s-delivered, .board .tripbar.s-invoiced, .board .tripbar.s-paid { background: rgba(34,181,115,.2); border-color: var(--ok); }
.board .tripbar.s-in_transit { background: rgba(240,160,32,.2); border-color: var(--warn); }
.board .sum { font-size: 11px; color: var(--muted); line-height: 1.5; }
.board .sum b { color: var(--text); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; width: 100%; }
.login { width: 360px; }
.login h1 { margin-bottom: 4px; }
.err-box { background: rgba(229,72,77,.12); border: 1px solid var(--bad); color: var(--text); padding: 8px 10px; border-radius: 6px; margin: 10px 0; }
.info-box { background: rgba(61,123,253,.1); border: 1px solid var(--accent); padding: 8px 10px; border-radius: 6px; margin: 10px 0; }
.colmenu { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; z-index: 60; max-height: 360px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.colmenu label { display: flex; gap: 6px; padding: 3px 4px; white-space: nowrap; }
@media print { .sidebar, .topbar, .toolbar, .pager { display: none !important; } .content { overflow: visible; } }

/* ---------- added: status lines, compliance, tasks ---------- */
.stat-line { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.stat-line > span:first-child { width: 110px; }
.stat-line b { width: 36px; text-align: right; }
.b-expired, .b-missing { background: var(--bad); }
.b-due { background: var(--warn); color: #222; }
.b-ok { background: var(--ok); }
.b-none, .b-low, .b-normal { background: var(--gray); }
.task-card { padding: 10px; margin-top: 8px; cursor: pointer; }
.task-card:hover { border-color: var(--accent); }
.board .drv { display: flex; flex-direction: column; gap: 3px; }
.toolbar .btn .badge { margin-right: 2px; }

/* ---------- Helplane additions: gross board, roles ---------- */
.tbl.gross td { vertical-align: top; min-width: 96px; }
.tbl.gross th.today { color: var(--accent); }
.gb-load { font-size: 12px; white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.task-card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(61,123,253,.25); }
[data-role] { cursor: pointer; }
.perm { margin-right: 14px; white-space: nowrap; cursor: pointer; }
.doc { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 5px; margin-right: 3px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.doc.on { background: var(--ok); border-color: var(--ok); color: #fff; }
label.btn input[hidden] { display: none; }
.bell { position: relative; }
.bell-n { position: absolute; top: -6px; right: -6px; background: var(--bad); color: #fff; border-radius: 9px; font-size: 10px; font-weight: 700; padding: 1px 5px; }
.alert-list { margin: 6px 0 0; padding-left: 18px; }
.alert-list li { margin: 2px 0; }
.chat { display: grid; grid-template-columns: 220px 1fr; gap: 12px; height: calc(100vh - 150px); }
.chat-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.chat-list a { padding: 6px 8px; border-radius: 5px; color: var(--text); }
.chat-list a.active { background: rgba(61,123,253,.18); }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-msgs { flex: 1; overflow-y: auto; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.msg.me { align-self: flex-end; border-color: var(--accent); }
.msg small { color: var(--muted); }
.chat-send { gap: 8px; align-items: flex-end; }
@media (max-width: 700px) { .chat { grid-template-columns: 1fr; height: auto; } }

/* ---------- maintenance, card import, rate con ---------- */
.b-overdue, .b-error { background: var(--bad); }
.b-soon, .b-no_driver { background: var(--warn); color: #222; }
.b-new, .b-pickup { background: var(--ok); }
.b-delivery { background: var(--accent); }
.b-no_history, .b-duplicate, .b-paused { background: var(--gray); }
.inp.filled { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }

/* ---------- broker credit ---------- */
.b-approved { background: var(--ok); }
.b-watch { background: var(--warn); color: #222; }
.b-do_not_use { background: var(--bad); }
.warn-box { background: rgba(240,160,32,.12); border: 1px solid var(--warn); color: var(--text); padding: 8px 10px; border-radius: 6px; margin: 10px 0; }

/* ---------- driver page (4 steps) ---------- */
.stepper { display: flex; justify-content: center; gap: 0; margin: 4px 0 16px; }
.stepper .st { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 150px; position: relative; color: var(--muted); text-align: center; font-size: 12px; }
.stepper .st:not(:last-child)::after { content: ''; position: absolute; top: 15px; left: calc(50% + 18px); width: calc(100% - 36px); height: 2px; background: var(--line); }
.stepper .st .n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); font-weight: 700; }
.stepper .st.cur { color: var(--text); font-weight: 600; }
.stepper .st.cur .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper .st.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.stepper .st.off { opacity: .5; }
.stepper a.st:hover { text-decoration: none; color: var(--text); }
.dform { max-width: 900px; margin: 0 auto; }
.dsec + .dsec { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.dsec h3 { margin-bottom: 10px; }
.dfoot { max-width: 900px; margin: 12px auto 30px; gap: 8px; }
.inv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.devbox { margin-bottom: 12px; }
.devbox select { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; min-height: 22px; }
.chip { background: var(--accent2); color: #fff; border-radius: 4px; padding: 2px 4px 2px 8px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.chip button { background: none; border: 0; color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
.radio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.deduct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.deduct-grid h4 { margin: 10px 0 4px; font-weight: 500; }
.deduct-grid h4 b { font-size: 15px; }
.d-fuel { color: var(--warn); } .d-toll { color: var(--violet); } .d-ok { color: var(--ok); }
.rgroup { margin: 12px 0 6px; color: var(--muted); font-weight: 600; }
.rgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; }
.big { font-size: 16px; font-weight: 600; padding-top: 6px; }
.kv { margin-top: 10px; border-collapse: collapse; }
.kv td { padding: 4px 24px 4px 0; }
.t-bad { color: var(--bad); } .t-ok { color: var(--ok); } .t-acc { color: var(--accent); }
@media (max-width: 760px) { .inv-grid, .deduct-grid { grid-template-columns: 1fr; } .rgrid { grid-template-columns: 1fr 1fr; } .stepper .st { width: 25%; } }
