/* Písmo nápisu ČASOMÍRA v záhlaví: Exo 2 ExtraBold Italic (SIL Open Font License, viz fonts/OFL-Exo2.txt) */
@font-face {
  font-family: 'Exo 2'; font-style: italic; font-weight: 800; font-display: swap;
  src: url(fonts/exo-2-latin-ext-800-italic.woff2) format('woff2');
  unicode-range: U+0100-024F, U+1E00-1EFF;
}
@font-face {
  font-family: 'Exo 2'; font-style: italic; font-weight: 800; font-display: swap;
  src: url(fonts/exo-2-latin-800-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F;
}

:root {
  --bg: #f1f4f9;
  --card: #ffffff;
  --text: #16202e;
  --muted: #64748b;
  --line: #dde3ec;
  --primary: #1d4ed8;
  --primary-text: #ffffff;
  --secondary: #e6ecf5;
  --danger: #b91c1c;
  --ok: #15803d;
  --air: #0e7490;
  --air-bg: #e0f4f8;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d131c;
    --card: #161e2a;
    --text: #e5ebf3;
    --muted: #93a1b5;
    --line: #2a3546;
    --primary: #3b82f6;
    --secondary: #243044;
    --danger: #ef4444;
    --ok: #22c55e;
    --air: #38bdf8;
    --air-bg: #102838;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- horní lišta ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button {
  border: 0; background: none; color: var(--muted);
  padding: 8px 12px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tabs button.active { background: var(--secondary); color: var(--text); }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; }
.live { color: var(--danger); font-size: 12px; }
.live.on { color: var(--ok); }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------- karty ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
h2 { margin: 0 0 12px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.count:not(:empty) {
  background: var(--secondary); border-radius: 99px; padding: 0 9px; font-size: 13px;
}
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 16px; }

/* ---------- formuláře ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 15px; }
input, select {
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  min-height: 42px;
  width: 100%;
}
input[type=checkbox] { width: 20px; min-height: 20px; height: 20px; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
[hidden] { display: none !important; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid .wide { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filters label { min-width: 150px; flex: 1 1 150px; }
.filters label.check { flex: 0 0 auto; min-width: 0; padding-bottom: 10px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }

button, .button {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 8px;
  padding: 10px 16px; min-height: 42px;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
button:disabled { opacity: .5; cursor: progress; }
.primary { background: var(--primary); color: var(--primary-text); }
.secondary { background: var(--secondary); color: var(--text); }
.danger { background: none; color: var(--danger); border: 1px solid var(--danger); }
.ghost { background: none; color: var(--muted); padding: 6px 10px; min-height: 34px; }
.ghost:hover { background: var(--secondary); color: var(--text); }

/* ---------- provoz ---------- */
.dayline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.dayline label { width: 180px; }
.kpis { display: flex; flex-wrap: wrap; gap: 8px; }
.kpis > div {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 14px; display: flex; flex-direction: column; min-width: 88px;
}
.kpis b { font-size: 20px; font-variant-numeric: tabular-nums; }
.kpis span { font-size: 12px; color: var(--muted); }
.kpis.big { margin-bottom: 16px; }
.kpis.big b { font-size: 26px; }

.new-flight { border-top: 4px solid var(--primary); }

.list { display: flex; flex-direction: column; gap: 8px; }
.flight {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
}
.flight.up { background: var(--air-bg); border-color: var(--air); }
.flight .reg { font-weight: 700; font-size: 17px; }
.flight .reg small, .flight .meta { color: var(--muted); font-weight: 400; font-size: 13px; }
.flight .timer {
  font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 700; color: var(--air);
}
.flight .timer.muted { color: var(--muted); font-size: 18px; }
.flight .btns { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.flight .btns .primary, .flight .btns .secondary { flex: 1; min-height: 48px; }
.flight:not(.up):not(.down) .btns { grid-column: 2; grid-row: 1; }
.empty { color: var(--muted); margin: 4px 0; }
/* vlečná: vlastní karta / řádek, graficky připojený ke kluzáku nad ním */
.flight.tow { margin-left: 26px; position: relative; border-style: dashed; }
.flight.tow::before { content: '↳'; position: absolute; left: -22px; top: 10px; color: var(--air); font-size: 20px; font-weight: 700; }
tr.towed td { border-bottom-color: transparent; }
tr.tow-row td { border-bottom-style: solid; }
tr.tow-row td.ac::before { content: '↳ '; color: var(--muted); font-weight: 700; }
tr.tow-row.linked td { padding-top: 2px; }

/* ---------- tabulky ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
td small { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.airborne td { background: var(--air-bg); }
tr.planned td { color: var(--muted); }
tr.inactive td { opacity: .5; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text, inherit); text-decoration: underline; }
label.check.inactive { opacity: .55; }
.row-actions { text-align: right; white-space: nowrap; }
.summary { margin-bottom: 8px; color: var(--muted); }
.summary b { color: var(--text); }

/* ---------- dialog ---------- */
dialog {
  border: 0; border-radius: 14px; padding: 20px;
  width: min(760px, calc(100vw - 32px));
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 150%);
  background: var(--text); color: var(--card);
  padding: 12px 18px; border-radius: 10px; font-weight: 600;
  transition: transform .2s; max-width: calc(100vw - 32px); z-index: 100;
}
#toast.show { transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }
#toast.ok { background: var(--ok); color: #fff; }

@media (max-width: 640px) {
  main { padding: 12px; }
  .topbar { gap: 8px; }
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .brand { min-width: 0; flex: 1 1 0; font-size: 16px; }
  #club-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .clock { font-size: 15px; }
  .user button { min-height: 34px; padding: 4px 10px; }
  .who { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  .tabs { order: 5; flex: 0 0 100%; }
}

#toast:not(.show) { visibility: hidden; }
td b { white-space: nowrap; }

/* ---------- uživatel, přihlášení ---------- */
.user { display: flex; align-items: center; gap: 6px; }
.who { font-weight: 600; white-space: nowrap; }
.who small { background: var(--primary); color: var(--primary-text); border-radius: 6px; padding: 1px 6px; font-size: 11px; }
.login { max-width: 380px; margin: 40px auto; display: flex; flex-direction: column; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.warn { color: var(--danger); font-weight: 600; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
body:not(.is-admin) .admin-only { display: none; }

.filters .full { flex-basis: 100%; margin-bottom: 0; }
.filters .grow { flex: 3 1 240px; }
.button.small { min-height: 28px; padding: 2px 10px; font-size: 12px; margin-left: auto; }

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--secondary); }
tr.selected td { background: var(--air-bg); }

.account .kpis { margin-bottom: 12px; }
.account .balance b { font-size: 26px; }
.account .balance.neg b { color: var(--danger); }

.settings { max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.settings small { font-weight: 400; }
.price-info { margin: 12px 0 0; color: var(--muted); }
.price-info b { color: var(--text); }

/* ---------- ceník podle kategorií ---------- */
.cat-prices { flex-basis: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.cat-prices h3 { margin: 0 0 8px; font-size: 15px; }
.cat-prices h3 small { color: var(--muted); font-weight: 400; }
.cat-row { display: grid; grid-template-columns: minmax(140px, 1.4fr) 1fr 1fr; gap: 10px; align-items: end; padding: 6px 0;
  border-bottom: 1px dashed var(--line); }
.cat-row > span { font-weight: 600; padding-bottom: 10px; }
.cat-row > span small { font-weight: 400; color: var(--muted); }
.cat-prices .hint { display: block; margin-top: 8px; }
th.mine, td.mine { background: var(--air-bg); }
td.muted { color: var(--muted); }
.tow-cell { white-space: nowrap; }
.filters .hint.full { flex-basis: 100%; }
@media (max-width: 640px) { .cat-row { grid-template-columns: 1fr 1fr; } .cat-row > span { grid-column: 1 / -1; padding: 0; } }

/* ---------- režim členství ---------- */
.mode-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.mode-pick { display: flex; gap: 8px; align-items: center; flex: 0 1 420px; }
.mode-pick select { flex: 1; }
.mode-card details { margin-top: 12px; }
.mode-card summary { cursor: pointer; color: var(--muted); font-weight: 600; }
h2 small.hint { font-weight: 400; }

/* ---------- přístupová práva ---------- */
fieldset.perms { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 10px; margin: 0; flex-basis: 100%; }
fieldset.perms legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 4px; }
fieldset.perms legend small { font-weight: 400; }
.perm-list { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.perm-list label.check { padding: 0; }
.user .who { font-weight: 600; color: var(--text); }
#password-dialog { width: min(640px, calc(100vw - 32px)); }

/* ---------- ceník po letech ---------- */
.price-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 6px; }
.price-head h2 { margin: 0; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
label.inline select { width: auto; }
table.prices th[scope=row] { font-weight: 600; white-space: nowrap; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
table.prices th[scope=row] small { font-weight: 400; color: var(--muted); }
table.prices td input { width: 100px; min-height: 34px; padding: 4px 8px; text-align: right; }
table.prices tr.group td { background: var(--secondary); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- vzhled Aeroklubu Kyjov: záhlaví v barvě klubu ---------- */
:root { --brand: #152a50; --brand-text: #ffffff; }
.topbar { background: var(--brand); border-bottom-color: var(--brand); color: var(--brand-text); }
.brand { font-size: 19px; letter-spacing: .01em; }
.brand-logo { height: 40px; width: auto; display: block; }
.topbar .tabs button { color: rgb(255 255 255 / .72); }
.topbar .tabs button:hover { color: #fff; background: rgb(255 255 255 / .08); }
.topbar .tabs button.active { color: #fff; background: rgb(255 255 255 / .18); }
.topbar .clock, .topbar .user .who { color: #fff; }
.topbar .ghost { color: rgb(255 255 255 / .8); }
.topbar .ghost:hover { color: #fff; background: rgb(255 255 255 / .12); }
.topbar .secondary { background: #fff; color: var(--brand); }
.topbar .who small { background: rgb(255 255 255 / .2); color: #fff; }
.topbar .live { color: #fca5a5; }
.topbar .live.on { color: #4ade80; }

.login-logo { display: block; width: 100%; max-width: 300px; margin: 4px auto 8px; }
@media (prefers-color-scheme: dark) { .login-logo { filter: brightness(0) invert(1); } }

@media (max-width: 640px) { .brand-logo { height: 32px; } .brand { font-size: 16px; } }
@media (max-width: 640px) {
  .topbar .clock { display: none; }            /* telefon ukazuje čas sám */
  .topbar .brand { flex: 1 1 auto; }
  #club-name { white-space: nowrap; }
}
@media (max-width: 420px) {
  .topbar .who small { display: none; }
  .who { max-width: 110px; }
}

/* ---------- uzavření letového dne ---------- */
.day-close { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.day-badge { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { background: var(--secondary); border-radius: 99px; padding: 4px 12px; font-size: 13px; font-weight: 600; }
.badge.done { background: var(--brand); color: #fff; }
.button.small-btn { min-height: 34px; padding: 4px 12px; font-size: 13px; }
#close-dialog { width: min(1100px, calc(100vw - 32px)); }
.close-table td { vertical-align: middle; }
.close-table td:nth-child(3) { font-size: 13px; }
.done-note { font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lock { font-size: 14px; opacity: .7; }

/* ---------- dotyková zařízení (telefon, tablet): větší ovládací prvky ---------- */
/* Počítač s myší se nemění – pravidla platí jen pro zařízení s dotykovým ovládáním. */
@media (pointer: coarse) {
  body { font-size: 16px; }
  input, select { min-height: 52px; font-size: 17px; padding: 10px 12px; }
  label { font-size: 14px; gap: 6px; }
  button, .button { min-height: 52px; font-size: 17px; padding: 12px 20px; }
  .ghost { min-height: 44px; min-width: 44px; padding: 8px 12px; font-size: 18px; }
  .tabs button { padding: 12px 16px; font-size: 16px; }
  .grid { gap: 16px; }
  .flight { padding: 14px; gap: 10px 14px; }
  .flight .reg { font-size: 19px; }
  .flight .timer { font-size: 30px; }
  .flight .btns .primary, .flight .btns .secondary { min-height: 60px; font-size: 19px; }
  .actions button { min-width: 140px; }
  th, td { padding: 10px 8px; }
  table { font-size: 15px; }
  input[type=checkbox] { width: 26px; height: 26px; min-height: 26px; }
  label.check { gap: 10px; font-size: 16px; }
}

/* Dlouhé jméno uživatele v záhlaví zkrátit zprava (tlačítko by jinak ořezalo text z obou stran). */
.topbar .who { display: block; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .topbar .who { max-width: 55vw; } }

/* odbornosti člena po letech */
.spec-pick { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: flex-end; }
.spec-pick label.check { padding: 0; }

/* ---------- podzáložky (menu uvnitř záložky) ---------- */
.subnav {
  display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; padding: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); width: fit-content; max-width: 100%;
}
.subnav button {
  background: none; border: 0; color: var(--muted); font-weight: 600; padding: 8px 16px; border-radius: 8px; min-height: 0;
}
.subnav button:hover { color: var(--text); background: var(--secondary); }
.subnav button.active { background: var(--brand, #152a50); color: #fff; }
.subnav.single { display: none; }
.subview { display: none; }
.subview.active { display: block; }
.subnav.inner { margin: 10px 0 0; border: 0; padding: 0; background: none; }
.subnav.inner button { padding: 6px 12px; }

/* záhlaví karty: nadpis, hledání, tlačítka v jednom řádku */
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card-head .list-search { width: auto; flex: 0 1 260px; margin: 0; }
.list-search { width: 100%; margin: 0 0 10px; }
.acc-head { margin-bottom: 12px; }
.acc-balance { font-weight: 700; font-size: 18px; }
.acc-pane { display: none; }
.acc-pane.active { display: block; }

/* formuláře v dialogu */
.form-dialog { width: min(560px, calc(100vw - 32px)); }
.form-dialog.wide { width: min(900px, calc(100vw - 32px)); }
.form-dialog h2 { margin: 0 0 4px; }
.form-dialog .actions { margin-top: 6px; }

/* na úzkém displeji menu podzáložek v jednom řádku s posouváním do strany */
.subnav button { white-space: nowrap; }
@media (max-width: 700px) {
  .subnav { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .subnav button { flex: 1 0 auto; }
}

/* ---------- záhlaví: logo + ČASOMÍRA + název klubu ---------- */
.brand { gap: 12px; }
.brand-text { display: flex; flex-direction: column; justify-content: center; line-height: 1; min-width: 0; }
.app-name {
  font-family: 'Exo 2', system-ui, sans-serif; font-style: italic; font-weight: 800;
  font-size: 26px; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
}
.brand-text #club-name { font-size: 15px; font-weight: 700; letter-spacing: .01em; margin-top: 3px; opacity: .9; }
@media (max-width: 640px) {
  .app-name { font-size: 22px; }
  .brand-text #club-name { font-size: 13px; }
}

/* ---------- hodiny: UTC (časy letů) a místní čas ---------- */
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.clock-row { white-space: nowrap; }
.clock-row small { font-size: 10px; font-weight: 700; letter-spacing: .06em; opacity: .7; }
.clock-utc b { font-size: 18px; }
.clock-lt { font-size: 12px; font-weight: 600; opacity: .8; }
@media (max-width: 640px) {
  /* na telefonu jen UTC – místní čas ukazuje telefon sám */
  .topbar .clock { display: flex; }
  .clock-lt { display: none; }
  .clock-utc b { font-size: 15px; }
}

/* ---------- účet a zabezpečení ---------- */
#password-dialog h3 { margin: 18px 0 6px; font-size: 16px; }
.twofa { border-top: 1px solid var(--line); margin-top: 18px; }
.twofa ol { padding-left: 20px; margin: 6px 0; }
.twofa .qr { background: #fff; width: 200px; max-width: 70vw; padding: 6px; border-radius: 8px; margin: 8px 0 12px; }
.twofa .qr svg { display: block; width: 100%; height: auto; }
.twofa code.secret { font-size: 14px; letter-spacing: .05em; user-select: all; word-break: break-all; }
.badge.ok { background: #dcfce7; color: #166534; }
.twofa-admin { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px;
  border-radius: 8px; background: var(--secondary); }
