/* Refresh OS - base stylesheet
   Min font-size 16px pro obsahový text. Žádné em-pomlčky. */

:root {
  --brand: #2d8a3e;
  --brand-dark: #1f6b2c;
  --brand-light: #e8f5ec;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --bg: #f7f8f7;
  --surface: #ffffff;
  --border: #e3e6e3;
  --danger: #c0392b;
  --warning: #d97706;
  --success: #15803d;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Lexend', system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

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

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 60px;
  box-sizing: border-box;
}

/* Druhá sticky lišta s kontextem stránky (název lokace, akce) */
.page-stage {
  position: sticky;
  top: 60px;
  z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 2px 4px rgba(0,0,0,.04);
  margin-bottom: 20px;
}
.page-stage .stage-title { flex: 1; min-width: 200px; }
.page-stage .stage-title h1 { margin: 0; font-size: 1.25rem; }
.page-stage .stage-title .meta { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }
.page-stage .stage-actions { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
  border: 1px solid var(--brand);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.icon-btn svg { display: block; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
}
.modal-box h2 { margin-top: 0; margin-bottom: 16px; }
.modal-recap {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .95rem;
  line-height: 1.8;
}
.modal-recap strong { color: var(--text-muted); font-weight: 600; }

/* ── Product picker (multi-select s limit inputem) ───────────────────────── */
.product-picker {
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
  max-height: 50vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  background: var(--bg);
}
.picker-cat {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 700;
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .05em;
  padding: 6px 12px;
  margin: 4px 0 2px;
  border-radius: 4px;
}
.picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 6px;
  margin: 2px 0;
  cursor: pointer;
  border: 1px solid transparent;
}
.picker-row:hover { background: var(--brand-light); }
.picker-row.checked {
  background: #ecfdf5;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}
.picker-row input[type=checkbox] {
  width: 20px;
  height: 20px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--brand);
}
.picker-info { flex: 1; min-width: 0; }
.picker-name { font-weight: 600; color: var(--text); }
.picker-meta { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }
.picker-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.picker-qty input[type=number] {
  width: 80px;
  padding: 6px 8px;
  font-size: .95rem;
  font-weight: 600;
  text-align: right;
  border: 1px solid var(--border);
  border-radius: 6px;
  -moz-appearance: textfield;
}
.picker-qty input[type=number]::-webkit-outer-spin-button,
.picker-qty input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.picker-qty input[type=number]:disabled {
  background: var(--bg);
  color: var(--text-muted);
  opacity: .5;
}
.picker-qty input[type=number]:not(:disabled) {
  background: white;
  border-color: var(--brand);
}
.picker-unit {
  color: var(--text-muted);
  font-size: .85rem;
  min-width: 24px;
}
.icon-btn:hover { background: var(--brand); color: white; }
@media (max-width: 700px) {
  .page-stage { padding: 10px 16px; }
  .page-stage .stage-title h1 { font-size: 1.05rem; }
}
.topbar .brand {
  display: flex;
  align-items: center;
  line-height: 1;
}
.topbar .brand a {
  display: block;
  line-height: 0;
}
.topbar .brand img {
  height: 44px;
  width: auto;
  display: block;
}
.topbar nav {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}
.topbar nav a {
  padding: 8px 14px;
  border-radius: 6px;
  color: var(--text);
}
.topbar nav a.active,
.topbar nav a:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  text-decoration: none;
}
.nav-badge {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: .7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
  min-width: 16px;
  text-align: center;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-link {
  padding: 12px 20px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 1rem;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tab-link:hover {
  color: var(--text);
  text-decoration: none;
}
.tab-link.active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
}
.tab-link .tab-count {
  display: inline-block;
  background: var(--border);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.tab-link.active .tab-count {
  background: var(--brand);
  color: white;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.pagination a,
.pagination .current,
.pagination .dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}
.pagination a { background: var(--bg); }
.pagination a:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  text-decoration: none;
}
.pagination a.disabled {
  opacity: .4;
  pointer-events: none;
}
.pagination .current {
  background: var(--brand);
  color: white;
}
.pagination .dots {
  color: var(--text-muted);
  min-width: auto;
}
.pagination .info {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .85rem;
}
@media (max-width: 700px) {
  .pagination .info { margin-left: 0; width: 100%; text-align: center; margin-top: 8px; }
}
.topbar .user {
  font-size: .95rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  align-items: center;
}
.topbar .user a { color: var(--text-muted); }

main {
  flex: 1;
  padding: 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

footer.app-footer {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: .9rem;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat .label {
  font-size: .9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat .value {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}
.stat .sub {
  font-size: .9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--brand);
  transition: width .3s;
}
.progress.warn > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

/* ── Tables ───────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: #fafbfa;
  font-weight: 600;
  font-size: .92rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
tbody tr:nth-child(even) { background: #f8faf8; }
tbody tr:hover { background: #eef5ef; }
tbody tr[data-href] { cursor: pointer; }
tbody tr[data-href]:hover { background: var(--brand-light); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Forms / buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }

input[type=text], input[type=email], input[type=password], input[type=number],
textarea, select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
label {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.field { margin-bottom: 16px; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert.error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.alert.success { background: var(--brand-light); border-color: #bce5c4; color: var(--brand-dark); }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}
.login-box h1 {
  text-align: center;
  color: var(--brand-dark);
  margin-bottom: 24px;
}

/* ── Tablet ───────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 12px; }
  .topbar nav a { padding: 8px 10px; }
  h1 { font-size: 1.5rem; }
}

/* ── Servisní rychlozadávání (kompaktní tlačítka pro tablet) ──────────────── */
.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.qty-control button {
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  border-radius: 6px;
  background: var(--brand-light);
  color: var(--brand-dark);
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 700;
  flex-shrink: 0;
}
.qty-control input {
  width: 56px;
  height: 36px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  padding: 0 4px;
  -moz-appearance: textfield;
}
.qty-control input::-webkit-outer-spin-button,
.qty-control input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-control button.confirm-btn {
  width: auto;
  padding: 0 10px;
  font-size: .85rem;
  background: white;
  color: var(--brand-dark);
  border: 1px solid var(--brand);
  white-space: nowrap;
}
.qty-control button.confirm-btn:hover { background: var(--brand-light); }

/* ── Cockpit karty (dashboard přehledy) ───────────────────────────────────── */
.cockpit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.cockpit-card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: transform .15s, box-shadow .15s;
}
.cockpit-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.cockpit-card.primary { border-left-color: var(--brand); }
.cockpit-card.warn    { border-left-color: var(--warning); background: #fffbeb; }
.cockpit-card.danger  { border-left-color: var(--danger); background: #fef2f2; }
.cockpit-label {
  font-size: .82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.cockpit-value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 4px;
  white-space: nowrap;
}
.cockpit-sub {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 6px;
}
.cockpit-link {
  display: inline-block;
  margin-top: 10px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--brand-dark);
}

/* ── Kalendář návštěv (globální) ──────────────────────────────────────────── */
.cal-wrap { overflow-x: auto; padding: 4px 0; }
.cal-table { border-collapse: separate; border-spacing: 2px; box-shadow: none; background: transparent; }
.cal-table th, .cal-table td { padding: 0; border: none; background: transparent; }
.cal-loc-col { text-align: left !important; padding-right: 12px !important; font-weight: 600; color: var(--text); white-space: nowrap; font-size: .9rem; text-transform: none !important; letter-spacing: 0 !important; background: transparent !important; }
.cal-day { width: 28px; height: 24px; text-align: center; font-size: .75rem; font-weight: 600; color: var(--text-muted); background: transparent !important; text-transform: none !important; letter-spacing: 0 !important; }
.cal-day.nonwork { color: #cbd5e1; }
.cal-day.today { background: var(--brand) !important; color: white !important; border-radius: 4px; }
.cal-cell { width: 28px; height: 28px; background: #f8faf8 !important; border-radius: 4px; text-align: center; vertical-align: middle; position: relative; }
.cal-cell.nonwork { background: #f1f5f9 !important; }
.cal-cell.today { background: #fef3c7 !important; box-shadow: inset 0 0 0 2px var(--brand); }
.cal-cell.clickable { cursor: pointer; }
.cal-cell.clickable:hover { background: var(--brand-light) !important; }
.cal-link { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; text-decoration: none; }

/* Stav návštěvy: ikony */
.cal-dot {
  display: inline-block; width: 16px; height: 16px; vertical-align: middle;
  background: transparent; border: none;
}
/* Plánovaná: zelený prázdný kruh */
.cal-dot.planned {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--brand);
}
/* Proběhlá: zelená fajfka */
.cal-dot.done {
  background: none; width: 16px; height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.5 3.5 6.5-7' fill='none' stroke='%232d8a3e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  border-radius: 0;
}
/* Zrušená adminem: červený křížek */
.cal-dot.cancelled, .cal-dot.cancelled-admin {
  background: none; width: 16px; height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' fill='none' stroke='%23dc2626' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  border-radius: 0;
}
/* Zrušená zákazníkem: oranžový křížek */
.cal-dot.cancelled-customer {
  background: none; width: 16px; height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' fill='none' stroke='%23f59e0b' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  border-radius: 0;
}
/* Přeskočená: žlutý vykřičník */
.cal-dot.skipped {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fbbf24;
}
/* Dnes indikátor */
.cal-dot.today {
  background: var(--brand);
  border: 2px solid var(--brand-dark);
  width: 12px; height: 12px;
  border-radius: 50%;
}
