/* Docházka – vzhled. Světlý i tmavý režim podle systému. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #dde2e9;
  --text: #1c2128;
  --muted: #667080;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e3ecfd;
  --ok: #16803c;
  --ok-soft: #e2f4e8;
  --warn: #b45309;
  --warn-soft: #fdf1df;
  --danger: #c62828;
  --danger-soft: #fdeaea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 1px 8px rgba(20, 30, 50, .04);
  --tabbar-h: 62px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1c1f25;
    --surface-2: #262a32;
    --border: #333843;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --accent: #5b8def;
    --accent-text: #0b1020;
    --accent-soft: #1f2d4a;
    --ok: #4cc276;
    --ok-soft: #173323;
    --warn: #f0a650;
    --warn-soft: #3a2a14;
    --danger: #f07070;
    --danger-soft: #3b1d1f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 22px; }
h3 { font-size: 16px; display: flex; align-items: center; gap: 6px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
main { outline: none; padding: 12px max(16px, env(safe-area-inset-left)) 24px max(16px, env(safe-area-inset-right)); max-width: 1180px; margin: 0 auto; }
.loading { text-align: center; padding: 40px 0; }

/* --- horní lišta --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.5) blur(12px);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 17px; }
.brand img { border-radius: 6px; }
.sync-pill {
  border: 0; border-radius: 999px; padding: 5px 12px 5px 22px; font: inherit; font-size: 13px; font-weight: 550;
  background: var(--surface-2); color: var(--muted); position: relative; cursor: pointer; min-height: 30px;
}
.sync-pill:empty { visibility: hidden; }
.sync-pill::before { content: ""; position: absolute; left: 10px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: currentColor; }
.sync-pill.ok { background: var(--ok-soft); color: var(--ok); }
.sync-pill.pending, .sync-pill.syncing { background: var(--warn-soft); color: var(--warn); }
.sync-pill.syncing::before { animation: pulse 1s infinite; }
.sync-pill.offline { background: var(--surface-2); color: var(--muted); }
.sync-pill.error { background: var(--danger-soft); color: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
body.logged-out .topbar, body.logged-out .tabs { display: none; }

/* --- navigace: dole na telefonu, vlevo na širokém displeji --- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.5) blur(12px);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11.5px; font-weight: 550;
}
.tab.active { color: var(--accent); }

/* --- tlačítka a vstupy --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.full { width: 100%; }
.icon-btn { padding: 0; width: 44px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

input, select, textarea {
  font: inherit; font-size: 16px; /* 16px = iOS nezoomuje */
  color: var(--text); background: var(--surface-2);
  border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
textarea { resize: vertical; min-height: 64px; }
input.short { width: 96px; text-align: right; }
label { font-size: 13px; color: var(--muted); font-weight: 550; display: block; margin-bottom: 4px; }
.field { margin-top: 12px; }
.field:first-child { margin-top: 0; }

