/*
 * Lokatrix: design system. Mobile first, jeden plik, bez frameworka.
 * Spokojnie i godnie zaufania: neutralne tło, jeden akcent, trzy kolory statusu (zawsze z tekstem i ikoną).
 */
@layer reset, tokens, base, layout, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; }
  img, svg { display: block; max-width: 100%; }
  button, input, textarea, select { font: inherit; color: inherit; }
  h1, h2, h3, h4, p { margin: 0; }
  ul, ol { margin: 0; padding: 0; }
}

@layer tokens {
  :root {
    /* Lokatrix: jasna, chłodna baza, wiodące indygo, ciepły akcent „zapalonego okna” */
    --bg: #F6F7FB; --surface: #FFFFFF; --surface-2: #F1F3F9; --ink: #141625; --muted: #646A7E; --line: #E3E6F0;
    --accent: #4B3FE0; --accent-strong: #3A2FC4; --accent-soft: #ECEBFD; --on-accent: #FFFFFF;
    --glow: #FFB938;
    --ok: #16805A; --ok-soft: #E3F5EC; --warn: #9A5800; --warn-soft: #FFF2D9; --bad: #C2271E; --bad-soft: #FDE8E6;
    --info: #2F5FD0; --info-soft: #E6EDFC;
    --shadow: 0 1px 2px rgb(20 22 37 / .05), 0 10px 30px rgb(20 22 37 / .07);
    --radius: 18px; --radius-sm: 12px;
    --tabbar: 72px;
    --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    color-scheme: light;
  }
  /* Lokatrix jest jasny. Ciemny wariant tylko na życzenie (data-theme="dark"), nigdy automatycznie z ustawień systemu. */
  :root[data-theme="dark"] {
    & {
      --bg: #0F1018; --surface: #181A26; --surface-2: #1F2230; --ink: #ECEDF3; --muted: #9AA0B4; --line: #2C2F40;
      --accent: #8E86FF; --accent-strong: #A8A2FF; --accent-soft: #24224A; --on-accent: #0E0D24;
      --glow: #FFC75A;
      --ok: #4CC58E; --ok-soft: #143024; --warn: #F0B54D; --warn-soft: #33270F; --bad: #F2796D; --bad-soft: #3A1917;
      --info: #82A6F2; --info-soft: #172338;
      --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 30px rgb(0 0 0 / .3);
      color-scheme: dark;
    }
  }
}

@layer base {
  body {
    background: var(--bg); color: var(--ink);
    font: 16px/1.5 var(--font); font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  }
  a { color: var(--accent); text-underline-offset: 3px; }
  h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); letter-spacing: -.02em; line-height: 1.15; }
  h2 { font-size: 1.25rem; letter-spacing: -.01em; }
  h3 { font-size: 1rem; }
  :focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
  ::selection { background: var(--accent-soft); }
  [hidden] { display: none !important; }
}

@layer layout {
  /* ---------- aplikacja mieszkańca ---------- */
  .app { min-height: 100dvh; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .app-head {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  }
  .app-head .home-name { display: grid; line-height: 1.2; text-decoration: none; color: inherit; }
  .app-head .home-name small { color: var(--muted); font-size: .78rem; font-weight: 600; }
  .app-head .home-name b { font-size: 1.1rem; }
  .app-main { max-width: 560px; margin: 0 auto; padding: 16px 16px 24px; display: grid; gap: 12px; }
  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: grid; justify-items: center; gap: 2px; padding: 8px 0; min-height: 52px; border-radius: 12px;
    color: var(--muted); text-decoration: none; font-size: .74rem; font-weight: 700;
  }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  @media (min-width: 900px) {
    .tabbar { inset: 0 auto 0 0; width: 92px; grid-template-columns: 1fr; grid-auto-rows: min-content; padding-top: 90px; gap: 6px; border-top: 0; border-right: 1px solid var(--line); }
    .app { padding: 0 0 0 92px; }
  }

  /* ---------- biuro ---------- */
  .office { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
  .office-top {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  }
  .office-body { display: grid; grid-template-columns: 1fr; min-width: 0; }
  .office-nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); scrollbar-width: none; }
  .office-nav a {
    display: flex; align-items: center; gap: 8px; white-space: nowrap; padding: 9px 12px; border-radius: 10px;
    color: var(--muted); text-decoration: none; font-weight: 700; font-size: .92rem;
  }
  .office-nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
  .office-nav .count { margin-left: auto; background: var(--accent); color: var(--on-accent); border-radius: 99px; padding: 0 7px; font-size: .72rem; line-height: 1.6; }
  .office-main { padding: 20px 16px 48px; min-width: 0; max-width: 1180px; width: 100%; }
  @media (min-width: 960px) {
    .office-body { grid-template-columns: 232px minmax(0, 1fr); }
    .office-nav { flex-direction: column; overflow: visible; border: 0; border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 61px; height: calc(100dvh - 61px); }
    .office-main { padding: 28px 36px 64px; }
  }

  /* ---------- proste strony (logowanie, wykonawca, plakat) ---------- */
  .simple { min-height: 100dvh; display: grid; place-items: start center; padding: calc(24px + env(safe-area-inset-top)) 16px 40px; }
  .simple-inner { width: min(100%, 460px); display: grid; gap: 14px; }
}

