/* Cutheads Design System — Premium Dark + Refined Gold */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Surface hierarchy — warm charcoal, not pure black */
  --bg: #0B0A09;
  --bg-subtle: #111110;
  --surface: #171614;
  --surface-hover: #1E1D1A;
  --card: #1A1917;
  --card-hover: #222119;
  --border: #2A2825;
  --border-hover: #3D3A34;

  /* Gold accent — desaturated, premium */
  --accent: #C9A84C;
  --accent-hover: #D4B85E;
  --accent-dim: rgba(201, 168, 76, 0.10);
  --accent-glow: rgba(201, 168, 76, 0.18);
  --accent-text: #E8D48B;
  --accent-gradient: linear-gradient(135deg, #C9A84C 0%, #E8D48B 50%, #C9A84C 100%);

  /* Semantic colors */
  --success: #3CB371;
  --success-dim: rgba(60, 179, 113, 0.10);
  --error: #D94F4F;
  --error-dim: rgba(217, 79, 79, 0.10);
  --warning: #D4A03C;
  --info: #5B8FD4;
  --info-dim: rgba(91, 143, 212, 0.10);

  /* Typography */
  --text: #EDECE9;
  --text-secondary: #9C9A93;
  --text-muted: #6B6963;
  --text-inverse: #0B0A09;

  /* Radii — consistent scale */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Shadows — tinted to background */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
  --shadow: 0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.55);
  --shadow-glow: 0 0 24px var(--accent-glow);

  /* Motion — exponential ease-out (no bounce) */
  --transition-fast: 120ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 320ms cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-expo: 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .fade-in {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Fade-in animation for Intersection Observer */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Subtle grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* Monospace for numbers */
.num, td.num, th.num, .kpi-card .value, .metric-pill .value {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-variant-numeric: tabular-nums;
}

/* Focus States — Accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: var(--text-inverse);
  padding: 8px 16px;
  z-index: 1000;
  font-weight: 600;
  border-radius: 0 0 var(--radius-sm) 0;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: 0; }

/* Navigation — Subtle glass with gold accent */
.nav {
  background: rgba(17, 17, 16, 0.92);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent-gradient);
  opacity: 0.3;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
  min-height: 36px;
  display: flex;
  align-items: center;
  letter-spacing: 0.01em;
}

.nav a:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.nav a.active {
  background: var(--accent-dim);
  color: var(--accent-text);
  font-weight: 600;
}

/* Header — Premium with gold accent */
.header {
  background: var(--surface);
  padding: 28px 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  opacity: 0.8;
}

.header::after {
  content: '';
  position: absolute;
  top: 0;
  right: -100px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  opacity: 0.15;
  pointer-events: none;
}

.header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: relative;
}

.header .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
  letter-spacing: 0.01em;
  position: relative;
}

/* Sections */
.section { padding: 24px; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-title:first-child { border-top: none; padding-top: 0; }

/* KPI Cards — Refined */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--ease-out-expo);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
  transform: translateY(-2px);
}

.kpi-card:hover::before { opacity: 1; }

/* KPI value animation on load */
@keyframes kpi-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.kpi-card .value {
  animation: kpi-fade-up 0.4s ease-out both;
}

.kpi-card .label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.kpi-card .value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.kpi-card .change {
  font-size: 12px;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.kpi-card .change.up { color: var(--success); }
.kpi-card .change.down { color: var(--error); }

.kpi-card .target {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  opacity: 0.75;
}

/* Chart Boxes */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.charts-full { grid-template-columns: 1fr; }

.chart-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 280px;
  overflow: hidden;
}

.chart-box:hover {
  border-color: var(--border-hover);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.chart-box h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-box canvas { min-height: 200px; }

/* Tables */
.table-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.table-box h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
  color: var(--text-secondary);
}

td.num { text-align: right; }
th.num { text-align: right; }

tr:last-child td { border-bottom: none; }

tr:hover td {
  background: var(--surface-hover);
  color: var(--text);
}

tr.highlight td { background: var(--accent-dim); }

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tag-maps { background: var(--accent-dim); color: var(--accent-text); }
.tag-site { background: var(--error-dim); color: var(--error); }
.tag-data { background: var(--success-dim); color: var(--success); }
.tag-plan { background: var(--accent-dim); color: var(--accent-text); }
.tag-finance { background: var(--error-dim); color: var(--error); }
.tag-marketing { background: var(--info-dim); color: var(--info); }

