/* ============================================================
   FSRS BI — BGP template-main visual identity
   Sidebar 244px + header 70px + page (gradient + dot grid + cards)
   ============================================================ */

:root {
  --bg:        #05080a;
  --bg-1:      #080c0f;
  --surface:   #0d1216;
  --surface-2: #11181d;
  --surface-3: #161f25;
  --border:    #1a242a;
  --border-2:  #243038;
  --text:      #ffffff;
  --text-2:    #b8c2c8;
  --mute:      #6b7680;
  --mute-2:    #3a4348;

  --cyan:      #22d3ee;
  --cyan-2:    #67e8f9;
  --cyan-3:    #a5f3fc;
  --cyan-dim:  #0e7490;
  --cyan-glow: rgba(34, 211, 238, 0.35);
  --cyan-glow-strong: rgba(34, 211, 238, 0.6);
  --cyan-soft: rgba(34, 211, 238, 0.15);

  --green:     #10b981;
  --green-2:   #34d399;
  --green-soft:rgba(16, 185, 129, 0.18);

  --red:       #ef4444;
  --red-2:     #f87171;
  --red-soft:  rgba(239, 68, 68, 0.18);

  --amber:     #f59e0b;
  --amber-2:   #fcd34d;
  --gold:      #facc15;
  --silver:    #94a3b8;
  --bronze:    #c2845f;
  --violet:    #a78bfa;

  --radius:    14px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  --font-ui:   "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bot: env(safe-area-inset-bottom, 0px);

  --sidebar-w: 244px;
  --header-h: 70px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; outline: none; color: inherit; background: none; border: 0; }
input, select { font-family: inherit; outline: none; color: inherit; }
::selection { background: rgba(34,211,238,0.3); color: var(--text); }

/* ============================================================
   APP GRID
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  background: linear-gradient(180deg, #0a1014 0%, #05080a 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  position: relative;
  z-index: 30;
}

.sb-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-logo-img {
  display: block;
  width: 100%;
  max-width: 160px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(34,211,238,0.22));
}

.sb-section {
  padding: 22px 16px 8px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mute-2);
  font-weight: 600;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 0 12px 2px;
  border-radius: 10px;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  white-space: nowrap;
  transition: all 160ms cubic-bezier(.2,.7,.2,1);
  width: calc(100% - 24px);
}
.sb-item svg {
  width: 18px;
  height: 18px;
  color: var(--mute);
  flex-shrink: 0;
  transition: color 160ms;
}
.sb-item:hover {
  background: rgba(255,255,255,0.025);
  color: var(--text);
  border-color: var(--border);
}
.sb-item.active {
  background: rgba(34,211,238,0.08);
  color: var(--text);
  border-color: rgba(34,211,238,0.14);
}
.sb-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 10px; bottom: 10px;
  width: 3px;
  background: var(--cyan);
  border-radius: 0 3px 3px 0;
}
.sb-item.active svg { color: var(--cyan); }
.sb-item .label { flex: 1; }
.sb-item .badge {
  margin-left: auto;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(34,211,238,0.12);
  color: var(--cyan-2);
  font-family: var(--font-mono);
  font-weight: 600;
  border: 1px solid rgba(34,211,238,0.2);
  letter-spacing: 0.06em;
}

.sb-spacer { flex: 1; }

.sb-user {
  padding: 14px 14px 18px;
  padding-bottom: calc(18px + var(--sa-bot));
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, transparent, rgba(34,211,238,0.03));
}
.sb-user .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--cyan-dim);
  display: grid; place-items: center;
  color: var(--cyan-3);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.sb-user .who { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.sb-user .who b { font-size: 13px; font-weight: 600; color: var(--text); }
.sb-user .who span { font-size: 11px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sb-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  z-index: 25;
}

/* ============================================================
   MAIN
   ============================================================ */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  padding-top: var(--sa-top);
  gap: 16px;
  background: rgba(8,12,15,0.7);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.hd-icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  transition: all 160ms;
  flex-shrink: 0;
}
.hd-icon-btn:hover {
  background: var(--surface-2);
  color: var(--cyan-2);
  border-color: rgba(34,211,238,0.25);
  box-shadow: 0 0 18px -6px var(--cyan-glow-strong);
}
.hd-icon-btn svg { width: 16px; height: 16px; }
.hd-menu { display: none; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--mute);
}
.breadcrumb b { color: var(--text); font-weight: 600; }
.breadcrumb svg { width: 12px; height: 12px; color: var(--mute-2); flex-shrink: 0; }

