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

:root {
  --bg:      #0e0f11;
  --surface: #161719;
  --surface2:#1e2023;
  --border:  #2a2d32;
  --accent:  #4ade80;  /* green — 8.6:1 on --bg, AA pass */
  --accent2: #40c8f0;  /* blue  — 7.5:1 on --bg, AA pass */
  --text:    #f0f0ee;  /* 19.2:1 on --bg */
  --muted:   #9199a1;  /* 4.8:1 on --bg, 4.6:1 on --surface, 4.4:1 on --surface2 — AA pass */
  --danger:  #f05040;  /* 5.0:1 on --bg */
  --gold:    #f0b040;  /* 9.2:1 on --bg */
  --silver:  #a0aab4;  /* 5.8:1 on --bg */
  --bronze:  #c87840;  /* 5.5:1 on --bg */
  --radius:  6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Barlow', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; }

/* ── HEADER ── */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 56px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 100;
  gap: 12px; overflow: hidden;
}
.wordmark {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 900; font-size: 22px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1;
}
.wordmark span { color: var(--text); font-weight: 300; }
.header-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.user-chip strong { color: var(--text); font-weight: 500; }

@media (max-width: 480px) {
  .user-chip strong, .user-chip > span:last-child { display: none; }
  .wordmark { font-size: 18px; }
}

/* ── CONTEXT BAR ── */
.context-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.context-bar label { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }

select {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 28px 6px 10px; border-radius: var(--radius);
  font-family: 'Barlow', sans-serif; font-size: 14px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239199a1'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; min-width: 140px; transition: border-color 0.15s;
}
select:focus { outline: none; border-color: var(--accent); }

/* ── LAYOUT ── */
.main { display: grid; grid-template-columns: 1fr 300px; height: calc(100vh - 113px); }

/* ── LEADERBOARD ── */
.leaderboard-panel { overflow-y: auto; padding: 20px 24px; }
.panel-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.panel-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 28px; letter-spacing: 0.02em; text-transform: uppercase; line-height: 1; }
.panel-sub { font-size: 12px; color: var(--muted); font-weight: 300; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group label { font-family: 'Barlow Condensed', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.multi-select-btn { position: relative; }
.multi-select-btn button { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: var(--radius); font-family: 'Barlow', sans-serif; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: border-color 0.15s; }
.multi-select-btn button:hover { border-color: var(--accent); }
.multi-select-btn button.active { border-color: var(--accent); color: var(--accent); }
.multi-select-btn .badge { background: var(--accent); color: var(--bg); border-radius: 10px; padding: 1px 6px; font-size: 11px; font-weight: 700; }
.dropdown-list { position: absolute; top: calc(100% + 4px); left: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); min-width: 200px; max-height: 220px; overflow-y: auto; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.5); display: none; }
.dropdown-list.open { display: block; }
.dropdown-list label { display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; transition: background 0.1s; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); }
.dropdown-list label:hover { background: var(--border); }
.dropdown-list input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; }

/* ── TABLE ── */
.lb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb-table thead th { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lb-table thead th.num { text-align: right; }
.lb-table tbody tr { border-bottom: 1px solid rgba(42,45,50,0.5); transition: background 0.1s; }
.lb-table tbody tr:hover { background: var(--surface2); }
.lb-table tbody td { padding: 9px 10px; vertical-align: middle; }
.lb-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }

.pos { font-family: 'Barlow Condensed', sans-serif; font-weight: 900; font-size: 18px; width: 40px; }
.pos-1 { color: var(--gold); }
.pos-2 { color: var(--silver); }
.pos-3 { color: var(--bronze); }
.pos-n { color: var(--muted); font-size: 14px; }
.car-name { font-weight: 500; }
.class-badge { display: inline-block; background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.time-val { font-family: 'Barlow Condensed', sans-serif; font-weight: 500; font-size: 16px; color: var(--accent2); }
.time-avg { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 16px; color: var(--accent); }

.empty-state { text-align: center; padding: 60px 0; color: var(--muted); font-size: 13px; }
.empty-state strong { display: block; font-family: 'Barlow Condensed', sans-serif; font-size: 20px; margin-bottom: 6px; color: var(--text); }

/* ── ENTRY PANEL ── */
.entry-panel { border-left: 1px solid var(--border); background: var(--surface); padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.entry-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-family: 'Barlow Condensed', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.lane-inputs { display: flex; flex-direction: column; gap: 8px; }
.lane-row { display: flex; align-items: center; gap: 8px; }
.lane-label { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); width: 54px; flex-shrink: 0; }
input[type=number], input[type=text], input[type=email] { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: var(--radius); font-family: 'Barlow', sans-serif; font-size: 14px; width: 100%; transition: border-color 0.15s; }
input[type=number]:focus, input[type=text]:focus, input[type=email]:focus { outline: none; border-color: var(--accent); }
.lane-time-input { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; text-align: right; font-variant-numeric: tabular-nums; }

.login-prompt { text-align: center; padding: 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.login-prompt strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 8px; }

/* ── BUTTONS ── */
.btn { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 16px; border-radius: var(--radius); border: none; cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--accent); color: var(--bg); width: 100%; justify-content: center; }
.btn-primary:hover { background: #22c55e; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--text); color: var(--text); }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-google { background: #fff; color: #333; border: none; padding: 9px 16px; border-radius: var(--radius); font-family: 'Barlow', sans-serif; font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: box-shadow 0.15s; }
.btn-google:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.btn-icon { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 7px 10px; border-radius: var(--radius); cursor: pointer; font-size: 13px; transition: all 0.15s; display: inline-flex; align-items: center; gap: 5px; font-family: 'Barlow Condensed', sans-serif; font-weight: 600; letter-spacing: 0.04em; text-decoration: none; }
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

.divider { border: none; border-top: 1px solid var(--border); }

/* ── MODAL ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 300; display: none; align-items: center; justify-content: center; padding: 20px; }
.overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; width: 100%; max-width: 680px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 20px; letter-spacing: 0.04em; text-transform: uppercase; }
.modal-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.modal-tab { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; padding: 10px 16px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; transition: all 0.15s; background: none; border-top: none; border-left: none; border-right: none; }
.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.modal-body { overflow-y: auto; flex: 1; padding: 20px; }
.setup-section { display: none; }
.setup-section.active { display: block; }

.setup-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.setup-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface2); border-radius: var(--radius); border: 1px solid var(--border); }
.setup-list li span { flex: 1; font-size: 13px; }
.setup-list li .item-sub { color: var(--muted); font-size: 12px; }
.setup-form { display: flex; flex-direction: column; gap: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.setup-form .form-row { display: flex; gap: 10px; }
.setup-form .form-row > * { flex: 1; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── TOAST ── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--accent); color: var(--bg); font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; padding: 10px 16px; border-radius: var(--radius); z-index: 500; transform: translateY(80px); opacity: 0; transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1); }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); color: #fff; }

/* ── CONFIRM DIALOG ── */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 600; display: none; align-items: center; justify-content: center; padding: 20px; }
.confirm-overlay.open { display: flex; }
.confirm-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px; max-width: 400px; width: 100%; }
.confirm-icon { font-size: 28px; margin-bottom: 12px; }
.confirm-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 18px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.confirm-msg { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }
.confirm-msg strong { color: var(--text); }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── EDIT FORM ── */
.edit-form { background: var(--bg); border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px; margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.edit-form .form-row { display: flex; gap: 8px; }
.edit-form .form-row > * { flex: 1; }
.edit-actions { display: flex; gap: 6px; }
.edit-actions .btn { padding: 7px 12px; font-size: 12px; }

/* ── LEADERBOARD ROW (admin clickable) ── */
.lb-table tbody tr.admin-row { cursor: pointer; }
.lb-table tbody tr.admin-row:hover { background: var(--surface2); outline: 1px solid var(--border); }

/* ── TIME EDIT PANEL ── */
.time-edit-panel { background: var(--surface2); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.time-edit-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .main { grid-template-columns: 1fr; height: auto; }
  .entry-panel { border-left: none; border-top: 1px solid var(--border); }
}