@layer components {
  .brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; color: inherit; text-decoration: none; }
  .logo { width: 34px; height: 34px; flex: none; display: block; }
  .logo svg { width: 100%; height: 100%; }
  .avatar {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: .82rem; border: 0; cursor: pointer;
  }

  .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
  .card.flat { box-shadow: none; }
  .card-title { font-size: .76rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .card-title a { text-transform: none; letter-spacing: 0; font-size: .85rem; }

  /* Stan płatności: bohater ekranu startowego */
  .hero { padding: 22px 20px; display: grid; gap: 4px; }
  .hero .label { font-weight: 800; display: flex; align-items: center; gap: 8px; }
  .hero .amount { font-size: clamp(2.4rem, 2rem + 3vw, 3.2rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 4px 0; }
  .hero .sub { color: var(--muted); font-weight: 600; }
  .hero.paid { background: var(--ok-soft); border-color: transparent; }
  .hero.paid .label { color: var(--ok); }
  .hero.overdue { background: var(--bad-soft); border-color: transparent; }
  .hero.overdue .label { color: var(--bad); }
  .hero .actions { margin-top: 14px; display: grid; gap: 10px; }
  .stamp { margin-top: 10px; color: var(--muted); font-size: .8rem; display: flex; gap: 6px; align-items: center; }

  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 18px;
    border: 0; border-radius: 14px; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 1rem;
    text-decoration: none; cursor: pointer; transition: transform .08s ease, background .15s ease;
  }
  .btn:hover { background: var(--accent-strong); }
  .btn:active { transform: scale(.98); }
  .btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
  .btn.secondary:hover { background: var(--surface-2); }
  .btn.ghost { background: transparent; color: var(--accent); padding-inline: 4px; min-height: 40px; }
  .btn.small { min-height: 38px; padding: 8px 13px; font-size: .9rem; border-radius: 11px; }
  .btn.block { width: 100%; }
  .btn.danger { background: var(--bad); color: #fff; }
  .btn svg { width: 1.15em; height: 1.15em; }
  .btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

  .pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
  .pill.ok { background: var(--ok-soft); color: var(--ok); }
  .pill.warn { background: var(--warn-soft); color: var(--warn); }
  .pill.bad { background: var(--bad-soft); color: var(--bad); }
  .pill.info { background: var(--info-soft); color: var(--info); }
  .pill.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
  .pill svg { width: 1em; height: 1em; }

  .banner { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--warn-soft); }
  .banner.info { background: var(--info-soft); }
  .banner.bad { background: var(--bad-soft); }
  .banner > svg { width: 22px; height: 22px; color: var(--warn); margin-top: 2px; }
  .banner.bad > svg { color: var(--bad); }
  .banner.info > svg { color: var(--info); }
  .banner p { color: var(--muted); font-size: .92rem; }

  .rows > * + * { border-top: 1px solid var(--line); }
  .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; color: inherit; text-decoration: none; }
  .row:first-child { padding-top: 2px; }
  .row:last-child { padding-bottom: 2px; }
  .row .meta { color: var(--muted); font-size: .82rem; }
  .row .main { display: grid; min-width: 0; }
  .row .main b { overflow: hidden; text-overflow: ellipsis; }
  .amount { font-weight: 800; white-space: nowrap; }
  .amount.plus { color: var(--ok); }

  .quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .quick a {
    display: grid; gap: 6px; padding: 16px; min-height: 92px; border-radius: var(--radius); background: var(--surface);
    border: 1px solid var(--line); color: inherit; text-decoration: none; font-weight: 800;
  }
  .quick a svg { width: 24px; height: 24px; color: var(--accent); }
  .quick a span { color: var(--muted); font-weight: 600; font-size: .85rem; }

  /* „Paragon miesiąca” */
  details.bill { border-radius: var(--radius-sm); }
  details.bill > summary { list-style: none; cursor: pointer; }
  details.bill > summary::-webkit-details-marker { display: none; }
  details.bill[open] > summary .chev { transform: rotate(180deg); }
  .chev { transition: transform .2s; color: var(--muted); }
  .receipt { background: var(--surface-2); border-radius: var(--radius-sm); padding: 6px 14px; margin: 4px 0 10px; }
  .receipt .line { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 9px 0; border-top: 1px dashed var(--line); font-size: .94rem; }
  .receipt .line:first-child { border-top: 0; }
  .receipt .line small { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; }
  .receipt .line .why { grid-column: 1 / -1; color: var(--info); font-size: .8rem; }
  .receipt .total { font-weight: 800; }
  .month { font-size: .78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 8px 4px -4px; }
  .split { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin: 10px 0 6px; background: var(--line); }
  .legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); }
  .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

  /* Arkusz od dołu (np. „Zapłać”) — natywny <dialog> */
  dialog.sheet {
    border: 0; padding: 0; margin: auto auto 0; width: min(100%, 520px); max-height: 92dvh; border-radius: 24px 24px 0 0;
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  }
  dialog.sheet::backdrop { background: rgb(8 10 12 / .45); }
  dialog.sheet[open] { animation: rise .22s ease-out; }
  @media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 24px; } }
  .sheet-body { padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 12px; overflow: auto; }
  .grip { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 6px; }
  @keyframes rise { from { transform: translateY(24px); opacity: .5; } to { transform: none; opacity: 1; } }

  .qr { width: 196px; aspect-ratio: 1; margin: 4px auto; padding: 12px; background: #fff; border-radius: 16px; border: 1px solid var(--line); }
  .qr svg { width: 100%; height: 100%; }
  .field-copy { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
  .field-copy small { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; }
  .field-copy b { word-break: break-word; }
  .copy { flex: none; border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: 6px 11px; font-size: .82rem; font-weight: 800; cursor: pointer; }
  .copy[data-copied] { color: var(--ok); border-color: var(--ok); }

  /* Formularze */
  .form { display: grid; gap: 14px; }
  .form label, .label { font-size: .85rem; font-weight: 800; color: var(--muted); display: block; margin-bottom: 6px; }
  .input, .form input[type=text], .form input[type=email], .form input[type=number], .form textarea, .form select, input.input, select.input, textarea.input {
    width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px; background: var(--surface-2); min-height: 48px;
  }
  textarea.input, .form textarea { min-height: 96px; resize: vertical; }
  .input:focus, .form input:focus, .form textarea:focus, .form select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .form .help, .help { color: var(--muted); font-size: .8rem; }
  .form-error, .form ul li { color: var(--bad); font-size: .85rem; list-style: none; }
  .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; color: var(--ink) !important; }
  .check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin-top: 1px; }

  /* Wybór miejsca jako „chipsy” (radio) */
  .chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .chips > div { display: contents; }
  .chips input { position: absolute; opacity: 0; pointer-events: none; }
  .chips label, .chip {
    display: inline-flex; align-items: center; min-height: 42px; padding: 8px 14px; margin: 0; border-radius: 99px; cursor: pointer;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; font-size: .92rem; text-decoration: none;
  }
  .chips input:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
  .chips input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }

  /* Aparat / zdjęcie */
  .camera {
    position: relative; display: grid; place-items: center; gap: 8px; min-height: 220px; border-radius: var(--radius); cursor: pointer; overflow: hidden;
    background: #111417; color: #aab0b6; text-align: center; font-weight: 700;
  }
  .camera svg { width: 42px; height: 42px; color: #fff; }
  .camera input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
  .camera img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .photo { width: 100%; max-height: 280px; object-fit: cover; border-radius: var(--radius-sm); }

  /* Czat */
  .chat { display: grid; gap: 10px; }
  .bubble { max-width: 88%; padding: 11px 14px; border-radius: 18px; font-size: .97rem; white-space: pre-line; }
  .bubble.resident { justify-self: end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
  .bubble.assistant, .bubble.office { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
  .bubble .who { display: flex; gap: 6px; align-items: center; font-size: .74rem; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
  .bubble .src { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); font-size: .74rem; color: var(--muted); }
  .composer {
    position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px 0;
    background: linear-gradient(transparent, var(--bg) 30%);
  }
  .composer input { flex: 1; min-width: 0; }
  .ai-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; background: var(--info-soft); color: var(--info); font-size: .72rem; font-weight: 800; }
  .ai-tag svg { width: .95em; height: .95em; }

  /* Oś statusu usterki */
  .timeline { list-style: none; display: grid; }
  .timeline li { position: relative; padding: 0 0 16px 28px; }
  .timeline li::before { content: ""; position: absolute; left: 5px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
  .timeline li::after { content: ""; position: absolute; left: 10.5px; top: 19px; bottom: 0; width: 1px; background: var(--line); }
  .timeline li:last-child::after { display: none; }
  .timeline li.done::before { background: var(--ok); }
  .timeline li.now::before { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
  .timeline small { display: block; color: var(--muted); font-size: .82rem; }

  /* Flash */
  .flashes { display: grid; gap: 8px; }
  .flash { padding: 12px 14px; border-radius: 14px; font-weight: 700; font-size: .94rem; display: flex; gap: 10px; align-items: center; animation: rise .25s ease-out; }
  .flash.ok { background: var(--ok-soft); color: var(--ok); }
  .flash.info { background: var(--info-soft); color: var(--info); }
  .flash.error { background: var(--bad-soft); color: var(--bad); }

  /* Biuro: kolejka wyjątków */
  .page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
  .page-head p { color: var(--muted); margin-top: 4px; }
  .exceptions { display: grid; gap: 10px; }
  .exception {
    display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 14px; padding: 14px 16px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none;
  }
  .exception .ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
  .exception .ico svg { width: 22px; height: 22px; }
  .exception b { display: block; }
  .exception div span { display: block; color: var(--muted); font-size: .9rem; }
  .exception .go { color: var(--on-accent); }
  .exception .go { grid-column: 1 / -1; justify-self: start; }
  .exception.hot { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
  .exception.hot .ico { color: var(--bad); background: var(--bad-soft); }
  .exception.done { opacity: .6; }
  .exception.done .ico { color: var(--ok); background: var(--ok-soft); }
  @media (min-width: 720px) { .exception { grid-template-columns: 44px minmax(0, 1fr) auto; } .exception .go { grid-column: auto; } }
  .autopilot { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 14px 16px; margin-top: 16px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); font-weight: 800; }
  .autopilot span { color: var(--ink); font-weight: 600; }

  .kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
  @media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
  .kpi { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
  .kpi small { display: block; color: var(--muted); font-weight: 700; font-size: .78rem; }
  .kpi b { font-size: 1.3rem; }

  .tx { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
  .tx[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .tx-head { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 12px 16px; background: var(--surface-2); }
  .tx-head .amount { color: var(--ok); font-size: 1.1rem; grid-row: span 2; align-self: center; }
  .tx-head small { color: var(--muted); }
  .candidate { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); }
  .candidate small { display: block; color: var(--muted); font-size: .82rem; }
  .candidate form { display: flex; gap: 8px; align-items: center; }
  .confidence { font-weight: 800; font-size: .85rem; }
  .kbd { font: 700 .72rem var(--font); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--surface); color: var(--muted); }

  .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
  .table th { text-align: left; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
  .table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
  .table tr:last-child td { border-bottom: 0; }
  .table a { color: inherit; font-weight: 700; }

  .group { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .group > svg { width: 22px; height: 22px; color: var(--ok); }
  .group.anomaly { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
  .group.anomaly > svg { color: var(--warn); }
  .group ul { grid-column: 2; list-style: none; color: var(--muted); font-size: .88rem; display: grid; gap: 4px; margin-top: 2px; }
  .group > summary { list-style: none; }

  .two-col { display: grid; gap: 16px; }
  @media (min-width: 960px) { .two-col { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
  .three-col { display: grid; gap: 16px; }
  @media (min-width: 1100px) { .three-col { grid-template-columns: 260px minmax(0, 1fr) 260px; align-items: start; } }

  .search { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 520px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; }
  .search input { border: 0; background: transparent; padding: 10px 0; min-height: 42px; width: 100%; outline: 0; }
  .search svg { color: var(--muted); flex: none; }
  .threads a { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
  .threads a[aria-current="true"] { background: var(--accent-soft); }
  .threads small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .empty { text-align: center; padding: 36px 16px; display: grid; gap: 6px; justify-items: center; color: var(--muted); }
  .empty svg { width: 40px; height: 40px; color: var(--ok); }
  .empty b { color: var(--ink); font-size: 1.05rem; }

  .demo-users { display: grid; gap: 8px; }
  .demo-users a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: inherit; text-decoration: none; }
  .demo-users small { color: var(--muted); }

  .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2s infinite; display: inline-block; }
  @keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
  @media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
}

@layer utilities {
  .muted { color: var(--muted); }
  .small { font-size: .86rem; }
  .center { text-align: center; }
  .stack { display: grid; gap: 12px; }
  .stack-sm { display: grid; gap: 6px; }
  .between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .nowrap { white-space: nowrap; }
  .mt { margin-top: 12px; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- druk: listy, plakat, zaświadczenie (A4) ---------- */
@media print {
  @page { size: A4; margin: 16mm; }
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
  .page { break-after: page; }
}
.print { background: #fff; color: #111; }
.print .page { max-width: 760px; margin: 0 auto; padding: 32px; min-height: 100vh; display: grid; align-content: start; gap: 18px; }
.print .toolbar { position: sticky; top: 0; display: flex; justify-content: center; gap: 10px; padding: 12px; background: #f3f1ec; border-bottom: 1px solid #ddd; }
.print .qr-big { width: 260px; margin: 8px auto; }
.print .qr-big svg { width: 100%; height: auto; }
.print .code { font: 800 2rem/1 var(--font); letter-spacing: .12em; text-align: center; }
.print h1 { font-size: 2.2rem; }
.print .poster-title { font-size: 3.4rem; line-height: 1; letter-spacing: -.03em; text-align: center; }

/* ---------- Wspólnota: podnawigacja, formularze siatkowe, stawki w czasie, głosowanie ---------- */
@layer components {
  .subnav { display: flex; gap: 6px; overflow-x: auto; margin: -4px 0 16px; padding-bottom: 4px; scrollbar-width: thin; }
  .subnav a { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 700; font-size: .85rem; }
  .subnav a svg { width: 16px; height: 16px; flex: none; max-width: none; color: var(--muted); }
  .subnav a[aria-current] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  .subnav a[aria-current] svg { color: var(--accent); }

  .grid-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .grid-form .wide { grid-column: 1 / -1; }
  .grid-form[hidden] { display: none; }
  .num { text-align: right; font-variant-numeric: tabular-nums; }
  .warn-text { color: var(--warn); }
  .ok-text { color: var(--ok); }
  .link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font: inherit; font-size: .85rem; }
  summary.link, summary.btn { list-style: none; cursor: pointer; width: fit-content; }
  summary.link::-webkit-details-marker, summary.btn::-webkit-details-marker { display: none; }
  .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
  .kpis.compact { grid-template-columns: repeat(3, 1fr); }
  .kpis.compact .kpi b { font-size: 1.15rem; }

  .person { padding: 8px 0; border-bottom: 1px dashed var(--line); display: grid; gap: 2px; }
  .person.past { opacity: .6; }

  .ratesgrid th small, .ratesgrid td small { display: block; color: var(--muted); font-weight: 600; font-size: .72rem; }
  .ratesgrid tbody th, .ratesgrid tfoot th { text-align: left; white-space: nowrap; }
  .ratesgrid td.closed, .ratesgrid th.closed { background: var(--surface-2); color: var(--muted); }
  .ratesgrid td.changed, .chip-change { background: var(--accent-soft); color: var(--accent); font-weight: 800; box-shadow: inset 3px 0 0 var(--accent); }
  .chip-change { padding: 1px 8px; border-radius: 6px; box-shadow: none; }
  .ratesgrid tfoot td, .ratesgrid tfoot th { border-top: 2px solid var(--line); }

  .votebar { display: grid; gap: 8px; }
  .votebar-track { position: relative; display: flex; height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
  .votebar-track i { display: block; height: 100%; }
  .votebar-track .for { background: var(--ok); }
  .votebar-track .against { background: var(--bad); }
  .votebar-track .abstain { background: var(--muted); opacity: .5; }
  .votebar-track .half { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; }
  .vote-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .vote-buttons .btn { justify-content: center; }
  .vote-buttons .btn.chosen { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

  .home-switch { position: relative; }
  .home-switch summary { list-style: none; cursor: pointer; }
  .home-switch summary::-webkit-details-marker { display: none; }
  .home-switch summary b { display: inline-flex; align-items: center; gap: 4px; }
  .home-switch .chev { width: 16px; height: 16px; flex: none; }
  .home-switch > .card { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 240px; box-shadow: 0 12px 30px rgb(0 0 0 / .12); }
  .home-switch button.row { background: none; border: 0; text-align: left; cursor: pointer; font: inherit; color: inherit; }
  .home-switch button.row[aria-current] b { color: var(--accent); }

  .ballot { display: flex; gap: 28px; margin: 18px 0; font-size: 1.2rem; font-weight: 800; }
  .ballot i { display: inline-block; width: 24px; height: 24px; border: 2px solid currentColor; border-radius: 4px; margin-right: 10px; vertical-align: middle; }
}

@layer components {
  .map { height: 260px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); z-index: 0; }
  .contacts-edit { display: grid; gap: 8px; }
  .contacts-edit .row-edit { display: grid; grid-template-columns: 1.2fr .8fr 2fr; gap: 8px; }
  @media (max-width: 640px) { .contacts-edit .row-edit { grid-template-columns: 1fr 1fr; } .contacts-edit .row-edit input:last-child { grid-column: 1 / -1; } }
  .phone-list a { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); color: inherit; text-decoration: none; }
  .phone-list a b.tel { color: var(--accent); white-space: nowrap; }
}

@layer components {
  .report h1 { font-size: 1.9rem; margin: 18px 0 2px; }
  .report h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
  .report .letter { margin: 14px 0; padding: 14px 18px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 12px 12px 0; font-size: .98rem; line-height: 1.55; }
  .report-kpis { grid-template-columns: repeat(4, 1fr); }
  .report-kpis .kpi b { font-size: 1.15rem; }
  .report .table td, .report .table th { padding: 5px 8px; }
  .report .bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin: 2px 0; overflow: hidden; }
  .report .bar i { display: block; height: 100%; }
  @media print {
    .print .page.report { min-height: 0; padding: 0; gap: 4px; max-width: none; font-size: 10.5px; break-after: page; }
    .print .page.report:last-child { break-after: auto; }
    .report h1 { font-size: 1.55rem; margin: 6px 0 0; }
    .report h2 { font-size: .8rem; margin: 8px 0 2px; }
    .report .letter { margin: 6px 0; padding: 8px 12px; font-size: 10.5px; line-height: 1.45; }
    .report .kpi { padding: 6px 10px; }
    .report .table td, .report .table th { padding: 1px 6px; font-size: 9.5px; line-height: 1.3; }
    .report .bar { height: 4px; margin: 1px 0; }
    .report p { margin: 0; }
    .report .two-col { gap: 12px; }
  }
}

/* Opłaty: grupy zmian do przejrzenia przed wysyłką */
@layer components {
  .change-group { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
  .change-group > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
  .change-group > summary::-webkit-details-marker { display: none; }
  .change-group .cg-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); flex: none; }
  .change-group .cg-icon svg { width: 20px; height: 20px; }
  .change-group.rate .cg-icon, .change-group.parameter .cg-icon { background: var(--accent-soft); color: var(--accent); }
  .change-group.anomaly { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
  .change-group.anomaly .cg-icon { background: var(--warn-soft); color: var(--warn); }
  .change-group .cg-title { display: grid; gap: 2px; flex: 1; min-width: 0; }
  .change-group .chev { width: 18px; height: 18px; color: var(--muted); transition: transform .15s; flex: none; }
  .change-group[open] .chev { transform: rotate(180deg); }
  .change-group .cg-body { padding: 0 16px 14px; border-top: 1px solid var(--line); padding-top: 12px; }
  .change-group .cg-why { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: .9rem; margin-bottom: 10px; }
  .change-group .cg-why svg { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 1px; }
  .change-group .table-wrap { border: 0; box-shadow: none; }
  .cg-table td, .cg-table th { padding: 8px 10px; }
  .cg-table col.amount { width: 130px; }
  .cg-table col.unit { width: 200px; }
  .table th.num { text-align: right; }
}

@layer components {
  /* zakładki wspólnoty zawijają się na komputerze, na telefonie przewijają w poziomie */
  @media (min-width: 861px) { .subnav.wrap { flex-wrap: wrap; overflow: visible; } }
  .report-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .report-pick .input { width: auto; min-height: 36px; padding: 6px 10px; }
}

/* Skrzynka: lista wątków | rozmowa z odpowiedzią | kontekst lokalu */
@layer components {
  .inbox-top { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; margin-bottom: 14px; }
  .inbox-top h1 { margin: 0; }
  .inbox-top .subnav { margin: 0; padding: 0; }
  .inbox-search { position: relative; min-width: 220px; margin-left: auto; }
  .inbox-search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--muted); }
  .inbox-search .input { padding-left: 36px; min-height: 40px; }
  .subnav .count { margin-left: 2px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: .74rem; line-height: 1.6; }
  .subnav .count.muted { background: var(--surface-2); color: var(--muted); }

  .inbox { display: grid; gap: 16px; grid-template-columns: 300px minmax(0, 1fr) 280px; align-items: start; }
  .inbox-list { padding: 0; overflow: hidden auto; max-height: calc(100dvh - 190px); position: sticky; top: 16px; }
  .inbox-list a { display: grid; gap: 4px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; border-left: 3px solid transparent; }
  .inbox-list a:hover { background: var(--surface-2); }
  .inbox-list a[aria-current="true"] { background: var(--accent-soft); border-left-color: var(--accent); }
  .inbox-list .preview { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .inbox-list .tags { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

  .inbox-thread { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 0; overflow: hidden; height: calc(100dvh - 190px); min-height: 480px; }
  .thread-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
  .thread-head h2 { margin: 0; font-size: 1.15rem; }
  .thread-chat { overflow-y: auto; padding: 18px 18px 16px; display: grid; gap: 10px; align-content: start; background: var(--surface-2); }
  .thread-chat .day { justify-self: center; font-size: .74rem; font-weight: 800; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
  .msg { max-width: 78%; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
  .msg.resident { justify-self: start; border-bottom-left-radius: 4px; }
  .msg.resident.waiting { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); box-shadow: 0 0 0 3px var(--warn-soft); }
  .msg.assistant { justify-self: end; background: var(--accent-soft); border-color: transparent; border-bottom-right-radius: 4px; }
  .msg.office { justify-self: end; background: var(--accent); color: var(--on-accent); border-color: transparent; border-bottom-right-radius: 4px; }
  .msg .who { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .74rem; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
  .msg .who svg { width: 14px; height: 14px; }
  .msg.office .who, .msg.office .who .muted { color: color-mix(in srgb, var(--on-accent) 80%, transparent); }
  .msg .text { white-space: pre-line; line-height: 1.5; }
  .msg .src { margin-top: 6px; padding-top: 6px; border-top: 1px dashed color-mix(in srgb, var(--ink) 15%, transparent); font-size: .72rem; color: var(--muted); }
  .reply-box { display: grid; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); background: var(--surface); }
  .reply-box textarea { min-height: 0; }
  .quick-replies { display: flex; flex-wrap: wrap; gap: 6px; }
  .quick-replies .chip { cursor: pointer; font-size: .8rem; padding: 4px 10px; min-height: 0; }
  .inbox-context { display: grid; gap: 12px; position: sticky; top: 16px; align-items: start; }
  .reply-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .reply-actions .btn:not(.secondary) { flex: none; }

  @media (max-width: 1280px) { .inbox { grid-template-columns: 260px minmax(0, 1fr); } .inbox-context { grid-column: 1 / -1; position: static; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
  @media (max-width: 860px) {
    .inbox { grid-template-columns: 1fr; }
    .inbox-list { position: static; max-height: 260px; }
    .inbox-thread { height: auto; min-height: 0; }
    .thread-chat { max-height: 60dvh; }
    .msg { max-width: 92%; }
  }
}

/* Konto w prawym rogu paska biura */
@layer components {
  .user-menu { position: relative; margin-left: auto; }
  .user-menu > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 4px 4px 10px; border-radius: 999px; }
  .user-menu > summary::-webkit-details-marker { display: none; }
  .user-menu > summary:hover { background: var(--surface-2); }
  .user-menu .who { display: grid; text-align: right; line-height: 1.2; }
  .user-menu .who b { font-size: .9rem; }
  .user-menu .who small { color: var(--muted); font-size: .76rem; }
  .user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 240px; display: grid; gap: 2px; padding: 10px; box-shadow: 0 12px 30px rgb(0 0 0 / .12); }
  .user-menu .menu .small { padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .user-menu .menu a { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: .9rem; }
  .user-menu .menu a:hover { background: var(--surface-2); }
  .user-menu .menu svg { width: 16px; height: 16px; color: var(--muted); }
  @media (max-width: 860px) { .user-menu .who { display: none; } }
}

/* Pasek biura: marka Lokatrix, przełącznik wspólnoty; menu w sekcjach Praca / Wspólnota / Firma */
@layer components {
  .office-top .brand { gap: 10px; }
  .brand-text { display: grid; line-height: 1.1; }
  .brand-text b { font-size: 1.15rem; letter-spacing: -.01em; }
  .brand-text small { font-size: .72rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
  .ctx-switch { position: relative; display: flex; align-items: center; }
  .ctx-switch svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--accent); pointer-events: none; }
  .ctx-switch select { appearance: none; border: 1px solid var(--line); background: var(--accent-soft); color: var(--accent); font: inherit; font-weight: 800; font-size: .9rem; padding: 9px 30px 9px 32px; border-radius: 12px; cursor: pointer; max-width: 220px;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
  .nav-section { display: none; }
  .nav-foot { display: none; }
  @media (min-width: 960px) {
    .nav-section { display: block; padding: 14px 12px 4px; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .nav-section:first-child { padding-top: 0; }
    .office-nav { overflow-y: auto; gap: 2px; }
    .office-nav a { padding: 8px 12px; }
    .nav-foot { display: block; margin-top: auto; padding: 16px 12px 0; font-size: .72rem; color: var(--muted); }
  }
  @media (max-width: 860px) { .ctx-switch select { max-width: 150px; } }
}

@layer components {
  .crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 2px; }
  .crumbs a { color: var(--muted); text-decoration: none; font-weight: 700; }
  .crumbs a:hover { color: var(--accent); }
  .crumbs span { color: var(--ink); font-weight: 700; }
}

@layer components {
  .app-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 18px 0 0; font-size: .74rem; color: var(--muted); }
  .app-foot .logo { width: 16px; height: 16px; }
}

/* Pasek biura na telefonie: logo, przełącznik wspólnoty, lupa, avatar — bez przewijania w bok */
@layer components {
  .office-top > * { min-width: 0; }
  .office-top .brand, .user-menu { flex: none; }
  @media (max-width: 860px) {
    .office-top { gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
    .office-top .brand { margin-right: auto; }
    .office-top .user-menu { margin-left: 0; }
    .ctx-switch { flex: 1 1 100%; min-width: 0; order: 5; }
    .ctx-switch select { max-width: none; width: 100%; padding-right: 26px; text-overflow: ellipsis; }
    .office-top .search { position: relative; flex: none; width: 42px; padding: 0; justify-content: center; }
    .office-top .search .kbd { display: none; }
    /* pole leży niewidoczne na lupie: dotknięcie lupy daje fokus i rozwija wyszukiwarkę na całą szerokość */
    .office-top .search input { position: absolute; inset: 0; opacity: 0; padding: 0 12px; }
    .office-top .search:focus-within { position: absolute; left: 12px; right: 12px; top: 8px; width: auto; z-index: 5; background: var(--surface); padding: 0 12px; justify-content: flex-start; }
    .office-top .search:focus-within input { position: static; opacity: 1; padding: 10px 0; }
  }
}

/* QA: na telefonie nic nie wychodzi poza ekran */
@layer components {
  .two-col > *, .three-col > *, .kpis > * { min-width: 0; }
  .kpis.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-title { overflow-wrap: anywhere; }
  @media (max-width: 640px) {
    .row form.btn-row, .row .btn-row { flex-wrap: wrap; }
  }
  @media screen and (max-width: 760px) {
    .print .page { padding: 16px; min-height: 0; }
    .print h1 { font-size: 1.5rem; overflow-wrap: anywhere; }
    .print .between { flex-wrap: wrap; gap: 6px; }
    .print .table { display: block; overflow-x: auto; }
    .print .toolbar { flex-wrap: wrap; }
  }
}
@layer components {
  .stack > *, .stack-sm > * { min-width: 0; }
  @media screen and (max-width: 760px) { .print .page { overflow-wrap: anywhere; } .print .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
}

@layer components {
  .map .leaflet-control-attribution { background: transparent !important; font-size: 9px; opacity: .45; padding: 0 4px; }
  .map .leaflet-control-attribution a { color: inherit; text-decoration: none; }
}
@layer components { #dane:target { outline: 3px solid var(--accent); outline-offset: 3px; scroll-margin-top: 80px; } }

/* Składniki opłat: lista z akcjami w wierszu */
@layer components {
  .components { margin-bottom: 18px; }
  .comp-list { display: grid; margin-top: 12px; }
  .comp-head, .comp-row { display: grid; grid-template-columns: minmax(160px, 1.4fr) 1fr auto 140px 1.2fr auto; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .comp-head { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 0; }
  .comp-row > span { min-width: 0; display: grid; gap: 2px; }
  .comp-row.off { opacity: .55; }
  .comp-row .actions { display: flex; gap: 6px; justify-content: flex-end; position: relative; }
  .comp-row .chip-change { display: inline-block; margin: 0 4px 2px 0; }
  .comp-row details, .add-component { position: relative; }
  .comp-row details > summary, .add-component > summary { list-style: none; cursor: pointer; }
  .comp-row details > summary::-webkit-details-marker, .add-component > summary::-webkit-details-marker { display: none; }
  .pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; width: min(440px, 92vw); box-shadow: 0 16px 40px rgb(0 0 0 / .14); }
  .pop-foot { position: absolute; right: 0; top: calc(100% + 6px); z-index: 24; }
  .comp-row details[open] .pop + .pop-foot { top: auto; }
  @media (max-width: 900px) {
    .comp-head { display: none; }
    .comp-row { grid-template-columns: 1fr auto; }
    .comp-row > span:nth-child(2), .comp-row > span:nth-child(3) { display: none; }
    .comp-row > span:nth-child(5) { grid-column: 1 / -1; }
    .comp-row .actions { grid-column: 1 / -1; justify-content: flex-start; }
    .pop { left: 0; right: auto; }
  }
}
@layer components { .board-member { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px dashed var(--line); } }
@layer components {
  .file-input { position: relative; display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; min-width: 0; }
  .file-input input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
  .file-input:focus-within .btn { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }
  .file-input .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
}
@layer components {
  .vote-buttons .btn { gap: 6px; }
  .vote-buttons .btn.chosen.vote-for { background: var(--ok); border-color: var(--ok); color: #fff; }
  .vote-buttons .btn.chosen.vote-against { background: var(--bad); border-color: var(--bad); color: #fff; }
  .vote-buttons .btn.chosen.vote-abstain { background: var(--ink); border-color: var(--ink); color: var(--surface); }
  .vote-receipt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--ok-soft); color: var(--ink); }
  .vote-receipt svg { width: 22px; height: 22px; color: var(--ok); flex: none; }
  @media (max-width: 480px) { .vote-buttons { grid-template-columns: 1fr; } }
}

/* Faktury: upuść plik → formularz wypełniony do sprawdzenia */
@layer components {
  .dropzone { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 22px 16px; border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: var(--radius); background: var(--accent-soft); cursor: pointer; transition: background .15s, border-color .15s; }
  .dropzone > svg { width: 34px; height: 34px; color: var(--accent); }
  .dropzone.over { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border-color: var(--accent); }
  .dropzone.busy { opacity: .7; pointer-events: none; }
  .dropzone.done { padding: 12px 16px; grid-auto-flow: column; justify-content: center; align-items: center; }
  .dropzone.done > svg { width: 22px; height: 22px; }
  .dropzone.done .muted { display: none; }
  .read-banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); }
  .read-banner > svg { width: 20px; height: 20px; color: var(--accent); flex: none; margin-top: 2px; }
  .read-banner.warn { background: var(--warn-soft); }
  .read-banner.warn > svg { color: var(--warn); }
  .ai-filled .input:not(:placeholder-shown) { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
}

/* QA: pasek menu biura na telefonie nie rozciąga się na krótkich stronach; odpowiedź w skrzynce mieści się */
@layer components {
  .office-body { align-content: start; }
  @media (max-width: 959px) { .office-nav { align-self: start; } .office-nav a[aria-current] { scroll-margin-inline: 40px; } }
  @media (max-width: 520px) { .reply-actions { flex-direction: column-reverse; align-items: stretch; } .reply-actions .btn { justify-content: center; } }
  /* tabele biura na telefonie: chowamy kolumny pomocnicze, zostaje to, co najważniejsze */
  @media (max-width: 640px) { .table .hide-sm { display: none; } }
}
@layer components {
  .office-contact { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; justify-content: center; }
  .office-contact a { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--accent); text-decoration: none; }
  .office-contact a svg { width: 14px; height: 14px; }
  .row .meta .office-contact { justify-content: flex-start; }
  @media (max-width: 899px) { .tabbar { grid-template-columns: repeat(5, 1fr); } .tabbar a { font-size: .72rem; } }
  .app-head .user-menu { margin-left: 0; }
}
@layer components {
  .app-head > .btn-row { flex-wrap: nowrap; flex: none; }
  .app-head .home-name, .app-head .home-switch { min-width: 0; }
  .app-head .home-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Karta lokalu: przegląd → zakładki, portfel jak historia konta w banku */
@layer components {
  .h1-meta { font-size: .95rem; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
  .print-menu { margin-left: 0; }
  .print-menu > summary { padding: 6px 12px; border-radius: var(--radius-sm); }
  .unit-kpis .kpi { display: grid; gap: 2px; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
  .unit-kpis .kpi:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgb(0 0 0 / .06); }
  .unit-kpis .kpi > span { color: var(--muted); font-size: .82rem; }
  .unit-kpis .kpi.overdue { background: var(--bad-soft); border-color: transparent; }
  .unit-kpis .kpi.overdue b, .unit-kpis .kpi.overdue > span { color: var(--bad); }
  .unit-kpis .kpi.due b { color: var(--warn); }
  .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table-wrap.flat { border: 0; border-radius: 0; background: none; }
  .table.ledger td { padding: 10px 12px; }
  .table.ledger .meta, .table.lines .meta { color: var(--muted); font-size: .8rem; font-weight: 400; }
  .table.ledger .balance { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
  .table.ledger .balance.neg { color: var(--bad); }
  .table.ledger .month-row th { background: var(--surface-2); color: var(--ink); text-transform: none; letter-spacing: 0; font-size: .82rem; padding: 6px 12px; }
  .table.ledger details.bill-lines > summary { list-style: none; cursor: pointer; }
  .table.ledger details.bill-lines > summary::-webkit-details-marker { display: none; }
  .table.ledger details.bill-lines[open] .link { display: none; }
  .table.ledger details.bill-lines .lines { margin-top: 8px; }
  .table.lines { width: 100%; border-collapse: collapse; font-size: .88rem; }
  .table.lines td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
  .table.lines td + td { padding-left: 12px; }
  .table.lines tr.total td { border-bottom: 0; font-weight: 700; }
  .wallet-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
  .wallet-head small, .wallet-sums small { display: block; color: var(--muted); font-weight: 700; font-size: .78rem; }
  .wallet-balance { font-size: clamp(1.8rem, 1.5rem + 1.5vw, 2.4rem); font-weight: 800; letter-spacing: -.02em; color: var(--ok); }
  .wallet-balance.neg { color: var(--bad); }
  .wallet-sums { display: flex; gap: 24px; }
  .wallet-sums b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
  .wallet-sums b.plus { color: var(--ok); }
  .wallet-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; }
  .wallet-filter .grow { flex: 1 1 220px; display: flex; align-items: center; gap: 6px; color: var(--muted); }
  .wallet-filter .grow svg { width: 18px; height: 18px; flex: none; }
  .wallet-filter .input { width: auto; }
  .wallet-filter .grow .input { flex: 1; min-width: 0; }
  .wallet-filter .push { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
  .wallet-filter .push svg { width: 16px; height: 16px; }
  .card.alert { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
  .big-number { font-size: 1.6rem; font-weight: 800; }
  .big-number.bad { color: var(--bad); }
  .big-number small { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); }
  .notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--ink); }
  .notice svg { width: 18px; height: 18px; flex: none; color: var(--warn); margin-top: 1px; }
  .doc-row { padding: 8px 0; border-bottom: 1px dashed var(--line); }
  .show-sm { display: none; }
  @media (max-width: 640px) {
    .show-sm { display: block; }
    td.show-sm { display: table-cell; }
    .wallet-sums { gap: 14px; }
    .wallet-filter .input[type=date] { flex: 1 1 40%; }
  }
}
@layer components {
  .table.ledger td form { display: inline; }
  .table.ledger button.link { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; }
  .table.ledger button.link svg { width: 14px; height: 14px; }
}
@layer components {
  .wallet-filter .grow { flex-basis: 100%; }
  .wallet-filter select.input { flex: 1 1 140px; }
  .wallet-filter .input[type=date] { flex: 0 1 160px; }
}

/* Mieszkaniec i zarząd: marka w nagłówku i w szynie, szeroki układ na komputerze */
@layer components {
  .head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .head-logo .logo svg, .rail-brand .logo svg { width: 34px; height: 34px; }
  .head-logo { flex: none; }
  .head-switch svg { width: 16px; height: 16px; }
  .rail-board { display: none !important; }
  @media (min-width: 900px) {
    .tabbar { padding-top: 84px; }
    .rail-board { display: grid !important; margin-top: 10px; padding-top: 14px !important; border-top: 1px solid var(--line); border-radius: 0 !important; }
    .head-switch { display: none !important; }
  }
  .cols, .col { display: grid; gap: 12px; align-content: start; }
  @media (min-width: 1100px) {
    .app-main.wide { max-width: 1120px; padding: 24px 28px 32px; }
    .cols { grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
    .col { gap: 16px; }
    .side-quick { grid-template-columns: 1fr; }
  }
  .history-more { display: block; text-align: center; padding: 10px; font-weight: 700; }
  /* zarząd */
  .board-head { display: grid; gap: 4px; margin: 4px 0 4px; }
  .board-head h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); letter-spacing: -.03em; }
  .board-head p { color: var(--muted); font-weight: 600; }
  .board-head .who { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 800; font-size: .85rem; }
  .board-head .who svg { width: 16px; height: 16px; }
  .board-kpis .kpi > span { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
  .board-kpis .kpi.bad b { color: var(--bad); }
  .decide { border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); }
  .decide-item + .decide-item { border-top: 1px solid var(--line); padding-top: 14px; }
  .fund-bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
  .fund-bar i { display: block; height: 100%; border-radius: 6px; }
  .all-done { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); font-weight: 700; }
  .all-done svg { width: 20px; height: 20px; flex: none; }
}
@layer components {
  .app-head .home-name b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .head-switch { gap: 6px; }
  @media (max-width: 480px) { .head-switch .lbl { display: none; } .head-switch { padding-inline: 10px; } }
  .phone-list a { gap: 12px; }
  .phone-list a > span { min-width: 0; }
  .phone-list .tel { flex: none; white-space: nowrap; }
}

/* Znak Lokatrix w nagłówku mieszkańca i zarządu; na telefonie lokal w drugim rzędzie */
@layer components {
  .app-head { flex-wrap: wrap; justify-content: flex-start; }
  .app-head .head-brand { flex: none; }
  .app-head .head-left { flex: 1; min-width: 0; padding-left: 16px; margin-left: 4px; border-left: 1px solid var(--line); }
  .app-head > .btn-row { margin-left: auto; }
  .brand .logo svg { width: 36px; height: 36px; }
  @media (max-width: 720px) {
    .app-head { row-gap: 8px; }
    .app-head .head-left { order: 5; flex: 1 1 100%; padding-left: 0; margin-left: 0; border-left: 0; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
  }
}