.switch {
  appearance: none; -webkit-appearance: none; width: 51px; height: 31px; min-height: 0; padding: 0;
  border-radius: 999px; background: var(--border); position: relative; cursor: pointer; flex-shrink: 0; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus { border-color: transparent; background: var(--border); }
.switch:checked:focus { background: var(--ok); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; font-size: 16px; color: var(--text); font-weight: 600; }
.switch-row span { display: inline-flex; align-items: center; gap: 8px; }

.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 14.5px; font-weight: 550; cursor: pointer; min-height: 40px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.banner { background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 14.5px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }

/* --- obrazovka dne --- */
.day-layout { display: grid; gap: 16px; }
.day-side { display: none; }
.day-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.day-title { position: relative; text-align: center; margin: 0; color: var(--text); cursor: pointer; }
.day-name { display: block; font-size: 21px; font-weight: 700; }
.day-name::first-letter { text-transform: uppercase; }
.day-date { display: block; font-size: 14px; color: var(--muted); font-weight: 500; }
.date-picker { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.back-today { display: block; text-align: center; font-size: 14px; margin-bottom: 10px; font-weight: 550; }

.type-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.type-picker .chip { padding: 8px 4px; border-radius: 12px; }

.time-field label { margin-bottom: 6px; }
.time-row { display: flex; gap: 6px; align-items: center; }
input.time { font-size: 26px; font-weight: 650; text-align: center; min-height: 56px; padding: 6px 4px; font-variant-numeric: tabular-nums; min-width: 0; flex: 1; }
input.time::-webkit-date-and-time-value { text-align: center; }
.btn.now { min-height: 56px; padding: 0 12px; background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.clear { width: 32px; padding: 0; font-size: 22px; color: var(--muted); }

.worked { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin: 16px 0 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.worked-value { display: inline; font-size: 34px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.worked-value.muted { color: var(--muted); font-weight: 600; }
.worked-label { color: var(--muted); margin-left: 8px; font-weight: 550; }
.worked-detail { color: var(--muted); font-size: 13.5px; }
.break-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.break-field label { margin: 0; }
.break-field input { max-width: 200px; text-align: right; }

.trip .field, .trip .grid2 { margin-top: 12px; }
.trip .switch-row { margin-bottom: 4px; }
.expenses { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.exp-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.exp-head h3 { color: var(--text); }
.exp-total { color: var(--text); font-weight: 700; font-size: 16px; }
.exp-row { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 6px; padding: 8px 0; border-bottom: 1px dashed var(--border); align-items: center; }
.exp-row .exp-note { grid-column: 1 / 3; }
.exp-row .icon-btn { grid-row: 1 / 3; grid-column: 3; color: var(--danger); }
.amount-wrap { position: relative; }
.amount-wrap .amount { padding-right: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.amount-wrap .unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.btn.add { margin-top: 6px; padding-left: 0; }

.day-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; justify-content: space-between; }
.saved-badge { color: var(--muted); font-size: 13px; transition: color .3s; }
.saved-badge.flash { color: var(--ok); }
.history { margin-top: 4px; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }

/* --- kalendář --- */
.calendar.compact { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.cal-title { font-weight: 650; margin-bottom: 8px; }
.cal-title::first-letter { text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.cal-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 50px; border-radius: 10px; background: var(--surface-2); color: var(--text); padding: 2px;
}
.compact .cal-cell { min-height: 42px; }
.cal-cell.pad { background: transparent; }
.cal-num { font-weight: 650; font-size: 14px; }
.cal-label { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 14px; }
.cal-trip { position: absolute; top: 3px; right: 4px; color: var(--accent); line-height: 0; }
.cal-cell.weekend, .cal-cell.holiday { background: transparent; border: 1px solid var(--border); }
.cal-cell.weekend .cal-num, .cal-cell.holiday .cal-num { color: var(--muted); }
.cal-cell.done { background: var(--ok-soft); }
.cal-cell.done .cal-label { color: var(--ok); font-weight: 600; }
.cal-cell.partial { background: var(--warn-soft); }
.cal-cell.missing { background: var(--danger-soft); }
.cal-cell.missing .cal-num { color: var(--danger); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.selected { background: var(--accent); }
.cal-cell.selected .cal-num, .cal-cell.selected .cal-label { color: var(--accent-text); }

/* --- měsíc --- */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-nav h2::first-letter { text-transform: uppercase; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 550; }
.stat-value { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; color: var(--muted); }
.stat.pos .stat-value { color: var(--ok); }
.stat.neg .stat-value { color: var(--danger); }
.warning { background: var(--danger-soft); border-color: transparent; }
.warn-head { display: flex; align-items: center; gap: 4px; font-weight: 650; color: var(--danger); margin-bottom: 8px; }
.missing-list { display: flex; flex-wrap: wrap; gap: 6px; }
.missing-list .chip { background: var(--surface); min-height: 36px; padding: 6px 12px; color: var(--danger); }
.filters { display: flex; gap: 6px; overflow-x: auto; margin: -4px -4px 10px; padding: 4px; scrollbar-width: none; }
.filters .chip { white-space: nowrap; }
.day-table { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.day-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--border); }
.day-table td { padding: 9px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.day-table tr { cursor: pointer; }
.day-table tr:hover td { background: var(--surface-2); }
.day-table tr.missing td.c-date a { color: var(--danger); }
.c-date { white-space: nowrap; font-weight: 600; }
.c-num { text-align: right; font-weight: 650; }
.missing-tag { color: var(--danger); font-weight: 600; }
.empty { text-align: center; padding: 20px 0; }
.breakdown { margin-top: 14px; }
.breakdown-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.export-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; }
.cal-card { display: none; }

@media (max-width: 599px) {
  /* Na telefonu časy pod sebou – velká pole pro palec */
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .type-picker .chip { font-size: 14px; }
  /* Na telefonu jen podstatné sloupce */
  .day-table th:nth-child(3), .day-table td:nth-child(3), .day-table th:nth-child(4), .day-table td:nth-child(4) { display: none; }
  .day-table td.c-trip { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* --- nastavení --- */
.settings h2 { margin-bottom: 12px; }
.settings h3 { margin-bottom: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-row input[type=time] { width: 120px; text-align: center; }
.set-label { font-weight: 550; }
.day-toggles { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-toggles .chip { padding: 6px 0; }
.guide { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.guide.warning { background: var(--warn-soft); }
.guide ol { margin: 8px 0; padding-left: 22px; }
.guide li { margin: 4px 0; }
.guide svg { vertical-align: -3px; }
.status-line { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.status-line.ok { color: var(--ok); }
.status-line.off { color: var(--muted); }
.devices ul { margin: 4px 0 0; padding-left: 20px; font-size: 14px; }

/* --- přihlášení --- */
.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login img { border-radius: 18px; }
.login h1 { margin: 12px 0 20px; }
.login form { display: grid; gap: 10px; }
.login input { text-align: center; }

/* --- toast --- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; font-weight: 550;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* --- široký displej (Mac, iPad) --- */
@media (min-width: 600px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .cal-card { display: block; }
}
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 92px; }
  .tabs {
    top: 0; right: auto; width: 92px; height: auto; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 70px 0 0; border-top: 0; border-right: 1px solid var(--border);
  }
  .tab { flex: none; height: 68px; }
  .topbar { padding-left: 28px; padding-right: 28px; }
  main { padding: 20px 28px 40px; }
  #toast { bottom: 24px; }
  .day-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 24px; }
  .day-side { display: block; position: sticky; top: 76px; }
  .month-body { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
  .month-body .card { margin-bottom: 0; }
  .exp-row { grid-template-columns: 150px 140px 1fr 44px; }
  .exp-row .exp-note { grid-column: auto; }
  .exp-row .icon-btn { grid-row: auto; grid-column: auto; }
}
@media (min-width: 900px) and (max-width: 1100px) {
  .month-body { grid-template-columns: 1fr; }
}
