:root {
  /* Oficiální barevná paleta dle dokumentu "Standardy SCM/VSCM" (ČLS) */
  --cls-cream: #f8f1e7;
  --cls-cream-dark: #efe3d2;
  --cls-gold: #f2c230;
  --cls-gold-dark: #d9a714;
  --cls-peach: #f5bc8e;
  --cls-peach-light: #fcf1e8;
  --cls-peach-border: #e59b60;
  --cls-blue: #9cc9df;
  --cls-blue-light: #eef6fa;
  --cls-blue-dark: #1d5b79;
  --cls-green-bg: #dfefe0;
  --cls-green-text: #1c6b2a;
  --cls-navy: #0f2b5b;
  --cls-red: #d9232e;

  --bg-page: #faf7f2;
  --bg-card: #ffffff;
  --text-main: #18181b;
  --text-muted: #52525b;
  --border-color: #e4ded5;

  --status-ok: #16a34a;
  --status-ok-bg: #dcfce7;
  --status-warn: #d97706;
  --status-warn-bg: #fef3c7;
  --status-missing: #dc2626;
  --status-missing-bg: #fee2e2;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 43, 91, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 43, 91, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 43, 91, 0.14);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

a {
  color: var(--cls-navy);
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

.initial-loader {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--cls-cream-dark);
  border-top-color: var(--cls-navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================
   HLAVIČKA DLE DOKUMENTU STANDARDY SCM/VSCM
   ========================================= */
.app-header {
  background: var(--cls-cream);
  border-bottom: 2px solid var(--cls-peach);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.archery-emblem {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--cls-peach);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.brand-titles h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #111;
  line-height: 1.15;
}

.brand-titles p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.cls-logo-box {
  background: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
}

.cls-logo-img {
  height: 40px;
  width: auto;
  object-fit: contain;
  display: block;
}

.user-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.user-pill-name {
  font-weight: 700;
  color: var(--text-main);
}

.header-text-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-main);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.header-text-link:hover {
  color: #9a3412;
}

.user-role-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.role-badge.archer { background: var(--cls-peach-light); color: #9a4a06; border: 1px solid var(--cls-peach); }
.role-badge.personal_coach { background: var(--cls-blue-light); color: var(--cls-blue-dark); border: 1px solid var(--cls-blue); }
.role-badge.center_coach { background: #fef3c7; color: #92400e; border: 1px solid var(--cls-gold); }
.role-badge.admin { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }

/* NAVIGAČNÍ ZÁLOŽKY */
.nav-bar {
  background: #fff;
  border-bottom: 1px solid var(--border-color);
}

.nav-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow-x: auto;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--text-main);
  background: var(--bg-page);
}

.nav-tab.active {
  color: var(--cls-navy);
  border-bottom-color: var(--cls-gold);
  background: #fffdf7;
}

/* HLAVNÍ OBSAH */
.main-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* TLAČÍTKA */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--cls-navy);
  color: #fff;
}
.btn-primary:hover {
  background: #173f82;
}

.btn-gold {
  background: var(--cls-gold);
  color: #111;
  font-weight: 700;
}
.btn-gold:hover {
  background: var(--cls-gold-dark);
}

