:root {
  --background-primary: #05080c;
  --background-secondary: #080d13;
  --surface-primary: #0d131a;
  --surface-elevated: #121a23;
  --surface-active: #17210f;
  --border-subtle: #202b36;
  --border-strong: #344453;
  --text-primary: #f7f9fb;
  --text-secondary: #b4bec8;
  --text-muted: #778592;
  --accent-primary: #d5ff17;
  --accent-pressed: #b6dc00;
  --success: #37d982;
  --warning: #ffb547;
  --danger: #ff5864;
  --info: #5caaff;
  --broadcast: #a88bff;
  --font-display: "Bahnschrift Condensed", "Arial Narrow", sans-serif;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --motion-fast: 160ms;
  --motion-base: 260ms;
  --content-max: 1580px;
  --bg: var(--background-primary);
  --panel: var(--surface-primary);
  --panel-2: var(--surface-elevated);
  --line: var(--border-subtle);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --lime: var(--accent-primary);
  --lime-dark: var(--accent-pressed);
  --blue: var(--info);
  --orange: var(--warning);
  --red: var(--danger);
  --green: var(--success);
  --radius: var(--radius-md);
  --shadow: 0 24px 70px rgba(0,0,0,.42);
  font-family: var(--font-ui);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { background-image: linear-gradient(120deg, rgba(213,255,23,.018) 0 1px, transparent 1px 96px); background-size: 96px 96px; }
body { font-size: 15px; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
code { color: var(--lime); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; padding: 20px 14px; background: rgba(5,8,12,.98); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 50; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 22px; }
.brand span:last-child { display: flex; flex-direction: column; }
.brand strong { font-family: var(--font-display); letter-spacing: .14em; font-size: 18px; }
.brand small { color: var(--muted); font-size: 10px; letter-spacing: .04em; margin-top: 3px; }
.brand-logo-wrap { width: 52px; height: 52px; flex: 0 0 52px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); background: #000; }
.brand-logo { width: 100%; height: 100%; object-fit: contain; }
.sidebar nav { display: grid; gap: 5px; overflow-y: auto; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 12px; color: var(--muted); border-left: 2px solid transparent; border-radius: 2px; font-weight: 700; transition: color var(--motion-fast), background var(--motion-fast), border-color var(--motion-fast); }
.nav-link:hover { background: var(--panel); color: var(--text); }
.nav-link.active { color: var(--text); background: rgba(213,255,23,.08); border-left-color: var(--lime); }
.nav-divider { height: 1px; background: var(--line); margin: 10px 4px; }
.nav-label { color: #687384; font-size: 10px; letter-spacing: .15em; padding: 8px 12px 3px; font-weight: 800; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.connection { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.connection.online i { background: var(--green); box-shadow: 0 0 12px var(--green); }
.link-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.shell { margin-left: 264px; min-height: 100vh; }
.topbar { min-height: 84px; padding: 16px 30px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 30; background: rgba(5,8,12,.94); backdrop-filter: blur(16px); }
.topbar h1 { font-family: var(--font-display); font-size: clamp(24px, 3vw, 34px); letter-spacing: .015em; line-height: 1; margin: 3px 0 0; text-transform: uppercase; }
.eyebrow { color: var(--lime); letter-spacing: .16em; font-size: 10px; font-weight: 850; margin: 0; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 28px 30px 80px; max-width: var(--content-max); margin: 0 auto; }
.icon-btn { display: none; border: 1px solid var(--line); background: var(--panel); color: white; width: 42px; height: 42px; border-radius: 8px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 10px 28px rgba(0,0,0,.14); }
.card.accent { border-color: rgba(204,255,0,.45); }
.card h2, .card h3 { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .015em; margin: 0 0 8px; }
.event-card { display:flex; flex-direction:column; }
.event-card-main { display:block; flex:1; }
.event-card-actions { margin-top:14px; padding-top:14px; border-top:1px solid var(--line); }
.event-card-actions .btn { flex:1; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head p { margin: 3px 0 0; }
.metric { padding: 18px; border-top: 2px solid var(--lime); }
.metric strong { display: block; font-family: var(--font-display); font-size: clamp(32px,4vw,48px); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.metric span { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 28px 0 14px; }
.section-title:first-child { margin-top: 0; }
.section-title h2 { margin: 0; }
.btn { border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text); border-radius: var(--radius-sm); min-height: 44px; padding: 10px 15px; font-family: var(--font-display); font-size: 14px; letter-spacing: .055em; text-transform: uppercase; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: transform var(--motion-fast), background var(--motion-fast), border-color var(--motion-fast); }
.btn:hover { border-color: #5b6d7c; transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--lime); color: #090b0f; border-color: var(--lime); }
.btn.primary:hover { background: #e0ff55; }
.btn.secondary { background: transparent; border-color: #526271; color: #e3e8ed; }
.btn.compact { min-height: 36px; padding: 7px 11px; font-size: 12px; }
.btn.danger { background: rgba(255,77,89,.12); color: #ff8a92; border-color: rgba(255,77,89,.4); }
.btn.warning { background: rgba(255,138,48,.12); color: #ffb072; border-color: rgba(255,138,48,.4); }
.btn.ghost { background: transparent; }
.btn.xl { min-height: 54px; padding: 13px 20px; font-size: 17px; }
.btn.finish { min-height: 64px; font-size: 18px; background: var(--lime); color: #090b0f; border: 0; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
label { display: grid; gap: 7px; color: #cbd2db; font-weight: 620; }
input, select, textarea { width: 100%; min-height: 44px; background: #0c0f14; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: 0; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(204,255,0,.1); }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.form-grid .span-2 { grid-column: span 2; }
.stack { display: grid; gap: 14px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; background: #2a323e; color: #cbd2db; }
.status.in_progress, .status.result_displayed { background: rgba(54,209,124,.16); color: #63e79b; }
.status.awaiting_review, .status.pending, .status.paused { background: rgba(255,138,48,.16); color: #ffad6b; }
.status.confirmed, .status.result_confirmed, .status.displayed { background: rgba(77,163,255,.16); color: #85beff; }
.status.dnf, .status.dns, .status.disqualified, .status.cancelled { background: rgba(255,77,89,.16); color: #ff858d; }
.heat-card, .entry-card, .result-card { position: relative; }
.heat-meta, .entry-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; color: var(--muted); font-size: 13px; margin: 10px 0 16px; }
.race-time { font-family: var(--font-display); font-size: clamp(38px,6vw,64px); font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.045em; margin: 10px 0; }
.result-time { color: var(--lime); font-family: var(--font-display); font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; font-weight: 750; color: #cad1da; }
.badge.lime { color: var(--lime); border-color: rgba(204,255,0,.4); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(8,13,19,.72); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { color: var(--muted); font-family: var(--font-display); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; text-align: left; padding: 12px 14px; background: #080d13; }
td { padding: 13px 14px; border-top: 1px solid var(--line); }
.filters { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 160px; }
.setting-toggle { display:flex; align-items:flex-start; gap:11px; padding:12px 0; cursor:pointer; }
.setting-toggle input { width:20px; height:20px; min-height:0; margin:1px 0 0; accent-color:var(--lime); }
.setting-toggle span { display:grid; gap:3px; }
.setting-toggle small { color:var(--muted); font-weight:400; }
.operation-section { margin-top:28px; }
details.operation-section > summary { display:flex; align-items:center; justify-content:space-between; gap:16px; cursor:pointer; list-style:none; padding:18px 0; border-top:1px solid var(--line); font-family:var(--font-display); font-size:clamp(20px,2vw,30px); text-transform:uppercase; }
details.operation-section > summary::-webkit-details-marker { display:none; }
details.operation-section > summary::before { content:"＋"; color:var(--lime); font-size:22px; }
details.operation-section[open] > summary::before { content:"−"; }
details.operation-section > summary > span:first-child { flex:1; }
.alert { padding: 12px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); }
.alert.error { border-color: rgba(255,77,89,.5); color: #ff9da3; }
.alert.warning { border-color: rgba(255,138,48,.5); color: #ffba82; }
.alert.success { border-color: rgba(54,209,124,.5); color: #75e8aa; }
.alerts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.empty { text-align: center; padding: 50px 20px; border: 1px dashed #34404e; border-radius: var(--radius); color: var(--muted); }
.loading-panel { min-height: 50vh; display: grid; place-items: center; align-content: center; color: var(--muted); }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #29313c; border-top-color: var(--lime); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast-root { position: fixed; z-index: 1000; right: 20px; bottom: 20px; display: grid; gap: 8px; width: min(360px, calc(100vw - 30px)); }
.toast { padding: 13px 15px; background: #202731; border: 1px solid #3c4858; border-left: 4px solid var(--lime); border-radius: 9px; box-shadow: var(--shadow); animation: toast-in .25s ease; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
.dialog-backdrop { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.72); display: grid; place-items: center; padding: 18px; }
.dialog { width: min(720px,100%); max-height: calc(100vh - 36px); overflow: auto; background: #0b1118; border: 1px solid #3a4655; border-top: 3px solid var(--lime); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 22px; }
.dialog.wide { width: min(920px,100%); }
.dialog-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; }
.close-btn { border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.search-results { display: grid; gap: 6px; max-height: 230px; overflow: auto; margin-top: 8px; }
.student-result { border: 1px solid var(--line); background: #0b0f14; color: white; padding: 11px; border-radius: 8px; text-align: left; cursor: pointer; }
.student-result:hover { border-color: var(--lime); }
.selected-student { padding: 12px; border: 1px solid rgba(204,255,0,.45); border-radius: 9px; background: rgba(204,255,0,.06); display: flex; justify-content: space-between; gap: 10px; }
.participant-summary { display: grid; gap: 5px; padding: 15px 16px; border-left: 3px solid var(--lime); background: rgba(213,255,23,.045); }
.participant-summary span { color: var(--lime); font-size: 10px; letter-spacing: .14em; font-weight: 850; text-transform: uppercase; }
.participant-summary strong { font-family: var(--font-display); font-size: 22px; text-transform: uppercase; }
.participant-summary small { color: var(--muted); }
.dialog-actions { justify-content: flex-end; padding-top: 6px; }
.queue-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.queue-item:first-child { border-top: 0; }
.queue-number { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); }
.queue-item .grow { flex: 1; }
.preview-frame { width: 100%; aspect-ratio: 16/9; border: 1px solid var(--line); border-radius: 10px; background: #050607; }
.mode-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.mode-btn { min-height: 64px; }
.timer-hero { background: radial-gradient(circle at top right, rgba(204,255,0,.1), transparent 38%), var(--panel); }
.timer-hero .race-time { color: var(--lime); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 5%, #18200d 0, #05080c 43%); }
.login-card { width: min(430px,100%); background: rgba(10,15,21,.96); border: 1px solid #35404e; border-top: 3px solid var(--lime); border-radius: var(--radius-md); padding: 34px; box-shadow: var(--shadow); }
.login-logo { width: 112px; height: 112px; display: block; object-fit: contain; margin: -6px 0 22px; }
.login-card h1 { font-family: var(--font-display); font-size: 42px; text-transform: uppercase; letter-spacing: .02em; margin: 5px 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 1050px) {
  .grid.four, .grid.three { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.menu-open .sidebar { transform: translateX(0); }
  .shell { margin-left: 0; }
  .icon-btn { display: block; }
}
@media (max-width: 900px) {
  .participant-table-wrap { overflow: visible; border: 0; background: transparent; }
  .participant-table { display: block; min-width: 0; }
  .participant-table thead { display: none; }
  .participant-table tbody { display: grid; gap: 12px; }
  .participant-table tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px 18px; padding: 16px; border: 1px solid var(--line); border-top: 2px solid rgba(213,255,23,.5); background: var(--panel); }
  .participant-table td { display: grid; align-content: start; gap: 5px; min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
  .participant-table td::before { content: attr(data-label); color: var(--muted); font-family: var(--font-display); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
  .participant-table td[data-label="Participante"] { grid-column: 1 / -1; }
  .participant-table td[data-label="Ações"] { grid-column: 1 / -1; align-self: end; }
  .participant-table td[data-label="Ações"] .btn { width: 100%; }
}
@media (max-width: 700px) {
  .topbar { padding: 14px 16px; min-height: 76px; }
  .top-actions .btn span { display: none; }
  .content { padding: 18px 14px 80px; }
  .grid.two, .grid.three, .grid.four, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .mode-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filters > * { width: 100% !important; }
  .dialog { padding: 17px; }
  .entry-card .actions .btn, .result-card .actions .btn { flex: 1; }
}
@media (max-width: 480px) {
  .participant-table tr { grid-template-columns: 1fr; }
  .participant-table td[data-label="Participante"], .participant-table td[data-label="Ações"] { grid-column: auto; }
}
