:root {
  --bg: #0A1F44;
  --bg-2: #0F2A5C;
  --bg-3: #163A7A;
  --active: #1E4ED8;
  --accent: #3B82F6;
  --accent-soft: #60A5FA;
  --text: #E6EDF7;
  --text-2: #A9B8D4;
  --text-3: #6B7CA3;
  --line: rgba(169, 184, 212, 0.16);
  --panel: rgba(9, 26, 60, 0.86);
  --panel-2: rgba(16, 42, 92, 0.92);
  --gold: #d7b86b;
  --green: #39d98a;
  --green-soft: rgba(57, 217, 138, .12);
  --red: #ff7d7d;
  --red-soft: rgba(255, 125, 125, .12);
  --yellow: #ffd76b;
  --yellow-soft: rgba(255, 215, 107, .12);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
  --radius: 22px;
  --radius-sm: 14px;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(96, 165, 250, 0.18), transparent 24%),
    radial-gradient(circle at bottom left, rgba(30, 78, 216, 0.18), transparent 28%),
    linear-gradient(180deg, #081a39 0%, #091731 45%, #071224 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: radial-gradient(circle, rgba(255,255,255,0.25) 1px, transparent 1px);
  background-size: 42px 42px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
img { max-width: 100%; display: block; }
a { color: inherit; }

.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, rgba(15,42,92,.96), rgba(8,24,55,.96));
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(10px);
}
.sidebar-top { display: grid; gap: 22px; }
.sidebar-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand strong { display: block; font-size: 0.98rem; font-weight: 800; letter-spacing: -0.01em; }
.sidebar-brand span { display: block; color: var(--text-2); font-size: 0.85rem; margin-top: 4px; }
.sidebar-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.35));
}
.menu { display: grid; gap: 8px; }
.menu-item {
  text-align: left;
  color: var(--text-2);
  background: transparent;
  padding: 13px 14px;
  border-radius: 14px;
  transition: .18s ease;
}
.menu-item:hover        { background: var(--bg-3); color: var(--text); }
.menu-item:active       { filter: brightness(0.88); transition-duration: .06s; }
.menu-item.active       { background: var(--active); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.menu-item:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: -3px; border-radius: 14px; }
.sidebar-user {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  display: grid;
  gap: 4px;
}
.sidebar-user-label { color: var(--text-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
#sidebarUserMeta { color: var(--text-2); font-size: .88rem; }

.main-area { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 20, 45, 0.82);
  backdrop-filter: blur(14px);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar h1 { margin: 0; font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em; }
.topbar p { margin: 4px 0 0; color: var(--text-2); font-size: .92rem; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255,255,255,.06); color: var(--text);
  display: none; place-items: center;
}

.content { padding: 28px; display: grid; gap: 28px; }
.view { display: none; }
.view.active { display: block; }
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.section-head p { margin: 6px 0 0; }
.section-grid { display: grid; gap: 18px; }
.section-grid.two-col { grid-template-columns: 1.1fr .9fr; }
.section-grid.top-cards { grid-template-columns: repeat(3, 1fr); }

.panel {
  background: linear-gradient(180deg, rgba(14,35,77,.88), rgba(8,23,52,.88));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.panel h3 { margin: 4px 0 14px; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.panel-head.between { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.hero-card {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 18px;
  align-items: stretch;
}
.hero-copy, .hero-side, .mini-panel {
  background: linear-gradient(180deg, rgba(14,35,77,.88), rgba(8,23,52,.88));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-copy { padding: 28px; }
.hero-side { padding: 18px; display: grid; gap: 18px; }
.mini-panel { padding: 18px; }
.hero-logo, .login-logo {
  width: min(240px, 72%);
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,.34));
}
.eyebrow, .mini-label {
  color: var(--accent-soft);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .76rem;
}
.hero-copy h2 { margin: 12px 0; font-size: clamp(1.8rem, 3vw, 2.8rem); line-height: 1.1; font-weight: 900; letter-spacing: -0.03em; }
.hero-copy p { color: var(--text-2); max-width: 62ch; }
.hero-actions, .inline-actions, .filter-row { display: flex; gap: 10px; flex-wrap: wrap; }
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 180px); }
.narrow { max-width: 520px; width: 100%; }

.form-stack { display: grid; gap: 14px; }
.form-stack.compact { gap: 12px; }
label { display: grid; gap: 8px; color: var(--text-2); }
input, select, textarea {
  width: 100%;
  background: rgba(255,255,255,.05);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(96,165,250,.7);
  box-shadow: 0 0 0 4px rgba(59,130,246,.16);
}
textarea { resize: vertical; min-height: 180px; }

.score-grid {
  display: grid;
  grid-template-columns: 1fr 54px 1fr;
  gap: 10px;
  align-items: end;
}
.versus {
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--accent-soft);
  font-weight: 800;
  font-size: 1.1rem;
}

.btn {
  padding: 12px 16px;
  border-radius: 14px;
  color: var(--text);
  transition: .18s ease;
}
.btn:hover       { transform: translateY(-1px); filter: brightness(1.12); }
.btn:active      { transform: translateY(0);    filter: brightness(0.92); transition-duration: .06s; }
.btn:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 3px;
}
.btn-primary { background: linear-gradient(180deg, var(--accent), #2563eb); }
.btn-secondary { background: rgba(255,255,255,.08); }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.12); }
.btn.full { width: 100%; }