.header-info {
  margin-left: auto;
  font-size: 12px;
  color: var(--mute);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-info strong { color: var(--text); font-weight: 600; }
.header-info .dot-led {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  flex-shrink: 0;
}

/* ============================================================
   LIVE INDICATOR — "AO VIVO" com pulse + age ticker
   ============================================================ */

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.10);
  border: 1px solid rgba(16, 185, 129, 0.28);
  font-size: 11px;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--green-2);
  flex-shrink: 0;
  transition: background 200ms, border-color 200ms, color 200ms;
  user-select: none;
}
.live-indicator .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: liveDotPulse 2s ease-in-out infinite;
}
.live-indicator .live-label { letter-spacing: 0.16em; }
.live-indicator .live-age {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--mute);
  font-weight: 500;
  letter-spacing: 0;
}
.live-indicator .live-age b { color: var(--text-2); font-weight: 700; }

@keyframes liveDotPulse {
  0%, 100% { transform: scale(1);   opacity: 1;   box-shadow: 0 0 8px var(--green); }
  50%      { transform: scale(1.35); opacity: 0.8; box-shadow: 0 0 14px var(--green); }
}

/* polling: ciano spinning-ish */
.live-indicator.polling {
  background: rgba(34, 211, 238, 0.10);
  border-color: rgba(34, 211, 238, 0.34);
  color: var(--cyan-2);
}
.live-indicator.polling .live-dot {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: livePollingDot 800ms ease-in-out infinite;
}
@keyframes livePollingDot {
  0%, 100% { transform: scale(0.8); opacity: 0.6; }
  50%      { transform: scale(1.3); opacity: 1; }
}

/* pulse: flash verde forte quando dados mudaram */
.live-indicator.pulse {
  background: rgba(16, 185, 129, 0.30);
  border-color: var(--green-2);
  color: var(--green-2);
  box-shadow: 0 0 22px -4px rgba(16,185,129,0.7);
}
.live-indicator.pulse .live-dot {
  animation: liveFlash 800ms ease-out;
}
@keyframes liveFlash {
  0%   { transform: scale(2.6); opacity: 0.0; }
  60%  { transform: scale(1.0); opacity: 1.0; }
  100% { transform: scale(1.0); opacity: 1.0; }
}

/* stale: âmbar — dados envelhecidos (> 3min) */
.live-indicator.stale {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.34);
  color: var(--amber-2);
}
.live-indicator.stale .live-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

/* error: vermelho */
.live-indicator.error {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.36);
  color: var(--red-2);
}
.live-indicator.error .live-dot {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: none;
}

/* ============================================================
   PAGE — gradient + dot grid + cards
   ============================================================ */

.page {
  flex: 1;
  overflow: auto;
  padding: 24px 28px 56px;
  position: relative;
  display: grid;
  grid-auto-rows: max-content;
  gap: 16px;
  background:
    radial-gradient(1800px 1100px at 100% -10%, rgba(34,211,238,0.18), transparent 55%),
    radial-gradient(1400px 900px at -10% 110%, rgba(8,145,178,0.14), transparent 55%),
    radial-gradient(1000px 700px at 50% 50%, rgba(20,184,166,0.05), transparent 60%),
    linear-gradient(180deg, #061218 0%, #04101a 50%, #050d18 100%);
}
.page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(180,220,235,0.10) 1.2px, transparent 0);
  background-size: 24px 24px;
}
.page > * { position: relative; z-index: 1; }

.screen { display: none; grid-auto-rows: max-content; gap: 16px; }
.screen.active { display: grid; animation: fadeIn 0.18s ease-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PAGE TITLE
   ============================================================ */

.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.page-title h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 4px;
  color: var(--text);
  line-height: 1.1;
}
.page-title .subtitle {
  color: var(--mute);
  font-size: 13px;
}
.page-title .subtitle b { color: var(--cyan-2); font-weight: 500; }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: rgba(8, 14, 18, 0.78);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: background 220ms;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 20px 40px -20px rgba(0,0,0,0.7),
    0 0 0 1px rgba(0,0,0,0.4);
  min-width: 0;
}
.card:hover { background: rgba(12, 19, 24, 0.84); }
.card.no-pad { padding: 0; overflow: hidden; }

.card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mute);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 16px;
  line-height: 1;
}
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title-row .card-title { margin: 0; }

.filters-card { padding: 14px 16px; }

