:root {
  --side-w: 68px;
  --badge-h: 56px; /* Netlify "Powered by" badge alatt hagyott hely */
  --bg: #f6f3ec;
  --card: #ffffff;
  --ink: #26301f;
  --muted: #6b7360;
  --line: #e3ddcd;
  --brand: #2f5d3a;
  --brand-ink: #ffffff;
  --accent: #b5833a;
  --bad: #b3261e;
  --warn: #a8650b;
  --bad-bg: #fbe4e1;
  --warn-bg: #fdefd2;
  --radius: 14px;
  --nav-h: 64px;
}
/* Sötét téma: a rendszerbeállítás szerint, és ha a megjelenítő kifejezetten sötétet kér (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161a14;
    --card: #20261c;
    --ink: #ecebe2;
    --muted: #9aa38f;
    --line: #333b2d;
    --brand: #5c9468;
    --brand-ink: #0f160d;
    --accent: #d4a45a;
    --bad: #ff8a80;
    --warn: #f2b45c;
    --bad-bg: #3b1f1c;
    --warn-bg: #3a2c12;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161a14;
  --card: #20261c;
  --ink: #ecebe2;
  --muted: #9aa38f;
  --line: #333b2d;
  --brand: #5c9468;
  --brand-ink: #0f160d;
  --accent: #d4a45a;
  --bad: #ff8a80;
  --warn: #f2b45c;
  --bad-bg: #3b1f1c;
  --warn-bg: #3a2c12;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
h1 { font-size: 1.5rem; margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
a { color: var(--brand); }
p { margin: .3rem 0 .6rem; }

/* ---- Szerkezet ---- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem; padding-top: calc(.7rem + env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.top .stable { opacity: .85; font-size: .9rem; margin-left: auto; }
#view { padding: 1rem; padding-bottom: calc(var(--badge-h) + 1.5rem + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
header.top, #view { margin-left: calc(var(--side-w) + env(safe-area-inset-left)); }
@media (min-width: 900px) { #view { margin-left: calc(var(--side-w) + env(safe-area-inset-left) + max(0px, (100vw - var(--side-w) - 720px) / 2)); } }
.bottom {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 5; width: var(--side-w);
  display: flex; flex-direction: column; gap: 0; overflow-x: hidden; overflow-y: auto;
  background: var(--card); border-right: 1px solid var(--line);
  padding: 56px 0 calc(var(--badge-h) + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  box-sizing: content-box;
}
.bottom a {
  flex: 0 0 auto; min-height: 62px; width: 100%; box-sizing: border-box; padding: .3rem 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .62rem; line-height: 1.15; text-align: center; hyphens: auto; overflow-wrap: anywhere;
  color: var(--muted); text-decoration: none;
}
.bottom a .ico { font-size: 1.35rem; line-height: 1; }
.bottom a.on { color: var(--brand); font-weight: 600; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
.auth h1 { text-align: center; }
.loading { color: var(--muted); text-align: center; padding: 2rem 0; }

/* ---- Elemek ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .4rem; }
.page-head h1 { margin: 0; }
.back { display: inline-block; margin-bottom: .4rem; text-decoration: none; font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
.list { display: flex; flex-direction: column; gap: .5rem; margin: .8rem 0; }
.row { display: flex; align-items: center; gap: .7rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; }
.card .row { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding-left: 0; padding-right: 0; }
.card .row:last-child { border-bottom: 0; }
.link-row { color: inherit; text-decoration: none; }
.grow { flex: 1; min-width: 0; }
.ico { font-size: 1.4rem; width: 1.8rem; text-align: center; flex: none; }
.avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; flex: none; }
.muted { color: var(--muted); }
.big { font-size: 1.6rem; font-weight: 700; margin: .2rem 0 .5rem; }
input.inline { width: 5.2rem; padding: .45rem .5rem; text-align: right; }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; word-break: break-word; }
.err { color: var(--bad); white-space: pre-wrap; font-size: .9rem; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: .7rem .9rem; font-size: .9rem; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 99px; background: var(--line); color: var(--ink); font-size: .78rem; white-space: nowrap; }
.top .pill { background: rgba(255,255,255,.2); color: inherit; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.check { display: flex; align-items: center; gap: .4rem; margin: .6rem 0; color: var(--muted); font-size: .9rem; }
.check input { width: auto; }

/* ---- Űrlap ---- */
.field { display: block; margin-bottom: .8rem; }
.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit;
  padding: .65rem .75rem; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; }
