/* Portál ZŠ Hostivice – mobile-first. Barvy převzaté z www.zshostivice.cz */
:root {
  --primary: #079992;
  --primary-600: #05827c;
  --primary-800: #034643;
  --primary-900: #023230;
  --tint: #c2eae8;
  --light: #ebfffe;
  --bg: #f4f8f8;
  --surface: #ffffff;
  --text: #1c2b2a;
  --muted: #5d6f6e;
  --border: #d9e6e5;
  --danger: #c62828;
  --warn-bg: #fff4d6;
  --warn-text: #7a5a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(2, 50, 48, .06), 0 4px 16px rgba(2, 50, 48, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary-600); }
h1, h2 { line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
code { font-size: .9em; background: var(--light); padding: 1px 5px; border-radius: 4px; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 20px; padding-bottom: 32px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* --- Hlavička --- */
.topbar { background: var(--primary); color: #fff; padding-top: env(safe-area-inset-top); } /* iPhone aplikace: pruh až pod hodiny */
/* iPhone aplikace (iOS 26): pevný pruh pod hodinami – iOS z něj bere barvu stavového řádku místo rozmazání obsahu */
.safe-top { position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); background: var(--primary); z-index: 1000; pointer-events: none; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand-logo { display: block; height: 44px; width: auto; }
.brand-label { padding: 4px 0 4px 14px; border-left: 1px solid rgba(255, 255, 255, .45); font-family: Comfortaa, sans-serif; font-weight: 700; font-size: 1.15rem; line-height: 1.2; color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.userbox { display: flex; align-items: center; gap: 10px; }
.userbox form { margin: 0; }
.userbox-text { display: none; flex-direction: column; line-height: 1.2; }
.userbox-text small { color: var(--light); font-size: .78rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255, 255, 255, .6); }
.avatar-initial { display: grid; place-items: center; background: var(--primary-800); font-weight: 700; }

.adminnav { background: var(--primary-800); }
.adminnav-inner { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.adminnav a { color: var(--tint); text-decoration: none; padding: 10px 12px; white-space: nowrap; border-bottom: 3px solid transparent; font-size: .95rem; }
.adminnav a:hover { color: #fff; }
.adminnav a.active { color: #fff; border-bottom-color: var(--tint); }

/* --- Tlačítka a formuláře --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--primary); color: #fff; font: inherit; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--primary-600); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; }
.btn-block { width: 100%; }
.btn-ghost { background: rgba(255, 255, 255, .15); min-height: 38px; padding: 0 14px; }
.btn-ghost:hover { background: rgba(255, 255, 255, .28); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: .875rem; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid currentColor; }
.btn-danger:hover { background: #fdecec; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 500; font-size: .95rem; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=tel], input[type=time], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: inherit;
  font-size: max(16px, 1em); /* iPhone při menším písmu než 16 px stránku po klepnutí do pole přiblíží */
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
textarea { resize: vertical; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.code-input { font-size: 1.5rem !important; letter-spacing: .3em; text-align: center; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; }
.form-inline input, .form-inline select { flex: 1 1 220px; min-width: 0; max-width: 100%; }
.form-grid { grid-template-columns: 1fr; }
.actions { display: flex; align-items: end; }

/* --- Karty a obsah --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.page-title { font-size: 1.5rem; margin: 4px 0 18px; color: var(--primary-800); }
.breadcrumb { margin: 0 0 12px; }
.breadcrumb a { text-decoration: none; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.alert-ok { background: var(--light); color: var(--primary-800); border: 1px solid var(--tint); }
.alert-info { background: var(--warn-bg); color: var(--warn-text); }
.alert-error { background: #fdecec; color: var(--danger); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 500; }
.badge-ok { background: var(--light); color: var(--primary-600); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }

/* --- Přihlášení --- */
.page-login { background: linear-gradient(160deg, var(--primary) 0%, var(--primary-600) 50%, var(--primary-800) 100%); }
.page-login .topbar { background: transparent; }
.page-login .main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.page-login .footer { background: transparent; color: var(--tint); }
.login-card { width: 100%; max-width: 420px; text-align: center; padding: 28px 22px; }
.today-hero { margin: 0; text-align: center; color: #fff; }
.today-hero time { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.today-day { font-family: Comfortaa, sans-serif; font-weight: 700; font-size: clamp(2.25rem, 9vw, 3.25rem); line-height: 1.05; letter-spacing: -.01em; text-shadow: 0 2px 12px rgba(2, 50, 48, .25); }
.today-date { color: var(--tint); font-size: 1.1rem; letter-spacing: .04em; padding-top: 8px; border-top: 2px solid rgba(255, 255, 255, .35); }
.login-card h1 { font-family: Comfortaa, sans-serif; color: var(--primary-800); font-size: 1.6rem; margin: 0 0 6px; }
.login-card .form { text-align: left; margin-top: 16px; }
.google-button { display: flex; justify-content: center; min-height: 44px; margin: 22px 0 8px; transition: opacity .25s ease; }
/* Do načtení tlačítka od Googlu skrýt jeho nenastylovaný zástupný obsah (velké „G“) */
.google-button:not(.is-ready) { height: 44px; overflow: hidden; opacity: 0; pointer-events: none; }
/* Pojistka: logo „G“ v zástupném obsahu nikdy nesmí být velké (skutečné tlačítko je v iframe) */
.google-button svg { width: 18px !important; height: 18px !important; }
.login-status { min-height: 1.5em; margin: 8px 0 0; color: var(--muted); }
.login-status.is-error { color: var(--danger); }
.steps { text-align: left; padding-left: 20px; color: var(--muted); }
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr img { width: 220px; height: 220px; image-rendering: pixelated; border-radius: 8px; }
.secret code { display: inline-block; margin-top: 4px; font-size: 1rem; letter-spacing: .05em; word-break: break-all; }

/* --- Dlaždice --- */
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; }
.tile {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); color: inherit; text-decoration: none;
  transition: transform .12s ease, border-color .12s ease;
}
.tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.tile-icon { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 12px; background: var(--light); color: var(--primary); }
.tile-icon .icon { width: 26px; height: 26px; }
.tile-text { display: flex; flex-direction: column; }
.tile-text strong { font-size: 1.05rem; color: var(--primary-800); }
.tile-text small { color: var(--muted); }

.placeholder, .empty { text-align: center; padding: 36px 20px; }
.error-code { font-family: Comfortaa, sans-serif; font-size: 3rem; color: var(--primary); margin: 0; }

/* --- Administrace --- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.stat strong { font-size: 1.6rem; color: var(--primary); }
.stat span { color: var(--muted); font-size: .9rem; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: grid; grid-template-columns: 12px 1fr; column-gap: 10px; align-items: baseline; }
.checks li .muted { grid-column: 2; font-size: .875rem; word-break: break-all; }
.checks .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.checks .ok .dot { background: var(--primary); }
.result { margin-top: 16px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .85rem; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table form { margin: 0; }
.app-row { position: relative; }
.app-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-delete { margin-top: 10px; }
.form-gap { margin-top: 12px; }
.pwa-install { margin-top: 20px; }
.pwa-install p { margin: 0 0 8px; }
.pwa-install .actions { gap: 8px; flex-wrap: wrap; }
.pwa-install [hidden] { display: none; }
.grid-2 { display: grid; gap: 16px; }

/* --- Historie, filtry, stránkování --- */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head a { font-weight: 400; }
.filters { grid-template-columns: 1fr; align-items: end; }
.btn-light { background: var(--light); color: var(--primary-800); border: 1px solid var(--tint); }
.btn-light:hover { background: var(--tint); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.pager-links { display: flex; gap: 6px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table .ua { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.table .details { word-break: break-word; max-width: 420px; }
.list-input { min-height: 200px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; line-height: 1.5; }
.changelog h2 { font-size: 1.2rem; color: var(--primary-800); margin: 20px 0 8px; }
.changelog h2:first-child { margin-top: 0; }
.changelog h3 { font-size: 1rem; margin: 14px 0 6px; }
.changelog ul { margin: 0 0 10px; padding-left: 20px; }
.changelog li { margin: 3px 0; }

.footer { padding: 16px 0; font-size: .85rem; color: var(--muted); }

@media (max-width: 479px) { .brand-label { font-size: 1rem; padding-left: 10px; } }
@media (max-width: 399px) { .brand-label { display: none; } }

/* --- Větší obrazovky --- */
@media (min-width: 640px) {
  .userbox-text { display: flex; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile { flex-direction: column; align-items: flex-start; padding: 20px; min-height: 150px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid .span-2, .form-grid .app-head { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 2fr 1fr 1fr; }
  .page-title { font-size: 1.75rem; }
}
@media (min-width: 960px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; }
}
