/* ==========================================================================
   Vozový park — hand-written, no build step.
   Mobile first: the phone is the main device; wider screens add a sidebar.
   ========================================================================== */

:root {
  --c-bg: #f6f7f9;
  --c-surface: #ffffff;
  --c-surface-2: #f0f2f5;
  --c-border: #dfe3e8;
  --c-text: #131820;
  --c-muted: #5b6675;
  --c-faint: #8792a2;
  --c-accent: #2f6df0;
  --c-accent-hover: #2559cc;
  --c-accent-soft: #e8effd;
  --c-on-accent: #ffffff;
  --c-ok: #17864a;
  --c-ok-soft: #e2f5eb;
  --c-warn: #a56b00;
  --c-warn-soft: #fdf1dc;
  --c-danger: #c22e2e;
  --c-danger-soft: #fce9e9;
  --c-info: #1f6f8b;
  --c-info-soft: #e2f0f5;
  --r: 10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 62px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #0f1319;
    --c-surface: #171c24;
    --c-surface-2: #1e242e;
    --c-border: #2a323e;
    --c-text: #e7ebf0;
    --c-muted: #a0abba;
    --c-faint: #6f7c8c;
    --c-accent: #5a8cf7;
    --c-accent-hover: #7aa3f9;
    --c-accent-soft: #1c2942;
    --c-on-accent: #0f1319;
    --c-ok: #4ac585;
    --c-ok-soft: #16301f;
    --c-warn: #e0a33c;
    --c-warn-soft: #33260e;
    --c-danger: #f07171;
    --c-danger-soft: #351a1a;
    --c-info: #5ab6d4;
    --c-info-soft: #142a33;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; font-weight: 650; }
h1 { font-size: 21px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 12px; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: 13px; }
.muted { color: var(--c-muted); }
.faint { color: var(--c-faint); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* --- shell -------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
}
.topbar h1 { margin: 0; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { font-size: 22px; line-height: 1; padding: 4px 8px 4px 0; color: var(--c-text); }
.offline-badge { display: none; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--c-warn-soft); color: var(--c-warn); }
body.is-offline .offline-badge { display: inline-block; }

.content { padding: 16px; padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); max-width: 1100px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--c-surface); border-top: 1px solid var(--c-border);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--c-muted); font-size: 11px; text-decoration: none;
}
.tabbar a .ico { font-size: 20px; line-height: 1; }
.tabbar a.is-active { color: var(--c-accent); font-weight: 600; }
.sidebar { display: none; }
/* A grid child grows to its widest content unless told otherwise; a wide table
   would otherwise push the whole page off the right edge. */
.main { min-width: 0; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh; padding: 16px 12px;
    background: var(--c-surface); border-right: 1px solid var(--c-border);
  }
  .sidebar .brand { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; color: var(--c-text); }
  .sidebar a.nav { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); color: var(--c-text); }
  .sidebar a.nav:hover { background: var(--c-surface-2); text-decoration: none; }
  .sidebar a.nav.is-active { background: var(--c-accent-soft); color: var(--c-accent); font-weight: 600; }
  .sidebar .foot { margin-top: auto; }
  .content { padding: 24px 32px 48px; }
  .topbar { padding: 14px 32px; }
}

/* --- cards and lists ---------------------------------------------------- */

.card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: 10px; }
.card--flush { padding: 0; overflow: hidden; }
.card--flush > h2 { padding: 14px 16px 0; }
.grid { display: grid; gap: 16px; }
@media (min-width: 700px) { .grid--2 { grid-template-columns: 1fr 1fr; } .grid--3 { grid-template-columns: repeat(3, 1fr); } }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 16px; border-top: 1px solid var(--c-border); }
.list > li:first-child { border-top: 0; }
.list a.item { display: block; color: inherit; margin: -12px -16px; padding: 12px 16px; }
.list a.item:hover { background: var(--c-surface-2); text-decoration: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--c-muted); }
.kv dd { margin: 0; }

.stat { display: flex; flex-direction: column; }
.stat .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--c-muted); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* "Co hoří" */
.due { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-top: 1px solid var(--c-border); color: inherit; }
.due:first-child { border-top: 0; }
a.due:hover { background: var(--c-surface-2); text-decoration: none; }
.due .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.due--overdue .dot { background: var(--c-danger); }
.due--soon .dot { background: var(--c-warn); }
.due--upcoming .dot { background: var(--c-info); }
.due--info .dot { background: var(--c-faint); }
.due .t { font-weight: 600; }
.due .w { font-size: 13px; white-space: nowrap; }
.due--overdue .w { color: var(--c-danger); font-weight: 600; }
.due--soon .w { color: var(--c-warn); font-weight: 600; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--c-surface-2); color: var(--c-muted); white-space: nowrap; }
.badge--danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge--warn { background: var(--c-warn-soft); color: var(--c-warn); }
.badge--ok { background: var(--c-ok-soft); color: var(--c-ok); }
.badge--info { background: var(--c-info-soft); color: var(--c-info); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }

