/* ==========================================================================
   STATISTICKÝ PŘEHLED NABÍDEK VE MĚSTECH ČR - STYLY
   ========================================================================== */

/* Hlavní navigace v hlavičce */
.main-nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 22, 34, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px;
  border-radius: 12px;
  backdrop-filter: blur(12px);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.nav-link:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.15);
}

.nav-new-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #ffffff;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
}

/* Sekce filtrů pro statistický přehled */
.stats-filter-panel {
  padding: 20px 24px;
  margin-bottom: 24px;
  background: rgba(17, 24, 39, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.stats-filter-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.stats-filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stats-filter-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Decentní rolovátko dispozic */
.disposition-select-wrapper {
  position: relative;
  min-width: 190px;
}

.disposition-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 9px 38px 9px 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #f1f5f9;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.disposition-select:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(15, 23, 42, 0.95);
}

.disposition-select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.disposition-select-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #64748b;
  transition: transform 0.2s ease;
}

.disposition-select:focus + .disposition-select-icon {
  color: #38bdf8;
  transform: translateY(-50%) rotate(180deg);
}

/* Hledání a akce */
.stats-secondary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.search-box-wrap {
  position: relative;
  min-width: 260px;
  flex: 1;
  max-width: 400px;
}

.search-box-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #f1f5f9;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.search-box-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
  background: rgba(15, 23, 42, 0.95);
}

.search-box-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
}

.btn-stats-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #e2e8f0;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-stats-action:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-stats-action.primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-color: rgba(56, 189, 248, 0.4);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.btn-stats-action.primary:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

.col-count-pill {
  padding: 2px 7px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ==========================================================================
   KPI KARTY SOUHRNU (AGREGOVANÁ DATA)
   ========================================================================== */
.overview-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.overview-kpi-card {
  padding: 20px;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.overview-kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.16);
}

.overview-kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.kpi-speed::before {
  background: linear-gradient(90deg, #10b981, #06b6d4);
}

.kpi-dom::before {
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
}

.kpi-spread::before {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.kpi-volume::before {
  background: linear-gradient(90deg, #06b6d4, #3b82f6);
}

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

.kpi-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.kpi-icon {
  font-size: 1.3rem;
}

.kpi-main-val {
  font-size: 1.85rem;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi-subtext {
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.4;
}

.kpi-highlights-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-city-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.kpi-city-name {
  font-weight: 600;
  color: #e2e8f0;
}

.kpi-city-speed {
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  padding: 1px 7px;
  border-radius: 6px;
}

/* ==========================================================================
   STATISTICKÁ TABULKA
   ========================================================================== */
.stats-table-card {
  padding: 0;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  position: relative;
}

.table-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(17, 24, 39, 0.85);
  flex-wrap: wrap;
  gap: 12px;
}

.table-title-group h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.table-count-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.table-subtitle {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-top: 4px;
}

.table-responsive-container {
  width: 100%;
  overflow-x: auto;
  max-height: 720px;
  position: relative;
}

/* Custom scrollbar pro tabulku */
.table-responsive-container::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}
.table-responsive-container::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.8);
}
.table-responsive-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 5px;
}
.table-responsive-container::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.4);
}

.stats-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
  text-align: left;
  white-space: nowrap;
}

/* Hlavička tabulky - Tier 1 a Tier 2 s neprůhledným pozadím pro plynulý scroll */
:root {
  --tier1-header-height: 38px;
}

.stats-table thead {
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-tier-group th {
  position: sticky;
  top: 0;
  z-index: 32;
  background-clip: padding-box;
  background-color: #0d131f;
  padding: 6px 12px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  line-height: 1.25;
}

.tier1-badge {
  font-weight: 800;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tier1-sub {
  font-size: 0.67rem;
  font-weight: 500;
  opacity: 0.85;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 2px;
}

.header-tier-group th.group-meta {
  background-color: #162032;
  color: #94a3b8;
  text-align: left;
}

.header-tier-group th.group-g1 {
  background-color: #271d12;
  color: #fbbf24;
  border-bottom-color: #f59e0b;
}

.header-tier-group th.group-spread-1 {
  background-color: #0f241a;
  color: #34d399;
}

.header-tier-group th.group-g2 {
  background-color: #121e33;
  color: #60a5fa;
  border-bottom-color: #3b82f6;
}

.header-tier-group th.group-spread-2 {
  background-color: #0f241a;
  color: #34d399;
}

.header-tier-group th.group-g3 {
  background-color: #0d2224;
  color: #2dd4bf;
  border-bottom-color: #14b8a6;
}

.header-tier-group th.group-dom {
  background-color: #1e132b;
  color: #c084fc;
}

.header-tier-group th.group-delisted {
  background-color: #10281b;
  color: #4ade80;
  border-bottom-color: #22c55e;
}

.header-tier-group th.group-action {
  background-color: #162032;
  color: #94a3b8;
}

.header-tier-cols th {
  position: sticky;
  top: var(--tier1-header-height, 38px);
  z-index: 31;
  background-clip: padding-box;
  background-color: #0f172a;
  padding: 11px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.header-tier-cols th:hover {
  background-color: #1e293b;
  color: #f1f5f9;
}

.header-tier-cols th.sorted {
  color: #38bdf8;
  background-color: #16263f;
}

.th-content {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
}

.th-content.right {
  justify-content: flex-end;
}

.th-sort-icon {
  font-size: 0.7rem;
  color: #64748b;
}

.header-tier-cols th.sorted .th-sort-icon {
  color: #38bdf8;
}

/* Řádky tabulky */
.stats-table tbody tr {
  transition: background 0.12s ease;
}

.stats-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.stats-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.06);
}

.stats-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
}

