*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f5f7;
  --white: #ffffff;
  --border: #dde1e7;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-light: #eff4ff;
  --accent-hover: #1d4ed8;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --total-bg: #f1f5fd;
  --head-bg: #1e293b;
  --head-text: #e2e8f0;
  --row-hover: #f8faff;
  --cell-hover: #dbeafe;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* Nav */
.topnav {
  background: var(--head-bg);
  color: var(--head-text);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
  color: var(--head-text);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 13px;
  opacity: .8;
  transition: opacity .15s, background .15s;
}
.nav-links a:hover { opacity: 1; background: rgba(255,255,255,.1); }
.nav-logout {
  background: none;
  border: 1px solid rgba(255,255,255,.25);
  color: var(--head-text);
  cursor: pointer;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 5px;
  opacity: .8;
  transition: opacity .15s, background .15s;
  align-self: center;
}
.nav-logout:hover { opacity: 1; background: rgba(255,255,255,.1); }

/* Main layout */
main { padding: 24px; max-width: 100%; }

.page-header { margin-bottom: 20px; }

/* KPI karty */
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  text-align: center;
}
.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  white-space: nowrap;
}
.kpi-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--text); }
.meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.meta.empty { color: var(--red); }

/* Pivot table wrapper */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--white);
}

table.pivot {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 13px;
}

table.pivot thead tr {
  background: var(--head-bg);
  color: var(--head-text);
}

table.pivot th {
  padding: 10px 12px;
  font-weight: 600;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.08);
  background: var(--head-bg);
}
table.pivot th.col-technik {
  text-align: left;
  min-width: 160px;
  position: sticky;
  left: 0;
  z-index: 4;
}
table.pivot th.col-month   { text-align: right; min-width: 80px; }
table.pivot th.col-total   { text-align: right; min-width: 90px; background: rgba(255,255,255,.07); }

table.pivot tbody tr:hover { background: var(--row-hover); }
table.pivot tbody tr:nth-child(even) { background: #fafbfc; }
table.pivot tbody tr:nth-child(even):hover { background: var(--row-hover); }

.cell-technik {
  padding: 8px 12px;
  font-weight: 500;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--white);
  z-index: 2;
  border-right: 2px solid var(--border);
}
tbody tr:nth-child(even) .cell-technik { background: #fafbfc; }
tbody tr:hover .cell-technik { background: var(--row-hover); }

.cell-val {
  padding: 8px 12px;
  text-align: right;
  white-space: nowrap;
  color: var(--muted);
  border-right: 1px solid var(--border);
}
.cell-val.has-val {
  color: var(--text);
  cursor: pointer;
  transition: background .12s;
}
.cell-val.has-val:hover { background: var(--cell-hover); color: var(--accent); }

.cell-rowtotal {
  padding: 8px 14px;
  text-align: right;
  font-weight: 600;
  background: var(--total-bg);
  white-space: nowrap;
  color: var(--accent);
  border-left: 2px solid var(--border);
}

table.pivot tfoot tr {
  background: var(--total-bg);
  border-top: 2px solid var(--border);
}
table.pivot tfoot td { padding: 9px 12px; }
.cell-coltotal {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
  border-right: 1px solid var(--border);
}
.cell-grandtotal {
  text-align: right;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  white-space: nowrap;
  border-left: 2px solid var(--border);
  padding: 9px 14px;
}
tfoot .cell-technik { font-weight: 700; background: var(--total-bg); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 960px;
  animation: slide-in .15s ease;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 16px 18px; overflow-x: auto; }
.modal-body .loading { color: var(--muted); }

/* Detail table inside modal */
table.detail {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
table.detail th {
  background: var(--head-bg);
  color: var(--head-text);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  font-weight: 600;
}
table.detail th.num { text-align: right; }
table.detail td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.detail td.num { text-align: right; }
table.detail tr:last-child td { border-bottom: none; }
table.detail tr:hover td { background: var(--row-hover); }
table.detail tfoot td {
  font-weight: 700;
  background: var(--total-bg);
  border-top: 2px solid var(--border);
  padding: 8px 10px;
  color: var(--accent);
}
table.detail tfoot td.num { text-align: right; }
.modal-count { color: var(--muted); font-size: 12px; margin-top: 10px; text-align: right; }

/* Card / forms */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 540px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.card p  { color: var(--muted); margin-bottom: 16px; font-size: 13px; }
.card-top-actions { text-align: right; margin-bottom: 16px; }

.login-card { max-width: 360px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--accent); }

.btn {
  display: inline-block;
  padding: 9px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 13px;
  padding: 6px 14px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.alert {
  padding: 12px 16px;
  border-radius: 5px;
  margin-bottom: 20px;
  font-size: 13px;
}
.alert-ok    { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.alert-error { background: var(--red-bg);   color: var(--red);   border: 1px solid #fecaca; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 32px 20px;
  text-align: center;
  margin-bottom: 16px;
  transition: border-color .15s, background .15s;
  position: relative;
}
.drop-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }
.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.drop-label { color: var(--muted); cursor: pointer; font-size: 13px; }
.drop-label u { color: var(--accent); }

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}

/* Badge */
.badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Technici list */
.technici-list {
  list-style: none;
  margin-top: 12px;
}
.technici-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.technici-list li:last-child { border-bottom: none; }

.technik-stat-only .technik-name { color: var(--muted); }

.tag-odmeny {
  display: inline-block;
  background: var(--green-bg);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.tag-stat {
  display: inline-block;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.btn-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.btn-toggle:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.btn-hide {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.btn-hide:hover { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }

.btn-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 4px;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.btn-remove:hover { background: var(--red-bg); color: var(--red); }

.btn-locked {
  font-size: 14px;
  cursor: default;
  opacity: .5;
  display: inline-block;
  padding: 2px 4px;
}

.add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.select-field, .text-field {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.select-field:focus, .text-field:focus { border-color: var(--accent); }

.divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 12px 0;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--border);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }

/* Weekend rows in detail */
tr.row-weekend td { background: #fffbeb; }
tr.row-weekend:hover td { background: #fef3c7; }

/* Excluded rows in detail */
tr.row-excluded td { color: var(--muted); background: #fafafa !important; }
tr.row-excluded .odmena-cell { color: var(--red); }
tr.row-excluded.row-weekend td { background: #fafafa !important; }

.btn-excl {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 4px;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.btn-excl:hover { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.btn-excl.btn-excl-on { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }

.cell-nazev { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

/* Ceník — stromová tabulka */
.row-current { background: #f8faff; }

.stav-group-row { cursor: pointer; }
.stav-group-row:hover td { background: var(--row-hover) !important; }
.stav-group-row td { border-bottom: 1px solid var(--border); }

.cell-stav { padding: 9px 12px; font-weight: 500; }

.expand-icon {
  display: inline-block;
  width: 14px;
  font-size: 9px;
  color: var(--muted);
  transition: color .15s;
  margin-right: 4px;
}

.badge-versions {
  background: #e0e7ff;
  color: #3730a3;
}

.version-container td { padding: 0; }
.version-row td { border-bottom: 1px solid #f0f0f0; background: var(--bg); }
.version-current td { background: #f0fdf4; }
.version-add-row td { background: #f8f9fb; border-top: 1px dashed var(--border); }

.inline-add-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline-input { padding: 5px 8px; font-size: 12px; }

/* Empty state */
.tag-hourly {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}
.tag-flat {
  display: inline-block;
  background: #f0fdf4;
  color: #16a34a;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}

.btn-warn {
  background: #d97706;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-warn:hover { background: #b45309; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state p { margin-bottom: 16px; font-size: 15px; }