/* ============================================================
   KPI ROW
   ============================================================ */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.kpi-tile {
  background: rgba(8, 14, 18, 0.78);
  backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 18px 20px 16px;
  position: relative;
  overflow: hidden;
  transition: background 220ms;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 20px 40px -20px rgba(0,0,0,0.7),
    0 0 0 1px rgba(0,0,0,0.4);
}
.kpi-tile:hover { background: rgba(12, 19, 24, 0.84); }
.kpi-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(560px 280px at 100% 0%, rgba(34,211,238,0.10), transparent 62%);
  pointer-events: none;
}
.kpi-tile.green::before {
  background:
    radial-gradient(560px 280px at 100% 0%, rgba(16,185,129,0.22), transparent 62%),
    linear-gradient(135deg, rgba(16,185,129,0.06), transparent 55%);
}
.kpi-tile.green { border-color: rgba(16,185,129,0.18) !important; }
.kpi-tile.amber::before {
  background:
    radial-gradient(560px 280px at 100% 0%, rgba(245,158,11,0.22), transparent 62%),
    linear-gradient(135deg, rgba(245,158,11,0.05), transparent 55%);
}
.kpi-tile.amber { border-color: rgba(245,158,11,0.18) !important; }
.kpi-tile.cyan::before {
  background:
    radial-gradient(560px 280px at 100% 0%, rgba(34,211,238,0.20), transparent 62%),
    linear-gradient(135deg, rgba(34,211,238,0.05), transparent 55%);
}
.kpi-tile.cyan { border-color: rgba(34,211,238,0.18) !important; }
.kpi-tile.violet::before {
  background:
    radial-gradient(560px 280px at 100% 0%, rgba(167,139,250,0.22), transparent 62%),
    linear-gradient(135deg, rgba(167,139,250,0.05), transparent 55%);
}
.kpi-tile.violet { border-color: rgba(167,139,250,0.18) !important; }
.kpi-tile > * { position: relative; }

.kpi-tile .kpi-label {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 6px;
}
.kpi-tile .kpi-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--text);
  line-height: 1;
  font-feature-settings: "tnum" 1, "ss01" 1;
}
.kpi-tile .kpi-sub {
  font-size: 11.5px;
  color: var(--mute);
  margin-top: 8px;
}

/* ============================================================
   GRID HELPERS
   ============================================================ */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.chart-host { width: 100%; min-height: 180px; }
.chart-host svg { width: 100%; height: auto; display: block; }

/* ============================================================
   FILTERS BAR
   ============================================================ */

.filters-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-lbl {
  font-size: 10.5px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
}

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 30px 9px 12px;
  font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='%236b7680' stroke-width='1.4' d='M2 4l3 3 3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: all 160ms;
  max-width: 100%;
}
.filter-select:hover { border-color: var(--border-2); background-color: var(--surface-2); }
.filter-select:focus { outline: 0; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,0.15); }

.filter-meta {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--mute);
  font-family: var(--font-mono);
}

/* ============================================================
   BAR CHART (rows) — legível e clicável
   ============================================================ */

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 7px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 13px;
  transition: background 140ms;
  border: 1px solid transparent;
}
.bar-row-clickable:hover {
  background: rgba(34,211,238,0.07);
  border-color: rgba(34,211,238,0.18);
}
.bar-row-clickable:hover .bar-arrow { color: var(--cyan-2); transform: translateX(2px); }
.bar-row-clickable:hover .bar-fill { box-shadow: 0 0 14px var(--cyan-glow-strong); }

.bar-label {
  flex: 0 0 auto;
  min-width: 120px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.bar-track {
  flex: 1;
  height: 20px;
  background: var(--surface-3);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
  min-width: 60px;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--cyan-2));
  border-radius: 5px;
  transition: width 0.4s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 10px var(--cyan-glow);
}
.bar-val {
  flex: 0 0 42px;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.bar-arrow {
  flex: 0 0 12px;
  color: var(--mute-2);
  font-size: 18px;
  line-height: 1;
  transition: transform 140ms, color 140ms;
  user-select: none;
}

.chart-empty {
  color: var(--mute);
  font-size: 12.5px;
  padding: 24px 0;
  text-align: center;
  font-style: italic;
}

/* ============================================================
   DRILLDOWN MODAL
   ============================================================ */

.drill-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.drill-modal.open { display: flex; animation: fadeIn 0.18s ease-out; }

.drill-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 10, 0.82);
  backdrop-filter: blur(10px) saturate(120%);
}

