/* Csalogány condo site.
   Visual idea: the blue enamel house-number plates of Budapest. Unit codes are drawn
   as plates; everything else stays quiet so the balance figure is what you see first. */

:root {
  --bg: #edf1ef;
  --surface: #ffffff;
  --ink: #18222f;
  --muted: #586372;
  --line: #ccd4d0;
  --accent: #1d4a86;
  --accent-ink: #ffffff;
  --plate: #1d4a86;
  --over: #11693a;
  --over-bg: #e3f2e8;
  --under: #b3261e;
  --under-bg: #fbe8e6;
  --warn-bg: #fff4d6;
  --focus: #e8a33d;
  --radius: 6px;
  --font: 'Atkinson Hyperlegible Next', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131a22;
    --surface: #1b2430;
    --ink: #e8edf2;
    --muted: #a3afbd;
    --line: #34404f;
    --accent: #6f9fe0;
    --accent-ink: #0d1520;
    --plate: #2a5aa0;
    --over: #6fd39a;
    --over-bg: #173426;
    --under: #ff8f85;
    --under-bg: #3a1d1b;
    --warn-bg: #3a3218;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 112.5%; } /* 18px: an older readership reads this comfortably */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; font-weight: 800; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; margin-top: 1.4em; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: .7rem 1.25rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
}
.brand { font-weight: 800; color: var(--ink); text-decoration: none; margin-right: auto; }
#nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.1rem; font-size: .95rem; }
#nav a { color: var(--ink); text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
#nav a:hover { border-bottom-color: var(--line); }
#nav a[aria-current='page'] { border-bottom-color: var(--accent); font-weight: 600; }
.linklike {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left;
}
#nav .linklike { color: var(--ink); }
.linklike.strong { font-weight: 600; color: var(--ink); }
.lang-switch {
  font: inherit; font-size: .85rem; background: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: .15rem .7rem; cursor: pointer;
}

main { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; outline: none; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; margin-bottom: 1.25rem;
}
.card.narrow { max-width: 30rem; margin: 2rem auto; }
.card.attention { border-color: var(--focus); }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.lead { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: .3em 0 0; }
.muted { color: var(--muted); }
.error { color: var(--under); font-weight: 600; min-height: 0; }
.error:empty { display: none; }
.ok-text { color: var(--over); font-weight: 600; }
.notice { background: var(--bg); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.notice.warn { background: var(--warn-bg); }
.links { margin: .8rem 0 0; font-size: .95rem; }
.two-col { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); align-items: start; }
.two-col .card { margin: 0; }