/* Index Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 40px 24px;
  max-width: 1000px;
  width: 100%;
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition-slow), transform var(--ease-out-expo);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--accent-glow) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.card:hover::before { opacity: 1; }

.card .icon {
  width: 44px;
  height: 44px;
  background: var(--accent-dim);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  transition: background var(--transition), transform var(--ease-out-expo);
  position: relative;
}

.card:hover .icon {
  background: var(--accent-glow);
  transform: scale(1.05);
}

.card .icon svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 6px; letter-spacing: 0.01em; }
.card p { font-size: 13px; color: var(--text-secondary); line-height: 1.55; }
.card .tag { margin-top: 12px; }

/* Forms */
input, select, textarea {
  font-family: inherit;
  font-size: 13px;
}

button {
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  min-height: 36px;
}

/* Footer */
.footer {
  padding: 20px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  letter-spacing: 0.01em;
}

/* Tab bar — premium pill style */
.tab-bar {
  display: flex;
  gap: 3px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
}

.tab-btn {
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 34px;
  letter-spacing: 0.01em;
}

.tab-btn:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.tab-btn.active {
  background: var(--accent-dim);
  color: var(--accent-text);
  border-color: rgba(201, 168, 76, 0.15);
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Metric pills */
.metric-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.metric-pill {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  flex: 1;
  min-width: 140px;
  transition: border-color var(--transition);
}

.metric-pill:hover { border-color: var(--border-hover); }

.metric-pill .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.metric-pill .value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
}

.metric-pill .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-red { background: var(--error-dim); color: var(--error); }
.badge-green { background: var(--success-dim); color: var(--success); }
.badge-yellow { background: var(--accent-dim); color: var(--accent-text); }

/* Barber cards */
.barber-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  flex: 1;
  min-width: 200px;
  transition: border-color var(--transition);
}

.barber-card:hover { border-color: var(--border-hover); }

.barber-card h4 {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
  font-weight: 600;
}

.barber-stat {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.barber-stat:last-child { border-bottom: none; }
.barber-stat .k { color: var(--text-muted); }
.barber-stat .v { color: var(--text); font-weight: 500; }

/* Simple table (analytics) */
.table-simple { width: 100%; }
.table-simple th { font-size: 10px; }
.table-simple td { font-size: 12px; padding: 8px 10px; }

/* Responsive — Mobile First */
@media (max-width: 1024px) {
  .nav { padding: 0 16px; }
  .header { padding: 24px 16px; }
  .section { padding: 16px; }
}

@media (max-width: 768px) {
  .nav { padding: 0 12px; gap: 4px; }
  .nav-toggle { display: flex !important; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(17, 17, 16, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 6px;
    gap: 1px;
    z-index: 99;
    max-height: 70vh;
    overflow-y: auto;
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: 12px 14px;
    font-size: 14px;
    min-height: 44px;
    width: 100%;
    border-radius: var(--radius-sm);
    flex-shrink: 1;
  }
  .nav-links a.active { background: var(--accent-dim); color: var(--accent-text); }
  .header { padding: 20px 16px; }
  .header h1 { font-size: 18px; letter-spacing: 0.06em; }
  .header .subtitle { font-size: 12px; margin-top: 3px; }
  .section { padding: 12px; }
  .section-title { font-size: 10px; padding-top: 14px; margin-bottom: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-card .value { font-size: 20px; }
  .kpi-card .label { font-size: 10px; }
  .charts { grid-template-columns: 1fr; gap: 10px; }
  .chart-box { padding: 14px; min-height: 220px; overflow: hidden; }
  .chart-box h3 { font-size: 11px; margin-bottom: 12px; }
  .chart-box canvas { min-height: 160px; width: 100% !important; }
  .cards { grid-template-columns: 1fr; padding: 16px; gap: 10px; }
  .card { padding: 18px; }
  .card h2 { font-size: 15px; }
  .card p { font-size: 13px; }
  table { font-size: 12px; }
  th { padding: 8px; font-size: 10px; }
  td { padding: 8px; font-size: 12px; }
  .table-box { padding: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .footer { padding: 14px; font-size: 11px; }
  .filter-form { flex-direction: column !important; align-items: stretch; gap: 8px !important; }
  .filter-form label { margin-bottom: -4px; }
  .filter-form select,
  .filter-form input[type="date"] { width: 100%; }
  .filter-form .filter-row { display: flex; gap: 8px; align-items: center; }
  .filter-form .filter-row span { flex-shrink: 0; }
  .actions-grid { grid-template-columns: 1fr !important; }
  .summary-text { font-size: 12px !important; }
  .compare-grid { grid-template-columns: 1fr !important; }
  .tab-bar { padding: 8px 12px; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 7px 12px; font-size: 12px; white-space: nowrap; min-height: 32px; }
  .metric-pill { min-width: 120px; }
  .barber-card { min-width: auto; }
}

@media (max-width: 480px) {
  .header { padding: 16px 12px; }
  .header h1 { font-size: 16px; }
  .kpi-grid { grid-template-columns: 1fr !important; }
  .kpi-card { padding: 12px; }
  .kpi-card .value { font-size: 18px; }
  .section { padding: 10px; }
  .section-title { font-size: 10px; padding-top: 12px; margin-bottom: 10px; }
  .chart-box { padding: 10px; min-height: 180px; }
  .chart-box canvas { min-height: 140px; }
  .barber-card { padding: 12px; min-width: auto; }
  .barber-stat { font-size: 11px; }
  .svc-row { flex-wrap: wrap; gap: 8px; padding: 10px; }
  .svc-stats { width: 100%; justify-content: space-between; }
  .svc-stat { min-width: auto; }
  .metric-row { gap: 8px; }
  .metric-pill { min-width: 100%; padding: 10px 12px; }
  .metric-pill .value { font-size: 18px; }
  .metric-pill .label { font-size: 9px; }
  .tab-bar { padding: 8px 10px; gap: 2px; }
  .tab-btn { padding: 6px 10px; font-size: 11px; white-space: nowrap; min-height: 30px; }
  .compare-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .nav a { font-size: 12px; padding: 6px 10px; }
  .cards { padding: 12px; }
  .card { padding: 16px; }
  .card h2 { font-size: 14px; }
  .card p { font-size: 12px; }
}

/* Hamburger menu */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 8px 10px;
  min-height: 36px;
  min-width: 36px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
  .nav a, .tab-btn, button, .card, .kpi-card {
    min-height: 44px;
    min-width: 44px;
  }
  .svc-row { cursor: default; }
  .svc-row:hover { border-color: var(--border); }
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Mobile touch scroll for tables and tab bars */
.table-box, .charts {
  -webkit-overflow-scrolling: touch;
}

/* Mobile form improvements */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px;
    padding: 12px;
  }
  button {
    min-height: 44px;
    padding: 10px 18px;
  }
  .nav-links a {
    padding: 14px 16px;
    min-height: 48px;
  }
  .filter-form input[type="date"],
  .filter-form select {
    min-height: 44px;
  }
}

/* Safe area for notch devices */
@supports (padding: env(safe-area-inset-bottom)) {
  .footer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .nav { padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); }
}

/* Utility Classes */
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-text); }

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Selection color */
::selection {
  background: var(--accent-dim);
  color: var(--accent-text);
}