textarea { resize: vertical; margin-bottom: .6rem; }
input.uncertain, select.uncertain { background: var(--warn-bg); border-color: var(--warn); }

/* ---- Gombok ---- */
button, .btn {
  font: inherit; cursor: pointer; text-decoration: none; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .65rem 1rem; border-radius: 10px; border: 1px solid transparent; min-height: 44px;
}
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--brand); color: var(--brand-ink); }
.secondary { background: transparent; color: var(--brand); border-color: var(--brand); }
.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.ghost { background: transparent; color: var(--muted); padding: .4rem .6rem; min-height: 36px; }
.link { background: transparent; color: var(--brand); width: 100%; margin-top: .4rem; }
.btn.small { min-height: 36px; padding: .3rem .8rem; font-size: .85rem; }
.actions.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: .5rem; }
.actions.tiles .btn { flex-direction: column; gap: .15rem; min-height: 56px; padding: .4rem .3rem; text-align: center; line-height: 1.15; font-size: .8rem; white-space: normal; overflow-wrap: anywhere; }
.actions.tiles .btn .ico { font-size: 1.2rem; line-height: 1; }
form > .primary { width: 100%; }
.card > .primary, .card > .secondary { margin-top: .2rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .8rem; }
.chip { min-height: 32px; padding: .2rem .7rem; font-size: .85rem; background: var(--bg); border-color: var(--line); color: var(--ink); border-radius: 99px; }

/* ---- Fülek ---- */
.tabs { display: flex; gap: .3rem; overflow-x: auto; margin: 0 0 .9rem; border-bottom: 1px solid var(--line); }
.tab { background: transparent; color: var(--muted); border-radius: 0; border-bottom: 3px solid transparent; padding: .6rem .8rem; white-space: nowrap; }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ---- Fotó ---- */
.photo { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.photo img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius); }
.photo-empty { width: 96px; height: 96px; border-radius: var(--radius); background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 2.4rem; font-weight: 700; }

