/* Chatová osada Brodský – moderní, lehký vzhled bez externích knihoven a fontů (CSP: style-src 'self') */

:root {
  --bg: #f3f7fb;
  --bg-grad: radial-gradient(1200px 500px at 85% -10%, #dff1ff 0%, transparent 60%),
             radial-gradient(900px 400px at -10% 10%, #e3fbf6 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --text: #0f1e2e;
  --muted: #5f6f82;
  --line: #e3eaf2;
  --primary: #0b6fbf;
  --primary-2: #0ea5e9;
  --primary-ink: #ffffff;
  --accent: #14b8a6;
  --ok: #0f9d6b;  --ok-bg: #e3f7ef;
  --warn: #b26a00; --warn-bg: #fff3dc;
  --err: #c2362f; --err-bg: #fde8e7;
  --info: #0b6fbf; --info-bg: #e4f1fc;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(16, 40, 70, .05), 0 8px 24px -12px rgba(16, 40, 70, .18);
  --shadow-hover: 0 2px 4px rgba(16, 40, 70, .06), 0 18px 36px -16px rgba(16, 40, 70, .28);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1420;
    --bg-grad: radial-gradient(1200px 500px at 85% -10%, rgba(14,165,233,.16) 0%, transparent 60%),
               radial-gradient(900px 400px at -10% 10%, rgba(20,184,166,.10) 0%, transparent 55%);
    --surface: #111d2c;
    --surface-2: #0f1a28;
    --text: #e6eef7;
    --muted: #93a4b8;
    --line: #1f2f43;
    --primary: #3aa0f0;
    --primary-2: #38bdf8;
    --ok: #34d399;  --ok-bg: rgba(52,211,153,.12);
    --warn: #fbbf24; --warn-bg: rgba(251,191,36,.12);
    --err: #f87171; --err-bg: rgba(248,113,113,.12);
    --info: #60b4f5; --info-bg: rgba(96,180,245,.12);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px -14px rgba(0,0,0,.6);
    --shadow-hover: 0 2px 4px rgba(0,0,0,.35), 0 18px 36px -16px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--text);
  background: var(--bg-grad), var(--bg); background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .6rem; }
h1 { font-size: clamp(1.55rem, 1.2rem + 1.4vw, 2.1rem); font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 .8rem; }
svg { width: 1.15em; height: 1.15em; fill: currentColor; flex: none; }
.sprite { display: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.break { word-break: break-all; font-size: .8rem; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary-2) 55%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Horní lišta ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1120px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.05rem; letter-spacing: -.01em; }
.brand-text small { color: var(--muted); font-size: .75rem; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 70%, transparent);
}
.brand-mark-lg { width: 64px; height: 64px; border-radius: 20px; font-size: 1.8rem; margin-bottom: 1rem; }
.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav a {
  display: flex; align-items: center; gap: .45rem; padding: .5rem .8rem; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: .93rem; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.icon-btn:hover { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.logout { margin: 0; }

/* ---------- Stránka ---------- */
.page { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.page-auth { display: grid; place-items: center; }
.narrow { max-width: 560px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: .5rem 0 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.back { display: inline-block; color: var(--muted); font-size: .9rem; font-weight: 600; margin-bottom: .35rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--muted); margin-bottom: .35rem; display: flex; align-items: center; gap: .35rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem 2rem; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  padding: 2rem 2rem 2.6rem; margin-bottom: 1.5rem; border-radius: calc(var(--radius) + 6px); color: #fff;
  background: linear-gradient(120deg, #0b5fa8 0%, #0b6fbf 35%, #0ea5e9 75%, #14b8a6 120%);
  box-shadow: 0 20px 40px -24px rgba(11, 95, 168, .7);
}
.hero h1 { color: #fff; margin-bottom: .4rem; }
.hero .eyebrow { color: rgba(255,255,255,.8); }
.hero .lead { color: rgba(255,255,255,.88); max-width: 46ch; margin: 0; }
.hero-wave { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 46px; z-index: -1; fill: rgba(255,255,255,.12); }

/* ---------- Karty a mřížky ---------- */
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-chaty { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.stack { display: grid; gap: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.35rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.grid > .card, .stack > .card { margin-bottom: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .9rem; }
.card-title h2 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-title h2 svg { color: var(--primary); }
.card-link { display: flex; flex-direction: column; color: var(--text); transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
.card-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); }
.card-more { margin-top: auto; padding-top: .8rem; display: flex; align-items: center; gap: .25rem; color: var(--primary); font-weight: 600; font-size: .9rem; }
.empty { text-align: center; padding: 2.5rem 1.5rem; }
.link { font-weight: 600; font-size: .9rem; }

.chata-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.chata-no { font-weight: 750; font-size: 1.1rem; }
.stat { display: flex; align-items: baseline; gap: .35rem; margin: .2rem 0 .15rem; }
.stat-num { font-size: 2.2rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-unit { color: var(--muted); font-weight: 600; }
.pending { color: var(--info); font-weight: 600; }
.due { margin: .6rem 0 0; padding: .55rem .75rem; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn); font-size: .92rem; }

/* ---------- Odznaky, upozornění ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge-lg { font-size: .9rem; padding: .35rem .85rem; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-info { background: var(--info-bg); color: var(--info); }
a.badge:hover { text-decoration: none; filter: brightness(.96); }
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .93rem; }
.alert-error { background: var(--err-bg); color: var(--err); }
.toasts { display: grid; gap: .5rem; margin-bottom: 1rem; }
.toast { padding: .85rem 1.1rem; border-radius: var(--radius-sm); background: var(--info-bg); color: var(--info); font-weight: 600; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); animation: slide .35s ease; }
.toast-success { background: var(--ok-bg); color: var(--ok); }
.toast-warning { background: var(--warn-bg); color: var(--warn); }
.toast-error { background: var(--err-bg); color: var(--err); }
@keyframes slide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Tlačítka ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.15rem; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 650; line-height: 1.2; transition: transform .1s, box-shadow .15s, filter .15s, background .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: var(--primary-ink); background: linear-gradient(135deg, var(--primary-2), var(--primary)); box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--primary) 80%, transparent); }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 12px 24px -12px color-mix(in srgb, var(--primary) 90%, transparent); }
.btn-light { background: #fff; color: #0b5fa8; box-shadow: 0 10px 24px -12px rgba(0,0,0,.45); }
.btn-light:hover { filter: brightness(.97); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.btn-lg { padding: .9rem 1.4rem; font-size: 1.05rem; border-radius: 14px; }
.btn-block { width: 100%; margin-top: .4rem; }

/* ---------- Formuláře ---------- */
.form { display: grid; gap: .2rem; }
.field { margin-bottom: .85rem; }
.field > label { display: block; font-weight: 650; font-size: .92rem; margin-bottom: .35rem; }
.field input:not([type=checkbox]):not([type=file]), .field select, .field textarea {
  width: 100%; padding: .75rem .9rem; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; background: var(--surface); border-color: var(--primary-2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-2) 18%, transparent);
}
.field input[type=number] { font-family: var(--num); font-size: 1.25rem; letter-spacing: .02em; }
.field input[type=file] {
  width: 100%; padding: 1.1rem; border: 2px dashed var(--line); border-radius: 14px; background: var(--surface-2);
  color: var(--muted); font: inherit; cursor: pointer;
}
.field input[type=file]::file-selector-button {
  margin-right: .9rem; padding: .55rem 1rem; border: 0; border-radius: 10px; cursor: pointer;
  background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font: inherit; font-weight: 650;
}
.field-check label { display: flex; align-items: flex-start; gap: .6rem; font-weight: 500; cursor: pointer; }
.field-check input { width: 1.15rem; height: 1.15rem; margin-top: .18rem; accent-color: var(--primary); }
.help { color: var(--muted); font-size: .84rem; margin: .35rem 0 0; }
.help ul { margin: .2rem 0 0; padding-left: 1.1rem; }
.err { color: var(--err); font-size: .86rem; font-weight: 600; margin: .35rem 0 0; }
.has-error input, .has-error select { border-color: var(--err) !important; }
.steps { margin: 0 0 1.2rem; padding: 0; list-style: none; counter-reset: s; display: grid; gap: .55rem; }
.steps li { counter-increment: s; display: flex; gap: .7rem; align-items: flex-start; color: var(--muted); font-size: .94rem; }
.steps li::before {
  content: counter(s); flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 750; font-size: .85rem;
}

/* ---------- Tabulky ---------- */
.table-wrap { overflow-x: auto; margin: 0 -.4rem; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: .5rem .4rem; border-bottom: 1px solid var(--line); }
.table td { padding: .7rem .4rem; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Graf ---------- */
.chart { width: 100%; height: 190px; display: block; }
.chart-bar { fill: var(--primary-2); opacity: .9; transition: opacity .15s; }
.chart-bar:hover { opacity: 1; fill: var(--primary); }
.chart-axis { stroke: var(--line); stroke-width: .6; vector-effect: non-scaling-stroke; }
.chart-labels { display: flex; margin-top: .3rem; }
.chart-labels span { flex: 1; text-align: center; font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; }
.chart-labels strong { color: var(--text); font-size: .85rem; font-variant-numeric: tabular-nums; }

/* ---------- Vyúčtování a QR ---------- */
.bill { margin: 0 0 1rem; display: grid; }
.bill > div { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.bill dt { color: var(--muted); }
.bill dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.bill-total { border-bottom: 0 !important; padding-top: .9rem !important; }
.bill-total dt { color: var(--text); font-weight: 700; }
.bill-total dd { font-size: 1.5rem; font-weight: 800; color: var(--primary); letter-spacing: -.02em; }
.qr { background: #fff; border-radius: 14px; padding: .6rem; width: 220px; max-width: 100%; margin: 0 auto 1rem; border: 1px solid var(--line); }
.qr svg { width: 100%; height: auto; display: block; }
.qr-small { width: 200px; }
.pay-info { margin: 0 0 .8rem; display: grid; gap: .35rem; font-size: .92rem; }
.pay-info > div { display: flex; justify-content: space-between; gap: 1rem; }
.pay-info dt { color: var(--muted); }
.pay-info dd { margin: 0; font-weight: 650; font-family: var(--num); font-size: .88rem; }

/* ---------- Termíny, nástěnka, dokumenty ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.timeline li { display: flex; gap: .9rem; align-items: center; }
.tl-date {
  flex: none; width: 58px; padding: .4rem 0; border-radius: 12px; text-align: center; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: color-mix(in srgb, var(--accent) 80%, var(--text));
}
.tl-day { font-weight: 800; font-size: .98rem; line-height: 1.1; }
.tl-month { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.tl-body { display: flex; flex-direction: column; line-height: 1.35; }
.tl-body .muted { font-size: .85rem; }
.post-row { display: flex; gap: .9rem; padding: .6rem .5rem; margin: 0 -.5rem; border-radius: 10px; color: var(--text); }
.post-row:hover { background: var(--surface-2); text-decoration: none; }
.post-date { flex: none; width: 3.2rem; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; padding-top: .1rem; }
.post-title { font-weight: 600; }
.post-title .pin { vertical-align: -.1em; margin-right: .3rem; }
.pin { color: var(--accent); width: 1em; height: 1em; }
.post h2 a { color: var(--text); }
.post-pinned { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.prose { color: color-mix(in srgb, var(--text) 88%, var(--muted)); }
.prose p:last-child { margin-bottom: 0; }
.group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.2rem 0 .5rem; }
.group-title:first-child { margin-top: 0; }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.files a { display: flex; align-items: center; gap: .9rem; padding: .7rem .8rem; border-radius: 12px; border: 1px solid var(--line); color: var(--text); background: var(--surface-2); transition: border-color .15s, transform .15s; }
.files a:hover { text-decoration: none; border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); transform: translateX(2px); }
.file-ico { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; font-size: .68rem; font-weight: 800; letter-spacing: .04em; color: #fff; background: linear-gradient(135deg, var(--primary-2), var(--primary)); }
.file-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.file-body .muted { font-size: .85rem; }
.file-date { font-size: .82rem; white-space: nowrap; }

/* ---------- Přihlášení ---------- */
.auth-wrap { width: 100%; max-width: 920px; display: grid; grid-template-columns: 1fr 420px; gap: 2.5rem; align-items: center; }
.auth-side h1 { font-size: clamp(2rem, 1.5rem + 2vw, 2.8rem); }
.auth-side p { color: var(--muted); font-size: 1.1rem; max-width: 34ch; }
.auth-card { padding: 1.8rem; margin: 0; }
.auth-links { margin: 1rem 0 .6rem; text-align: center; font-weight: 600; font-size: .92rem; }
body.auth .footer { padding-top: 0; }

/* ---------- Mobil: spodní lišta jako v aplikaci ---------- */
@media (max-width: 860px) {
  .grid-main { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; gap: 1.2rem; text-align: center; }
  .auth-side p { margin: 0 auto; }
  .auth-side .brand-mark-lg { margin: 0 auto 1rem; }
}
@media (max-width: 760px) {
  .brand-text small { display: none; }
  /* backdrop-filter by z lišty udělal containing block a fixní spodní menu by se lepilo nahoru */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
  .topbar-in { justify-content: space-between; }
  .nav {
    position: fixed; z-index: 30; left: .6rem; right: .6rem; bottom: calc(.6rem + env(safe-area-inset-bottom));
    margin: 0; padding: .35rem; justify-content: space-around; gap: 0;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 12px 30px -12px rgba(0,0,0,.35);
  }
  .nav a { flex: 1; flex-direction: column; gap: .15rem; padding: .45rem .2rem; font-size: .68rem; border-radius: 14px; }
  .nav a svg { width: 1.35rem; height: 1.35rem; }
  .nav-admin { display: none !important; }
  .page { padding: 1rem .9rem 6.5rem; }
  .hero { padding: 1.5rem 1.3rem 2.2rem; }
  .hero .btn { width: 100%; }
  .card { padding: 1.15rem 1.1rem; }
  .footer { padding-bottom: 6.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Soukromé soubory správce */
.soubory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.soubor { position: relative; display: grid; gap: .25rem; align-content: start; padding: .5rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.soubor:has(input:checked) { border-color: var(--primary); outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.soubor input { position: absolute; top: .9rem; left: .9rem; width: 1.2rem; height: 1.2rem; z-index: 1; }
.soubor-nahled { display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 8px; background: var(--surface); }
.soubor-nahled img { width: 100%; height: 100%; object-fit: cover; }
.soubor-nazev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
