:root {
    --bg: #f6f8fa;
    --bg2: #ffffff;
    --bg3: #f0f2f5;
    --border: #d0d7de;
    --text: #1f2328;
    --text-dim: #6e7781;
    --ok: #1a7f37;
    --scoring: #9a6700;
    --suspect: #cf222e;
    --accent: #0969da;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
}

/* ── Header ─────────────────────────────────────── */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
}

.header-left { flex: 0 0 auto; }
.header-center { flex: 1; text-align: center; font-weight: 600; font-size: 1rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.header-right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

h1 { font-size: 1.15rem; color: var(--text); white-space: nowrap; }
.sep { margin: 0 .5rem; color: var(--text-dim); }

.status-indicator { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--text-dim); }

.dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}
.dot.connected    { background: var(--ok); }
.dot.connecting   { background: var(--scoring); animation: blink .9s ease-in-out infinite; }
.dot.disconnected { background: var(--suspect); }

@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

#last-update { font-size: .72rem; color: var(--text-dim); }

/* ── Main ────────────────────────────────────────── */
main { padding: 1.25rem; }

/* No-data state */
#no-data {
    text-align: center;
    padding: 5rem 1rem;
    color: var(--text-dim);
}
.no-data-icon { font-size: 3.5rem; margin-bottom: 1.25rem; }
#no-data p { font-size: 1.05rem; }
#no-data .hint { font-size: .85rem; margin-top: .5rem; }
#no-data .hint.url { margin-top: 1rem; }
#no-data code {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: .82rem;
    color: var(--accent);
}

/* Broadcast-off state */
#broadcast-off {
    text-align: center;
    padding: 5rem 1rem;
}
.off-icon { font-size: 4rem; margin-bottom: 1.25rem; opacity: .5; }
.off-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .4rem;
}
.off-sub {
    font-size: 1rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}
.off-meta {
    display: inline-flex;
    gap: .5rem;
    align-items: center;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .35rem 1rem;
    font-size: .9rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: .75rem;
}
.off-meta:empty { display: none; }
.off-time {
    font-size: .8rem;
    color: var(--text-dim);
}

/* Stats bar */
.stats-bar {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.stat {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
}

.stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }
.stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.stat-value.ok      { color: var(--ok); }
.stat-value.scoring { color: var(--scoring); }
.stat-value.suspect { color: var(--suspect); }

/* Table toolbar */
.table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: .6rem;
}

#filter-input {
    width: 220px;
    padding: .4rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .875rem;
    background: var(--bg2);
    color: var(--text);
    outline: none;
}
#filter-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(9,105,218,.15); }

/* Table */
.table-wrapper { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg2);
}

thead { background: var(--bg3); }

th {
    padding: .6rem .9rem;
    text-align: left;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-dim);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    user-select: none;
}

th[data-col] {
    cursor: pointer;
}
th[data-col]:hover { color: var(--text); }

th[data-col]::after { content: ""; margin-left: 5px; opacity: .3; font-style: normal; }
th[data-col]:hover::after { content: "↕"; opacity: .5; }
th.sort-asc::after  { content: "↑"; opacity: 1; color: var(--accent); }
th.sort-desc::after { content: "↓"; opacity: 1; color: var(--accent); }

td {
    padding: .55rem .9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(0,0,0,.025); }

/* Row accent by status */
tbody tr.ok           td:first-child { border-left: 3px solid var(--ok); }
tbody tr.saisie_en_cours td:first-child { border-left: 3px solid var(--scoring); }
tbody tr.attente_tablette td:first-child { border-left: 3px solid var(--suspect); }

/* Cell styles */
.cell-target { font-weight: 700; font-size: .95rem; font-family: monospace; white-space: nowrap; }
.cell-name   { font-weight: 500; }
.cell-score  { font-family: monospace; text-align: right; }
.cell-total  { font-family: monospace; font-weight: 700; text-align: right; }
.cell-ts     { color: var(--text-dim); font-size: .78rem; white-space: nowrap; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-ok      { background: #dafbe1; color: var(--ok); }
.badge-scoring { background: #fff8c5; color: var(--scoring); }
.badge-suspect { background: #ffebe9; color: var(--suspect); }

/* Responsive */
@media (max-width: 640px) {
    header { height: auto; flex-wrap: wrap; padding: .6rem; }
    .header-center { order: 3; flex: 1 0 100%; text-align: left; font-size: .9rem; }
    th, td { padding: .45rem .6rem; }
}
