:root {
  --bg:      #06070a;
  --bg-2:    #0b0c11;
  --bg-3:    #10121a;
  --fg:      #f2efe7;
  --fg-dim:  #9b978d;
  --fg-mute: #5a574e;
  --green:   #7ee787;
  --red:     #ff6b6b;
  --yellow:  #e3b341;
  --blue:    #79c0ff;
  --line:    rgba(255,255,255,0.07);
  --line-2:  rgba(255,255,255,0.16);
  --mono:    'JetBrains Mono', ui-monospace, monospace;
  --sans:    'Inter', system-ui, sans-serif;
  --radius:  6px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--sans);
  line-height: 1.5; min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}
a { color: var(--blue); }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

/* ─── Auth / login ─────────────────────────────────────────────────────── */
.auth-wrap {
  max-width: 380px; margin: 0 auto; padding: 18vh 1.5rem 2rem;
}
.term-prompt { color: var(--green); font-family: var(--mono); font-size: 13px; margin-bottom: 1.25rem; }
.term-prompt .dim { color: var(--fg-mute); }
.auth-error {
  background: rgba(255,107,107,.08); border: 1px solid rgba(255,107,107,.25);
  color: var(--red); font-family: var(--mono); font-size: 12px;
  padding: .6rem .8rem; border-radius: var(--radius); margin-bottom: 1rem;
}
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label {
  font-family: var(--mono); font-size: 10.5px; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: .08em;
}
.input, .select, .textarea {
  width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box;
  background: var(--bg-2); border: 1px solid var(--line-2);
  color: var(--fg); font-size: 16px; padding: .62rem .8rem;
  border-radius: var(--radius); outline: none; transition: border-color .15s;
}
.input, .textarea { -webkit-appearance: none; appearance: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--green); }
.textarea { min-height: 70px; resize: vertical; }
/* iOS: date input drugače raste čez rob in ignorira width */
.input[type="date"] {
  -webkit-appearance: none; appearance: none;
  min-height: 2.7rem; line-height: 1.2; text-align: left;
}
.input[type="date"]::-webkit-date-and-time-value { text-align: left; }

.btn {
  background: var(--green); color: #06070a; font-weight: 700; font-size: 14px;
  padding: .68rem 1.1rem; border: none; border-radius: var(--radius); cursor: pointer;
  transition: opacity .15s; display: inline-flex; align-items: center; gap: .4rem;
  justify-content: center;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--line-2); }
.btn-ghost:hover { border-color: var(--fg-dim); opacity: 1; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(255,107,107,.4); }
.btn-danger:hover { background: rgba(255,107,107,.1); opacity: 1; }
.btn-sm { padding: .4rem .7rem; font-size: 12.5px; }

.muted { color: var(--fg-dim); }
.mono { font-family: var(--mono); }
.small { font-size: 12.5px; }

/* ─── App shell ────────────────────────────────────────────────────────── */
.shell { max-width: 900px; margin: 0 auto; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: nowrap;
  padding: .8rem 1rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.topbar > * { min-width: 0; }
.topbar .logo { font-family: var(--mono); font-weight: 700; color: var(--green); font-size: 14px; flex: none; }
.topbar .spacer { flex: 1 1 auto; min-width: 0; }
.chip {
  font-family: var(--mono); font-size: 11px; padding: .25rem .55rem;
  border: 1px solid var(--line-2); border-radius: 100px; color: var(--fg-dim);
  white-space: nowrap; flex: none;
}
.chip.admin { color: var(--yellow); border-color: rgba(227,179,65,.4); }
.chip.open { color: var(--green); border-color: rgba(126,231,135,.4); }
.chip.closed { color: var(--red); border-color: rgba(255,107,107,.4); }
.chip.chip-current { color: var(--blue); border-color: rgba(121,192,255,.4); }
.topbar .btn { flex: none; }

.group-select {
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--fg);
  font-size: 13px; padding: .35rem .5rem; border-radius: var(--radius);
  flex: 0 1 auto; min-width: 3ch; max-width: 42vw;
  text-overflow: ellipsis;
}

.content { flex: 1; padding: 1rem 1rem 6rem; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--bg-2); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: none; color: var(--fg-mute);
  font-family: var(--mono); font-size: 11px; padding: .7rem .2rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
}
.tabbar button.active { color: var(--green); }
.tabbar button .ico { font-size: 17px; line-height: 1; }

@media (min-width: 720px) {
  .shell { max-width: 900px; }
  .content { padding: 1.5rem 1.5rem 2rem; }
  .tabbar {
    position: sticky; top: 57px; bottom: auto; border-top: none;
    border-bottom: 1px solid var(--line); background: var(--bg);
    max-width: 900px; margin: 0 auto;
  }
  .tabbar button { flex: 0 0 auto; flex-direction: row; padding: .6rem 1rem; font-size: 12px; }
}

/* ─── Cards / lists ────────────────────────────────────────────────────── */
.section-title {
  font-family: var(--mono); font-size: 11px; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: .1em; margin: 1.4rem 0 .6rem;
}
.section-title:first-child { margin-top: 0; }