/* Smooth page transitions */
@keyframes page-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.section {
  animation: page-enter 0.35s ease-out both;
}

/* Table row stagger animation */
@keyframes row-enter {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

tr {
  animation: row-enter 0.2s ease-out both;
}

/* Stagger effect for table rows */
tr:nth-child(1) { animation-delay: 0ms; }
tr:nth-child(2) { animation-delay: 20ms; }
tr:nth-child(3) { animation-delay: 40ms; }
tr:nth-child(4) { animation-delay: 60ms; }
tr:nth-child(5) { animation-delay: 80ms; }
tr:nth-child(6) { animation-delay: 100ms; }
tr:nth-child(7) { animation-delay: 120ms; }
tr:nth-child(8) { animation-delay: 140ms; }
tr:nth-child(9) { animation-delay: 160ms; }
tr:nth-child(10) { animation-delay: 180ms; }

/* Progress bar for loading states */
.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar::after {
  content: '';
  display: block;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 2px;
  animation: progress-shimmer 1.5s ease-in-out infinite;
}

@keyframes progress-shimmer {
  0% { width: 0%; }
  50% { width: 100%; }
  100% { width: 0%; }
}

/* Tooltip style */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background: var(--surface);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* KPI Section Levels — grid-based collapse (no layout thrash) */
.kpi-section-collapsed {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s ease-out;
  margin-bottom: 0;
  overflow: hidden;
}

.kpi-section-collapsed > .kpi-section-inner,
.kpi-section-expanded > .kpi-section-inner {
  overflow: hidden;
  min-height: 0;
}

.kpi-section-collapsed > * {
  min-height: 0;
}

.kpi-section-expanded {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.4s ease-in;
  margin-bottom: 24px;
}

/* Toggle button for KPI sections */
.kpi-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 16px;
  font-family: 'DM Sans', sans-serif;
}

.kpi-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}

.kpi-toggle .arrow {
  transition: transform var(--transition);
  font-size: 10px;
}

.kpi-toggle.active .arrow {
  transform: rotate(180deg);
}

/* Empty state component */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  min-height: 200px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 1.5;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.5;
}

/* Error state component */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: var(--error-dim);
  border: 1px solid rgba(217, 79, 79, 0.2);
  border-radius: var(--radius);
  text-align: center;
  min-height: 200px;
}

.error-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
}

.error-state-icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--error);
  fill: none;
  stroke-width: 1.5;
}

.error-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--error);
  margin-bottom: 8px;
}

