:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e5e9f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --success: #16a34a;
  --success-dark: #15803d;
  --success-soft: #e7f8ec;
  --danger: #e11d48;
  --danger-dark: #be123c;
  --warning: #d97706;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.topbar .brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.topbar .brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 0.25rem; align-items: center; }
.topbar nav a.navlink {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  display: none; /* na mobilu skryté – odkazy jsou ve spodní liště */
}
.topbar nav a.navlink:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.topbar nav a.navlink.active { color: var(--primary); background: var(--primary-soft); }
.topbar .user {
  color: var(--muted);
  font-size: 0.85rem;
  display: none;
}
.topbar .spacer { flex: 1; }

/* ---------- Spodní navigace (mobil) ---------- */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 60;
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  padding: 0.3rem 0.5rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
}
.bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.35rem 0.25rem;
  border-radius: 10px;
  color: var(--muted-2);
  font-size: 0.68rem;
  font-weight: 700;
}
.bottomnav a:hover { text-decoration: none; }
.bottomnav a.active { color: var(--primary); }
.bottomnav .ico { font-size: 1.35rem; line-height: 1; }

/* ---------- Layout ---------- */
.container { max-width: 720px; margin: 0 auto; padding: 1.25rem 1rem 5rem; }
.container.narrow { max-width: 420px; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; letter-spacing: -0.02em; }
h2 { font-size: 1rem; margin: 1.75rem 0 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }

.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin-bottom: 0.15rem; }
.page-head p { margin: 0; color: var(--muted); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card.flush { padding: 0; overflow: hidden; }

/* ---------- Flash ---------- */
.flash {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 500;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.flash.notice { background: var(--success-soft); color: var(--success-dark); }
.flash.alert { background: #fee2e2; color: var(--danger-dark); }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.9rem 0 0.35rem; font-weight: 600; }
label.inline { display: flex; align-items: center; gap: 0.5rem; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=datetime-local], input[type=time], input[type=number], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* 16px brání nechtěnému přiblížení na iOS */
  font-family: inherit;
  line-height: 1.2;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
/* Datum/čas: kurzor pointer, ať je jasné, že pole otevírá výběr */
input[type=date], input[type=datetime-local], input[type=time] { cursor: pointer; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { min-height: 88px; resize: vertical; }
input[type=checkbox] { width: 1.15rem; height: 1.15rem; accent-color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.2rem;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: transform 0.05s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn.big { padding: 1.15rem 1.5rem; font-size: 1.15rem; width: 100%; border-radius: 14px; box-shadow: var(--shadow); }
.btn.success { background: var(--success); }
.btn.success:hover { background: var(--success-dark); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-dark); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.block { width: 100%; }

/* ---------- Clock / hero ---------- */
.clock-hero {
  text-align: center;
  padding: 1.5rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  color: #fff;
}
.clock-hero.working { background: linear-gradient(135deg, #16a34a, #15803d); }
.clock-hero.idle { background: linear-gradient(135deg, #1e293b, #334155); }
.clock-hero .status-line {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.92;
  margin-bottom: 0.5rem;
}
.clock-hero .big-clock { font-size: 2.8rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.clock-hero .sub { opacity: 0.85; font-size: 0.95rem; margin-top: 0.25rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; display: inline-block; }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.7);} 70% { box-shadow: 0 0 0 8px rgba(255,255,255,0);} 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0);} }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border); font-size: 0.93rem; white-space: nowrap; }
th { color: var(--muted-2); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
td.wrap { white-space: normal; }

/* ---------- List rows (mobil-friendly) ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; }
.list-row .sub { color: var(--muted); font-size: 0.85rem; }
.list-row .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge.green { background: var(--success-soft); color: var(--success-dark); }
.badge.gray { background: #eef2f7; color: #475569; }
.badge.blue { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 0.5rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 0.75rem; text-align: center; box-shadow: var(--shadow-sm); }
.stat .num { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.stat .num.accent { color: var(--success); }
.stat .lbl { color: var(--muted); font-size: 0.78rem; margin-top: 0.15rem; }

/* ---------- Helpers ---------- */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.mt { margin-top: 1rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }
.empty .ico { font-size: 1.8rem; display: block; margin-bottom: 0.4rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.6rem; display: flex; gap: 0.4rem; align-items: flex-start; }

.geo-status { font-size: 0.85rem; font-weight: 600; margin: 0.7rem 0 0; text-align: center; }
.geo-status[data-state="loading"] { color: var(--muted); }
.geo-status[data-state="ok"] { color: var(--success-dark); }
.geo-status[data-state="error"], .geo-status[data-state="insecure"] { color: var(--danger-dark); }

/* ---------- Kalendář flatpickr (sladění s designem) ---------- */
.flatpickr-calendar {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-family: inherit;
  width: 19rem;
  padding-bottom: 0.3rem;
}
.flatpickr-calendar::before, .flatpickr-calendar::after { display: none; } /* skryje šipku-zobáček */

.flatpickr-months { padding-top: 0.4rem; }
.flatpickr-months .flatpickr-month {
  color: var(--text);
  height: 44px;
}
.flatpickr-current-month { font-size: 1rem; font-weight: 700; }
.flatpickr-current-month .flatpickr-monthDropdown-months { font-weight: 700; border-radius: 8px; }
.flatpickr-current-month input.cur-year { font-weight: 700; }

/* navigační šipky */
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  fill: var(--primary);
}
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover { background: var(--primary-soft); }
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg { fill: var(--primary); }

.flatpickr-weekdays { margin-top: 0.25rem; }
span.flatpickr-weekday { color: var(--muted-2); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; }

.dayContainer { padding: 0 6px 4px; }
.flatpickr-day {
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  border: none;
  height: 38px; line-height: 38px;
  max-width: 38px;
}
.flatpickr-day:hover { background: var(--primary-soft); color: var(--primary-dark); }
.flatpickr-day.today { border: 1.5px solid var(--primary); color: var(--primary-dark); }
.flatpickr-day.today:hover { background: var(--primary-soft); }
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.flatpickr-day.flatpickr-disabled, .flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: var(--muted-2); opacity: 0.5; }

/* čas */
.flatpickr-time { border-top: 1px solid var(--border); margin-top: 0.3rem; height: 42px; }
.flatpickr-time input { font-size: 1rem; font-weight: 700; color: var(--text); }
.flatpickr-time input:hover, .flatpickr-time input:focus { background: var(--primary-soft); }
.flatpickr-time .flatpickr-time-separator { color: var(--muted); }
.flatpickr-time .numInputWrapper:hover { background: var(--primary-soft); }

/* ---------- Desktop ---------- */
@media (min-width: 600px) {
  .topbar { padding: 0.75rem 1.5rem; }
  .topbar nav a.navlink { display: inline-flex; }
  .container { padding-top: 1.75rem; padding-bottom: 2rem; }
  .stat .num { font-size: 2rem; }
  .bottomnav { display: none; }
}