.td-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Město buňka - kompaktní 2 řádky pro zamezení roztažení */
.stats-table th[data-col="city_name"],
.stats-table td[data-col="city_name"] {
  width: 160px;
  min-width: 140px;
  max-width: 175px;
  white-space: normal;
}

.city-cell-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.city-link-btn {
  font-weight: 700;
  color: #f1f5f9;
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.25;
  transition: color 0.15s ease;
  word-break: normal;
  overflow-wrap: break-word;
}

.city-link-btn:hover {
  color: #38bdf8;
}

.city-badges-sub {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.city-rank-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.growth-badge-small {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 4px;
}

.growth-up {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.growth-down {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.growth-flat {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
}

/* Hodnoty za metr a spready */
.val-m2-bold {
  font-weight: 700;
  color: #f8fafc;
}

.val-dom {
  color: #cbd5e1;
}

.spread-tag {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.spread-tag-czk {
  font-weight: 700;
  color: #10b981;
}

.spread-tag-czk.negative {
  color: #ef4444;
}

.spread-tag-pct {
  font-size: 0.72rem;
  color: #6ee7b7;
}

.spread-tag-pct.negative {
  color: #fca5a5;
}

/* Rychlost prodeje stažených */
.speed-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
}

.speed-ultra-fast {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.speed-fast {
  background: rgba(6, 182, 212, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.speed-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.speed-slow {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.val-delist-price {
  font-weight: 700;
  color: #e2e8f0;
}

.val-delist-sub {
  font-size: 0.72rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  font-weight: 600;
}

.val-delist-dom-sub {
  font-size: 0.72rem;
  color: #34d399;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  font-weight: 600;
}

.val-delist-m2-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  font-weight: 500;
}

.delist-sub-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
  line-height: 1;
}

.val-delist-dom-sub .delist-sub-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.25);
}

.btn-row-detail {
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-row-detail:hover {
  background: #38bdf8;
  color: #0f172a;
}

/* Agregovaný souhrnný řádek (Footer) */
.stats-table tfoot {
  position: sticky;
  bottom: 0;
  z-index: 15;
}

.stats-table tfoot tr {
  background: #0f172a !important;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
}

.stats-table tfoot td {
  padding: 14px 14px;
  border-top: 2px solid rgba(56, 189, 248, 0.3);
  font-weight: 800;
  color: #f8fafc;
  background: #0f172a;
}

.stats-table tfoot .summary-label {
  color: #38bdf8;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ==========================================================================
   MODÁLNÍ OKNO NASTAVENÍ SLOUPCŮ (COLUMN MANAGER)
   ========================================================================== */
.col-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 20px 0;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 8px;
}

.col-modal-section {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 16px;
}

.col-modal-sec-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.col-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.col-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
  user-select: none;
}

.col-checkbox-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.col-checkbox-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.8);
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.col-checkbox-item input[type="checkbox"]:checked {
  background: #0284c7;
  border-color: #38bdf8;
}

.col-checkbox-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.col-checkbox-label {
  font-size: 0.85rem;
  color: #cbd5e1;
  font-weight: 500;
}

.col-presets-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.col-preset-btn {
  padding: 6px 12px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.col-preset-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

/* Skrytý sloupec */
.col-hidden {
  display: none !important;
}

/* Responsivita */
@media (max-width: 900px) {
  .stats-filter-main-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .stats-secondary-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box-wrap {
    max-width: 100%;
  }

  .main-nav-links {
    width: 100%;
    justify-content: center;
    margin-top: 10px;
  }
}

/* Městské části Prahy v tabulce */
.is-district-row {
  background: rgba(30, 41, 59, 0.22);
}

.is-district-row:hover {
  background: rgba(56, 189, 248, 0.08) !important;
}

.city-cell-district {
  padding-left: 14px;
}

.district-tree-branch {
  color: #38bdf8;
  font-weight: 700;
  margin-right: 4px;
}

.district-sub-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
  letter-spacing: 0.03em;
}