.error-state-text {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.error-state-action {
  padding: 10px 20px;
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-family: 'DM Sans', sans-serif;
}

.error-state-action:hover {
  background: #c44040;
}

/* Level indicators */
.kpi-level-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-text);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-level-label::before {
  content: '';
  flex: 0 0 20px;
  height: 1px;
  background: var(--accent);
  opacity: 0.4;
}

/* Loading skeleton for KPI cards */
.kpi-skeleton {
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
  min-height: 100px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton loading */
@keyframes skeleton-pulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { opacity: 0.6; }
}

.skeleton {
  background: var(--surface);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  width: 100%;
}

.skeleton-line:last-child {
  width: 60%;
}

.skeleton-card {
  height: 100px;
  width: 100%;
}

.skeleton-chart {
  height: 200px;
  width: 100%;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

/* Notification dot */
.badge-dot {
  position: relative;
}

.badge-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 6px;
  height: 6px;
  background: var(--error);
  border-radius: 50%;
  border: 1.5px solid var(--card);
}

/* ============================================
   Nav Group Separators
   ============================================ */
.nav-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
  opacity: 0.6;
}

@media (max-width: 768px) {
  .nav-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .nav-separator {
    width: 100%;
    height: 1px;
    margin: 4px 0;
  }
}

/* ============================================
   Dashboard Component Classes
   ============================================ */

/* Header */
.header-layout {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.header-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Telegram Button */
.btn-telegram {
  padding: 7px 16px;
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.01em;
}

.btn-telegram:hover {
  background: var(--accent-hover);
}

.tg-status {
  font-size: 11px;
  color: var(--text-muted);
}

/* Filter Form */
.filter-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-label {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.filter-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

.filter-input:focus {
  border-color: var(--accent);
  outline: none;
}

.filter-submit {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

.filter-submit:hover {
  background: var(--accent-hover);
}

.filter-reset {
  padding: 7px 16px;
  border-radius: 6px;
  background: var(--error);
  color: #fff;
  font-size: 13px;
  text-decoration: none;
}

.filter-reset:hover {
  opacity: 0.9;
}

.filter-info {
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
}

.filter-separator {
  color: var(--text-muted);
  font-size: 13px;
  margin-left: 16px;
}

.filter-separator-inline {
  color: var(--text-muted);
}

/* Marketing Toggle */
.marketing-toggle {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--border);
  font-weight: 500;
  transition: background 0.15s;
}

.marketing-toggle.on {
  background: var(--success);
  color: var(--text-inverse);
}

.marketing-toggle.off {
  background: var(--card);
  color: var(--text-secondary);
}

/* KPI Grid Variants */
.kpi-grid-180 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi-grid-160 {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.kpi-grid-3col {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
  .kpi-grid-3col {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* KPI Card Variants */
.kpi-border-success { border-color: var(--success); }
.kpi-border-accent  { border-color: var(--accent); }
.kpi-border-error   { border-color: var(--error); }
.kpi-border-blue    { border-color: var(--blue, #3B82F6); }
.kpi-border-info    { border-color: var(--info, #3B82F6); }
.kpi-border-marketing { border-color: var(--error); }

/* Accent via subtle top border (not side-tab) */
.kpi-left-success {
  border-top: 2px solid var(--success);
}

.kpi-left-default {
  border-top: 2px solid var(--border);
}

.kpi-small-value {
  font-size: 20px;
}

/* Color utility for values */
.value-success { color: var(--success); }
.value-accent  { color: var(--accent); }
.value-error   { color: var(--error); }
.value-blue    { color: var(--blue, #3B82F6); }
.value-info    { color: var(--info, #3B82F6); }

/* Chart Box */
.chart-box-margin {
  margin-bottom: 16px;
}

/* Summary Box */
.summary-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.summary-forecast {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  font-family: 'JetBrains Mono', monospace;
}

.summary-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 14px;
}

.summary-actions-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.action-card-title {
  font-size: 12px;
  font-weight: 600;
}

.action-card-title.success { color: var(--success); }
.action-card-title.accent  { color: var(--accent-text); }
.action-card-title.muted   { color: var(--text-secondary); }

.action-card-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Table highlight */
.text-success-cell { color: var(--success); }

/* Notification link accent */
.nav-link-accent { color: var(--accent); }
.nav-link-error  { color: var(--error); }

/* Skeleton loading overlay */
.skeleton-overlay {
  position: relative;
  z-index: 10;
  transition: opacity 0.3s ease-out;
}

.skeleton-overlay .kpi-grid {
  pointer-events: none;
}

.skeleton-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
}

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-hover) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-value {
  height: 28px;
  width: 60%;
  margin-bottom: 8px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Scrollbar theming */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Selection */
::selection {
  background: var(--accent-dim);
  color: var(--accent-text);
}