.drill-content {
  position: relative;
  background: rgba(11, 17, 22, 0.96);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  width: 100%;
  max-width: 1100px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 30px 80px -20px rgba(0,0,0,0.7),
    0 0 0 1px rgba(34,211,238,0.08);
  overflow: hidden;
}

.drill-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(800px 280px at 0% 0%, rgba(34,211,238,0.10), transparent 60%),
    rgba(13, 18, 22, 0.6);
  flex-shrink: 0;
}

.drill-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan-2);
  margin-bottom: 6px;
}

.drill-header h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.15;
}

.drill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--mute);
}
.drill-meta .dot-sep { color: var(--mute-2); }

.drill-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  transition: all 160ms;
}
.drill-close svg { width: 16px; height: 16px; }
.drill-close:hover {
  background: var(--surface-2);
  color: var(--red-2);
  border-color: rgba(239,68,68,0.32);
}

.drill-body {
  padding: 18px 26px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.drill-empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--mute);
  font-size: 13px;
}

.drill-table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.drill-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.drill-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--mute);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,18,22,0.6);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.drill-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.drill-table tr:last-child td { border-bottom: 0; }
.drill-table tbody tr:hover { background: rgba(34,211,238,0.04); }

.drill-table .drill-num {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--mute);
  font-size: 12px;
  width: 38px;
}

.drill-table .drill-cat {
  font-size: 12px;
  color: var(--text-2);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drill-fase-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--cyan-soft);
  color: var(--cyan-2);
  border: 1px solid rgba(34,211,238,0.2);
}

.drill-atletas { font-size: 13px; line-height: 1.5; min-width: 200px; }
.drill-atletas > div { display: flex; align-items: center; gap: 6px; }
.drill-atletas .drill-winner { color: var(--green-2); font-weight: 700; }
.drill-atletas .drill-loser { color: var(--mute); opacity: 0.75; }

.drill-uf-mini {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--cyan-2);
  background: var(--cyan-soft);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(34,211,238,0.15);
}

.drill-agenda {
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
}

