:root {
    --on: #48bb78;
    --comwatt: #ecc94b;
    --off: #f56565;
    --other: #4299e1;
    --border: #e2e8f0;
    --muted: #718096;
    --bg: #f4f9fc;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #2d3748;
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

.title { display: flex; align-items: center; gap: 12px; }
.subtitle { color: var(--muted); }
.actions { display: flex; align-items: center; gap: 16px; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
}
.badge-app { background: #c6f6d5; color: #22543d; }

.btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    padding: 7px 14px;
    cursor: pointer;
    font: inherit;
}
.btn:hover { background: #edf2f7; }
.btn-danger { background: #e53e3e; border-color: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-small { padding: 3px 10px; font-size: 12px; }
.btn.active { background: #ebf8ff; border-color: #4299e1; color: #2b6cb0; }

.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle-track {
    width: 40px; height: 22px; border-radius: 999px; background: var(--off);
    position: relative; transition: background .2s;
}
.toggle-thumb {
    position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
    border-radius: 50%; background: #fff; transition: left .2s;
}
.toggle input:checked + .toggle-track { background: var(--on); }
.toggle input:checked + .toggle-track .toggle-thumb { left: 21px; }
.toggle-label { font-weight: 600; min-width: 60px; }
.toggle-label.ok { color: #2f855a; }
.toggle-label.ko { color: #c53030; }

.ws-status { font-size: 12px; }
.ws-on { color: #2f855a; }
.ws-off { color: #c53030; }

main { padding: 20px; }
.summary { margin-bottom: 10px; color: var(--muted); }

table.plannings {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.plannings th, .plannings td {
    text-align: left;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.plannings th { background: #f7fafc; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 6px; }

.planning-row.new { animation: flash 2s ease-out; }
@keyframes flash { from { background: #fefcbf; } to { background: transparent; } }

.detail-row td { background: #fbfdfe; padding: 16px 18px; }

.empty { text-align: center; color: var(--muted); padding: 30px; }

pre.json {
    margin: 0;
    max-height: 360px;
    overflow: auto;
    background: #1a202c;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
}

/* Diagramme 24 h */
.chart { position: relative; }
.chart-bar {
    position: relative;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    background: #edf2f7;
}
.segment {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    border-right: 1px solid rgba(255, 255, 255, .6);
}
.segment.mode-on { background: var(--on); }
.segment.mode-comwatt { background: var(--comwatt); color: #744210; }
.segment.mode-off { background: var(--off); }
.segment.mode-other { background: var(--other); }

.chart-axis { position: relative; height: 18px; margin-top: 6px; }
.chart-axis span {
    position: absolute;
    transform: translateX(-50%);
    font-size: 11px;
    color: #a0aec0;
}
.chart-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart-caption { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