.btn-outline {
  background: #fff;
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-outline:hover {
  background: var(--cls-cream);
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fecaca;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 13px 22px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

/* =========================================
   PŘIHLAŠOVACÍ OBRAZOVKA
   ========================================= */
.login-wrapper {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-grid {
  max-width: 480px;
  width: 100%;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #111;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: #27272a;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d4cfc7;
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--cls-navy);
  box-shadow: 0 0 0 3px rgba(15, 43, 91, 0.12);
}

.demo-account-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 440px;
  overflow-y: auto;
}

.demo-account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fcfaf7;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.demo-account-item:hover {
  border-color: var(--cls-gold-dark);
  background: var(--cls-cream);
}

/* =========================================
   PÁS KALENDÁŘNÍCH TÝDNŮ (MOBILE-FIRST)
   ========================================= */
.missing-weeks-alert {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-left: 5px solid #ea580c;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.missing-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.missing-chip {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.missing-chip:hover {
  background: #fecaca;
}

.week-strip-container {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.week-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.week-strip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-behavior: smooth;
}

.week-pill {
  min-width: 96px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  background: #fafafa;
  cursor: pointer;
  text-align: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.week-pill.filled {
  background: #f0fdf4;
  border-color: #86efac;
}

.week-pill.missing {
  background: #fef2f2;
  border-color: #fca5a5;
}

.week-pill.selected {
  border-color: var(--cls-navy);
  box-shadow: 0 0 0 3px rgba(15, 43, 91, 0.18);
  transform: translateY(-1px);
}

.week-pill-num {
  font-weight: 800;
  font-size: 0.9rem;
  color: #111;
}

.week-pill-dates {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 2px 0 4px;
}

.week-pill-status {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  display: inline-block;
}

.week-pill.filled .week-pill-status {
  background: #dcfce7;
  color: #15803d;
}

.week-pill.missing .week-pill-status {
  background: #fee2e2;
  color: #b91c1c;
}

/* =========================================
   FORMULÁŘ TÝDENNÍHO ZÁZNAMU LUKOSTŘELCE
   ========================================= */
.log-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.log-entry-card {
  border: 2.5px solid var(--cls-peach-border);
  box-shadow: 0 6px 20px rgba(229, 155, 96, 0.18);
}

.log-editor-grid > *,
.card,
.week-strip-container {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 960px) {
  .log-editor-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.section-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-banner.archery {
  background: var(--cls-peach);
  color: #111;
}

.section-banner.conditioning {
  background: var(--cls-blue);
  color: #111;
}

.metric-input-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  background: #fff;
}

.metric-input-card.archery-tint {
  background: #fffaf5;
  border-color: #f3d5b8;
}

.metric-input-card.cond-tint {
  background: #f7fbfd;
  border-color: #c5e0ed;
}

.metric-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.metric-name {
  font-weight: 700;
  font-size: 0.98rem;
}

.metric-target-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.metric-number-input {
  width: 120px;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  padding: 8px 10px;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-sm);
}

.quick-Chip-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-btn {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.quick-btn:hover {
  background: var(--cls-cream);
  border-color: var(--cls-navy);
}

.progress-track {
  height: 8px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.25s ease;
}

.progress-fill.good { background: var(--status-ok); }
.progress-fill.warn { background: var(--status-warn); }
.progress-fill.low  { background: var(--status-missing); }

/* =========================================
   KPI KARTY A REPORTING
   ========================================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--cls-gold);
}

.kpi-card.archery::before { background: var(--cls-peach-border); }
.kpi-card.conditioning::before { background: var(--cls-blue-dark); }

.kpi-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  margin: 6px 0 4px;
  color: #111;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.pct-badge {
  font-size: 0.76rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 99px;
}
.pct-badge.good { background: var(--status-ok-bg); color: var(--status-ok); }
.pct-badge.warn { background: var(--status-warn-bg); color: var(--status-warn); }
.pct-badge.low  { background: var(--status-missing-bg); color: var(--status-missing); }

/* TABULKA STANDARDŮ A REPORTINGU */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.scm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.scm-table th {
  background: var(--cls-gold);
  color: #111;
  font-weight: 800;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #d9a714;
  white-space: nowrap;
}

.scm-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.scm-table tr:hover td {
  background: #fcf9f2;
}

/* FILTRAČNÍ PANEL REPORTINGU */
.filter-bar {
  background: var(--cls-cream);
  border: 1px solid var(--cls-peach);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

/* GRAFY */
.chart-box {
  width: 100%;
  overflow-x: auto;
}

.metric-pill-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.metric-pill {
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-color);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.metric-pill.active {
  background: var(--cls-navy);
  color: #fff;
  border-color: var(--cls-navy);
}

/* MODÁLNÍ OKNA (Metodika ČLS, Editace uživatele, Detail střelce) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-window {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 860px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

/* ZELENÝ BOX DLE PDF */
.cls-green-callout {
  background: var(--cls-green-bg);
  border: 1px solid #b7dfb9;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: #14532d;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
}

/* PATIČKA */
.app-footer {
  background: var(--cls-cream);
  border-top: 1px solid var(--border-color);
  padding: 20px 16px;
  margin-top: 40px;
}

.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.toast-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  background: #15803d;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
  box-shadow: var(--shadow-lg);
}
.toast-notification.error {
  background: #b91c1c;
}

/* =========================================
   MOBILNÍ OPTIMALIZACE (<= 640px)
   ========================================= */
body.mobile-preview-mode {
  width: 390px !important;
  max-width: 390px !important;
}

@media (max-width: 640px) {
  .header-inner {
    padding: 8px 10px;
    gap: 8px;
  }
  .archery-emblem {
    width: 34px;
    height: 34px;
  }
  .brand-titles h1 {
    font-size: 1.05rem;
  }
  .brand-titles p {
    display: none;
  }
  .cls-logo-img {
    height: 26px;
  }
  .cls-logo-box {
    padding: 2px 6px;
  }
  .header-right {
    width: auto;
    justify-content: flex-end;
    gap: 6px;
  }
  .user-pill {
    padding: 4px 8px;
    font-size: 0.76rem;
    gap: 6px;
  }
  .nav-inner {
    padding: 0 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .nav-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }
  .nav-tab {
    justify-content: center;
    padding: 9px 6px;
    font-size: 0.82rem;
  }
  .main-container {
    padding: 10px 8px 40px;
  }
  .card {
    padding: 12px 10px;
    border-radius: var(--radius-md);
  }
  .week-strip-container {
    padding: 10px;
    margin-bottom: 12px;
  }
  .week-pill {
    min-width: 82px;
    padding: 6px 6px;
  }
  .metric-input-card {
    padding: 10px;
    margin-bottom: 10px;
  }
  .metric-top-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-bottom: 6px;
  }
  .metric-name {
    font-size: 0.9rem;
  }
  .metric-target-label {
    font-size: 0.76rem;
  }
  .metric-controls-row {
    display: grid;
    grid-template-columns: 88px 1fr;
    align-items: stretch;
    gap: 8px;
  }
  .metric-number-input {
    width: 100%;
    font-size: 1.3rem;
    padding: 6px 4px;
    height: 100%;
  }
  .quick-Chip-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    width: 100%;
  }
  .quick-btn {
    padding: 6px 4px;
    font-size: 0.75rem;
    text-align: center;
    white-space: nowrap;
  }
}

.export-icons-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.export-badge-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.export-badge-link.pdf {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.export-badge-link.pdf:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.export-badge-link.excel {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.export-badge-link.excel:hover {
  background: #dcfce7;
  border-color: #4ade80;
}
