:root {
    --bg: #0F1720;
    --surface: #1A2532;
    --surface-alt: #232F3E;
    --border: #2C3A4B;
    --primary: #4F9DFF;
    --primary-soft: rgba(79, 157, 255, 0.16);
    --text: #F2F5F8;
    --text-muted: #8A97A6;
    --success: #3DDC97;
    --danger: #FF6B6B;
}

* {
    box-sizing: border-box;
}

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

/* Login */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

.login-card {
    max-width: 380px;
    width: 100%;
    text-align: center;
}

.logo {
    width: 84px;
    height: 84px;
    border-radius: 20px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 24px;
}

.login-card h1 {
    font-size: 26px;
    margin: 0 0 8px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 32px;
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    color: #08131F;
    border: none;
    padding: 14px 24px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.footnote {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 24px;
}

/* Dashboard */
.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 48px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 16px;
}

.page-header h1 {
    font-size: 20px;
    margin: 0;
}

.unit-line {
    color: var(--text-muted);
    font-size: 13px;
    margin: 2px 0 0;
}

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
}

.toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.btn-ghost {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--primary-soft);
}

.banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 13px;
}

.banner-error {
    background: rgba(255, 107, 107, 0.12);
    color: var(--danger);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.toast.toast-error {
    color: var(--danger);
    border-color: var(--danger);
}

.empty-text {
    color: var(--text-muted);
    text-align: center;
    margin-top: 40px;
}

.room-section {
    margin-bottom: 16px;
}

.room-title {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 0 0 8px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 16px;
}

.card-offline {
    opacity: 0.55;
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 12px;
    flex-shrink: 0;
}

.card-title {
    flex: 1;
    min-width: 0;
}

.card-name {
    font-weight: 600;
    font-size: 16px;
}

.card-room {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.card-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
}

.status-online {
    background: var(--success);
}

.status-offline {
    background: var(--danger);
}

.control-row {
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.control-header-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.control-label {
    font-size: 14px;
}

.control-value {
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-pill {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    transition: 0.2s;
}

.slider-pill::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

.switch input:checked + .slider-pill {
    background: var(--primary);
}

.switch input:checked + .slider-pill::before {
    transform: translateX(18px);
}

.switch input:disabled + .slider-pill {
    opacity: 0.5;
}

.slider {
    width: 100%;
    accent-color: var(--primary);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chip {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    text-transform: capitalize;
    cursor: pointer;
}

.chip-active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.unsupported {
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

.control-row-primary {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* Timer widget */
.timer-widget .control-label {
    display: block;
    margin-bottom: 8px;
}

.timer-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.timer-presets .chip {
    text-transform: none;
}

.timer-active {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
}

/* Author styles override the UA [hidden] rule by origin regardless of
   specificity, so re-assert it explicitly wherever we set `display` above. */
.timer-active[hidden],
.timer-presets[hidden] {
    display: none;
}

.timer-countdown {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

/* Energy monitor */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.metric-tile {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.metric-icon {
    font-size: 16px;
    margin-bottom: 4px;
}

.metric-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.metric-value span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}