.state-pill, .badge, .movement {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: .82rem;
  border: 1px solid rgba(255,255,255,.08);
}
.state-pill { background: rgba(59,130,246,.12); color: var(--accent-soft); }
.state-pill.upcoming { background: rgba(215,184,107,.12); color: var(--gold); }
.badge.exato   { background: var(--green-soft);  color: var(--green); }
.badge.parcial { background: var(--yellow-soft); color: var(--yellow); }
.badge.erro    { background: var(--red-soft);    color: var(--red); }
.movement.up { color: var(--green); }
.movement.down { color: var(--red); }
.movement.same { color: var(--text-2); }
.notice {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text-2);
}
.countdown { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 800; letter-spacing: -.03em; }
.muted { color: var(--text-2); }
.highlight { color: var(--accent-soft); font-weight: 700; }
.hidden { display: none !important; }

.table-wrap { overflow: auto; }
table {
  width: 100%; border-collapse: collapse; min-width: 680px;
}
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-align: left;
  vertical-align: middle;
}
th { color: var(--text-2); font-size: .84rem; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even)  { background: rgba(255,255,255,.025); }
tbody tr:hover            { background: rgba(96,165,250,.07); transition: background .12s ease; }

.stats-grid {
  display: grid;
  gap: 18px;
}
.stats-section-full {
  width: 100%;
}
.stats-kicker {
  color: var(--accent-soft);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .76rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.stats-global-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.stats-profiles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stats-chart-wrap {
  background: linear-gradient(180deg, rgba(14,35,77,.88), rgba(8,23,52,.88));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  position: relative;
  height: 320px;
}
.stats-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.stat-card {
  padding: 22px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14,35,77,.88), rgba(8,23,52,.88));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stat-card .label { color: var(--text-2); margin-bottom: 10px; }
.stat-card .value { font-size: 1.2rem; font-weight: 700; }

/* ── Home dual-state layout ── */
.home-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}
.home-login-panel { padding: 28px; }
.home-logo {
  width: min(160px, 60%);
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.35));
  margin-bottom: 16px;
}
.home-title {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  margin: 8px 0 10px;
  line-height: 1.1;
}
.home-side-panels { display: grid; gap: 16px; }
.home-user-card { padding: 28px; }
.home-ia-grid { grid-template-columns: repeat(3, 1fr) !important; }

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  padding: 10px 18px;
  border-radius: 12px 12px 0 0;
  background: transparent;
  color: var(--text-2);
  font-size: .92rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  transition: .15s ease;
}
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,.05); }
.tab-btn.active {
  color: var(--text);
  background: linear-gradient(180deg, rgba(30,78,216,.18), rgba(14,35,77,.88));
  border-color: var(--line);
  border-bottom-color: transparent;
}
.tab-pane { display: block; }
.tab-pane.hidden { display: none; }

.print-toolbar { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.print-sheet { background: linear-gradient(180deg, rgba(12,30,68,.98), rgba(7,18,36,.98)); }
.print-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.print-brand img { width: 88px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0,0,0,.3)); }
.print-kicker { color: var(--accent-soft); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(10px); }
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(5, 17, 39, 0.94);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: var(--shadow);
  z-index: 50;
  animation: toast-in .18s ease forwards;
}
.toast.hiding {
  animation: toast-out .18s ease forwards;
}

@media (max-width: 1100px) {
  .section-grid.top-cards, .section-grid.two-col, .hero-card { grid-template-columns: 1fr; }
  .stats-global-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-profiles-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: min(82vw, 320px);
    transform: translateX(-102%);
    transition: .22s ease;
    z-index: 60;
  }
  .sidebar.open { transform: translateX(0); }
  .icon-btn { display: grid; }
  .content { padding: 18px; }
  .topbar { padding: 16px 18px; }
  .home-two-col { grid-template-columns: 1fr; }
  .home-ia-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .topbar-left { width: 100%; }
  .score-grid { grid-template-columns: 1fr 40px 1fr; }
  .hero-copy { padding: 20px; }
  .panel, .mini-panel { padding: 18px; }
  table { min-width: 620px; }
  .stats-global-grid { grid-template-columns: 1fr 1fr; }
  .stats-profiles-grid { grid-template-columns: 1fr 1fr; }
}

@media print {
  body { background: #fff; color: #111; }
  .sidebar, .topbar, .print-toolbar, .toast { display: none !important; }
  .view { display: none !important; }
  #view-print { display: block !important; }
  .panel, .print-sheet { box-shadow: none; border: 1px solid #ddd; background: #fff; color: #111; }
  .print-kicker, .muted, .badge, .movement { color: #111 !important; }
}


.btn-danger  { background: linear-gradient(180deg, #ef4444, #b91c1c); }
.btn-warning { background: linear-gradient(180deg, #f59e0b, #d97706); color: #1a1000; }
.btn-success { background: linear-gradient(180deg, #10b981, #059669); }

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.ai-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(96,165,250,0.25);
  border-top-color: var(--accent-soft);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
.ai-loading-text {
  animation: pulse-text 1.4s ease-in-out infinite;
  color: var(--accent-soft);
  font-size: .92rem;
}

select option {
  color: #16335f;
  background: #f3f6fc;
}

select option:checked,
select option:hover {
  color: #0b2348;
  background: #dbe8ff;
}
/* ── Countdown urgente ── */
@keyframes pulse-urgent {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.02); }
}
.countdown-urgent {
  color: var(--red) !important;
  animation: pulse-urgent 1s ease-in-out infinite;
}

/* ── Avatar inline nas tabelas ── */
td:has(.avatar-initial) { white-space: nowrap; }
