:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --gold: #FFD700;
  --silver: #C0C0C0;
  --bronze: #CD7F32;
  --nav-h: 60px;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

.hidden { display: none !important; }

/* NAVBAR */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; gap: 1rem;
  box-shadow: 0 1px 8px rgba(0,0,0,.07);
}
.nav-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--primary); }
.nav-icon { font-size: 1.4rem; }
.nav-links { display: flex; align-items: center; gap: .25rem; }
.nav-link { text-decoration: none; color: var(--text-muted); padding: .4rem .7rem; border-radius: 8px; font-size: .9rem; transition: all .15s; white-space: nowrap; }
.nav-link:hover, .nav-link.active { background: #eff6ff; color: var(--primary); }
.btn-logout { background: none; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .8rem; cursor: pointer; font-size: .9rem; color: var(--text-muted); transition: all .15s; }
.btn-logout:hover { background: #fee2e2; border-color: var(--danger); color: var(--danger); }
.hamburger { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: .4rem; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: .2s; }

/* MAIN */
main { padding-top: var(--nav-h); min-height: 100vh; }
.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* CARDS */
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.card-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--text); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1.1rem; border-radius: 8px; border: none; cursor: pointer; font-size: .9rem; font-weight: 500; transition: all .15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-icon { background: none; border: none; cursor: pointer; padding: .3rem; border-radius: 6px; font-size: 1rem; transition: background .15s; }
.btn-icon:hover { background: var(--bg); }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-muted); margin-bottom: .4rem; text-transform: uppercase; letter-spacing: .04em; }
.form-input, .form-select { width: 100%; padding: .6rem .85rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: .95rem; background: var(--surface); color: var(--text); transition: border-color .15s; outline: none; }
.form-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.time-inputs { display: flex; gap: .5rem; align-items: center; }
.time-inputs .form-input { text-align: center; }
.time-sep { font-weight: 700; color: var(--text-muted); font-size: 1.2rem; }
.time-label { font-size: .72rem; color: var(--text-muted); text-align: center; margin-top: .2rem; }

/* AUTH PAGES */
.auth-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); }
.auth-card { background: var(--surface); border-radius: 16px; padding: 2rem; width: 100%; max-width: 400px; box-shadow: 0 8px 32px rgba(59,130,246,.12); }
.auth-title { font-size: 1.6rem; font-weight: 800; color: var(--primary); text-align: center; margin-bottom: .25rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-link { display: block; text-align: center; margin-top: 1rem; color: var(--primary); font-size: .9rem; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }

/* FILTERS */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1.5rem; padding: 1rem; background: var(--bg); border-radius: var(--radius); border: 1px solid var(--border); }
.filter-group { display: flex; flex-direction: column; gap: .3rem; min-width: 140px; }
.filter-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* CHART */
.chart-container { position: relative; width: 100%; height: 380px; }

/* LIST */
.list-table { width: 100%; border-collapse: collapse; }
.list-table th { background: var(--bg); padding: .7rem 1rem; text-align: left; font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--border); }
.list-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.list-table tr:last-child td { border-bottom: none; }
.list-table tr:hover td { background: #f8faff; }
.user-cell { display: flex; align-items: center; gap: .6rem; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--border); }
.user-avatar-placeholder { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.time-badge { font-family: 'SF Mono', 'Monaco', monospace; font-weight: 700; color: var(--primary); font-size: .95rem; }
.actions-cell { display: flex; gap: .4rem; }

/* PODIUM */
.podium-section { text-align: center; margin-bottom: 2rem; }
.podium-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 2rem; }
.podium-stage { display: flex; align-items: flex-end; justify-content: center; gap: 1rem; margin-bottom: 2.5rem; }
.podium-place { display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.podium-avatar-wrap { position: relative; }
.podium-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 4px solid; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.podium-medal { position: absolute; bottom: -4px; right: -4px; font-size: 1.4rem; }
.podium-name { font-weight: 700; font-size: .9rem; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-time { font-family: monospace; font-weight: 700; font-size: .85rem; color: var(--text-muted); }
.podium-sub-spacer { font-size: .72em; color: var(--text-muted); height: 1.2em; line-height: 1.2em; }
.podium-block { border-radius: 8px 8px 0 0; width: 90px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.3); }
.place-1 .podium-avatar { border-color: var(--gold); }
.place-1 .podium-block { height: 90px; background: linear-gradient(135deg, #FFD700, #FFA500); box-shadow: 0 0 20px rgba(255,215,0,.5); }
.place-2 .podium-avatar { border-color: var(--silver); }
.place-2 .podium-block { height: 65px; background: linear-gradient(135deg, #C0C0C0, #909090); }
.place-3 .podium-avatar { border-color: var(--bronze); }
.place-3 .podium-block { height: 45px; background: linear-gradient(135deg, #CD7F32, #8B4513); }
.podium-others { list-style: none; max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.podium-others li { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.podium-others li:last-child { border-bottom: none; }
.podium-others li.is-me { background: #eff6ff; font-weight: 600; }
.podium-rank { width: 28px; height: 28px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; color: var(--text-muted); flex-shrink: 0; }
.podium-sticky { position: sticky; bottom: 0; background: #eff6ff; border-top: 2px solid var(--primary); padding: .75rem 1rem; display: flex; align-items: center; gap: .75rem; font-weight: 600; font-size: .9rem; border-radius: 0 0 var(--radius) var(--radius); }

/* PROFILE */
.profile-photo-wrap { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.profile-photo { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid var(--primary); }
.profile-photo-placeholder { width: 100px; height: 100px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: #fff; }
.file-input-label { cursor: pointer; color: var(--primary); font-size: .85rem; text-decoration: underline; }
.file-input-hidden { display: none; }

/* TOAST */
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; max-width: 320px; }
.toast { padding: .75rem 1rem; border-radius: 10px; font-size: .9rem; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.12); animation: slideIn .2s ease; display: flex; align-items: center; gap: .5rem; }
.toast-success { background: #ecfdf5; color: #065f46; border-left: 4px solid var(--success); }
.toast-error { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.toast-info { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* MISC */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 800; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state p { font-size: 1rem; margin-bottom: .5rem; }
.spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; padding: 3rem; }
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 9999px; font-size: .75rem; font-weight: 600; }
.badge-admin { background: #fef3c7; color: #92400e; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); font-size: .85rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .nav-links {
    display: none; position: absolute; top: var(--nav-h); left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-direction: column; align-items: stretch; padding: .75rem;
    box-shadow: 0 8px 16px rgba(0,0,0,.08);
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: .6rem .75rem; font-size: .95rem; }
  .btn-logout { width: 100%; text-align: center; justify-content: center; margin-top: .25rem; }
  .podium-stage { gap: .5rem; }
  .podium-avatar { width: 60px; height: 60px; }
  .podium-block { width: 70px; }
  .place-1 .podium-block { height: 70px; }
  .place-2 .podium-block { height: 50px; }
  .place-3 .podium-block { height: 35px; }
  .grid-2 { grid-template-columns: 1fr; }
  .list-table { font-size: .8rem; }
  .list-table th, .list-table td { padding: .5rem .6rem; }
  .filters { flex-direction: column; }
  .filter-group { width: 100%; }
  .page { padding: 1rem .75rem 2rem; }
  .chart-container { height: 260px; }
}
