:root {
  --orange: #FE9109;
  --orange-d: #e07d00;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1b1d21;
  --muted: #6b7280;
  --line: #e6e8ec;
  --green: #17924a;
  --red: #d33a2c;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 20px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#15171b; --card:#1e2126; --ink:#f2f3f5; --muted:#9aa1ab; --line:#2c3037; --shadow:0 1px 3px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  min-height: 100dvh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.km { font-size: .55em; color: var(--muted); font-weight: 600; }

/* LOGIN */
.login-wrap { max-width: 380px; margin: 0 auto; padding: 14dvh 24px 24px; text-align: center; }
.login-wrap .logo { width: 72px; height: 72px; }
.login-wrap h1 { margin: 14px 0 2px; font-size: 26px; }
#login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }
input, .search { font-size: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); width: 100%; }
input:focus { outline: 2px solid var(--orange); border-color: transparent; }

.btn { font-size: 16px; font-weight: 600; padding: 14px; border: 0; border-radius: 12px; background: var(--card); color: var(--ink); border: 1px solid var(--line); cursor: pointer; }
.btn.primary { background: var(--orange); color: #fff; border: 0; }
.btn.primary:active { background: var(--orange-d); }
.btn:disabled { opacity: .55; }
.err { color: var(--red); font-size: 14px; min-height: 18px; }

/* APP SHELL */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px calc(14px); background: var(--card); border-bottom: 1px solid var(--line); padding-top: max(14px, env(safe-area-inset-top)); }
.brand { font-weight: 800; color: var(--orange); }
.icon-btn { background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; }
.tab { padding: 14px 16px 96px; max-width: 620px; margin: 0 auto; }
h2 { font-size: 20px; margin: 6px 0 12px; }
h3 { font-size: 15px; color: var(--muted); margin: 22px 0 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 20px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.search { margin: 10px 0 14px; }

/* LISTA VOZAČA */
.list { display: flex; flex-direction: column; gap: 10px; }
.driver { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--orange); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.driver .info { flex: 1; min-width: 0; }
.driver .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.driver .sub { font-size: 12px; color: var(--muted); }
.bal { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bal.debt { color: var(--red); }
.bal.ok { color: var(--green); }
.driver .go { margin-left: 8px; }

/* CARD FORME */
.card, .debt-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.card label, .modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.card label input, .modal-card label input { margin-top: 2px; }
.msg { min-height: 18px; font-size: 14px; }
.msg.ok { color: var(--green); }
.msg.bad { color: var(--red); }

/* DUG */
.debt-card { text-align: center; }
.debt-amount { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.debt-amount.debt, #drv-balance.debt { color: var(--red); }
.debt-card .btn { margin-top: 14px; }
.led-item { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.led-item .t { font-size: 13px; }
.led-item .a { font-weight: 700; font-variant-numeric: tabular-nums; }
.led-item .a.plus { color: var(--red); }
.led-item .a.minus { color: var(--green); }

/* BOTTOM NAV */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.navbtn { flex: 1; background: none; border: 0; padding: 10px 0 12px; font-size: 20px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.navbtn span { font-size: 11px; }
.navbtn.active { color: var(--orange); }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: end center; z-index: 20; }
.modal-card { background: var(--card); width: 100%; max-width: 620px; border-radius: 20px 20px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); animation: up .18s ease; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
.modal h3 { color: var(--ink); font-size: 18px; margin: 0 0 4px; }
.modal .big-input { font-size: 30px; font-weight: 700; text-align: center; padding: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }
.balbox { display: flex; justify-content: space-between; font-size: 14px; background: var(--bg); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.balbox b { font-variant-numeric: tabular-nums; }
.seg { display: flex; gap: 8px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.seg button.sel { background: var(--orange); color: #fff; border-color: var(--orange); }

/* i18n / role / flags */
.lang { margin-top: 18px; font-size: 13px; }
.lang a { color: var(--muted); text-decoration: none; padding: 0 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.alarm { background: var(--orange); }
.dot.blok { background: var(--red); }
#role-seg { margin: 18px 0 4px; }
.admrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.admrow .num { width: 120px; text-align: right; padding: 10px; }
.ck { display: flex; align-items: center; gap: 8px; }
.ck input, .admrow input[type=checkbox] { width: auto; }
select { font-size: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); width: 100%; }
.daterange { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; }
.daterange input[type=date] { flex: 1; min-width: 120px; padding: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.chip.sel { background: var(--orange); color: #fff; border-color: var(--orange); }
.debt-card .btn { margin: 6px 4px 0; }
@media print { .topbar, .bottomnav, .btn, .navbtn { display: none !important; } .tab { padding: 0 !important; } }

/* TOAST */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 40; box-shadow: var(--shadow); max-width: 90%; }