.drill-result { min-width: 90px; }
.drill-score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--green-2);
  letter-spacing: -0.02em;
}
.drill-score .drill-x { color: var(--mute-2); margin: 0 4px; font-weight: 400; }
.drill-games { font-family: var(--font-mono); font-size: 11px; color: var(--mute); margin-top: 2px; }
.drill-pending {
  font-size: 10.5px;
  color: var(--amber-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.drill-row-finalized { background: rgba(16, 185, 129, 0.03); }

.drill-section-title {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 4px 0 12px;
}

.drill-atletas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.drill-atleta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.drill-atleta-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.drill-atleta-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.drill-cat-chip {
  font-size: 10px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  letter-spacing: 0.04em;
}

/* ============================================================
   STATES — pódio + tabela
   ============================================================ */

.podium {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.podium-card {
  background: rgba(8, 14, 18, 0.78);
  backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 18px 14px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 20px 40px -20px rgba(0,0,0,0.7),
    0 0 0 1px rgba(0,0,0,0.4);
}
.podium-card.gold { border-color: rgba(250,204,21,0.30); box-shadow: 0 0 32px -8px rgba(250,204,21,0.30), 0 1px 0 rgba(255,255,255,0.05) inset; }
.podium-card.silver { border-color: rgba(148,163,184,0.25); }
.podium-card.bronze { border-color: rgba(194,132,95,0.30); }

.podium-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.podium-card.gold::before   { background: radial-gradient(420px 220px at 100% 0%, rgba(250,204,21,0.16), transparent 60%); }
.podium-card.silver::before { background: radial-gradient(420px 220px at 100% 0%, rgba(148,163,184,0.12), transparent 60%); }
.podium-card.bronze::before { background: radial-gradient(420px 220px at 100% 0%, rgba(194,132,95,0.14), transparent 60%); }
.podium-card > * { position: relative; z-index: 1; }

.podium-medal { font-size: 24px; line-height: 1; margin-bottom: 4px; }
.podium-uf {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
  margin: 4px 0;
}
.podium-card.gold   .podium-uf { color: var(--gold); }
.podium-card.silver .podium-uf { color: var(--silver); }
.podium-card.bronze .podium-uf { color: var(--bronze); }
.podium-points {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.podium-meta { font-size: 10.5px; color: var(--mute); margin-top: 4px; letter-spacing: 0.5px; }

/* tabela de estados */
.states-table-host { overflow-x: auto; }
.states-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.states-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--mute);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.states-table th.num, .states-table td.num { text-align: right; }
.states-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.states-table tr:last-child td { border-bottom: 0; }
.states-table tbody tr { transition: background 140ms; }
.states-table tbody tr:hover { background: rgba(34,211,238,0.04); }

.uf-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.uf-rank {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: var(--surface-3);
  color: var(--mute);
}
.uf-rank.gold   { background: var(--gold); color: #1a0f00; }
.uf-rank.silver { background: var(--silver); color: #0a1015; }
.uf-rank.bronze { background: var(--bronze); color: #1a0700; }

.states-pts {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--cyan-2);
}
.states-pts.champ { color: var(--gold); }

/* top atletas */
.atletas-list { display: flex; flex-direction: column; gap: 4px; }
.atleta-row {
  display: grid;
  grid-template-columns: 32px 1fr 70px 50px;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12.5px;
}
.atleta-row:hover { background: var(--surface-2); }
.atleta-rank { font-family: var(--font-mono); font-weight: 700; font-size: 11px; color: var(--mute); text-align: center; }
.atleta-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atleta-cat { font-size: 10px; color: var(--mute); }
.atleta-uf {
  font-family: var(--font-mono); font-weight: 700; font-size: 11px;
  color: var(--cyan-2);
  text-align: center;
  background: var(--cyan-soft);
  padding: 3px 6px; border-radius: 5px;
  border: 1px solid rgba(34,211,238,0.2);
}
.atleta-pts { font-family: var(--font-mono); font-weight: 700; color: var(--text); text-align: right; }

/* ============================================================
   BRACKET
   ============================================================ */

.bracket-host {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  min-height: 320px;
}

.bracket {
  display: inline-flex;
  gap: 36px;
  align-items: stretch;
  min-width: 100%;
}

.bracket-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  min-width: 230px;
}

.bracket-col-title {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--mute);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 14px;
  text-align: center;
}

.match {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 6px 0;
  padding: 6px 0;
  font-size: 12px;
  position: relative;
  transition: all 160ms;
}
.match:hover { border-color: var(--border-2); transform: translateY(-1px); }
.match.finalized { border-color: rgba(16,185,129,0.32); box-shadow: 0 0 18px -6px rgba(16,185,129,0.35); }
.match.pending { border-style: dashed; opacity: 0.95; }

.match-meta {
  display: flex; justify-content: space-between;
  padding: 0 12px 5px;
  font-size: 9px;
  color: var(--mute);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}
.match-side {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  font-size: 12.5px;
  min-height: 30px;
}
.match-side.winner { background: var(--green-soft); font-weight: 700; color: var(--green-2); }
.match-side.loser { color: var(--mute); opacity: 0.7; }
.side-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 8px; }
.side-name.placeholder, .side-name.bye { color: var(--mute); font-style: italic; }
.side-score { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--text); min-width: 18px; text-align: right; }

.match-games {
  display: flex; gap: 4px;
  padding: 5px 12px;
  border-top: 1px dashed var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mute);
  flex-wrap: wrap;
}
.match-agenda { font-size: 9.5px; color: var(--cyan-2); }

/* ============================================================
   AGENDA
   ============================================================ */

.agenda-host { display: grid; gap: 16px; }

.agenda-day {
  background: rgba(8, 14, 18, 0.78);
  backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 20px 40px -20px rgba(0,0,0,0.7),
    0 0 0 1px rgba(0,0,0,0.4);
}
.agenda-day h3 {
  margin: 0 0 14px 0;
  font-size: 16px;
  color: var(--cyan-2);
  letter-spacing: -0.01em;
  text-transform: capitalize;
  font-weight: 600;
}
.agenda-day-meta { font-size: 11.5px; color: var(--mute); margin-left: 8px; font-weight: 400; text-transform: none; }

.agenda-list { display: flex; flex-direction: column; gap: 6px; }

.agenda-item {
  display: grid;
  grid-template-columns: 60px 50px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12.5px;
}
.agenda-item:hover { background: var(--surface-2); border-color: var(--border-2); }

.agenda-time { font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--cyan-2); }

.agenda-court {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 7px;
  text-align: center;
  font-size: 10px;
  color: var(--mute);
}
.agenda-court b { display: block; color: var(--text); font-size: 13px; font-family: var(--font-mono); }

