:root {
    color-scheme: light dark;
    --bg: #f7f6f3;
    --fg: #21201c;
    --muted: #6b6a66;
    --accent: #3d8bfd;
    --border: #ddd9d0;
    --pill-bg: #fff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1b19;
        --fg: #ece9e2;
        --muted: #9a988f;
        --border: #3a3833;
        --pill-bg: #26241f;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--fg);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--fg);
    text-decoration: none;
}

.logout-form button {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
}

main {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem;
}

.empty { color: var(--muted); }

.device-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.device-pill {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--pill-bg);
    color: var(--fg);
    min-width: 8rem;
    position: relative;
}

.device-pill.selected {
    border-color: var(--accent);
}

.device-pill-name {
    font-weight: 600;
    text-decoration: none;
    color: var(--fg);
    padding-right: 1.4rem;
}

.device-pill-latest { font-size: 0.85rem; color: var(--muted); }

.device-pill-settings {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0;
}

dialog {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--pill-bg);
    color: var(--fg);
    padding: 1.25rem;
    min-width: 280px;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

dialog h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

dialog label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.9rem;
}

dialog input {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--fg);
    font-size: 1rem;
}

.dialog-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.dialog-actions button {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    color: var(--fg);
    cursor: pointer;
}

.dialog-actions button[type="submit"] {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tabs button {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.tabs button.tab-active {
    border-color: var(--accent);
    color: var(--fg);
    font-weight: 600;
}

.chart {
    background: var(--pill-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.chart h3 {
    margin: 0 0 0.5rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.chart-latest { color: var(--accent); }
.chart-axis { font-size: 10px; fill: var(--muted); }
.chart-empty { color: var(--muted); font-size: 0.9rem; }

.login {
    max-width: 320px;
    margin: 4rem auto;
    text-align: center;
}

.login form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.login input {
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--pill-bg);
    color: var(--fg);
}

.login button {
    padding: 0.6rem;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

.error { color: #d1453b; }
