:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --ok: #0a7d3c;
  --ok-soft: #dcfce7;
  --warn: #9a6700;
  --warn-soft: #fef3c7;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --radius: 14px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d24;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --line: #2b2f38;
    --accent: #2dd4bf;
    --accent-soft: #11302d;
    --ok: #4ade80;
    --ok-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0b;
    --danger: #f87171;
    --danger-soft: #3b1515;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Noto Sans Georgian", "BPG Arial", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  padding-top: env(safe-area-inset-top, 0px);
}
body.has-tabs { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); }

#app { max-width: 640px; margin: 0 auto; padding: 12px 16px 32px; }
.loading { padding: 64px 0; text-align: center; color: var(--muted); }

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- ზედა ზოლი ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.topbar .who { font-size: 13px; color: var(--muted); }
.topbar .title { font-size: 20px; font-weight: 700; }
.icon-btn { white-space: nowrap;
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 14px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
}
.icon-btn:active { background: var(--line); }

/* ---------- ბარათები ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); border: 1px solid var(--line);
}
a.card { display: block; color: inherit; text-decoration: none; }
a.card:active { opacity: .7; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row > .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount { font-weight: 700; font-size: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.hero {
  background: var(--accent); color: #fff; border-radius: var(--radius); padding: 18px 18px 16px; margin: 6px 0 14px;
}
.hero .label { opacity: .85; font-size: 14px; }
.hero .big { font-size: 36px; font-weight: 800; line-height: 1.1; margin: 4px 0; font-variant-numeric: tabular-nums; }
.hero .sub { opacity: .85; font-size: 13px; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.badge.paid { background: var(--ok-soft); color: var(--ok); }
.badge.unpaid { background: var(--warn-soft); color: var(--warn); }
.badge.lock { background: var(--line); color: var(--muted); }

/* ---------- პროექტის დეტალები ---------- */
details.card summary { list-style: none; cursor: pointer; }
details.card summary::-webkit-details-marker { display: none; }
details.card[open] summary { margin-bottom: 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }
.kv:first-child { border-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { background: var(--accent-soft); color: var(--accent); font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.note { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 8px 10px; font-size: 14px; margin-top: 8px; }

/* ---------- თვის გადამრთველი ---------- */
.monthnav { display: flex; align-items: center; justify-content: space-between; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; margin: 6px 0 10px; }
.monthnav button { border: 0; background: transparent; font-size: 22px; width: 44px; height: 40px; border-radius: 10px; color: var(--accent); cursor: pointer; }
.monthnav button:active { background: var(--accent-soft); }
.monthnav .m { font-weight: 700; }

/* ---------- ფორმები ---------- */
label.f { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=tel], input[type=date], input[type=datetime-local], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 16px; border: 0; border-radius: 12px; padding: 12px 18px;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.danger.confirm { background: var(--danger); color: #fff; }
.btn.ok { background: var(--ok-soft); color: var(--ok); }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.actions .btn { flex: 1; }

.err { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.info { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.lockbar { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }

/* ცხრილები */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl td { padding: 7px 0; border-top: 1px solid var(--line); }
.tbl tr:first-child td { border-top: 0; }
.tbl td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.total td { font-weight: 700; border-top: 2px solid var(--line); }


/* ქვედა ტაბები */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#tabs .inner { display: flex; width: 100%; max-width: 640px; }
#tabs a {
  flex: 1; height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px;
}
#tabs a .i { font-size: 20px; line-height: 1; }
#tabs a.on { color: var(--accent); font-weight: 600; }

.fab {
  position: fixed; right: max(16px, calc(50vw - 304px)); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 9; border-radius: 999px; box-shadow: 0 6px 20px rgba(15,118,110,.35); padding: 14px 20px;
}

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 84px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20;
  max-width: calc(100vw - 32px);
}

/* შესვლა */
.login { max-width: 380px; margin: 8vh auto 0; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 12px; }
.login h1 { text-align: center; }
.login p.sub { text-align: center; color: var(--muted); margin: 0 0 18px; }

.install-tip { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 36px 0; }

/* ---------- ნაშთი ---------- */
.hero.low { background: #b45309; }
.hero.neg { background: #b42318; }
.hero .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px;
  padding-top: 10px; border-top: 1px solid rgba(255,255,255,.25); }
.hero .stats .v { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.hero .stats .l { font-size: 11px; opacity: .8; }
.neg-text { color: var(--danger); }
.low-text { color: var(--warn); }
.pos-text { color: var(--ok); }

/* ---------- მგზავრობის ღილაკი ---------- */
.bigbtn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  font: inherit; font-size: 20px; font-weight: 800; border: 0; border-radius: var(--radius);
  padding: 22px 16px; background: var(--ok); color: #fff; cursor: pointer; text-decoration: none;
  box-shadow: 0 6px 18px rgba(10,125,60,.25);
}
.bigbtn.stop { background: var(--danger); box-shadow: 0 6px 18px rgba(180,35,24,.25); }
.bigbtn:active { opacity: .85; }
@media (prefers-color-scheme: dark) { .bigbtn { color: #06240f; } .bigbtn.stop { color: #2a0705; } }

.ontrip { border: 2px solid var(--ok); }
.ontrip .live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ok); }
.ontrip .live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- GPS და სპიდომეტრი ---------- */
.gps { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); border: 1px dashed var(--line); margin-top: 8px; }
.gps.ok { background: var(--ok-soft); color: var(--ok); border-style: solid; border-color: transparent; }
.gps.bad { background: var(--warn-soft); color: var(--warn); border-style: solid; border-color: transparent; }
.gps .grow { flex: 1; min-width: 0; }
.gps button { font: inherit; font-size: 13px; border: 0; background: rgba(0,0,0,.06); color: inherit; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
input.odo { font-size: 30px; font-weight: 800; text-align: center; letter-spacing: 1px; padding: 14px 12px; font-variant-numeric: tabular-nums; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.calc { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; text-align: center; margin-top: 14px;
  background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 12px 14px; }
.calc .v { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.calc .l { font-size: 11px; opacity: .75; }

/* ---------- ისტორია ---------- */
.day-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 0 4px; text-transform: none; }
.trip .route { font-size: 14px; line-height: 1.35; }
.trip .route .to::before { content: '→ '; color: var(--muted); }
.trip .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.trip .meta a { color: var(--accent); text-decoration: none; }
.fuel-in { background: var(--ok-soft); border-color: transparent; }
.fuel-in .amount { color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.live { background: var(--ok); color: #fff; }

.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.summary > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.summary .v { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.summary .l { font-size: 12px; color: var(--muted); }

/* ---------- ლიტრების სწრაფი არჩევა ---------- */
.quick { display: flex; gap: 8px; margin-bottom: 8px; }
.quick button { flex: 1; font: inherit; font-weight: 700; font-size: 17px; padding: 12px 6px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
.quick button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ცხრილი ანგარიშში */
.rep { width: 100%; border-collapse: collapse; font-size: 14px; }
.rep th { font-size: 11px; font-weight: 600; color: var(--muted); text-align: right; padding: 4px 0 6px 6px; }
.rep th:first-child { text-align: left; padding-left: 0; }
.rep td { padding: 9px 0 9px 6px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rep td:first-child { text-align: left; white-space: normal; padding-left: 0; }
.rep td a { color: inherit; text-decoration: none; font-weight: 600; }
.rep tr.total td { font-weight: 800; border-top: 2px solid var(--line); }
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 10px; }
.two > div { min-width: 0; }
input[type=datetime-local] { min-width: 0; font-size: 15px; padding: 11px 8px; }
