/* Crew admin: compact, phone-friendly, reuses the campaign tokens. */

:root {
    --paper: #E9F0DE;
    --ink: #0A0A0A;
    --yellow: #F2E33D;
    --danger: #b91c1c;
    --ok: #15803d;
    --font: 'Outfit', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--paper);
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.hidden { display: none !important; }

/* ---- login ---- */

#login-overlay {
    position: fixed;
    inset: 0;
    background: var(--ink);
    color: var(--yellow);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(320px, 85vw);
}

#login-form h1 { font-weight: 600; }

#login-form input {
    font: inherit;
    font-size: 18px;
    padding: 12px;
    border: 2px solid var(--yellow);
    background: transparent;
    color: var(--yellow);
}

#login-form button {
    font: inherit;
    font-size: 18px;
    font-weight: 600;
    padding: 12px;
    background: var(--yellow);
    color: var(--ink);
    border: none;
    cursor: pointer;
}

.login-error { color: var(--danger); min-height: 1.2em; font-weight: 500; }

/* ---- layout ---- */

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 12px 40px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 14px 2px;
}

.topbar h1 { font-size: 20px; font-weight: 700; }

.conn-status { font-size: 13px; }
.conn-status.ok { color: var(--ok); }
.conn-status.bad { color: var(--danger); }

.panel {
    background: #fff;
    border: 2px solid var(--ink);
    padding: 14px;
    margin-bottom: 14px;
}

.panel h2 {
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

/* ---- run control ---- */

.run-panel { position: sticky; top: 0; z-index: 10; }

.run-status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.phase-badge {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    background: var(--ink);
    color: #fff;
}

.phase-badge[data-phase="ready"] { background: #a16207; }
.phase-badge[data-phase="running"] { background: var(--danger); }
.phase-badge[data-phase="finished"] { background: var(--ok); }

.live-bpm { font-size: 20px; font-weight: 600; }

.live-signal { font-size: 13px; color: var(--danger); font-weight: 500; }
.live-signal.ok { color: var(--ok); }

.run-participant { font-size: 16px; font-weight: 500; min-height: 1.3em; margin-bottom: 8px; }

#register-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
}

#register-form input {
    font: inherit;
    padding: 10px;
    border: 2px solid var(--ink);
}

button {
    font: inherit;
    font-weight: 600;
    padding: 10px 14px;
    background: #fff;
    border: 2px solid var(--ink);
    cursor: pointer;
}

button:active { transform: translateY(1px); }
button.primary { background: var(--ink); color: #fff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.big { font-size: 18px; padding: 12px 22px; }
button.small { font-size: 13px; padding: 5px 10px; font-weight: 500; }
button:disabled { opacity: 0.35; cursor: default; }

.run-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.action-error { color: var(--danger); font-weight: 500; min-height: 1.2em; margin-top: 6px; font-size: 14px; }

/* ---- sensors + simulator ---- */

.sensor-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.sensor-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid #bbb;
}

.sensor-row.active { border: 2px solid var(--ink); background: var(--paper); }

.sensor-row .s-label {
    font: inherit;
    font-weight: 500;
    border: none;
    background: transparent;
    border-bottom: 1px dashed #999;
    min-width: 0;
}

.sensor-row .s-bpm { font-weight: 600; white-space: nowrap; }
.sensor-row .s-seen { font-size: 12px; color: #666; white-space: nowrap; }

.sim-controls { border-top: 1px solid #ccc; padding-top: 10px; }

.sim-toggle { font-weight: 600; display: block; margin-bottom: 8px; }

.sim-slider-row { display: flex; align-items: center; gap: 10px; }

.sim-slider-row input[type="range"] { flex: 1; accent-color: var(--ink); }

#sim-bpm-value { font-size: 20px; font-weight: 700; min-width: 2.2ch; text-align: right; }

/* ---- scoreboard ---- */

.board-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 14px;
    margin-bottom: 10px;
}

.runs-table { width: 100%; border-collapse: collapse; font-size: 14px; }

.runs-table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--ink);
    padding: 4px 6px;
}

.runs-table td { border-bottom: 1px solid #ccc; padding: 6px; }

.runs-table tr.hidden-run td { opacity: 0.45; }
.runs-table tr.aborted-run td { opacity: 0.45; font-style: italic; }

.runs-table .cell-edit {
    font: inherit;
    border: none;
    background: transparent;
    border-bottom: 1px dashed transparent;
    width: 100%;
    min-width: 7ch;
}

.runs-table .cell-edit:focus { border-bottom-color: #999; outline: none; }

.runs-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.runs-table .row-actions button { padding: 3px 7px; font-size: 12px; border-width: 1px; }

.runs-table .winner-btn.on { background: var(--yellow); }

.runs-table .beats-cell { font-weight: 700; }

/* ---- tools ---- */

.tools-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 14px;
}

.duration-btn.on, .force-btn.on { background: var(--ink); color: #fff; }

.today-stats { font-weight: 500; }

#csv-link { color: var(--ink); font-weight: 600; }

@media (max-width: 560px) {
    #register-form { grid-template-columns: 1fr; }
    .runs-table th:nth-child(5), .runs-table td:nth-child(5) { display: none; }
}
