:root {
  --bg: #f4f7f9; --card: #fff; --text: #17252f; --muted: #5f6f7a; --line: #dde5ea;
  --brand: #0b6e99; --brand-dark: #085579; --ok: #1d7a46; --ok-bg: #e3f4ea;
  --warn: #8a5a00; --warn-bg: #fff3d6; --bad: #b3261e; --bad-bg: #fde7e5;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f171c; --card: #172228; --text: #e5edf1; --muted: #9aabb5; --line: #2a3a43;
    --brand: #3aa7d6; --brand-dark: #2b8fbb; --ok: #6fd39b; --ok-bg: #173826; --warn: #f2c35b; --warn-bg: #3a2e12;
    --bad: #ff8a80; --bad-bg: #401b18; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: .4em 0 .3em; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 1.6em 0 .5em; }
h3 { font-size: 1rem; margin: 1.2em 0 .5em; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--brand); color: #fff; }
.top a, .top .link { color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.brand svg { width: 22px; height: 22px; fill: currentColor; }
.top nav { display: flex; gap: 16px; align-items: center; }
.top nav form { margin: 0; }
.subnav { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.subnav a { white-space: nowrap; padding: 6px 10px; border-radius: 8px; text-decoration: none; font-size: .95rem; }
.subnav a:hover { background: var(--bg); }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
main.wide { max-width: 1100px; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 32px 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.narrow { max-width: 420px; margin: 24px auto; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.big { font-size: 1.2rem; font-weight: 600; margin: 0 0 4px; }
.crumb { margin: 0; font-size: .9rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

label { display: block; margin-bottom: 12px; font-weight: 500; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; }
input.code { font-size: 1.6rem; letter-spacing: .3em; text-align: center; }
#value { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { width: auto; margin-top: 4px; flex: none; }
.flags { display: flex; flex-wrap: wrap; gap: 0 18px; }
.flags label.check { margin-bottom: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; font: inherit; font-weight: 600;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: .88rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.block { display: flex; width: 100%; padding: 14px; font-size: 1.05rem; }
@media (max-width: 600px) { .btn.block-sm { display: flex; width: 100%; padding: 14px; } }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.camera { margin: 8px 0 4px; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

.unit-list { display: grid; gap: 10px; }
.unit-tile { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-decoration: none; color: inherit; margin: 0; flex-wrap: wrap; }
.status { border-left: 4px solid var(--brand); }
.invoice .amount { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.invoice.overdue { border-color: var(--bad); }
.invoice .row + .row { margin-top: 8px; }
.authorize { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-bottom: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 44px; background: var(--brand); border-radius: 4px 4px 0 0; }
.bar-val { font-size: .75rem; color: var(--muted); }
.bar-label { font-size: .72rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td form { margin: 0; }
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; display: block; }
.contact { display: grid; gap: 8px; }
.contact-email { word-break: break-all; }
#preview img { width: 100%; max-height: 360px; object-fit: contain; border-radius: 8px; background: #000; margin: 8px 0; }
.help { margin-top: 16px; }
.help summary { cursor: pointer; font-weight: 600; }
.help img { width: 100%; max-width: 420px; border-radius: 8px; margin-top: 10px; }
.stat { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .88rem; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; margin: 0; padding: 5px 8px; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.install { display: flex; align-items: center; gap: 12px; max-width: 760px; margin: 12px auto 0; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); }
.install[hidden] { display: none; }
.install img { border-radius: 9px; flex: none; }
.install-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.install-close { background: none; border: 0; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 6px; }
.share-icon { width: 16px; height: 16px; vertical-align: -3px; }
@media (max-width: 792px) { .install { margin: 12px 16px 0; } }