/* --- tables: on a phone every row becomes a small card ------------------ */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-top: 1px solid var(--c-border); text-align: left; vertical-align: top; }
.table th { font-size: 12px; font-weight: 600; color: var(--c-muted); border-top: 0; white-space: nowrap; }
.table tfoot td { font-weight: 650; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 699px) {
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tr { padding: 10px 16px; border-top: 1px solid var(--c-border); }
  .table--cards tr:first-child { border-top: 0; }
  .table--cards td { border: 0; padding: 2px 0; text-align: left; }
  .table--cards td[data-label]::before { content: attr(data-label) ": "; color: var(--c-muted); }
  .table--cards td.num { text-align: left; }
}

/* --- tabs --------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px; border-bottom: 1px solid var(--c-border); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; color: var(--c-muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.is-active { color: var(--c-accent); border-bottom-color: var(--c-accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--c-text); }

/* --- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--c-surface-2); text-decoration: none; }
.btn--primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.btn--primary:hover { background: var(--c-accent-hover); }
.btn--danger { color: var(--c-danger); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn--link { border: 0; background: none; color: var(--c-accent); padding: 0; min-height: 0; font-weight: 500; }
.btn--block { width: 100%; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick .btn { flex-direction: column; min-height: 72px; gap: 2px; font-size: 13px; }
.quick .btn .ico { font-size: 22px; }

/* --- forms -------------------------------------------------------------- */

form.inline { display: inline; }
.form { display: grid; gap: 14px; }
.form .cols { display: grid; gap: 14px; }
@media (min-width: 700px) { .form .cols { grid-template-columns: 1fr 1fr; } .form .cols--3 { grid-template-columns: repeat(3, 1fr); } }
label.field { display: grid; gap: 4px; font-weight: 600; font-size: 13px; color: var(--c-muted); }
label.field > span.hint { font-weight: 400; color: var(--c-faint); }
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  font: 16px/1.4 var(--font); /* 16px keeps iOS from zooming in on focus */
  color: var(--c-text); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
}
textarea { min-height: 80px; }
input:focus, select, textarea:focus { outline-color: var(--c-accent); }
input[type="color"] { width: 64px; height: 44px; border: 1px solid var(--c-border); border-radius: var(--r-sm); background: none; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; min-height: 36px; }
label.check input { width: 20px; height: 20px; }
.checks { display: grid; gap: 4px; }
@media (min-width: 700px) { .checks { grid-template-columns: 1fr 1fr; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
details.add { margin-top: 12px; }
details.add > summary { cursor: pointer; color: var(--c-accent); font-weight: 600; list-style: none; padding: 8px 0; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { margin-bottom: 8px; }

.alert { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 16px; border: 1px solid transparent; }
.alert--ok { background: var(--c-ok-soft); color: var(--c-ok); }
.alert--error { background: var(--c-danger-soft); color: var(--c-danger); }
.alert--warn { background: var(--c-warn-soft); color: var(--c-warn); }
.alert--info { background: var(--c-info-soft); color: var(--c-info); }

.empty { padding: 24px 16px; text-align: center; color: var(--c-muted); }

/* --- calendar ----------------------------------------------------------- */

#calendar { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r); padding: 8px; }
.fc { --fc-border-color: var(--c-border); --fc-page-bg-color: var(--c-surface); --fc-neutral-bg-color: var(--c-surface-2);
      --fc-list-event-hover-bg-color: var(--c-surface-2); --fc-today-bg-color: var(--c-accent-soft); font-size: 14px; }
.fc .fc-toolbar { flex-wrap: wrap; gap: 8px; }
.fc .fc-toolbar-title { font-size: 17px; }
.fc .fc-button { padding: 6px 10px; }
@media (max-width: 699px) { .fc .fc-toolbar.fc-header-toolbar { flex-direction: column; align-items: stretch; } }

/* --- login -------------------------------------------------------------- */

.login { max-width: 380px; margin: 12vh auto; padding: 0 16px; }

@media print {
  .tabbar, .sidebar, .topbar, .actions, form { display: none !important; }
  .content { padding: 0; }
}
