/* Track Meet Manager — Offline-First & Mobile-First Stylesheet */
:root {
    --primary: #0f3d6e;
    --primary-dark: #092747;
    --accent: #e65100;
    --bg: #f3f6fa;
    --surface: #ffffff;
    --border: #dce3ec;
    --text: #1c2430;
    --muted: #64748b;
    --success: #15803d;
    --danger: #b91c1c;
    --warning: #b45309;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top Navbar */
.topbar {
    background: var(--primary);
    color: #fff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
}

.topbar-brand .badge-stage {
    font-size: 0.7rem;
    background: var(--accent);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.menu-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Layout */
.app-shell {
    display: flex;
    min-height: calc(100vh - 54px);
}

.sidebar {
    width: 245px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem 0.75rem;
    flex-shrink: 0;
}

.sidebar-section {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 0.75rem 0.75rem 0.35rem;
    font-weight: 700;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.58rem 0.8rem;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.18rem;
}

.nav-link:hover {
    background: #eef3f9;
    text-decoration: none;
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
}

.nav-link.disabled {
    color: #94a3b8;
    cursor: not-allowed;
    pointer-events: none;
}

.pill-soon {
    font-size: 0.65rem;
    background: #e2e8f0;
    color: #475569;
    padding: 1px 6px;
    border-radius: 999px;
}

.main-content {
    flex: 1;
    padding: 1.25rem;
    max-width: 1260px;
    width: 100%;
    margin: 0 auto;
}

/* Cards & Grids */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.7rem;
    margin-bottom: 1rem;
}

.card-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
}

.stat-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.stat-value { font-size: 1.6rem; font-weight: 800; margin-top: 0.2rem; color: var(--primary-dark); }

.heat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1rem;
}

.heat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 1rem;
}

.lane-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: 0.88rem;
    flex-shrink: 0;
}

/* Mobile-First Field Cards */
.lane-card-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    flex-wrap: wrap;
    border: 1px solid var(--border);
    border-left: 5px solid #cbd5e1;
    border-radius: 10px;
    padding: 0.85rem 0.95rem;
    margin-bottom: 0.7rem;
    background: #fff;
}

.lane-card-mobile.state-hadir { border-left-color: var(--success); background: #f0fdf4; }
.lane-card-mobile.state-dns   { border-left-color: var(--danger); background: #fef2f2; }
.lane-card-mobile.state-dq    { border-left-color: var(--danger); background: #fff1f2; }

.lane-info-main {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 210px;
}

.tap-btn-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.tap-btn {
    min-width: 76px;
    min-height: 40px;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    font-size: 0.86rem;
    cursor: pointer;
}

.tap-btn.active-hadir { background: var(--success); color: #fff; border-color: var(--success); }
.tap-btn.active-belum { background: #475569; color: #fff; border-color: #475569; }
.tap-btn.active-dns   { background: var(--danger); color: #fff; border-color: var(--danger); }

.wind-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
}

.wind-box.wind-illegal { background: #fffbeb; border-color: #f59e0b; }

.medal-emas     { background: #fef08a; color: #854d0e; }
.medal-perak    { background: #e2e8f0; color: #334155; }
.medal-perunggu { background: #fed7aa; color: #9a3412; }

/* ==================== TIMING CONSOLE (TAHAP 4) ==================== */
.timing-clock-panel {
    background: #0b192c;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    margin-bottom: 1rem;
    border: 2px solid #1e3a5f;
}

.timing-clock-panel.running {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}

.timing-led {
    font-family: "Consolas", "Courier New", ui-monospace, monospace;
    font-size: clamp(2.4rem, 6vw, 4.1rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #4ade80;
    line-height: 1.1;
    margin: 0.35rem 0 0.8rem;
}

.timing-clock-panel.idle .timing-led { color: #f8fafc; }
.timing-clock-panel.stopped .timing-led { color: #fbbf24; }

.timing-controls {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn-xl {
    padding: 0.72rem 1.35rem;
    font-size: 0.98rem;
    border-radius: 9px;
    font-weight: 800;
}

.timing-layout {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 1rem;
    align-items: start;
}

.lane-timing-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: #fff;
    margin-bottom: 0.55rem;
    transition: border-color 0.15s, background 0.15s;
}

.lane-timing-btn.captured {
    border-color: var(--success);
    background: #f0fdf4;
}

.lane-timing-btn.inactive-lane {
    opacity: 0.65;
    background: #fef2f2;
    border-color: #fecaca;
}

.lane-capture-trigger {
    min-width: 95px;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: 0.86rem;
    cursor: pointer;
}

.lane-capture-trigger:hover { background: var(--primary-dark); }
.lane-capture-trigger:disabled { background: #94a3b8; cursor: not-allowed; }

.time-pill {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary-dark);
    min-width: 82px;
    text-align: right;
}

.queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.45rem;
    background: #f8fafc;
}

.camera-stage {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    margin-bottom: 0.75rem;
}

.camera-stage video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.finish-line-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: rgba(239, 68, 68, 0.92);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.85);
    pointer-events: none;
    z-index: 5;
}

.kbd {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.75rem;
    font-family: monospace;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
}

.kbd-dark {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.75rem;
    font-family: monospace;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #1e293b;
}

.switch-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.95rem 1.05rem;
    background: #f8fafc;
    margin-bottom: 0.85rem;
}

/* Utilities */
.filter-bar {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.btn-group {
    display: inline-flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.85rem;
}

.form-group { margin-bottom: 0.85rem; }
.form-group label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    margin-bottom: 0.28rem;
}

.form-control {
    width: 100%;
    padding: 0.52rem 0.68rem;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 0.92rem;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 61, 110, 0.12);
}

.form-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 0.92rem;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #c2410c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-outline { background: #fff; border-color: #cbd5e1; color: var(--text); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 0.32rem 0.62rem; font-size: 0.8rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
th, td {
    text-align: left;
    padding: 0.6rem 0.65rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
th {
    background: #f8fafc;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    white-space: nowrap;
}

/* Badges & Alerts */
.badge {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-success   { background: #dcfce7; color: #166534; }
.badge-secondary { background: #e2e8f0; color: #334155; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-primary   { background: #dbeafe; color: #1e40af; }
.badge-danger    { background: #fee2e2; color: #991b1b; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* Auth Box */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.auth-card {
    background: #fff;
    width: 100%;
    max-width: 400px;
    padding: 1.75rem;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

/* Responsive */
@media (min-width: 861px) {
    .menu-toggle { display: none; }
}

@media (max-width: 960px) {
    .timing-layout { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        top: 52px;
        left: -260px;
        bottom: 0;
        z-index: 60;
        transition: left 0.2s ease;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }
    .sidebar.open { left: 0; }
    .main-content { padding: 0.85rem; }
    .heat-grid { grid-template-columns: 1fr; }
    .hide-xs { display: none; }
    .tap-btn-group { width: 100%; }
    .tap-btn { flex: 1; }
}