.agenda-match { min-width: 0; }
.agenda-match-cat { font-size: 9px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; }
.agenda-match-players { font-size: 12.5px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.agenda-match-players span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.agenda-fase {
  font-size: 9.5px;
  color: var(--cyan-2);
  background: var(--cyan-soft);
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.14em;
  font-weight: 700;
  text-transform: uppercase;
  border: 1px solid rgba(34,211,238,0.2);
}

/* ============================================================
   RESULTS
   ============================================================ */

.results-host { display: grid; gap: 8px; }

.results-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--mute);
  background: rgba(8, 14, 18, 0.78);
  backdrop-filter: blur(28px) saturate(160%);
  border: 1px dashed var(--border-2);
  border-radius: 18px;
}
.results-empty-ico { font-size: 38px; opacity: 0.35; margin-bottom: 12px; }
.results-empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.results-empty-sub { font-size: 12.5px; line-height: 1.55; }

.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
}
.result-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
  font-size: 10.5px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
}
.result-players { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.result-player { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.result-player.winner { color: var(--green-2); font-weight: 700; }
.result-player.loser { color: var(--mute); }

.result-games { display: flex; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--mute); }

/* ============================================================
   LOADING
   ============================================================ */

.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 8, 10, 0.85);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  z-index: 1000;
  transition: opacity 0.3s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 22px var(--cyan-glow);
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 11px;
  color: var(--mute);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

/* live indicator compacto em telas médias */
@media (max-width: 1000px) {
  .live-indicator .live-label { display: none; }
}

/* === MOBILE: sidebar drawer === */
@media (max-width: 900px) {
  :root { --sidebar-w: 260px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 200ms cubic-bezier(.2,.7,.2,1);
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 12px 60px rgba(0,0,0,0.6); }
  .sb-backdrop { display: block; opacity: 0; pointer-events: none; transition: opacity 180ms; }
  .sb-backdrop.open { opacity: 1; pointer-events: auto; }
  .hd-menu { display: grid; }
  .header { padding: 0 16px; gap: 10px; }
  .header-info { font-size: 11px; }
  .live-indicator { padding: 5px 9px; }
  .live-indicator .live-age { font-size: 10px; }
  .header-info { display: none; }   /* esconde no mobile pra dar espaço ao indicador */
  .page { padding: 18px 14px 40px; }
  .page-title h1 { font-size: 19px; }
  .breadcrumb span:first-child,
  .breadcrumb svg:nth-of-type(1),
  .breadcrumb span:nth-of-type(2),
  .breadcrumb svg:nth-of-type(2) { display: none; }
  .filters-bar { gap: 8px; }
  .filter-lbl { display: none; }
  .agenda-item { grid-template-columns: 52px 44px 1fr auto; gap: 8px; padding: 9px 10px; }
  .podium-uf { font-size: 26px; }
  .podium-points { font-size: 16px; }
}

@media (max-width: 520px) {
  .header { padding: 0 12px; }
  .page { padding: 14px 12px 36px; }
  .page-title h1 { font-size: 17px; }
  .card { padding: 14px; border-radius: 14px; }
  .kpi-tile { padding: 14px 16px 12px; border-radius: 14px; }
  .kpi-tile .kpi-value { font-size: 22px; }
  .podium { grid-template-columns: 1fr; }
  .podium-card { padding: 14px; }
  .atleta-row { grid-template-columns: 28px 1fr 60px 50px; padding: 7px 10px; font-size: 12px; }
  .filter-select { font-size: 12px; padding: 8px 28px 8px 10px; }
  .bar-label { min-width: 90px; max-width: 140px; font-size: 12px; }
  .bar-val { font-size: 12px; flex-basis: 36px; }
}

@media (max-width: 720px) {
  .drill-modal { padding: 0; }
  .drill-content {
    max-width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border-left: 0; border-right: 0;
  }
  .drill-header { padding: 18px 18px 14px; padding-top: calc(18px + var(--sa-top)); }
  .drill-header h2 { font-size: 18px; }
  .drill-body { padding: 14px 14px 24px; padding-bottom: calc(24px + var(--sa-bot)); }
  .drill-table th, .drill-table td { padding: 8px 10px; }
  .drill-table .drill-cat { max-width: 120px; font-size: 11.5px; }
  .drill-agenda { font-size: 11px; }
  .drill-score { font-size: 14px; }
  .drill-atletas-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .drill-atletas-grid { grid-template-columns: 1fr; }
  .drill-table thead { display: none; }
  .drill-table, .drill-table tbody, .drill-table tr, .drill-table td { display: block; }
  .drill-table tr {
    border-bottom: 1px solid var(--border);
    padding: 8px 4px;
  }
  .drill-table td {
    border-bottom: 0;
    padding: 4px 10px;
  }
  .drill-table td:first-child::before { content: "Jogo "; color: var(--mute); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
}
