/*
  Marius Pedersen – Evidence výroby
  Firemní barvy z loga: grafitová #2b2a29, modrá #00a0e3, bílá.
*/
:root {
  --ink: #1d2124;
  --ink-2: #2b2a29;
  --muted: #5d6973;
  --line: #dfe5ea;
  --line-2: #eef2f5;
  --bg: #f3f6f8;
  --card: #ffffff;
  --blue: #00a0e3;
  --blue-d: #0079b0;
  --blue-l: #e3f4fc;
  --ok: #17824b;
  --warn: #b45309;
  --bad: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 14px rgba(16, 24, 32, .05);
}

* { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Archivo", "Inter", system-ui, sans-serif; margin: 0; line-height: 1.2; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- tlačítka a pole ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid transparent;
  font: 600 14px "Inter", system-ui, sans-serif;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid rgba(0, 160, 227, .45); outline-offset: 2px; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--blue); color: var(--blue-d); }
.btn.quiet { background: transparent; color: var(--ink); }
.btn.quiet:hover { background: var(--line-2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }

input[type=text], input[type=password], input[type=month], textarea {
  font: 16px "Inter", system-ui, sans-serif;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  min-height: 42px;
  width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 160, 227, .2); }

/* ---------- přihlášení ---------- */
.login {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    linear-gradient(160deg, transparent 0 55%, rgba(0, 160, 227, .10) 55% 100%),
    linear-gradient(20deg, var(--ink-2) 0 18%, transparent 18%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(16, 24, 32, .14);
  padding: 32px;
  display: grid; gap: 8px;
}
.login-logo { width: 170px; height: auto; margin-bottom: 12px; }
.login-card h1 { font-size: 26px; }
.login-sub { margin: 0 0 12px; color: var(--muted); }
.login-card label { font-weight: 600; font-size: 14px; margin-top: 6px; }
.login-card .btn { margin-top: 16px; min-height: 46px; font-size: 15px; }
.form-error { color: var(--bad); font-size: 14px; margin: 6px 0 0; min-height: 1.2em; }

/* ---------- horní lišta ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 60px; padding: 0 20px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { height: 34px; width: auto; }
.brand-title { font: 600 16px "Archivo", sans-serif; padding-left: 14px; border-left: 1px solid var(--line); }
.appbar-right { display: flex; align-items: center; gap: 8px; }
.user { font-size: 14px; color: var(--muted); }
.user::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: 1px; }

/* ---------- rozvržení ---------- */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sidebar {
  background: #fff; border-right: 1px solid var(--line);
  padding: 20px 16px;
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px); overflow-y: auto;
}
.new-month label { font-weight: 600; font-size: 13px; color: var(--muted); display: block; margin-bottom: 6px; }
.new-month-row { display: flex; gap: 8px; }
.new-month-row input { flex: 1; }
.side-title { font: 600 13px "Inter", sans-serif; color: var(--muted); margin: 24px 0 8px; }
.month-list { display: grid; gap: 2px; }
.year { font: 700 12px "Archivo", sans-serif; color: var(--muted); margin: 12px 8px 4px; letter-spacing: .02em; }
.month-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--ink); text-decoration: none; cursor: pointer;
  border: 0; background: transparent; text-align: left; width: 100%; font: inherit;
}
.month-item:hover { background: var(--line-2); }
.month-item.active { background: var(--blue-l); box-shadow: inset 3px 0 0 var(--blue); }
.month-item .mn { font-weight: 600; text-transform: capitalize; }
.month-item .mt { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.month-item .mu { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

.main { padding: 24px clamp(16px, 3vw, 36px) 60px; display: grid; gap: 20px; align-content: start; }

/* ---------- hlavička měsíce ---------- */
.month-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.month-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.month-title h1 { font-size: clamp(26px, 3vw, 34px); text-transform: capitalize; min-width: 7ch; text-align: center; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--ink);
}
.icon-btn:hover { border-color: var(--blue); color: var(--blue-d); }
.status {
  font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: var(--line-2); color: var(--muted);
}
.status[data-state=saved] { background: #e6f4ec; color: var(--ok); }
.status[data-state=saving] { background: var(--blue-l); color: var(--blue-d); }
.status[data-state=error] { background: #fbe9e7; color: var(--bad); }
.status[data-state=new] { background: #fff4e5; color: var(--warn); }

.month-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 40px; padding: 0 6px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--blue); }
.more { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  padding: 6px; min-width: 240px; display: grid;
}
.menu button { border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 6px; font: 14px "Inter", sans-serif; cursor: pointer; color: var(--ink); }
.menu button:hover { background: var(--line-2); }
.menu button.danger { color: var(--bad); }

.banner {
  background: #fff4e5; border: 1px solid #f6d3a5; color: #7a3b05;
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between;
}

/* ---------- karty a tabulky ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { padding: 16px 20px 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 18px; }
.card-head p { margin: 0; }
.scroll { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; }
thead th { background: #f7f9fb; font: 600 12.5px "Inter", sans-serif; color: var(--muted); border-bottom: 1px solid var(--line); }
.num { text-align: right; }
tfoot td { font-weight: 700; background: #f7f9fb; border-top: 1px solid var(--line); border-bottom: 0; }

.summary td:first-child, .summary th:first-child { padding-left: 20px; }
.summary td:last-child, .summary th:last-child { padding-right: 20px; }
.summary td.closing { font-weight: 700; color: var(--blue-d); }
.mat { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.opening-cell { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.opening-cell .tag { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--line-2); border-radius: 4px; padding: 1px 6px; }
.opening-cell .tag.manual { background: #fff4e5; color: var(--warn); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { display: block; font-size: 13px; color: var(--muted); }
.kpi strong { font: 700 24px "Archivo", sans-serif; font-variant-numeric: tabular-nums; }
.kpi strong small { font: 500 14px "Inter", sans-serif; color: var(--muted); margin-left: 4px; }
.kpi.accent { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.kpi.accent span { color: #b9c2c9; }
.kpi.accent strong small { color: #b9c2c9; }

/* ---------- denní záznamy ---------- */
.days-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.days-head h2 { font-size: 20px; }
.day-jump { display: flex; flex-wrap: wrap; gap: 4px; }
.day-jump button {
  min-width: 34px; height: 32px; padding: 0 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  font: 600 13px "Inter", sans-serif; cursor: pointer; color: var(--ink);
}
.day-jump button.has { background: var(--blue-l); border-color: #b5e2f7; color: var(--blue-d); }
.day-jump button.today { outline: 2px solid var(--ink-2); outline-offset: 1px; }
.day-jump button.we { color: var(--muted); }

#days { display: grid; gap: 14px; }
.day { scroll-margin-top: 76px; }
.day.weekend { opacity: .92; }
.day-head { padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.day-head h3 { font-size: 16px; text-transform: capitalize; }
.day-head .we-tag { font: 600 11px "Inter", sans-serif; color: var(--warn); background: #fff4e5; padding: 2px 8px; border-radius: 4px; margin-left: 8px; vertical-align: 2px; text-transform: none; }
.day-head .day-total { font-size: 13px; color: var(--muted); }
.day-head .day-total b { color: var(--ink); }
.day.today .day-head { box-shadow: inset 4px 0 0 var(--blue); }

.grid th.grp { text-align: center; color: var(--ink); background: #f0f4f7; border-left: 1px solid var(--line); }
.grid th.sub { font-weight: 500; }
.grid .sep { border-left: 1px solid var(--line); }
.grid td { padding: 5px 8px; }
.grid td:first-child, .grid th:first-child { padding-left: 20px; position: sticky; left: 0; background: #fff; z-index: 1; }
.grid thead th:first-child { background: #f7f9fb; }
.grid tfoot td:first-child { background: #f7f9fb; }
.grid tbody tr:hover td { background: #fafcfd; }
.grid td.daysum { font-weight: 600; text-align: right; padding-right: 20px; color: var(--ink-2); }
.grid tfoot td { text-align: right; padding-right: 12px; }
.grid tfoot td:first-child { text-align: left; }
.grid tfoot td:last-child { padding-right: 20px; }

.cell {
  width: 88px; min-height: 34px; padding: 6px 8px;
  border: 1px solid transparent; border-radius: 6px;
  background: var(--line-2);
  font: 15px "Inter", sans-serif; font-variant-numeric: tabular-nums;
  text-align: right; color: var(--ink);
}
.cell.ks { width: 68px; }
.cell:hover { border-color: var(--line); background: #fff; }
.cell:focus { outline: none; background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 160, 227, .18); }
.cell.filled { background: #fff; border-color: var(--line); }
.cell::placeholder { color: #b3bcc4; }
.cell.bad { border-color: var(--bad); background: #fff5f4; }
.cell.opening { width: 110px; }

.note-card { padding: 16px 20px 20px; }
.note-card h2 { font-size: 18px; margin-bottom: 10px; }
.note-card textarea { resize: vertical; font-size: 15px; }

/* ---------- dialog a toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(16, 24, 32, .45); display: grid; place-items: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 12px; padding: 24px; width: min(440px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-box h2 { font-size: 20px; margin-bottom: 8px; }
.modal-box p { margin: 0 0 20px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--ink-2); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px);
}

.print-report { display: none; }

/* ---------- úzké obrazovky ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .month-list { grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); overflow-x: auto; padding-bottom: 6px; }
  .year { display: none; }
}
@media (max-width: 600px) {
  .appbar { padding: 0 12px; }
  .brand-title { display: none; }
  .user { display: none; }
  .month-actions { width: 100%; }
  .month-actions .btn.primary { flex: 1; }
  .kpi strong { font-size: 20px; }
  .day-head { padding: 10px 14px; flex-wrap: wrap; }
}

/* ---------- tisk ---------- */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; }
  #app, #login, .modal, .toast { display: none !important; }
  .print-report { display: block !important; font: 10pt/1.35 "Inter", Arial, sans-serif; color: #000; }
  .pr-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #2b2a29; padding-bottom: 6pt; margin-bottom: 10pt; }
  .pr-head img { height: 34pt; }
  .pr-head h1 { font: 700 16pt "Archivo", Arial, sans-serif; }
  .pr-head p { margin: 0; font-size: 9pt; color: #444; text-align: right; }
  .print-report h2 { font: 700 12pt "Archivo", Arial, sans-serif; margin: 12pt 0 6pt; }
  .print-report table { width: 100%; border-collapse: collapse; page-break-inside: auto; }
  .print-report th, .print-report td { border: 0.5pt solid #9aa5ad; padding: 3pt 5pt; font-size: 9pt; }
  .print-report thead th { background: #e3f4fc !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-report tfoot td { font-weight: 700; background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-report tr { page-break-inside: avoid; }
  .print-report .day-row td { border-top: 1.2pt solid #2b2a29; }
  .print-report .pr-note { border: 0.5pt solid #9aa5ad; padding: 6pt; white-space: pre-wrap; }
}
