:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --brand: #f5b301; --brand-ink: #1d2330; --primary: #1f4ed8; --danger: #c62828; --ok: #15803d;
  --free: #16a34a; --waiting: #d97706; --on_trip: #2563eb; --out_of_zone: #c026d3; --offline: #9ca3af;
  --radius: 10px; --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
[hidden] { display: none !important; }
h2 { margin: 0; font-size: 20px; } h3 { margin: 0 0 12px; font-size: 15px; }
small { color: var(--muted); }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #f1c4c4; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #374151; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; font-weight: 400; }
.logo { background: var(--brand); color: var(--brand-ink); font-weight: 800; padding: 4px 8px; border-radius: 6px; letter-spacing: .5px; }

/* Bejelentkezés */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #1d2330, #2d3748); }
.login-card { width: 100%; max-width: 360px; background: var(--panel); padding: 28px; border-radius: 14px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.form-error { color: var(--danger); margin: 0; font-weight: 600; }

/* Fejléc */
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: #1d2330; color: #fff; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs a { color: #cbd5e1; text-decoration: none; padding: 7px 12px; border-radius: 8px; white-space: nowrap; font-weight: 600; }
.tabs a:hover { background: rgba(255,255,255,.08); color: #fff; }
.tabs a.active { background: var(--brand); color: var(--brand-ink); }
.user { display: flex; align-items: center; gap: 10px; }
.user .btn { color: #fff; border-color: rgba(255,255,255,.25); }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.conn.on { background: #22c55e; }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; text-align: center; }
.pill.warn { background: var(--danger); color: #fff; }

main { padding: 16px; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* Térkép */
.map-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; height: calc(100vh - 90px); min-height: 460px; }
#map { border-radius: var(--radius); border: 1px solid var(--line); min-height: 360px; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.side h3 { margin: 6px 0 0; }
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.counter { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.counter b { font-size: 20px; }
.counter span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.driver-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.driver-list li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: center; }
.driver-list li:hover { background: #f8fafc; }
.driver-list li small { grid-column: 2 / 4; }
.empty { color: var(--muted); font-style: italic; padding: 8px 0; }
.leaflet-popup-content { font: 13px/1.4 system-ui, sans-serif; }

/* Táblázatok */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.compact td, .tbl.compact th { padding: 6px 10px; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions { display: flex; gap: 6px; justify-content: flex-end; }
.neg { color: var(--danger); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eef0f3; color: #374151; }
.badge.pending, .badge.searching, .badge.offered { background: #fff4d6; color: #8a5a00; }
.badge.approved, .badge.completed, .badge.active { background: #dcfce7; color: #166534; }
.badge.rejected, .badge.suspended, .badge.cancelled, .badge.no_driver, .badge.inactive { background: #fde2e2; color: #9b1c1c; }
.badge.accepted, .badge.arrived, .badge.in_progress { background: #dbeafe; color: #1e40af; }
.badge.homeward { background: #f3e8ff; color: #6b21a8; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: #1d2330; color: #fff; }

/* Pénzügyek */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat b { display: block; font-size: 22px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat small { display: block; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid2 > *, .map-layout > *, .fields > *, .coupon-form > *, .stats > * { min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.weight { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.weight-labels { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; gap: 8px; }
.weight input[type=range] { padding: 0; border: 0; accent-color: var(--primary); }

/* Kuponok */
.coupon-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; margin-bottom: 16px; }

/* Modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 2000; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal form .full { grid-column: 1 / -1; }
.modal .row-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: #1d2330; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--danger); }

@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; height: auto; }
  #map { height: 60vh; }
  .grid2 { grid-template-columns: 1fr; }
  .topbar { gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .user { margin-left: auto; }
  #me-name { display: none; }
  .modal form { grid-template-columns: 1fr; }
}

/* 4. mérföldkő */
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.hint-list { margin: 0; padding-left: 18px; color: #374151; display: grid; gap: 6px; }
fieldset.commission { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 14px 0 0; display: grid; gap: 6px; }
fieldset.commission legend { font-weight: 700; font-size: 13px; padding: 0 4px; }
.fields.two { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 6px 0 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pos { color: var(--ok); font-weight: 700; } .neg { color: var(--danger); font-weight: 700; }
.badge.paid, .badge.issued, .badge.captured { background: #dcfce7; color: #166534; }
.badge.test, .badge.authorized { background: #dbeafe; color: #1e40af; }
.badge.failed, .badge.capture_failed { background: #fde2e2; color: #9b1c1c; }
.badge.skipped, .badge.canceled { background: #eef0f3; color: #374151; }
pre.xml { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; max-height: 60vh; font-size: 12px; }
#szamlazz-mode .on[data-mode="live"] { background: var(--danger); }