/* ---- Alsó lap és értesítés ---- */
.sheet-back { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; background: var(--card); border-radius: 20px 20px 0 0; padding: 1rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.preview { width: 100%; border-radius: 10px; }
.pdf-frame { width: 100%; height: 60vh; border: 1px solid var(--line, #ddd); border-radius: 10px; margin-bottom: 12px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--badge-h) + 1rem + env(safe-area-inset-bottom)); z-index: 30; background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 99px; font-size: .9rem; max-width: 90vw; }

/* ---- Pénzügyek ---- */
.pos { color: var(--brand); }
.neg { color: var(--bad); }
.nowrap { white-space: nowrap; }
.tap { cursor: pointer; }
.danger.wide { width: 100%; margin-top: .6rem; }
.bar-row { margin: .35rem 0; }
.bar { height: 6px; border-radius: 3px; background: var(--line); }
.bar > div { height: 100%; border-radius: 3px; background: var(--accent); }

/* ---- HR és taskok ---- */
.quick { display: flex; gap: .5rem; margin: 0 0 .8rem; }
.quick input { flex: 1; min-width: 0; }
.check-btn { background: transparent; color: var(--brand); font-size: 1.5rem; padding: 0 .3rem; min-height: 44px; min-width: 44px; line-height: 1; }

/* ---- Csapat és jogosultságok ---- */
.perm-sel { flex: none; width: 11.5rem; }
.perm-sel select { padding: .45rem .5rem; font-size: .9rem; }
.btn.wide, button.wide { width: 100%; margin-top: .6rem; }
.viewing { display: flex; align-items: center; gap: .6rem; justify-content: space-between; background: var(--warn-bg); color: var(--warn); padding: .5rem 1rem; font-size: .9rem; }
.viewing button { min-height: 32px; padding: .2rem .7rem; background: transparent; color: inherit; border-color: currentColor; }
/* csak olvasható modul: a szerkesztő elemek rejtve */
#view.ro .primary, #view.ro .danger, #view.ro .check-btn, #view.ro .quick { display: none !important; }
#view.ro::before { content: attr(data-ro-label); display: block; background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: .5rem .8rem; margin-bottom: .8rem; font-size: .88rem; }

/* ---- Foglalások ---- */
.pub { max-width: 560px; margin: 0 auto; padding: 1rem; }
.pub-lang { display: flex; justify-content: flex-end; gap: .2rem; }
.day h2 { margin-top: 1rem; text-transform: capitalize; }
.slot-row { width: 100%; text-align: left; color: inherit; font: inherit; }
.slot-row:disabled { opacity: .55; cursor: default; }
.slot-time { font-weight: 700; min-width: 5.6rem; white-space: nowrap; }
.slot-side { text-align: right; flex: none; }
.chip, .chip.tab { min-height: 36px; padding: .25rem .8rem; border-radius: 99px; border: 1px solid var(--line); border-bottom-width: 1px; font-weight: 400; }
.chip.on, .chip.tab.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.pill.ok { background: var(--brand); color: var(--brand-ink); }
.bk-details > div { margin: .15rem 0; }
.pub details summary { cursor: pointer; margin: .6rem 0; }

/* Lovarda profil, nyilvános oldal fejléc */
.top a.stable { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; }
.top-logo { height: 1.5rem; width: 1.5rem; object-fit: contain; border-radius: .3rem; background: #fff; }
.logo-row { display: flex; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.logo-img { max-height: 5rem; max-width: 10rem; object-fit: contain; border-radius: .5rem; }
.row-between { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.check.vis { margin: .1rem 0 .8rem; font-size: .85rem; }
.pub-head { padding-bottom: .6rem; margin-bottom: .8rem; }
.pub-logo { max-height: 4.5rem; max-width: 70%; object-fit: contain; display: block; margin-bottom: .4rem; }
.pub-contact { margin-top: 1.2rem; }
.row .small[type=date], .row input[type=date] { width: auto; }
/* Admin: modul sor = név felül, alatta a vezérlők */
[data-module].row { display: grid; grid-template-columns: auto 1fr; gap: .4rem .7rem; align-items: center; }
[data-module].row .grow { grid-column: 2; min-width: 0; }
[data-module].row .adm-ctl { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
[data-module].row .adm-ctl select, [data-module].row .adm-ctl input[type=date] { width: auto; flex: 1 1 8rem; min-width: 0; }

.top a.stable { min-height: 2.75rem; padding: 0 .4rem; max-width: 60%; justify-content: flex-end; text-decoration: underline; text-underline-offset: 3px; }

/* Ikonok (core/icons.js): a szöveg színét és méretét követik */
.ic { width: 1.2em; height: 1.2em; vertical-align: -0.22em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico .ic { width: 1.5rem; height: 1.5rem; vertical-align: middle; }
.bottom a .ico { display: inline-flex; justify-content: center; }

/* Színsablonok */
.swatches { display: flex; flex-wrap: wrap; gap: .6rem; margin: .4rem 0 .8rem; }
.swatch { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line); padding: 0; cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); }
.swatch:disabled { opacity: .5; cursor: default; }
.swatch { min-width: 0; min-height: 0; flex: none; aspect-ratio: 1; box-sizing: border-box; }

.top a.brand-home { color: inherit; text-decoration: none; display: inline-flex; align-items: center; min-height: 2.75rem; }

/* Menü: mobilon balról beúszó fiók, nagy képernyőn állandó oldalsáv */
.menu-btn { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 2.75rem; height: 2.75rem; margin-left: -.6rem; padding: 0 .7rem; background: transparent; border: 0; color: inherit; cursor: pointer; min-height: 0; }
.menu-btn span { display: block; width: 100%; height: 2px; border-radius: 2px; background: currentColor; }
.nav-backdrop { display: none; }
@media (max-width: 899px) {
  header.top, #view { margin-left: 0; }
  .bottom { width: min(260px, 80vw); transform: translateX(-102%); transition: transform .22s ease; z-index: 40; box-shadow: none; padding: calc(.6rem + env(safe-area-inset-top)) 0 calc(var(--badge-h) + env(safe-area-inset-bottom)) 0; }
  .bottom a { flex-direction: row; justify-content: flex-start; gap: .8rem; padding: .5rem 1.1rem; min-height: 50px; font-size: .98rem; text-align: left; }
  .bottom a .ico { width: 1.6rem; font-size: 1.35rem; }
  .menu-open .bottom { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .menu-open .nav-backdrop { opacity: 1; pointer-events: auto; }
}
@media (min-width: 900px) { .menu-btn { display: none; } }
@media (prefers-reduced-motion: reduce) { .bottom, .nav-backdrop { transition: none; } }

/* Csoportos bejegyzés: lovanként költség-rész és továbbszámlázás */
.pick-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: .15rem 0; }
.pick-cost { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.pick-cost .share { width: 6.2rem; min-height: 2.4rem; padding: .3rem .5rem; text-align: right; }
.pick-cost .check { margin: 0; white-space: nowrap; }

/* Mentés + Mégse egy sorban */
.form-actions { display: flex; gap: .6rem; }
.form-actions > button { flex: 1; }
.form-actions > button.secondary { flex: 0 1 38%; }

/* Választó + "Egyéb" szabad szöveg */
.combo { display: grid; gap: .4rem; }

/* Személyes link oldal + megosztás */
.me-page { max-width: 640px; margin: 0 auto; padding: 1rem; }
.me-page .lesson { padding: .5rem 0; border-top: 1px solid var(--line); }
.me-page .lesson:first-of-type { border-top: 0; }
.riders { margin: .3rem 0 0; padding-left: 1.1rem; }
.qr { display: flex; justify-content: center; margin: .8rem 0; }
.qr svg { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.share-actions { justify-content: flex-start; }
button.danger, .link.danger { color: var(--danger, #a33); }
.head-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

/* Bértartás: keskeny kijelzőn a gombok külön sorba kerülnek */
.board-row { flex-wrap: wrap; }
.board-row .grow { flex: 1 1 9rem; }
.board-row .slot-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.board-actions { flex-basis: 100%; display: flex; justify-content: flex-end; gap: .5rem; }
.month-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: .4rem 0 .8rem; }
.month-nav button { min-width: 44px; }

/* Dátum/idő mezők iOS-en ne lógjanak ki az űrlapból */
.sheet input[type=date], .sheet input[type=time], form input[type=date], form input[type=time] { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; -webkit-appearance: none; appearance: none; text-align: left; }

.slot-riders { font-weight: 600; font-size: .9rem; margin-top: .15rem; overflow-wrap: anywhere; }
.slot-trainer { font-size: .9rem; margin-top: .1rem; }

/* Alsó lapok: a Netlify "Powered by" jelvény ne takarja a mentés gombot */
.sheet { padding-bottom: calc(var(--badge-h) + 1rem + env(safe-area-inset-bottom)); }
.horse-tag { font-weight: 600; }
.field-row { display: flex; flex-direction: column; gap: .25rem; margin: .5rem 0; }
.slot-side { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; flex: none; }
