:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1c2530;
  --muted: #6b7684;
  --line: #dfe3e8;
  --brand: #2f5d8a;
  --brand-ink: #ffffff;
  --ok-bg: #e5f3e8;
  --ok-ink: #1f6b39;
  --warn-bg: #fbeee0;
  --warn-ink: #a15a1f;
  --err-bg: #fbe6e6;
  --err-ink: #a12a2a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--brand); color: var(--brand-ink);
}
header.top button.menu-btn {
  background: none; border: 0; color: var(--brand-ink); font-size: 20px; line-height: 1;
  padding: 4px 6px; margin: -4px 0; cursor: pointer;
}
header.top h1 { font-size: 15px; margin: 0; flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.top select {
  background: rgba(255,255,255,.15); color: var(--brand-ink); border: 1px solid rgba(255,255,255,.4);
  border-radius: 6px; padding: 5px 8px; font-size: 14px;
}
header.top select option { color: var(--ink); }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px 40px; }

/* ---------- Drawer menü ---------- */
#drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30;
}
#drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 78%; max-width: 300px; z-index: 31;
  background: var(--card); box-shadow: 2px 0 12px rgba(0,0,0,.2);
  overflow-y: auto; padding: calc(14px + env(safe-area-inset-top)) 0 14px;
  transform: translateX(-100%); transition: transform .2s ease;
}
#drawer.open { transform: translateX(0); }
#drawer .dr-title { padding: 4px 16px 12px; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
#drawer button.dr-item {
  display: block; width: 100%; text-align: left; background: none; border: 0; font: inherit;
  padding: 11px 16px; padding-left: 16px; color: var(--ink); cursor: pointer;
}
#drawer button.dr-item.sub { padding-left: 30px; font-size: 14px; }
#drawer button.dr-item.active { background: #eaf0f6; color: var(--brand); font-weight: 700; }
#drawer .dr-sep { height: 1px; background: var(--line); margin: 6px 0; }
#drawer .dr-group { padding: 10px 16px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

/* ---------- Kártyák / statok (Dashboard, Kassza fejléc) ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 8px; }
.card h3 { font-size: 14.5px; margin: 0 0 10px; }
.card .big { font-size: 26px; font-weight: 700; }
.card .row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14.5px; }
.card .row + .row { border-top: 1px solid var(--line); }
.card .row .amt { font-variant-numeric: tabular-nums; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

.pos { color: var(--err-ink); }   /* hátralék / kiadás – piros, mint a fő appban */
.neg { color: var(--ok-ink); }    /* túlfizetés / bevétel-többlet – zöld */
.ok-mark { color: var(--ok-ink); font-weight: 700; }
.err-mark { color: var(--err-ink); font-weight: 700; }

.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { width: 116px; height: 116px; border-radius: 50%; flex: none; }
.legend { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px; }
.legend .item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .amt { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Lenyíló hónap-blokkok ---------- */
details.month { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
details.month > summary {
  list-style: none; cursor: pointer; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-weight: 600;
}
details.month > summary::-webkit-details-marker { display: none; }
details.month > summary .m { flex: 1; }
details.month > summary .sum { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 400; font-size: 14px; }
details.month .body { padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.hh-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.hh-row:last-child { border-bottom: 0; }
.hh-row .name { flex: 1; }
.hh-row .amt { font-variant-numeric: tabular-nums; }
.pill { font-size: 11px; padding: 2px 7px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.pill.sent { background: var(--warn-bg); color: var(--warn-ink); }
.pill.paid { background: var(--ok-bg); color: var(--ok-ink); }
.pill.none { background: var(--err-bg); color: var(--err-ink); }

/* ---------- Táblás nézetek (Összegző, Számlák, Mérőóra, Törzsadatok) ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; }
table.rep { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
table.rep th, table.rep td { padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--line); }
table.rep th:first-child, table.rep td:first-child { text-align: left; white-space: normal; }
table.rep thead th { background: #eef1f4; font-weight: 600; position: sticky; top: 0; }
table.rep tfoot th { background: #f7f8fa; font-weight: 700; }
table.rep tr.future td, table.rep tr.future th { color: var(--muted); background: #fafbfc; }
table.rep .sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }

details.block { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
details.block > summary { padding: 11px 14px; cursor: pointer; font-weight: 600; list-style-position: inside; }
details.block .table-wrap { border: 0; border-top: 1px solid var(--line); border-radius: 0; margin: 0; }

h2.sec { font-size: 15px; margin: 20px 0 8px; }
h2.sec:first-child { margin-top: 0; }
.section-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }

.muted { color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 18px; }
.link-btn { display: inline-block; background: var(--brand); color: var(--brand-ink); text-decoration: none;
  font-size: 13px; padding: 6px 12px; border-radius: 6px; border: 0; cursor: pointer; }

#offline-badge {
  display: none; background: var(--warn-bg); color: var(--warn-ink);
  font-size: 12.5px; padding: 6px 14px; text-align: center;
}
#offline-badge.show { display: block; }

.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; margin: 8px 0; white-space: pre-wrap; overflow-x: auto;
}
