:root {
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-border: #e2e5ea;
  --color-text: #1f2430;
  --color-text-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-warning: #d97706;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Barevné šablony (nastavitelné v profilu uživatele) ---------- */
[data-theme="green"] {
  --color-primary: #16a34a;
  --color-primary-dark: #15803d;
  --color-primary-light: #dcfce7;
}
[data-theme="violet"] {
  --color-primary: #7c3aed;
  --color-primary-dark: #6d28d9;
  --color-primary-light: #ede9fe;
}
[data-theme="teal"] {
  --color-primary: #0d9488;
  --color-primary-dark: #0f766e;
  --color-primary-light: #ccfbf1;
}
[data-theme="amber"] {
  --color-primary: #d97706;
  --color-primary-dark: #b45309;
  --color-primary-light: #fef3c7;
}
[data-theme="dark"] {
  --color-bg: #14161f;
  --color-surface: #1c1f2b;
  --color-border: #2e3242;
  --color-text: #e6e8ef;
  --color-text-muted: #9aa0b4;
  --color-primary: #60a5fa;
  --color-primary-dark: #3b82f6;
  --color-primary-light: #1e3a5f;
  --color-danger-light: #4c1d1d;
  --color-success-light: #143d26;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .day-cell.outside { background: #171a24; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: #20232f;
  color: var(--color-text);
}
[data-theme="dark"] button.secondary, [data-theme="dark"] .btn.secondary { background: #20232f; color: var(--color-text); }
[data-theme="dark"] .mini-calendar, [data-theme="dark"] .modal, [data-theme="dark"] .qr-box { background: var(--color-surface); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
}

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

h1, h2, h3 { margin: 0 0 .5em; font-weight: 600; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---------- Layout / topbar ---------- */
.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.topbar .brand {
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary); display: inline-block; }
.topbar nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.topbar nav a {
  color: var(--color-text);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}
.topbar nav a:hover { background: var(--color-bg); text-decoration: none; }
.topbar nav a.active { background: var(--color-primary-light); color: var(--color-primary-dark); }
.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 12px; flex-shrink: 0;
}

.page { padding: 24px; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef2ff 0%, #f3f4f6 60%);
}
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px;
  width: 100%;
  max-width: 400px;
}
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card p.subtitle { color: var(--color-text-muted); margin: 0 0 24px; font-size: 14px; }
.auth-card .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-card .logo .dot { width: 14px; height: 14px; border-radius: 4px; background: var(--color-primary); }
.auth-footer { text-align: center; margin-top: 18px; font-size: 14px; color: var(--color-text-muted); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 5px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
textarea { resize: vertical; min-height: 70px; }
.field-row { display: flex; gap: 12px; }
.field-row > div { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.checkbox-row input { width: auto; }
.help-text { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  font-family: inherit;
}
button:hover, .btn:hover { background: var(--color-primary-dark); text-decoration: none; }
button.secondary, .btn.secondary { background: #fff; color: var(--color-text); border-color: var(--color-border); }
button.secondary:hover, .btn.secondary:hover { background: var(--color-bg); }
button.danger, .btn.danger { background: var(--color-danger); }
button.danger:hover { background: #b91c1c; }
button.block, .btn.block { width: 100%; }
button.small, .btn.small { padding: 5px 10px; font-size: 12.5px; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.icon-btn { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); padding: 6px 10px; }
button.icon-btn:hover { background: var(--color-bg); }

/* ---------- Alerts / flashes ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; }
.alert.error { background: var(--color-danger-light); color: #991b1b; }
.alert.success { background: var(--color-success-light); color: #166534; }
.alert.info { background: var(--color-primary-light); color: #1e40af; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- Toolbar (calendar) ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }
.toolbar .nav-group { display: flex; align-items: center; gap: 4px; }
.toolbar h2 { min-width: 200px; text-align: center; font-size: 18px; }
.view-tabs { display: flex; gap: 2px; background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 2px; }
.view-tabs a { padding: 6px 12px; font-size: 13px; border-radius: 5px; color: var(--color-text); font-weight: 500; }
.view-tabs a.active { background: var(--color-primary); color: #fff; }
.view-tabs a:hover:not(.active) { background: var(--color-bg); text-decoration: none; }

.datepicker-wrap { position: relative; }
.mini-calendar {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 12px;
  width: 260px;
  display: none;
}
.mini-calendar.open { display: block; }
.mini-calendar .mc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 600; font-size: 13px; }
.mini-calendar table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mini-calendar th { color: var(--color-text-muted); font-weight: 500; padding: 3px 0; }
.mini-calendar td { text-align: center; padding: 0; }
.mini-calendar td button { width: 100%; background: transparent; color: var(--color-text); border: none; padding: 6px 0; border-radius: 5px; font-weight: 400; }
.mini-calendar td button:hover { background: var(--color-bg); }
.mini-calendar td button.today { border: 1px solid var(--color-primary); }
.mini-calendar td button.muted { color: #c7cbd3; }

/* ---------- Month calendar grid ---------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.week-grid .day-cell { min-height: 220px; }
.week-day-name { display: none; }
.calendar-grid .weekday-head {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  padding-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.day-cell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-height: 118px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.day-cell.outside { background: #fafafa; opacity: .55; }
.day-cell.today { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.day-cell.picked:not(.today) { border-color: var(--color-warning); box-shadow: 0 0 0 2px var(--color-warning); }
.day-cell.locked { background: repeating-linear-gradient(135deg, var(--color-surface), var(--color-surface) 10px, var(--color-bg) 10px, var(--color-bg) 20px); }
.day-cell .day-head {
  padding: 6px 8px 4px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}
.day-cell .day-head .lock { font-size: 12px; opacity: .8; }
.day-cell .day-num { font-weight: 700; font-size: 13.5px; }
.day-cell .day-header-label {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  cursor: default;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.day-cell .day-head-edit-btn {
  border: none; background: transparent; color: var(--color-text-muted);
  cursor: pointer; font-size: 11px; padding: 0 2px; flex-shrink: 0;
}
.day-cell .day-head-edit-btn:hover { color: var(--color-primary); }
.day-cell .absences { flex: 1; padding: 0 6px 6px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.absence-chip {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  line-height: 1.4;
}
.absence-chip .lock { opacity: .85; font-size: 10px; }
.day-cell .add-btn {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  text-align: left;
  padding: 4px 8px 6px;
  cursor: pointer;
}
.day-cell .add-btn:hover { color: var(--color-primary); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 460px;
  padding: 24px;
}
.modal h3 { display: flex; align-items: center; justify-content: space-between; font-size: 17px; }
.modal .close-x { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--color-text-muted); }
.modal-actions { display: flex; justify-content: space-between; margin-top: 20px; gap: 10px; }
.modal-actions .right { display: flex; gap: 8px; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th, table.data-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--color-border); }
table.data-table th { color: var(--color-text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data-table tr:hover td { background: #fafbfc; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: #fff; }
.color-swatch { width: 16px; height: 16px; border-radius: 4px; display: inline-block; vertical-align: middle; border: 1px solid rgba(0,0,0,.1); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }

.tabs-secondary { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 18px; }
.tabs-secondary a { padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--color-text-muted); border-bottom: 2px solid transparent; }
.tabs-secondary a.active { color: var(--color-primary); border-color: var(--color-primary); }
.tabs-secondary a:hover { text-decoration: none; color: var(--color-primary); }

.qr-box { text-align: center; padding: 16px; background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
code.secret { display: block; margin-top: 10px; font-size: 13px; letter-spacing: .05em; background: var(--color-bg); padding: 8px; border-radius: 6px; word-break: break-all; }

/* ---------- Mobilní agenda (pohled "Mobil") ---------- */
.agenda-range-info {
  font-size: 12px; color: var(--color-text-muted); text-align: center;
  padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px dashed var(--color-border);
}
.agenda-day {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.agenda-day:last-child { margin-bottom: 0; }
.agenda-day-today { box-shadow: 0 0 0 1px var(--color-primary); }
.agenda-day-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 14.5px; font-weight: 700; color: var(--color-text);
  margin-bottom: 8px;
}
.agenda-day-empty { padding: 8px 14px; }
.agenda-day-empty .agenda-day-head {
  font-size: 13px; font-weight: 600; opacity: .68; margin-bottom: 4px;
}
.agenda-empty-note { font-size: 12px; color: var(--color-text-muted); margin-bottom: 6px; }
.agenda-day-empty .agenda-add-btn { opacity: .75; }
.agenda-day-sub { font-weight: 400; font-size: 12.5px; color: var(--color-text-muted); margin-left: 7px; }
.agenda-header-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: #fff;
  padding: 3px 10px; border-radius: 999px; margin-bottom: 8px;
}
.agenda-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  border-left: 4px solid transparent;
  background: var(--color-bg); margin-bottom: 6px; cursor: pointer;
}
.agenda-item:hover { filter: brightness(0.97); }
.agenda-item-body { flex: 1; min-width: 0; }
.agenda-item-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.agenda-item-meta { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-add-btn { margin-top: 2px; }

@media print {
  .topbar, .toolbar, .no-print { display: none !important; }
  body { background: #fff; }
}

@media (max-width: 720px) {
  .page { padding: 14px; }
  .day-cell { min-height: 90px; }
  .toolbar h2 { min-width: 0; font-size: 16px; }
  .panel { padding: 14px; }

  /* Týdenní pohled: mřížka 7 sloupců se na úzké obrazovce nevejde čitelně -
     přepne se na jeden sloupec, dny pod sebou (jméno dne se přesune přímo
     k datu, protože samostatný řádek se záhlavími dnů se schová). */
  .week-grid { grid-template-columns: 1fr; gap: 8px; }
  .week-grid .weekday-head { display: none; }
  .week-grid .day-cell { min-height: 0; }
  .week-day-name { display: inline; font-weight: 700; margin-right: 4px; }

  /* Modaly ať využijí celou šířku obrazovky s menším okrajem. */
  .modal-overlay { padding: 16px 10px; }
  .modal { padding: 18px; }
}