/* ---------- forms ---------- */
.field { margin-bottom: 1rem; }
.field label, .label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .95rem; }
input:not([type='checkbox']):not([type='file']), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--muted); border-radius: var(--radius); padding: .55rem .7rem;
}
input[readonly] { background: var(--bg); border-color: var(--line); }
textarea { resize: vertical; line-height: 1.45; }
fieldset { border: 0; padding: 0; margin: 0 0 .2rem; }
legend { font-weight: 800; margin-bottom: .5rem; padding: 0; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 .75rem; }
.row3 legend { grid-column: 1 / -1; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }
.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; margin: .5rem 0 1rem; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.check.big { font-weight: 600; font-size: 1.05rem; }
.rules { list-style: none; padding: 0; margin: -.4rem 0 1rem; font-size: .85rem; color: var(--muted); }
.rules li::before { content: '○'; display: inline-block; width: 1.3em; }
.rules li.ok { color: var(--over); }
.rules li.ok::before { content: '✓'; }
.turnstile { margin: .5rem 0 1rem; min-height: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: .55rem 1.1rem; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.btn.busy { cursor: progress; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--under); border-color: var(--under); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--under); }
.btn.small { font-size: .85rem; padding: .3rem .7rem; }
form > .btn { width: 100%; margin-top: .25rem; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.icon-btn { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 .2rem; }

/* ---------- the plate ---------- */
.plate {
  display: inline-flex; align-items: baseline; gap: .35em;
  background: var(--plate); color: #fff; font-weight: 800; letter-spacing: .02em;
  font-variant-numeric: tabular-nums; line-height: 1;
  padding: .38em .62em; border-radius: 4px;
  outline: 1.5px solid rgba(255, 255, 255, .9); outline-offset: -4px;
  white-space: nowrap;
}
.plate small { font-weight: 600; font-size: .7em; opacity: .85; }
.plate-old { background: #6b7685; }
.plate-lg { font-size: 1.35rem; }
.plates { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.plate-btn { background: none; border: 0; padding: 0; cursor: pointer; font-size: .85rem; }
.unit-list { list-style: none; padding: 0; }
.unit-list li { margin-bottom: .5rem; }

/* ---------- balance (resident view) ---------- */
.period { color: var(--muted); }
.balances { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.balance {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; display: flex; flex-direction: column;
}
.balance header { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.25rem; }
.balance header p { margin: 0; }
.unit-desc { font-weight: 600; }
.verdict { font-size: 1.5rem; font-weight: 800; margin: 0; }
.amount {
  font-size: clamp(2.6rem, 9vw, 3.8rem); font-weight: 800; line-height: 1.05; margin: 0 0 .4rem;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.explain { margin-bottom: 1.25rem; }
.balance.over .verdict, .balance.over .amount { color: var(--over); }
.balance.under .verdict, .balance.under .amount { color: var(--under); }
.balance.over, .summary.over { box-shadow: inset 0 6px 0 var(--over); }
.balance.under, .summary.under { box-shadow: inset 0 6px 0 var(--under); }
.details { margin: auto 0 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.details div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); }
.details dd { margin: 0; text-align: right; white-space: nowrap; }
.details .strong dt, .details .strong dd { color: var(--ink); font-weight: 800; }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.5rem; margin-bottom: 1.25rem; }
.summary p { margin: 0; }
.summary-amount { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.summary.over .summary-amount { color: var(--over); }
.summary.under .summary-amount { color: var(--under); }
.sign-note { margin-top: 1.25rem; }

/* ---------- tables ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: .75rem; }
.toolbar input { max-width: 26rem; }
.toolbar select { width: auto; }
.toolbar .hint { margin: 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-weight: 600; color: var(--muted); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.numbers td:nth-child(n+4), .table.numbers th:nth-child(n+4) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 800; border-top: 2px solid var(--line); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--bg); white-space: nowrap; }
.badge.admin { margin-left: .4rem; background: var(--plate); color: #fff; }
.st-pending_approval { background: var(--warn-bg); }
.st-active { background: var(--over-bg); color: var(--over); }
.pending { list-style: none; padding: 0; margin: 0; }
.pending li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; padding: .75rem 0; border-top: 1px solid var(--line); }

/* ---------- building view (admin) ---------- */
/* Each block is drawn like a façade: top floor first, doors left to right. */
.building { display: grid; gap: 1.25rem; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.block.garages { margin-top: 1.25rem; }
.floor { display: grid; grid-template-columns: 4.5rem 1fr; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.floor-label { font-weight: 800; color: var(--muted); font-size: .85rem; padding-top: .3rem; }
.floor.storage { border-top: 2px dashed var(--line); }
.floor-units { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .5rem; align-items: start; }
.tile {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden;
}
.tile-main, .tile-old-link {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  background: none; border: 0; padding: .5rem; cursor: pointer;
}
.tile-main:hover, .tile-old-link:hover { background: var(--bg); }
.tile .plate { font-size: .85rem; margin-bottom: .35rem; }
.tile-old-link { border-top: 1px dashed var(--line); background: var(--bg); }
.tile-old-label { display: block; font-size: .7rem; font-weight: 600; color: var(--muted); }
.tile-users { list-style: none; padding: 0; margin: 0; font-size: .8rem; line-height: 1.3; }
.tile-part p { margin: 0; font-size: .8rem; }
.tile-bal { font-weight: 800; font-variant-numeric: tabular-nums; }
.tile-part .tile-bal { margin-top: .25rem; font-size: .8rem; }
.tile-bal.over { color: var(--over); }
.tile-bal.under { color: var(--under); }

/* ---------- dialogs ---------- */
.dialog {
  border: 0; border-radius: var(--radius); padding: 0; width: min(34rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem); background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgba(10, 20, 35, .35);
}
.dialog.wide { width: min(52rem, calc(100vw - 1.5rem)); }
.dialog::backdrop { background: rgba(15, 25, 40, .45); }
.dialog header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.dialog header h2 { margin: 0; font-size: 1.15rem; }
.dialog-body { padding: 1.25rem; overflow-y: auto; max-height: calc(100vh - 11rem); }
.dialog footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--line); border-radius: 999px; padding: .15rem .25rem .15rem .4rem; font-size: .85rem; }
.chip .plate { font-size: .75rem; }
.chip-x { background: none; border: 0; cursor: pointer; font-size: 1.1rem; line-height: 1; color: var(--muted); padding: 0 .3rem; }
.chips select { width: auto; max-width: 100%; font-size: .85rem; padding: .3rem .5rem; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: .5rem; }
.danger-zone .btn { margin: .5rem .5rem 0 0; }

/* ---------- upload ---------- */
.dropzone {
  display: flex; flex-direction: column; gap: .3rem; align-items: flex-start;
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.25rem; cursor: pointer;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone input { margin-top: .5rem; font: inherit; font-size: .85rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem 1.5rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.issues { display: grid; gap: .75rem; margin-bottom: 1rem; }
.issue { background: var(--warn-bg); border-radius: var(--radius); padding: .8rem 1rem; }
.issue h3 { margin: 0 0 .3rem; }
.compact { margin: .5rem 0 0; padding-left: 1.2rem; }
.compact li { margin-bottom: .3rem; }
details summary { cursor: pointer; font-weight: 600; margin: .5rem 0; }
.tabs { display: flex; gap: .3rem; margin: .75rem 0; }
.tab { font: inherit; font-size: .9rem; background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .25rem .8rem; cursor: pointer; }
.tab[aria-selected='true'] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.mail-preview {
  white-space: pre-wrap; font-family: inherit; font-size: .9rem; background: var(--bg);
  border-radius: var(--radius); padding: 1rem; margin: 0; min-height: 12rem;
}
.progress-box progress { width: 100%; height: .8rem; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 100; width: min(30rem, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: var(--surface); padding: .7rem 1rem; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.toast.error { background: var(--under); color: #fff; }

@media (max-width: 40rem) {
  html { font-size: 106.25%; }
  main { padding: 1.25rem .9rem 3rem; }
  .card, .balance { padding: 1.1rem; }
  .row3 { grid-template-columns: 1fr 1fr 1fr; gap: 0 .5rem; }
  .balance header { flex-direction: column; align-items: flex-start; gap: .6rem; }
  .floor { grid-template-columns: 1fr; gap: .4rem; }
  .floor-units { grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