.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem .9rem;
}
.card + .card { margin-top: .5rem; }

.row {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .2rem; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .ico-cat {
  width: 34px; height: 34px; flex: none; border-radius: 8px;
  display: grid; place-items: center; color: var(--fg-dim);
  background: var(--bg-3); border: 1px solid var(--line-2);
}
.row .grow { flex: 1; min-width: 0; }
.row .r-title {
  font-size: 14px; font-weight: 500; margin-bottom: 3px;
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
}
.row .r-sub { font-size: 12px; color: var(--fg-dim); font-family: var(--mono); }
.row .r-amt { font-family: var(--mono); font-weight: 600; font-size: 14px; white-space: nowrap; }
.row .r-actions { display: flex; gap: .3rem; flex: none; }
.row .r-right { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; flex: none; }
.row .r-edit { gap: .25rem; }

.thumb {
  width: 30px; height: 30px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--line-2); cursor: pointer; flex: none;
}

.pill-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill {
  font-family: var(--mono); font-size: 12px; padding: .4rem .7rem;
  border: 1px solid var(--line-2); border-radius: 100px; background: var(--bg-2);
  color: var(--fg-dim); cursor: pointer; user-select: none;
}
.pill.on { color: #06070a; background: var(--green); border-color: var(--green); font-weight: 700; }

.balance-pos { color: var(--green); }
.balance-neg { color: var(--red); }
.balance-zero { color: var(--fg-mute); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: right; padding: .5rem .4rem; border-bottom: 1px solid var(--line); }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl th { font-family: var(--mono); font-size: 10.5px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .06em; }
table.tbl td.num { font-family: var(--mono); }

.transfer {
  display: flex; align-items: center; gap: .5rem; font-family: var(--mono);
  font-size: 13.5px; padding: .55rem .2rem; border-bottom: 1px solid var(--line);
}
.transfer:last-child { border-bottom: none; }
.transfer .arrow { color: var(--fg-mute); }
.transfer .amt { margin-left: auto; font-weight: 600; }

.empty { text-align: center; color: var(--fg-mute); font-family: var(--mono); font-size: 12.5px; padding: 2.5rem 1rem; }

.notice {
  font-family: var(--mono); font-size: 12px; padding: .55rem .7rem;
  border-radius: var(--radius); margin-bottom: .8rem;
}
.notice.warn { background: rgba(227,179,65,.08); border: 1px solid rgba(227,179,65,.3); color: var(--yellow); }
.notice.ok { background: rgba(126,231,135,.08); border: 1px solid rgba(126,231,135,.3); color: var(--green); }
.notice.err { background: rgba(255,107,107,.08); border: 1px solid rgba(255,107,107,.3); color: var(--red); }

/* ─── FAB ──────────────────────────────────────────────────────────────── */
.fab {
  position: fixed; right: 1rem; bottom: calc(64px + env(safe-area-inset-bottom) + .8rem);
  width: 56px; height: 56px; border-radius: 50%; background: var(--green); color: #06070a;
  border: none; cursor: pointer; z-index: 25; padding: 0;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
}
.fab svg { width: 24px; height: 24px; stroke-width: 2.25; }
@media (min-width: 720px) {
  .fab { bottom: 1.5rem; right: calc((100vw - 900px)/2 + 1.5rem); }
}
@media (max-width: 933px) { .fab { right: 1rem; } }

/* ─── Modal ────────────────────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 720px) { .modal-back { align-items: center; } }
.modal {
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: 14px 14px 0 0; width: 100%; max-width: 480px;
  max-height: 92vh; overflow-y: auto; padding: 1.1rem 1.1rem 1.6rem;
}
@media (min-width: 720px) { .modal { border-radius: 14px; } }
.modal h3 { font-size: 16px; margin-bottom: 1rem; display: flex; align-items: center; }
.modal h3 .x { margin-left: auto; background: none; border: none; color: var(--fg-mute); font-size: 22px; cursor: pointer; line-height: 1; }

.amount-input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg);
  font-family: var(--mono); font-size: 30px; font-weight: 700; text-align: center;
  padding: .7rem; border-radius: var(--radius); outline: none;
}
.amount-input:focus { border-color: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; column-gap: .7rem; }
.grid-2 > * { min-width: 0; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }

.receipt-drop {
  border: 1px dashed var(--line-2); border-radius: var(--radius); padding: .9rem;
  text-align: center; color: var(--fg-dim); font-size: 13px; cursor: pointer;
}
.receipt-drop img { max-height: 160px; border-radius: var(--radius); margin-top: .5rem; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 60;
  display: grid; place-items: center; padding: 1rem;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

.actions-bar { display: flex; gap: .6rem; margin-top: 1.1rem; }
.actions-bar .btn { flex: 1; }

.list-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.list-head .spacer { flex: 1; }

/* ─── SVG ikone ────────────────────────────────────────────────────────── */
.icon { display: block; flex: none; }
.btn .icon, .pill .icon { margin: 0; }
.btn > span, .pill > span { line-height: 1; }

.btn-icon { padding: .42rem; }
.btn-icon .icon { width: 15px; height: 15px; }

.pill-ico { display: inline-flex; align-items: center; gap: .35rem; }
.pill-ico .icon { opacity: .8; }
.pill-ico.on .icon { opacity: 1; }

.ico-cat .icon { width: 18px; height: 18px; }

.tabbar button .ico { display: inline-flex; }
.tabbar button .ico .icon { width: 19px; height: 19px; }

.empty .icon { display: inline-block; vertical-align: -5px; color: var(--green); margin-right: .3rem; }

.transfer .arrow .icon, .transfer .arrow { display: inline-flex; }

/* wrap safety na ozkih ekranih */
.row .r-sub, .section-title, .transfer, .r-title { overflow-wrap: anywhere; }
.card, .row, .content { max-width: 100%; }
table.tbl { table-layout: fixed; }
table.tbl td, table.tbl th { overflow-wrap: anywhere; }

/* ─── Blagajna ────────────────────────────────────────────────────────── */
.cash-toggle {
  width: 100%; background: none; border: none; color: var(--fg); cursor: pointer;
  display: flex; align-items: center; gap: .5rem; padding: .35rem .1rem;
  font-size: 13px; font-weight: 500; text-align: left;
}
.cash-toggle span { flex: 1; }
.cash-body { margin-top: .8rem; }
.cash-body .field { margin-bottom: .8rem; }
.cash-sub {
  font-family: var(--mono); font-size: 10.5px; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: .08em; margin: .9rem 0 .4rem;
}
.cash-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cash-line {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .6rem; border-bottom: 1px solid var(--line);
}
.cash-line:last-child { border-bottom: none; }
.cash-line.done { background: rgba(126,231,135,.06); }
.cash-check { flex: none; display: flex; }
.cash-check input { width: 20px; height: 20px; accent-color: var(--green); }
.cash-who { flex: 1; min-width: 0; }
.cash-name { font-size: 13.5px; font-weight: 500; }
.cash-exp { font-family: var(--mono); font-size: 11.5px; color: var(--fg-dim); }
.cash-over { color: var(--yellow); }
.cash-under { color: var(--red); }
.cash-amt {
  flex: none; width: 92px; text-align: right; font-family: var(--mono);
  font-size: 16px; padding: .45rem .55rem;
}
.cash-list.ro .cash-amt, .cash-list.ro .cash-check input { pointer-events: none; opacity: .7; }
.cash-totals {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: 1rem;
}
.cash-totals > div {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .5rem .55rem; display: flex; flex-direction: column; gap: .15rem;
}
.cash-totals span { font-family: var(--mono); font-size: 9.5px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .05em; }
.cash-totals b { font-family: var(--mono); font-size: 14px; }
@media (max-width: 460px) {
  .cash-totals { grid-template-columns: 1fr; }
  .cash-totals > div { flex-direction: row; justify-content: space-between; align-items: baseline; }
}

/* ─── Stiliziran confirm / prompt ─────────────────────────────────────── */
.dialog-back {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.65); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 1.25rem;
  animation: dlg-fade .12s ease-out;
}
@keyframes dlg-fade { from { opacity: 0 } to { opacity: 1 } }
.dialog {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px;
  width: 100%; max-width: 380px; padding: 1.15rem 1.15rem 1.1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.dialog h3 { font-size: 15px; margin-bottom: .5rem; }
.dialog-msg { font-size: 13.5px; color: var(--fg-dim); line-height: 1.5; }
.dialog #dlg-input { margin-top: .9rem; }
.dialog-actions { display: flex; gap: .6rem; margin-top: 1.15rem; }
.dialog-actions .btn { flex: 1; }
.btn-danger-solid { background: var(--red); color: #06070a; border: none; font-weight: 700; }
.btn-danger-solid:hover { opacity: .88; }

/* ─── Manjši telefoni ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  html { font-size: 14px; }
  .topbar { gap: .45rem; padding: .7rem .7rem; }
  .topbar .logo { font-size: 13px; }
  .chip { font-size: 10px; padding: .2rem .42rem; }
  .topbar .btn-sm { padding: .34rem .55rem; font-size: 11px; }
  .group-select { max-width: 34vw; font-size: 12px; padding: .32rem .4rem; }
  .content { padding: .85rem .8rem 6rem; }
  .row { gap: .55rem; padding: .65rem .1rem; }
  .row .r-actions .btn-sm { padding: .34rem .5rem; font-size: 11.5px; }
  .modal { padding: 1rem .9rem 1.5rem; }
  .amount-input { font-size: 26px; }
  .actions-bar { flex-wrap: wrap; }
}
@media (max-width: 360px) {
  .topbar .logo { display: none; }
  .chip.admin, .chip.open, .chip.closed { font-size: 9.5px; }
}
