:root {
  color-scheme: light;
  --bg: #f4f6f9; --card: #fff; --text: #1d2433; --muted: #6b7385; --line: #e2e6ee;
  --primary: #1f5f8b; --primary-2: #174a6d; --danger: #c0392b; --ok: #1e8449; --warn: #b9770e;
  --inc: #2e86c1; --exp: #e67e22;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; --bg: #12161d; --card: #1b212b; --text: #e6e9ef; --muted: #98a1b3; --line: #2b3340;
    --primary: #4a9bd1; --primary-2: #3b87bb; --danger: #e5604f; --ok: #4cbb78; --warn: #e0a43a; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0 0 .8rem; } h2 { font-size: 1.1rem; margin: 0 0 .7rem; } h3 { font-size: .9rem; margin: 0 0 .3rem; color: var(--muted); text-transform: uppercase; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.top { background: var(--primary); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 12px; position: fixed; top: 0; left: 0; right: 0; height: 52px; box-sizing: border-box; z-index: 20; }
body.hashdr { padding-top: 52px; }
.top .brand { color: #fff; font-weight: 700; white-space: nowrap; padding: 12px 0; }
.top nav { display: flex; overflow-x: auto; gap: 2px; scrollbar-width: none; }
.top nav a { color: #dbe8f3; padding: 14px 10px; white-space: nowrap; border-bottom: 3px solid transparent; }
.top nav a.on, .top nav a:hover { color: #fff; border-bottom-color: #fff; }
@media (max-width: 700px) { .topsearch { max-width: none; } .brand { white-space: nowrap; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.head h1 { margin: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 140px; }
.row form { margin: 0; }
.grow { flex: 3 1 220px !important; }
.self-end { align-self: flex-end; margin-bottom: 12px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

label { display: block; margin-bottom: 12px; font-size: .85rem; color: var(--muted); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; margin: 0; }

.btn { display: inline-block; padding: 9px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { padding: 4px 9px; font-size: .85rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.tile span { display: block; color: var(--muted); font-size: .85rem; }
.tile b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.neg { color: var(--danger); }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--bg); }
tr.sum td { font-weight: 700; border-top: 2px solid var(--line); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; vertical-align: middle; }
.badge.kiállítva { background: #fdf2e0; color: var(--warn); }
.badge.fizetve { background: #e3f4ea; color: var(--ok); }
.badge.sztornó { background: #eceef2; color: var(--muted); text-decoration: line-through; }
.badge.overdue { background: #fbe3e0; color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .badge.kiállítva, .badge.fizetve, .badge.sztornó, .badge.overdue { background: var(--bg); }
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: .9rem; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.search { display: flex; gap: 8px; margin-bottom: 12px; max-width: 420px; }
.search input { margin: 0; }

.err { color: var(--danger); } .ok { color: var(--ok); font-weight: 600; } .muted { color: var(--muted); }
.warn { border-color: var(--danger); }
ul.plain { margin: 0; padding-left: 18px; }

/* számla űrlap */
.item { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.item label { margin-bottom: 0; }
.item .sm { flex: 1 1 80px; } .item .md { flex: 1 1 130px; }
.item .rowsum { text-align: right; font-weight: 600; padding-bottom: 10px; font-variant-numeric: tabular-nums; }
.item .del { margin-bottom: 4px; }
.totals { display: flex; justify-content: flex-end; gap: 24px; flex-wrap: wrap; margin: 16px 0; font-variant-numeric: tabular-nums; }
.totals .big { font-size: 1.2rem; }

/* számla nézet */
.invoice .inv-top { border-bottom: 3px solid var(--primary); padding-bottom: 10px; margin-bottom: 14px; }
.invoice .inv-top h2 { font-size: 1.6rem; letter-spacing: .1em; margin: 0; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.dates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: var(--bg); padding: 10px; border-radius: 8px; margin-bottom: 14px; font-size: .9rem; }
@media (max-width: 600px) { .parties { grid-template-columns: 1fr; } .dates { grid-template-columns: 1fr 1fr; } }
.inv-sum { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
table.mini { width: auto; font-size: .85rem; } table.mini td { padding: 3px 8px; }
.grand { font-size: 1.3rem; } .grand b { color: var(--primary); }

/* grafikon */
.legend { font-size: .85rem; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.sw.inc, i.inc { background: var(--inc); } .sw.exp, i.exp { background: var(--exp); }
.bars { display: flex; gap: 4px; height: 180px; align-items: stretch; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bar .pair { flex: 1; width: 100%; display: flex; gap: 2px; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.bar i { display: block; width: 40%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar small { color: var(--muted); margin-top: 4px; }

@media print {
  body { background: #fff; color: #000; }
  .top, .noprint { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: none; padding: 0; }
  .dates { background: #f2f2f2; }
}

.qr { background: #fff; padding: 12px; border-radius: 8px; width: 220px; max-width: 100%; margin-bottom: 12px; }
.qr svg { display: block; width: 100%; height: auto; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
ol { padding-left: 20px; } ol li { margin-bottom: 6px; }


/* oldalmenü (drawer) + felső kereső */
.burger { background: none; border: none; color: #fff; font-size: 1.5rem; line-height: 1; padding: 10px; cursor: pointer; }
.topsearch { flex: 1; max-width: 420px; margin: 0; }
.topsearch input { margin: 0; padding: 7px 12px; border-radius: 20px; border: none; background: #ffffff2e; color: #fff; }
.topsearch input::placeholder { color: #ffffffd0; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 264px; max-width: 82vw; background: var(--card); transform: translateX(-100%); transition: transform .22s ease; z-index: 30; overflow-y: auto; box-shadow: 2px 0 16px #0004; }
.drawer .dhead { background: var(--primary); color: #fff; font-weight: 700; padding: 18px 16px; font-size: 1.1rem; }
.drawer a { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: var(--text); border-bottom: 1px solid var(--line); }
.drawer a span { width: 24px; text-align: center; font-size: 1.1rem; }
.drawer a.on { background: var(--primary); color: #fff; }
.drawer hr { border: none; border-top: 6px solid var(--bg); margin: 0; }
.scrim { position: fixed; inset: 0; background: #0007; opacity: 0; visibility: hidden; transition: opacity .22s; z-index: 25; }
body.drawer-open .drawer { transform: translateX(0); }
body.drawer-open .scrim { opacity: 1; visibility: visible; }

.drawer a span svg { display: block; margin: auto; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12161d; --card: #1b212b; --text: #e6e9ef; --muted: #98a1b3; --line: #2b3340;
  --primary: #4a9bd1; --primary-2: #3b87bb; --danger: #e5604f; --ok: #4cbb78; --warn: #e0a43a;
}
.drawer-preferences { padding: 12px 16px 0; border-top: 1px solid var(--line); }
.subscriber-card .subscriber-filter { padding-bottom: 16px; align-items: center; }
.subscriber-card .subscriber-filter label { margin-bottom: 0; }
.subscriber-card .subscriber-filter button { align-self: end; }
.subscriber-code { font-variant-numeric: tabular-nums; white-space: nowrap; }
.subscriber-pagination { padding-top: 16px; align-items: center; }
.subscriber-details dt { color: var(--muted); margin-top: .6rem; }
.subscriber-details dd { margin-inline-start: 0; }
.subscriber-address { border-bottom: 1px solid var(--line); padding: 10px 0; }
.subscriber-details details { margin-top: 12px; }
.subscriber-details summary { color: var(--primary); cursor: pointer; }
.subscriber-details details form { margin-top: 12px; }

.provider-chart { list-style: none; margin: 12px 0 0; padding: 0; }
.provider-chart li { display: grid; grid-template-columns: 6rem 1fr 3rem; gap: 12px; align-items: center; margin-block: 8px; }
.provider-chart meter { width: 100%; height: 1.25rem; accent-color: var(--primary); }
.provider-chart b { text-align: end; font-variant-numeric: tabular-nums; }
