/* Boje firme Hermed: plava #237EC6, svetloplava #84C1F1, tamnoplava #191C45, uz belu */
:root {
  --bg: #F3F7FC; --card: #FFFFFF; --ink: #191C45; --muted: #5E6B85; --line: #DCE6F2;
  --accent: #237EC6; --accent-dark: #1B66A3; --accent-light: #84C1F1; --accent-soft: #E6F1FB;
  --nav: #237EC6; --nav-ink: #FFFFFF;
  --warn: #C8372D; --warn-soft: #FDECEA; --ok: #1F9D68;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); display: flex; min-height: 100vh; }
h1, h2 { color: var(--ink); }
#nav { width: 230px; flex-shrink: 0; background: var(--nav); color: var(--nav-ink);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#nav a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; font-size: 14px; opacity: .92; }
#nav a:hover { background: rgba(255, 255, 255, .14); opacity: 1; }
#nav a.active { background: #FFFFFF; color: var(--accent); font-weight: 600; opacity: 1; }
#nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255, 255, 255, .7); margin: 16px 12px 6px; }
#nav .muted { color: rgba(255, 255, 255, .75); }
#nav .user button { background: rgba(255, 255, 255, .16); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 0 8px 18px; }
.logo { background: #FFFFFF; color: var(--accent); border-radius: 8px; width: 32px; height: 32px; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.login .logo { background: var(--accent); color: #fff; }
.login { border-top: 4px solid var(--accent); }
#menu { display: none; }
main { flex: 1; padding: 28px 32px; min-width: 0; }
h1 { margin: 0 0 18px; font-size: 26px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.grow { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat, .card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat b { display: block; font-size: 28px; margin-top: 4px; }
.stat span { color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.vcard { cursor: pointer; text-align: center; transition: border-color .15s; }
.vcard:hover { border-color: var(--accent); }
.vcard .plates { display: inline-block; border: 1.5px solid var(--ink); border-radius: 4px; padding: 1px 8px; font-weight: 700; letter-spacing: .05em; margin: 6px 0; }
.vcard .make { font-size: 36px; color: var(--accent); font-weight: 800; }
.muted { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.grey { background: var(--bg); color: var(--muted); }
table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 14px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--ink); font-weight: 600; background: var(--accent-soft); position: sticky; top: 0; }
td.wrap { white-space: normal; min-width: 220px; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
button { border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; background: var(--bg); }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--accent-dark); }
button:not(.primary):not(.danger), .btn:not(.primary) { border: 1px solid var(--line); }
button:not(.primary):not(.danger):hover, .btn:not(.primary):hover { border-color: var(--accent); color: var(--accent); }
tbody tr:hover td { background: #F7FAFE; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; overflow-x: auto; }
.tabs button { background: none; border-radius: 0; border-bottom: 2px solid transparent; padding: 10px 14px; }
.tabs button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); width: min(520px, 94vw); }
dialog form { display: grid; gap: 10px; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--card); font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
a { color: var(--accent); }
[hidden] { display: none !important; }
#nav .user { border-top: 1px solid var(--line); margin-top: 16px; padding: 14px 12px 0; font-size: 14px; display: grid; gap: 8px; }
body.auth #nav, body.auth #menu { display: none; }
.login { max-width: 380px; margin: 10vh auto; padding: 28px; }
.login form { display: grid; gap: 12px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login .brand { padding: 0 0 16px; }

/* zajedničke kontrole */
.btn { display: inline-block; border-radius: 8px; padding: 8px 14px; cursor: pointer; background: var(--bg); color: var(--ink); text-decoration: none; border: 0; font-size: 14px; }
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.sm, .btn.sm { padding: 4px 10px; font-size: 13px; }
button.big, .btn.big { padding: 14px 20px; font-size: 17px; }
button.danger { background: var(--warn-soft); color: var(--warn); }
button:disabled { opacity: .5; cursor: not-allowed; }
.err { color: var(--warn); min-height: 1em; margin: 0; }
.more { font-size: 13px; font-weight: 400; float: right; }
.filters { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.inl { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.check { display: flex !important; gap: 8px; align-items: center; color: var(--ink) !important; }
.seg { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.seg button, .seg a { padding: 5px 10px; border-radius: 99px; background: var(--bg); font-size: 13px; color: var(--ink); text-decoration: none; }
.seg .on { background: var(--accent); color: #fff; }
a.stat { color: inherit; text-decoration: none; }
a.stat:hover, a.vcard:hover { border-color: var(--accent); }
a.vcard { color: inherit; text-decoration: none; display: block; }
.plates.big { font-size: 18px; border: 1.5px solid; border-radius: 4px; padding: 2px 8px; vertical-align: middle; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }
#nav a.cta { background: #FFFFFF; color: var(--accent); font-weight: 700; margin-bottom: 10px; text-align: center; opacity: 1; box-shadow: 0 2px 8px rgba(25, 28, 69, .18); }
#nav a.cta:hover { background: var(--accent-soft); }
#nav a .badge { float: right; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.files a { display: grid; gap: 4px; color: inherit; text-decoration: none; font-size: 13px; text-align: center; font-size: 40px; }
.files a span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* skeniranje računa */
.scan video { width: 100%; max-height: 60vh; border-radius: 10px; background: #000; margin: 10px 0; }
.receipt { margin-top: 14px; }
.receipt .amount { font-size: 24px; color: var(--accent); }
.receipt .items { margin: 12px 0; }
.grid-form { display: grid; gap: 10px; margin-top: 14px; }
.grid-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.ok-card { margin-top: 14px; text-align: center; }

/* mape */
.map { height: 420px; border-radius: 12px; border: 1px solid var(--line); z-index: 0; }
.map.tall { height: calc(100vh - 200px); min-height: 380px; }
.mapwrap { display: grid; grid-template-columns: 1fr 260px; gap: 12px; }
.mapwrap .card { overflow-y: auto; max-height: calc(100vh - 200px); }
.vrow { display: grid; padding: 8px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.pin span { background: var(--muted); color: #fff; padding: 3px 7px; border-radius: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: 0 1px 4px #0005; display: inline-block; transform: translate(-50%, -100%); }
.pin span.fresh { background: var(--accent); }
.leaflet-container a { color: var(--accent); }

/* poruke */
.chat { display: grid; grid-template-columns: 280px 1fr; gap: 12px; }
.chat.single { grid-template-columns: 1fr; }
.threads { padding: 6px; max-height: 70vh; overflow-y: auto; }
.threads a { display: grid; grid-template-columns: 1fr auto; gap: 2px; padding: 10px; border-radius: 8px; color: inherit; text-decoration: none; }
.threads a .muted { grid-column: 1 / -1; }
.threads a.on, .threads a:hover { background: var(--accent-soft); }
.msgs { height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.msg { max-width: 75%; background: var(--bg); padding: 8px 12px; border-radius: 12px; align-self: flex-start; white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: var(--accent-soft); }
.msg .muted { font-size: 11px; display: block; margin-top: 2px; }

/* kalendar podsetnika */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-h { font-size: 12px; color: var(--muted); text-align: center; padding: 4px; }
.cal-day { background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-height: 92px; padding: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.cal-day.empty { background: none; border: 0; }
.cal-day.today { border-color: var(--accent); }
.cal-item { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 2px 4px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.warn { background: var(--warn-soft); color: var(--warn); }
.cal-item.doc { background: var(--bg); color: var(--ink); }
.cal-item.done { opacity: .5; text-decoration: line-through; }

/* obaveštenja */
.notifs { display: grid; gap: 8px; }
.notif { display: flex; gap: 12px; color: inherit; text-decoration: none; padding: 12px 14px; }
.notif.unread { border-left: 4px solid var(--accent); }
.notif .nk { font-size: 22px; }

/* USB čitač QR koda */
.scanzone { border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; cursor: pointer; margin: 10px 0; }
.scanzone.active { border-color: var(--accent); background: var(--accent-soft); }

/* vozač na telefonu: krupnije, bez tabela gde nije potrebno */
body.driver #nav a.cta { font-size: 16px; padding: 12px; }

@media (max-width: 800px) {
  #nav .brand { padding-left: 48px; }
  .mapwrap, .chat { grid-template-columns: 1fr; }
  .threads { max-height: 30vh; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cal { grid-template-columns: 1fr; }
  .cal-h, .cal-day.empty, .cal-day:not(:has(.cal-item)) { display: none; }
  .cal-day { min-height: 0; }
}
@media print {
  #nav, #menu, .noprint, .filters, button, .btn, .tabs { display: none !important; }
  main { padding: 0; }
  body { background: #fff; color: #000; }
  .tablewrap { border: 0; overflow: visible; }
  th { background: #eee; }
}
@media (max-width: 800px) {
  #nav { position: fixed; z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  #nav.open { transform: none; box-shadow: 0 0 40px #0004; }
  #menu { display: block; position: fixed; top: 10px; left: 10px; z-index: 11; background: var(--accent); color: #fff; border: 0; box-shadow: 0 2px 8px rgba(25, 28, 69, .25); }
  main { padding: 56px 16px 24px; }
  .grid2 { grid-template-columns: 1fr; }
}
