/*
 * File:         style.css
 * Package:      AutoEnergy
 * Sub-package:  Dashboard/CSS
 * Version:      v1.9.0
 * Last Updated: 2026-03-31
 *
 * Purpose: Combined stylesheet for AutoEnergy SPA — header, nav, dashboard panels,
 *          toast notifications, modal overlays, pending flash, rules editor.
 *
 * Selectors/Blocks:
 *   - .ae-header               — SPA header bar + nav
 *   - .ae-toast-container      — Floating toast notifications (z-index 100000)
 *   - .ae-modal-overlay        — Full-screen modal backdrop (z-index 99999)
 *   - .ae-modal--centered      — Modal card (slide-in animation)
 *   - .ae-pending-flash        — Amber pulsing text for pending mode changes
 *   - .auto-panel              — Dashboard panels (battery, grid, forecast, etc.)
 *   - .auto-action-row         — Auto Mode action buttons row (Override + Test Mode)
 *   - .rules-container         — Rules editor view
 *
 * Changelog:
 *   v1.9.0 — CSV export: tabbed AEMO/Amber panel (.csv-tabs, .csv-tab, .csv-source-label,
 *            .csv-tab-content, .amber-export-btn). Tab active states with data-attribute colors.
 *   v1.8.1 — Added toggle switch styles (.ae-setup__toggle), state <select> styling.
 *   v1.8.0 — Restored setup wizard CSS (dropped in v2.0.0 rewrite). Translated CSS vars
 *            to hardcoded colors. Added setup address autocomplete + form section styles.
 *   v1.7.0 — Added Usage Profile widget + Usage Report view styles (Task 8C + 8D).
 *            Stats cards, period buttons, heatmap grid, report tables, price chart.
 *   v1.6.0 — (1) Removed .side-by-side-row — Auto Mode + Activity Log are now individual
 *            panels in .main 2-col grid (independently draggable).
 *            (2) Removed .log-panel grid-column:1/-1 (was forcing full-width).
 *            (3) Added .auto-action-row for separated action buttons row.
 *   v1.5.0 — FIX: .log-panel grid-column:1/-1 override inside .side-by-side-row — was forcing
 *            Activity Log to span both columns instead of sitting beside Auto Mode.
 *   v1.4.0 — Added ALL ae-auth-* styles for login/signup view (ae-auth-container, ae-auth-card,
 *            ae-auth__tabs, ae-auth__tab, ae-auth__divider, ae-auth__logo, ae-auth__note,
 *            ae-auth__form, ae-spinner). Fully responsive. Dark theme consistent.
 *   v1.3.0 — Added ENTIRE .ae-modal-overlay CSS block (was completely missing — modal
 *            rendered inline at bottom of page). Full modal styles: overlay, card, header,
 *            body, footer, buttons, animations. This fixes the "modal doesn't float" bug.
 *   v1.2.0 — Toast z-index 3000→100000. Deprecated old #toastContainer + .toast CSS.
 *            Added .ae-pending-flash animation. Added .ae-toast-container class to HTML.
 *   v1.1.0 — Merged SPA shell + dashboard + rules editor styles
 *   v1.0.0 — Initial combined stylesheet from Dashboard v3.7.1
 */

/* ============================================
 * AUTO ENERGY SPA — Combined Stylesheet
 * ============================================ */

/* SPA SHELL — Header & Nav (these sit ABOVE the dashboard) */
.ae-header {
    background: linear-gradient(135deg, #1a1f2e, #252b3d);
    border-bottom: 2px solid #f59e0b;
}
.ae-header__container {
    display: flex;
    align-items: center;
    padding: 10px 24px;
    gap: 16px;
}
.ae-header__logo {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.ae-logo-icon { font-size: 22px; }
.ae-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #e0e6ed;
}
.ae-header__nav {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    margin: 0 16px;
}
.ae-nav__link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: #64748b;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.ae-nav__link:hover {
    color: #e0e6ed;
    background: rgba(255,255,255,0.03);
}
.ae-nav__link.active {
    color: #f59e0b;
    border-bottom-color: #f59e0b;
}
.ae-nav__icon { font-size: 15px; }
.ae-header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.ae-header__theme-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}
.ae-header__user-name {
    font-size: 13px;
    color: #94a3b8;
}
.ae-header__settings-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
}
.ae-btn--ghost {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.ae-btn--ghost:hover {
    background: #ef4444;
    color: #fff;
}

/* Responsive header */
@media (max-width: 768px) {
    .ae-header__container { flex-wrap: wrap; padding: 8px 12px; }
    .ae-header__nav { order: 3; width: 100%; margin: 4px 0 0; overflow-x: auto; }
    .ae-nav__link { padding: 8px 12px; font-size: 12px; }
}
@media (max-width: 480px) {
    .ae-header__actions { gap: 6px; }
    .ae-btn--ghost { display: none; }
}

/* (nav styles moved into header section above) */

/* ── Fox API Budget Bar ── */
.ae-api-budget-bar {
    background: rgba(0,0,0,0.3);
    padding: 4px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ae-api-budget-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 1400px;
    margin: 0 auto;
    font-size: 11px;
    color: #94a3b8;
}
.ae-api-budget-label {
    white-space: nowrap;
    font-weight: 600;
}
.ae-api-budget-track {
    flex: 1;
    max-width: 200px;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}
.ae-api-budget-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background 0.5s ease;
    background: #22c55e;
}
.ae-api-budget-text {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: #22c55e;
    font-weight: 600;
}

/* App container */
#app {
    min-height: calc(100vh - 100px);
}

/* Loading spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: #64748b;
    font-size: 14px;
    gap: 16px;
}
.loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #1e293b;
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* SPA Toast — THE ONE AND ONLY toast system (v3.5.8: z-index 100000 to float above everything) */
.ae-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 400px;
}

/* Individual toast element */
.ae-toast {
    pointer-events: auto;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    animation: aeToastIn 0.3s ease;
    overflow: hidden;
}
.ae-toast__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
}
.ae-toast__message {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    flex: 1;
}
.ae-toast__close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.6;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}
.ae-toast__close:hover { opacity: 1; }

/* Toast type variants */
.ae-toast--success { background: #166534; color: #bbf7d0; border: 1px solid #22c55e; }
.ae-toast--error   { background: #7f1d1d; color: #fecaca; border: 1px solid #ef4444; }
.ae-toast--warning { background: #78350f; color: #fde68a; border: 1px solid #f59e0b; }
.ae-toast--info    { background: #1e3a5f; color: #bfdbfe; border: 1px solid #3b82f6; }

/* Toast exit animation */
.ae-toast--exiting {
    animation: aeToastOut 0.3s ease forwards;
}

@keyframes aeToastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes aeToastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* Pending mode flash — v3.5.8: after mode change, label flashes until inverter confirms */
.ae-pending-flash {
    animation: aePendingPulse 1s ease-in-out infinite;
    color: #f59e0b !important;
}
@keyframes aePendingPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* ═══ Modal Overlay — v3.5.9: was COMPLETELY MISSING, caused modal to render inline ═══ */
.ae-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(2px);
}
.ae-modal-overlay.ae-modal--exiting {
    animation: aeModalFadeOut 0.3s ease forwards;
}
.ae-modal--centered {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 0;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: aeModalSlideIn 0.2s ease;
}
.ae-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #334155;
}
.ae-modal__title {
    font-size: 1.1em;
    font-weight: 600;
    color: #f8fafc;
    margin: 0;
}
.ae-modal__close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.ae-modal__close:hover { color: #f8fafc; }
.ae-modal__body {
    padding: 20px;
    color: #cbd5e1;
    font-size: 0.95em;
    line-height: 1.5;
}
.ae-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid #334155;
}
.ae-modal__footer .ae-btn {
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}
.ae-btn--ghost {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #475569;
}
.ae-btn--ghost:hover { background: #334155; color: #f8fafc; }
.ae-btn--primary {
    background: #3b82f6;
    color: #fff;
}
.ae-btn--primary:hover { background: #2563eb; }
.ae-btn--danger {
    background: #ef4444;
    color: #fff;
}
.ae-btn--danger:hover { background: #dc2626; }

@keyframes aeModalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes aeModalFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* Settings view basic styles */
.ae-settings {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}
.ae-settings h1 {
    font-size: 22px;
    font-weight: 700;
    color: #e0e6ed;
    margin-bottom: 20px;
}
.ae-settings-section {
    background: #141926;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #1e293b;
    margin-bottom: 16px;
}
.ae-settings-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: #e0e6ed;
    margin-bottom: 12px;
}
.ae-form-group {
    margin-bottom: 12px;
}
.ae-form-group label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ae-form-group input,
.ae-form-group select {
    width: 100%;
    background: #0d1321;
    border: 1px solid #2a3050;
    color: #e0e6ed;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
}
.ae-form-group input:focus,
.ae-form-group select:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245,158,11,0.2);
}
.ae-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.ae-btn--primary {
    background: #f59e0b;
    color: #0a0e17;
}
.ae-btn--primary:hover {
    background: #d97706;
}
.ae-btn--danger {
    background: #ef4444;
    color: #fff;
}
.ae-btn--danger:hover {
    background: #dc2626;
}

/* Placeholder views */
.ae-placeholder-view {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}
.ae-placeholder-view h1 {
    font-size: 22px;
    color: #e0e6ed;
    margin-bottom: 8px;
}
.ae-placeholder-view p {
    font-size: 14px;
}

/* Login view (legacy) */
.ae-login {
    max-width: 400px;
    margin: 60px auto;
    padding: 30px;
    background: #141926;
    border-radius: 12px;
    border: 1px solid #1e293b;
    text-align: center;
}
.ae-login h1 {
    font-size: 24px;
    color: #e0e6ed;
    margin-bottom: 20px;
}
.ae-login .ae-form-group { text-align: left; }

/* ── Auth Container (login.js v1.0.0) ── */
.ae-auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #0f1219 0%, #1a1f2e 100%);
}
.ae-auth-card {
    width: 100%;
    max-width: 420px;
    background: #141926;
    border-radius: 16px;
    border: 1px solid #1e293b;
    padding: 40px 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Logo */
.ae-auth__logo {
    text-align: center;
    margin-bottom: 28px;
}
.ae-auth__logo .ae-logo-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 8px;
}
.ae-auth__logo .ae-logo-text {
    font-size: 26px;
    font-weight: 700;
    color: #e0e6ed;
    margin: 0;
}

/* Tabs (Sign In / Sign Up) */
.ae-auth__tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: #0f1219;
    border-radius: 8px;
    padding: 4px;
}
.ae-auth__tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ae-auth__tab:hover {
    color: #94a3b8;
}
.ae-auth__tab--active {
    background: #1e293b;
    color: #f59e0b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Form */
.ae-auth__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.ae-auth__form .ae-form-group {
    text-align: left;
}
.ae-auth__form .ae-form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.ae-auth__form .ae-form-group input {
    width: 100%;
    padding: 12px 14px;
    background: #0f1219;
    border: 1px solid #1e293b;
    border-radius: 8px;
    color: #e0e6ed;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.ae-auth__form .ae-form-group input:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
.ae-auth__form .ae-form-group input::placeholder {
    color: #475569;
}

/* Submit button */
.ae-auth__form .ae-btn--primary {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
    margin-top: 4px;
}

/* Divider */
.ae-auth__divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    gap: 12px;
}
.ae-auth__divider::before,
.ae-auth__divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #1e293b;
}
.ae-auth__divider span {
    font-size: 12px;
    color: #475569;
    text-transform: lowercase;
}

/* Google / secondary auth button */
.ae-auth-card .ae-btn--secondary {
    width: 100%;
    padding: 12px 20px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e0e6ed;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.ae-auth-card .ae-btn--secondary:hover {
    background: #334155;
    border-color: #475569;
}

/* Footer note */
.ae-auth__note {
    text-align: center;
    font-size: 12px;
    color: #475569;
    margin-top: 20px;
    line-height: 1.5;
}

/* Forgot password link */
.ae-auth__form .ae-link {
    font-size: 13px;
    color: #f59e0b;
    text-decoration: none;
}
.ae-auth__form .ae-link:hover {
    text-decoration: underline;
}

/* Spinner inside submit button */
.ae-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ae-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}
@keyframes ae-spin {
    to { transform: rotate(360deg); }
}

/* Auth responsive */
@media (max-width: 480px) {
    .ae-auth-card {
        padding: 28px 20px;
        border-radius: 12px;
    }
    .ae-auth__logo .ae-logo-text {
        font-size: 22px;
    }
}

/* Error view */
.ae-error {
    text-align: center;
    padding: 40px 20px;
    color: #ef4444;
}

/* Responsive SPA shell */
@media (max-width: 768px) {
    .ae-header { padding: 8px 12px; }
    .ae-header__brand { font-size: 15px; }
    .ae-nav { padding: 0 8px; overflow-x: auto; }
    .ae-nav__link { padding: 10px 12px; font-size: 12px; white-space: nowrap; }
}
@media (max-width: 480px) {
    .ae-header__signout { display: none; }
    .ae-nav__link { padding: 8px 10px; font-size: 11px; }
}

/* ============================================
 * ORIGINAL DASHBOARD v3.7.1 CSS (VERBATIM)
 * ============================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { max-width: 100vw; overflow-x: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0a0e17; color: #e0e6ed; min-height: 100vh; }

/* HEADER */
.header { background: linear-gradient(135deg, #1a1f2e, #252b3d); padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #f59e0b; max-width: 100vw; overflow: hidden; }
.header h1 { font-size: 22px; font-weight: 700; }
.header h1 span.amber { color: #f59e0b; }
.header h1 span.fox { color: #22c55e; }
.header .version { font-size: 12px; color: #64748b; }
.header .status-bar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.status-dot.green { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.status-dot.red { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
.status-dot.yellow { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.status-dot.grey { background: #64748b; }
.status-label { font-size: 13px; color: #94a3b8; }

.refresh-btn { background: #f59e0b; color: #0a0e17; border: none; border-radius: 6px; padding: 6px 14px; font-size: 12px; font-weight: 700; cursor: pointer; margin-left: 8px; transition: all 0.2s; }
.refresh-btn:hover { background: #d97706; transform: translateY(-1px); }
.refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.refresh-btn .spinner-inline { display: none; width: 12px; height: 12px; border: 2px solid rgba(0,0,0,0.2); border-top-color: #0a0e17; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-left: 4px; }
.refresh-btn.loading .spinner-inline { display: inline-block; }

/* OAUTH BUTTON */
.oauth-btn { background: #7c3aed; color: #fff; border: none; border-radius: 6px; padding: 5px 12px; font-size: 11px; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.oauth-btn:hover { background: #6d28d9; transform: translateY(-1px); }
.oauth-btn.authorized { background: #22c55e; cursor: default; }
.oauth-btn.authorized:hover { transform: none; }

/* MAIN GRID */
.main { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; }

/* PANELS */
.panel { background: #141926; border-radius: 12px; padding: 20px; border: 1px solid #1e293b; max-width: 100%; overflow: hidden; }
.panel-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.panel-title .icon { font-size: 20px; }

/* AMBER PRICING */
.price-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.price-card { background: #1a2035; border-radius: 10px; padding: 16px; text-align: center; border: 1px solid #2a3050; transition: all 0.3s; }
.price-card.import { border-left: 4px solid #ef4444; }
.price-card.export { border-left: 4px solid #22c55e; }
.price-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin-bottom: 6px; }
.price-card .value { font-size: 36px; font-weight: 800; line-height: 1.1; }
.price-card .unit { font-size: 13px; color: #64748b; }
.price-card .descriptor { font-size: 11px; margin-top: 4px; font-weight: 600; }

/* Price color coding */
.price-negative { color: #22c55e; }
.price-vlow { color: #4ade80; }
.price-low { color: #86efac; }
.price-neutral { color: #f59e0b; }
.price-high { color: #f97316; }
.price-spike { color: #ef4444; text-shadow: 0 0 10px rgba(239,68,68,0.5); }

/* NEM WHOLESALE PANEL */
.nem-panel { grid-column: 1 / -1; }
.nem-cards { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.nem-card { background: #1a2035; border-radius: 10px; padding: 14px; text-align: center; border: 1px solid #2a3050; transition: all 0.3s; }
.nem-card .label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin-bottom: 4px; }
.nem-card .value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.nem-card .unit { font-size: 11px; color: #64748b; }
.nem-card.spot { border-top: 3px solid #a78bfa; }
.nem-card.demand { border-top: 3px solid #38bdf8; }
.nem-card.solar { border-top: 3px solid #f59e0b; }
.nem-card.wind { border-top: 3px solid #22d3ee; }
.nem-card.temp { border-top: 3px solid #fb923c; }
.nem-spread { font-size: 11px; color: #64748b; margin-top: 2px; }
.nem-ts { font-size: 10px; color: #475569; margin-top: 4px; }
.nem-comparison { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 12px; }
.nem-compare-card { background: #1a2035; border-radius: 10px; padding: 14px; border: 1px solid #2a3050; }
.nem-compare-card h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin-bottom: 8px; }
.nem-bar { height: 8px; border-radius: 4px; margin: 4px 0; transition: width 0.5s; }
.nem-bar-label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 2px; }

/* CSV EXPORT PANEL */
.csv-panel { margin-top: 12px; background: #1a2035; border-radius: 10px; padding: 14px; border: 1px solid #2a3050; border-left: 3px solid #a78bfa; }
.csv-panel h3 { font-size: 13px; color: #a78bfa; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.csv-tabs { display: flex; gap: 0; margin-bottom: 8px; border-bottom: 1px solid #2a3050; }
.csv-tab { padding: 8px 16px; background: transparent; border: none; color: #94a3b8; font-size: 12px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; }
.csv-tab:hover { color: #e2e8f0; }
.csv-tab.active { color: #a78bfa; border-bottom-color: #a78bfa; }
.csv-tab[data-csv-tab="amber"].active { color: #f59e0b; border-bottom-color: #f59e0b; }
.csv-source-label { font-size: 10px; color: #64748b; margin-bottom: 10px; font-style: italic; }
.csv-tab-content { transition: opacity 0.2s; }
.amber-export-btn { border-color: #f59e0b44 !important; background: #f59e0b11 !important; color: #f59e0b !important; }
.amber-export-btn:hover { background: #f59e0b33 !important; }
.csv-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.csv-label { font-size: 12px; color: #94a3b8; min-width: 50px; font-weight: 600; }
.csv-input { background: #0d1321; border: 1px solid #2a3050; border-radius: 6px; padding: 6px 10px; color: #e0e6ed; font-size: 13px; }
.csv-preset { padding: 5px 12px; border: 1px solid #a78bfa44; background: #a78bfa11; color: #a78bfa; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.csv-preset:hover { background: #a78bfa33; transform: translateY(-1px); }
.csv-preset.active { background: #a78bfa; color: #0a0e17; }
.csv-export-btn { padding: 8px 20px; background: #a78bfa; color: #0a0e17; border: none; border-radius: 6px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.csv-export-btn:hover { background: #8b5cf6; transform: translateY(-1px); }
.csv-export-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.csv-status { font-size: 12px; color: #94a3b8; margin-left: 10px; }

/* FORECAST TABLE */
.forecast-grid { width: 100%; border-collapse: collapse; margin-top: 12px; }
.forecast-grid th { font-size: 11px; text-transform: uppercase; color: #64748b; padding: 6px 8px; text-align: left; border-bottom: 1px solid #1e293b; }
.forecast-grid td { padding: 8px; font-size: 13px; border-bottom: 1px solid #111827; }
.forecast-grid tr:hover { background: #1a2035; }
.forecast-row-main { cursor: pointer; }
.forecast-row-main:hover { background: #1a2035 !important; }
.forecast-chevron { display: inline-block; transition: transform 0.2s; margin-right: 4px; font-size: 10px; }
.forecast-chevron.expanded { transform: rotate(90deg); }
.forecast-row-5min { background: #0f1419; display: none; }
.forecast-row-5min.show { display: table-row; }
.forecast-row-5min td { padding: 4px 8px 4px 28px; font-size: 12px; color: #94a3b8; border-bottom: 1px solid #0d1117; }
.forecast-bar { height: 6px; border-radius: 3px; min-width: 2px; transition: width 0.5s; }

/* BATTERY GAUGE */
.battery-section { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
.battery-soc-col { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.battery-gauge { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.battery-gauge svg { transform: rotate(-90deg); }
.battery-gauge .bg { fill: none; stroke: #1e293b; stroke-width: 10; }
.battery-gauge .fill { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s ease, stroke 0.5s; }
.battery-gauge .center-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.battery-gauge .soc-value { font-size: 32px; font-weight: 800; }
.battery-gauge .soc-label { font-size: 11px; color: #64748b; }

.battery-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1; }
.bat-stat { background: #1a2035; border-radius: 8px; padding: 10px 12px; position: relative; transition: box-shadow 0.6s ease, border-color 0.6s ease; border: 1px solid transparent; overflow: hidden; }
.bat-stat .label { font-size: 10px; text-transform: uppercase; color: #64748b; letter-spacing: 0.5px; display: flex; align-items: center; gap: 5px; }
.bat-stat .label .tile-icon { font-size: 13px; opacity: 0.7; }
.bat-stat .val { font-size: 18px; font-weight: 700; margin-top: 2px; }
.bat-stat .val.charging { color: #22c55e; }
.bat-stat .val.discharging { color: #f59e0b; }

/* Active tile glow effects */
.bat-stat.glow-solar { border-color: #f59e0b44; box-shadow: 0 0 12px rgba(245,158,11,0.15), inset 0 0 12px rgba(245,158,11,0.05); }
.bat-stat.glow-grid-in { border-color: #ef444444; box-shadow: 0 0 12px rgba(239,68,68,0.15), inset 0 0 12px rgba(239,68,68,0.05); }
.bat-stat.glow-load { border-color: #38bdf844; box-shadow: 0 0 12px rgba(56,189,248,0.15), inset 0 0 12px rgba(56,189,248,0.05); }
.bat-stat.glow-export { border-color: #22c55e44; box-shadow: 0 0 12px rgba(34,197,94,0.15), inset 0 0 12px rgba(34,197,94,0.05); }
.bat-stat.glow-charge { border-color: #22c55e44; box-shadow: 0 0 12px rgba(34,197,94,0.2), inset 0 0 12px rgba(34,197,94,0.06); }
.bat-stat.glow-discharge { border-color: #f59e0b44; box-shadow: 0 0 12px rgba(245,158,11,0.2), inset 0 0 12px rgba(245,158,11,0.06); }
.bat-stat.glow-temp-hot { border-color: #ef444444; box-shadow: 0 0 12px rgba(239,68,68,0.15); }

/* Pulse animation for high-activity tiles */
@keyframes tilePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }
.bat-stat.pulse .val { animation: tilePulse 2s ease-in-out infinite; }

/* SoC ring glow */
@keyframes socGlow { 0%,100% { filter: drop-shadow(0 0 4px rgba(34,197,94,0.3)); } 50% { filter: drop-shadow(0 0 10px rgba(34,197,94,0.6)); } }
.battery-gauge svg.charging-glow { animation: socGlow 2s ease-in-out infinite; }
@keyframes socGlowOrange { 0%,100% { filter: drop-shadow(0 0 4px rgba(245,158,11,0.3)); } 50% { filter: drop-shadow(0 0 10px rgba(245,158,11,0.6)); } }
.battery-gauge svg.discharging-glow { animation: socGlowOrange 2s ease-in-out infinite; }
@keyframes socGlowRed { 0%,100% { filter: drop-shadow(0 0 4px rgba(239,68,68,0.3)); } 50% { filter: drop-shadow(0 0 10px rgba(239,68,68,0.6)); } }
.battery-gauge svg.low-glow { animation: socGlowRed 1.5s ease-in-out infinite; }

/* Battery state badge under SoC */
.bat-state-badge { text-align: center; margin-top: 6px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; display: inline-block; }
.bat-state-badge.state-charging { background: #22c55e22; color: #22c55e; border: 1px solid #22c55e44; }
.bat-state-badge.state-discharging { background: #f59e0b22; color: #f59e0b; border: 1px solid #f59e0b44; }
.bat-state-badge.state-idle { background: #64748b22; color: #64748b; border: 1px solid #64748b44; }
.bat-state-badge.state-full { background: #22c55e22; color: #22c55e; border: 1px solid #22c55e44; }

/* Flow arrows */
.flow-arrow { font-size: 11px; display: inline-block; }
@keyframes arrowBounceUp { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes arrowBounceDown { 0%,100% { transform: translateY(0); } 50% { transform: translateY(2px); } }
@keyframes arrowBounceRight { 0%,100% { transform: translateX(0); } 50% { transform: translateX(2px); } }
.flow-arrow.up { color: #22c55e; animation: arrowBounceUp 1s ease-in-out infinite; }
.flow-arrow.down { color: #f59e0b; animation: arrowBounceDown 1s ease-in-out infinite; }
.flow-arrow.right { color: #38bdf8; animation: arrowBounceRight 1s ease-in-out infinite; }
.flow-arrow.out { color: #22c55e; animation: arrowBounceRight 1s ease-in-out infinite; }

/* MODE CONTROLS */
.mode-controls { margin-top: 16px; }
.mode-label { font-size: 12px; color: #64748b; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.current-mode { font-size: 14px; color: #f59e0b; font-weight: 600; margin-bottom: 12px; padding: 8px 12px; background: #1a2035; border-radius: 8px; display: inline-block; }
.mode-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.mode-btn { padding: 12px 10px; border: 2px solid; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.3s; text-transform: uppercase; letter-spacing: 0.5px; position: relative; overflow: hidden; }
.mode-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.mode-btn:active { transform: translateY(0); }
.mode-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.mode-btn.active { box-shadow: 0 0 20px rgba(0,0,0,0.3); }

.mode-btn.force-charge { background: #0c1a0c; border-color: #22c55e; color: #22c55e; }
.mode-btn.force-charge:hover:not(:disabled) { background: #22c55e; color: #0a0e17; }
.mode-btn.force-charge.active { background: #22c55e; color: #0a0e17; }

.mode-btn.self-use { background: #1a1505; border-color: #f59e0b; color: #f59e0b; }
.mode-btn.self-use:hover:not(:disabled) { background: #f59e0b; color: #0a0e17; }
.mode-btn.self-use.active { background: #f59e0b; color: #0a0e17; }

.mode-btn.feedin { background: #0c0c1a; border-color: #6366f1; color: #6366f1; }
.mode-btn.feedin:hover:not(:disabled) { background: #6366f1; color: #fff; }
.mode-btn.feedin.active { background: #6366f1; color: #fff; }

.mode-btn.backup { background: #1a0c0c; border-color: #ef4444; color: #ef4444; }
.mode-btn.backup:hover:not(:disabled) { background: #ef4444; color: #fff; }
.mode-btn.backup.active { background: #ef4444; color: #fff; }

.mode-btn.force-discharge { background: #1a0a1a; border-color: #e879f9; color: #e879f9; }
.mode-btn.force-discharge:hover:not(:disabled) { background: #e879f9; color: #0a0e17; }
.mode-btn.force-discharge.active { background: #e879f9; color: #0a0e17; }

/* FORCE DISCHARGE PANEL */
.fd-panel { margin-top: 16px; background: #1a2035; border-radius: 10px; padding: 16px; border: 1px solid #2a3050; border-left: 3px solid #e879f9; }
.fd-panel h3 { font-size: 13px; color: #e879f9; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.fd-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.fd-row .fd-label { font-size: 12px; color: #94a3b8; min-width: 100px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.fd-input { width: 90px; background: #0d1321; border: 1px solid #2a3050; border-radius: 6px; padding: 6px 10px; color: #e0e6ed; font-size: 14px; font-weight: 600; text-align: center; }
.fd-status { font-size: 12px; padding: 4px 10px; border-radius: 6px; display: none; margin-top: 4px; }
.fd-status.show { display: inline-block; }
.fd-status.success { background: #22c55e22; color: #22c55e; }
.fd-status.error { background: #ef444422; color: #ef4444; }

/* EXPORT LIMIT PANEL */
.limit-panel { margin-top: 16px; background: #1a2035; border-radius: 10px; padding: 16px; border: 1px solid #2a3050; }
.limit-panel h3 { font-size: 13px; color: #94a3b8; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.limit-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.limit-row .limit-label { font-size: 12px; color: #94a3b8; min-width: 100px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.limit-row .limit-current { font-size: 18px; font-weight: 800; color: #f59e0b; min-width: 80px; }
.limit-row .limit-current.zero { color: #22c55e; }
.limit-input-group { display: flex; align-items: center; gap: 6px; }
.limit-input { width: 90px; background: #0d1321; border: 1px solid #2a3050; border-radius: 6px; padding: 6px 10px; color: #e0e6ed; font-size: 14px; font-weight: 600; text-align: center; }
.limit-input:focus { border-color: #f59e0b; outline: none; box-shadow: 0 0 6px rgba(245,158,11,0.3); }
.limit-unit { font-size: 12px; color: #64748b; }
.limit-btn { padding: 6px 14px; border: none; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.2s; text-transform: uppercase; letter-spacing: 0.5px; }
.limit-btn.save { background: #f59e0b; color: #000; }
.limit-btn.save:hover { background: #fbbf24; box-shadow: 0 0 8px rgba(245,158,11,0.4); }
.limit-btn.save:disabled { background: #3a3a3a; color: #666; cursor: not-allowed; }
.limit-btn.zero { background: #22c55e22; color: #22c55e; border: 1px solid #22c55e44; }
.limit-btn.zero:hover { background: #22c55e33; }
.limit-btn.max { background: #ef444422; color: #ef4444; border: 1px solid #ef444444; }
.limit-btn.max:hover { background: #ef444433; }
.limit-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.limit-preset { padding: 4px 10px; background: #0d1321; border: 1px solid #2a3050; border-radius: 4px; font-size: 11px; color: #94a3b8; cursor: pointer; transition: all 0.2s; }
.limit-preset:hover { border-color: #f59e0b; color: #f59e0b; }
.limit-status { font-size: 11px; margin-top: 6px; padding: 4px 8px; border-radius: 4px; display: none; }
.limit-status.show { display: inline-block; }
.limit-status.success { background: #22c55e22; color: #22c55e; }
.limit-status.error { background: #ef444422; color: #ef4444; }

/* SCHEDULER TABLE */
.scheduler-panel { margin-top: 16px; background: #1a2035; border-radius: 10px; padding: 16px; border: 1px solid #2a3050; }
.scheduler-panel h3 { font-size: 13px; color: #94a3b8; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.sched-table { width: 100%; border-collapse: collapse; }
.sched-table th { font-size: 10px; text-transform: uppercase; color: #64748b; padding: 6px 8px; text-align: left; border-bottom: 1px solid #2a3050; letter-spacing: 0.5px; }
.sched-table td { padding: 8px; font-size: 13px; border-bottom: 1px solid #111827; }
.sched-table tr:hover { background: rgba(255,255,255,0.03); }
.sched-table tr.active-row { background: rgba(245,158,11,0.1); }
.sched-table tr.active-row td:first-child { position: relative; }
.sched-table tr.active-row td:first-child::before { content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; background: #f59e0b; border-radius: 2px; }
.sched-table tr.disabled-row { opacity: 0.35; }
.sched-mode { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.sched-mode.ForceCharge { background: rgba(34,197,94,0.15); color: #22c55e; }
.sched-mode.SelfUse { background: rgba(245,158,11,0.15); color: #f59e0b; }
.sched-mode.Feedin { background: rgba(99,102,241,0.15); color: #6366f1; }
.sched-mode.Backup { background: rgba(239,68,68,0.15); color: #ef4444; }
.sched-mode.ForceDischarge { background: rgba(168,85,247,0.15); color: #a855f7; }
.sched-enabled { color: #22c55e; }
.sched-disabled { color: #ef4444; }

/* Schedule action buttons */
.sched-actions { display: flex; gap: 4px; }
.sched-action-btn { background: transparent; border: 1px solid #2a3050; color: #94a3b8; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; transition: all 0.2s; }
.sched-action-btn:hover { background: rgba(245,158,11,0.1); color: #f59e0b; border-color: #f59e0b; }
.sched-action-btn.toggle { background: transparent; border: none; padding: 4px 6px; }
.sched-toggle-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: #22c55e; }

/* Timeline bar */
.timeline-container { margin-top: 12px; background: #0d1117; border-radius: 8px; padding: 12px; }
.timeline-label { font-size: 10px; color: #64748b; text-transform: uppercase; margin-bottom: 6px; letter-spacing: 0.5px; }
.timeline-bar { position: relative; height: 28px; background: #1e293b; border-radius: 6px; overflow: hidden; }
.timeline-block { position: absolute; top: 0; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; letter-spacing: 0.3px; color: rgba(255,255,255,0.8); transition: all 0.3s; }
.timeline-block.ForceCharge { background: rgba(34,197,94,0.5); }
.timeline-block.SelfUse { background: rgba(245,158,11,0.4); }
.timeline-block.Feedin { background: rgba(99,102,241,0.5); }
.timeline-block.Backup { background: rgba(239,68,68,0.4); }
.timeline-block.ForceDischarge { background: rgba(168,85,247,0.4); }
.timeline-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; z-index: 10; box-shadow: 0 0 4px rgba(255,255,255,0.6); }
.timeline-hours { display: flex; justify-content: space-between; margin-top: 4px; font-size: 9px; color: #475569; }

/* Scheduler controls */
.sched-controls { margin-top: 12px; display: flex; gap: 8px; }
.sched-add-btn { padding: 8px 16px; background: #22c55e; color: #0a0e17; border: none; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.sched-add-btn:hover { background: #16a34a; transform: translateY(-1px); }
.sched-add-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.restore-sched-btn { padding: 8px 16px; background: #6366f1; color: #fff; border: none; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.restore-sched-btn:hover { background: #4f46e5; transform: translateY(-1px); }
.restore-sched-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.default-sched-btn { padding: 8px 16px; background: #f59e0b; color: #0a0e17; border: none; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.default-sched-btn:hover { background: #d97706; transform: translateY(-1px); }
.default-sched-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Inline edit form */
.inline-edit-form { margin-top: 12px; background: #0d1117; border-radius: 8px; padding: 12px; border: 1px solid #2a3050; display: none; }
.inline-edit-form.show { display: block; }
.edit-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 8px; }
.edit-field { display: flex; flex-direction: column; }
.edit-field label { font-size: 10px; color: #64748b; text-transform: uppercase; margin-bottom: 4px; }
.edit-field input,
.edit-field select { background: #1a2035; border: 1px solid #2a3050; color: #e0e6ed; padding: 6px 8px; border-radius: 4px; font-size: 12px; }
.edit-field input:focus,
.edit-field select:focus { outline: none; border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,0.2); }
.edit-buttons { display: flex; gap: 8px; margin-top: 8px; }
.edit-save-btn { padding: 6px 12px; background: #22c55e; color: #0a0e17; border: none; border-radius: 4px; font-size: 12px; font-weight: 700; cursor: pointer; }
.edit-save-btn:hover { background: #16a34a; }
.edit-cancel-btn { padding: 6px 12px; background: #2a3050; color: #94a3b8; border: none; border-radius: 4px; font-size: 12px; font-weight: 700; cursor: pointer; }
.edit-cancel-btn:hover { background: #3a4060; }

/* LOG — v1.6.0: removed grid-column:1/-1 so log-panel sits in single grid column (independently draggable) */
.log-entries { max-height: 350px; overflow-y: auto; font-family: 'SF Mono', Consolas, monospace; font-size: 12px; background: #0d1117; border-radius: 8px; padding: 10px; }
.log-entry { padding: 3px 0; border-bottom: 1px solid #111827; display: flex; gap: 8px; }
.log-time { color: #64748b; white-space: nowrap; }
.log-msg { color: #94a3b8; }
.log-msg.error { color: #ef4444; }
.log-msg.success { color: #22c55e; }
.log-msg.warn { color: #f59e0b; }

/* API EXPLORER */
.api-explorer { grid-column: 1 / -1; }
.api-test-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.api-test-btn { background: #1a2035; border: 1px solid #2a3050; color: #94a3b8; border-radius: 8px; padding: 12px; cursor: pointer; font-size: 12px; text-align: left; transition: all 0.2s; }
.api-test-btn:hover { border-color: #f59e0b; color: #e0e6ed; background: #1e2540; }
.api-test-btn.running { border-color: #f59e0b; opacity: 0.6; cursor: wait; }
.api-test-btn.success { border-color: #22c55e; }
.api-test-btn.fail { border-color: #ef4444; }
.api-test-btn .btn-title { font-weight: 700; font-size: 13px; color: #e0e6ed; display: block; margin-bottom: 4px; }
.api-test-btn .btn-path { font-family: monospace; font-size: 10px; color: #64748b; display: block; word-break: break-all; }
.api-result-box { background: #0d1117; border-radius: 8px; padding: 14px; font-family: 'SF Mono', Consolas, monospace; font-size: 11px; color: #94a3b8; max-height: 400px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; border: 1px solid #1e293b; }
.api-result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.api-result-label { font-size: 12px; color: #64748b; }
.api-result-status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.api-result-status.ok { background: #22c55e22; color: #22c55e; }
.api-result-status.err { background: #ef444422; color: #ef4444; }
.api-custom-row { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.api-custom-row select, .api-custom-row input { background: #1a2035; border: 1px solid #2a3050; color: #e0e6ed; padding: 8px 10px; border-radius: 6px; font-size: 12px; font-family: monospace; }
.api-custom-row select:focus, .api-custom-row input:focus { outline: none; border-color: #f59e0b; }
.api-custom-row .api-send-btn { background: #f59e0b; color: #0a0e17; border: none; border-radius: 6px; padding: 8px 16px; font-weight: 700; font-size: 12px; cursor: pointer; }
.api-custom-row .api-send-btn:hover { background: #d97706; }

/* FOOTER */
.footer { text-align: center; padding: 12px; color: #475569; font-size: 11px; border-top: 1px solid #1e293b; margin-top: 20px; }

/* Spinner */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.2); border-top-color: #f59e0b; border-radius: 50%; animation: spin 0.8s linear infinite; margin-left: 6px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* AUTO MODE PANEL */
.auto-panel { margin-top: 16px; background: #0d1117; border-radius: 10px; padding: 16px; border: 1px solid #2a3050; }
.auto-panel h3 { font-size: 13px; color: #94a3b8; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.auto-toggle-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.auto-action-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.auto-toggle { position: relative; width: 52px; height: 28px; cursor: pointer; }
.auto-toggle input { opacity: 0; width: 0; height: 0; }
.auto-toggle .slider { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: #2a3050; border-radius: 28px; transition: all 0.3s; }
.auto-toggle .slider::before { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; bottom: 3px; background: #64748b; border-radius: 50%; transition: all 0.3s; }
.auto-toggle input:checked + .slider { background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.4); }
.auto-toggle input:checked + .slider::before { transform: translateX(24px); background: #fff; }
.auto-status-label { font-size: 14px; font-weight: 700; }
.auto-status-label.on { color: #22c55e; }
.auto-status-label.off { color: #64748b; }
.auto-override-btn { padding: 5px 12px; background: #7c3aed; color: #fff; border: none; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer; margin-left: auto; transition: all 0.2s; }
.auto-override-btn:hover { background: #6d28d9; }
.auto-override-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auto-decision { background: #141926; border-radius: 8px; padding: 12px; margin-top: 8px; }
.auto-decision .decision-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 12px; }
.auto-decision .decision-label { color: #64748b; }
.auto-decision .decision-value { color: #e0e6ed; font-weight: 600; }
.auto-decision .decision-value.fc { color: #22c55e; }
.auto-decision .decision-value.su { color: #f59e0b; }
.auto-decision .decision-rule { font-size: 11px; color: #94a3b8; background: #1a2035; padding: 6px 10px; border-radius: 6px; margin-top: 8px; border-left: 3px solid #f59e0b; }
.auto-decision .decision-rule.active { border-left-color: #22c55e; }
.auto-decision.no-match-warning { border: 1px solid rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.06); }
.auto-decision .no-match-text { color: #f59e0b !important; }
.solar-cache-age { font-size: 10px; color: #64748b; }
.solar-cache-age.stale { color: #f59e0b; }
.solar-cache-age.fresh { color: #22c55e; }

/* TEST MODE */
.test-mode-panel { margin-top: 12px; background: #1a0a2e; border-radius: 10px; padding: 16px; border: 2px solid #7c3aed; display: none; }
.test-mode-panel.show { display: block; }
.test-mode-panel h4 { font-size: 13px; color: #c084fc; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.test-mode-badge { display: inline-block; background: #7c3aed; color: #fff; font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 4px; letter-spacing: 1px; animation: testPulse 1.5s ease-in-out infinite; }
@keyframes testPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.test-inputs { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.test-field { display: flex; flex-direction: column; }
.test-field label { font-size: 10px; color: #a78bfa; text-transform: uppercase; margin-bottom: 4px; letter-spacing: 0.5px; }
.test-field input { background: #2d1b4e; border: 1px solid #7c3aed; color: #e0e6ed; padding: 8px 10px; border-radius: 6px; font-size: 14px; font-weight: 700; text-align: center; width: 100%; }
.test-field input:focus { outline: none; border-color: #a78bfa; box-shadow: 0 0 0 2px rgba(124,58,237,0.3); }
.test-field .unit-hint { font-size: 9px; color: #7c3aed; margin-top: 2px; text-align: center; }
.test-run-btn { padding: 10px 24px; background: #7c3aed; color: #fff; border: none; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s; letter-spacing: 0.5px; }
.test-run-btn:hover { background: #6d28d9; transform: translateY(-1px); }
.test-result { margin-top: 10px; background: #0d0a1a; border-radius: 8px; padding: 12px; border: 1px solid #3b1f6e; display: none; }
.test-result.show { display: block; }
.test-result-header { font-size: 11px; color: #a78bfa; text-transform: uppercase; margin-bottom: 8px; letter-spacing: 1px; }
.test-result-mode { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.test-result-mode.fc { color: #22c55e; }
.test-result-mode.su { color: #f59e0b; }
.test-result-rule { font-size: 12px; color: #c084fc; background: #1a0a2e; padding: 8px 12px; border-radius: 6px; border-left: 3px solid #7c3aed; }
.dryrun-tag { display: inline-block; background: #7c3aed; color: #fff; font-size: 9px; font-weight: 800; padding: 1px 6px; border-radius: 3px; margin-left: 6px; letter-spacing: 0.5px; vertical-align: middle; }
.auto-panel.testmode { border-color: #7c3aed; box-shadow: 0 0 15px rgba(124,58,237,0.2); }

/* OLD Toast system — DEPRECATED v3.5.8: replaced by .ae-toast-container (z-index 100000).
   Kept commented out as reference only. SPA uses AE.Toast → .ae-toast-container exclusively.
#toastContainer { ... }
.toast { ... }
*/

/* ============================================================ */
/* RESPONSIVE DESIGN                                            */
/* ============================================================ */

/* TABLET — up to 1024px */
@media (max-width: 1024px) {
  .main { grid-template-columns: 1fr; max-width: 100%; }
  .nem-panel, .log-panel, .api-explorer { grid-column: 1; }
  .nem-cards { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .nem-comparison { grid-template-columns: 1fr 1fr 1fr; }
  .api-test-grid { grid-template-columns: 1fr 1fr; }
}

/* SMALL TABLET — up to 768px */
@media (max-width: 768px) {
  /* Header: stack vertically */
  .header { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; }
  .header h1 { font-size: 18px; }
  .header .status-bar { gap: 10px; width: 100%; }

  .main { padding: 12px; gap: 12px; }
  .panel { padding: 14px; }

  /* NEM 5 cards → 3+2 or 2+2+1 */
  .nem-cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .nem-card .value { font-size: 20px; }

  /* NEM comparison → stack */
  .nem-comparison { grid-template-columns: 1fr; gap: 10px; }

  /* Price cards — shrink values */
  .price-card .value { font-size: 28px; }

  /* Battery: stack gauge above stats */
  .battery-section { flex-direction: column; align-items: center; }
  .battery-gauge { width: 120px; height: 120px; }
  .battery-stats { grid-template-columns: 1fr 1fr; width: 100%; }

  /* Mode buttons: 3 cols still OK at 768 but shrink */
  .mode-buttons { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .mode-btn { padding: 10px 6px; font-size: 11px; }

  /* Test mode inputs: 2 cols */
  .test-inputs { grid-template-columns: 1fr 1fr; }

  /* API grid: single column */
  .api-test-grid { grid-template-columns: 1fr; }

  /* Scheduler controls wrap */
  .sched-controls { flex-wrap: wrap; }

  /* CSV row wrap */
  .csv-row { gap: 6px; }

  /* OLD toast responsive — removed v3.5.8 (SPA uses .ae-toast-container) */

  /* Force Discharge / Limit panels */
  .fd-row { flex-wrap: wrap; gap: 8px; }
  .limit-row { flex-wrap: wrap; gap: 8px; }
}

/* MOBILE — up to 480px */
@media (max-width: 480px) {
  .header { padding: 10px 12px; }
  .header h1 { font-size: 16px; }
  .header .status-bar { gap: 6px; font-size: 11px; flex-wrap: wrap; max-width: 100%; }
  .status-label { font-size: 11px; }
  .refresh-btn { padding: 5px 10px; font-size: 11px; }

  .main { padding: 8px; gap: 10px; }
  .panel { padding: 10px; border-radius: 10px; }
  .panel-title { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex-wrap: nowrap; }
  .panel-title .collapse-chevron { flex-shrink: 0; }
  .panel-title .icon { flex-shrink: 0; }
  .panel-title a { display: none; } /* hide NEMWEB link on mobile — saves space */

  /* NEM 5 cards → 2 cols + 1 row of 3 or stacked */
  .nem-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .nem-card { padding: 10px; }
  .nem-card .label { font-size: 9px; }
  .nem-card .value { font-size: 18px; }
  .nem-card .unit { font-size: 10px; }

  /* Price cards: stack */
  .price-cards { grid-template-columns: 1fr; gap: 8px; }
  .price-card .value { font-size: 30px; }

  /* Battery */
  .battery-gauge { width: 110px; height: 110px; }
  .battery-gauge .soc-value { font-size: 26px; }
  .battery-stats { grid-template-columns: 1fr 1fr; gap: 6px; }
  .bat-stat .val { font-size: 15px; }
  .bat-stat .label { font-size: 9px; }

  /* Mode buttons: 2 cols on mobile */
  .mode-buttons { grid-template-columns: 1fr 1fr; gap: 6px; }
  .mode-btn { padding: 10px 6px; font-size: 11px; letter-spacing: 0; }

  /* Test inputs: single column */
  .test-inputs { grid-template-columns: 1fr 1fr; gap: 8px; }
  .test-field input { font-size: 13px; padding: 6px 8px; }

  /* Forecast table: scrollable on mobile */
  .forecast-grid { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .forecast-grid thead, .forecast-grid tbody { display: table; width: 100%; }
  .forecast-grid th { font-size: 9px; padding: 4px 3px; white-space: nowrap; }
  .forecast-grid td { font-size: 11px; padding: 5px 3px; white-space: nowrap; }

  /* Schedule table: scrollable on mobile */
  .scheduler-panel { overflow-x: auto; }
  .sched-table th { font-size: 9px; padding: 4px 3px; white-space: nowrap; }
  .sched-table td { padding: 5px 3px; font-size: 11px; white-space: nowrap; }

  /* Log panel: smaller font */
  .log-entries { font-size: 10px; padding: 8px; max-height: 250px; }

  /* NEM comparison cards */
  .nem-compare-card { padding: 10px; }
  .nem-compare-card h4 { font-size: 10px; }

  /* API explorer */
  .api-custom-row { flex-direction: column; }
  .api-custom-row select, .api-custom-row input { width: 100%; }
  .api-result-box { font-size: 10px; max-height: 250px; }

  /* OLD toast responsive — removed v3.5.8 (SPA uses .ae-toast-container) */

  /* Footer */
  .footer { font-size: 10px; padding: 8px; }

  /* Auto mode panel */
  .auto-toggle-row { flex-wrap: wrap; }
  .auto-override-btn { margin-left: 0; margin-top: 8px; }

  /* Inline edit form */
  .edit-row { grid-template-columns: 1fr 1fr; }

  /* Limit panels */
  .limit-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .limit-input-group { width: 100%; }
  .limit-presets { justify-content: flex-start; }

  /* FD panel */
  .fd-row { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* Mobile overrides for inline-styled NEM comparison elements */
@media (max-width: 480px) {
  #nemRealCost, #nemAmberCharges { font-size: 18px !important; }
  #nemMarkupAmount { font-size: 22px !important; }
  #nemDailyCost { font-size: 22px !important; }
  #nemMonthlyCost, #nemYearlyCost { font-size: 18px !important; }
}

/* HIDE API Explorer & Activity Log on phones */
@media (max-width: 768px) {
  .api-explorer, .log-panel { display: none !important; }
}

/* EXTRA SMALL — up to 360px */
@media (max-width: 360px) {
  .header h1 { font-size: 14px; }
  .nem-cards { grid-template-columns: 1fr 1fr; }
  .nem-card .value { font-size: 16px; }
  .price-card .value { font-size: 24px; }
  .battery-gauge { width: 100px; height: 100px; }
  .battery-gauge .soc-value { font-size: 22px; }
  .battery-stats { grid-template-columns: 1fr; }
  .mode-buttons { grid-template-columns: 1fr; }
}

/* COLLAPSIBLE PANELS (mobile-friendly fold/unfold) */
.panel-title.collapsible { cursor: pointer; user-select: none; -webkit-user-select: none; }
.panel-title.collapsible:hover { opacity: 0.85; }
.panel-title .collapse-chevron { display: none; margin-left: auto; order: 99; font-size: 14px; transition: transform 0.3s; color: #64748b; flex-shrink: 0; }
.panel-title.collapsible .collapse-chevron { display: inline-block; }
.panel-title.collapsed .collapse-chevron { transform: rotate(-90deg); }
.panel-body { transition: max-height 0.35s ease, opacity 0.25s ease; overflow: hidden; }
.panel-body.collapsed { max-height: 0 !important; opacity: 0; padding-top: 0; padding-bottom: 0; margin: 0; }

/* Panel summary — visible ONLY when collapsed */
.panel-summary { display: none; margin-top: 8px; padding: 8px 10px; background: #0d1117; border-radius: 8px; border: 1px solid #1e293b; font-size: 12px; color: #94a3b8; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel-summary .sum-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.panel-summary .sum-val { font-weight: 700; font-size: 13px; }
.panel-summary .sum-label { font-size: 10px; color: #64748b; }
.panel-summary .sum-sep { color: #2a3050; margin: 0 2px; font-size: 8px; }
.panel-title.collapsed ~ .panel-summary { display: flex; }
.panel-title:not(.collapsed) ~ .panel-summary { display: none; }

/* On mobile: show collapse chevrons, auto-collapse secondary panels */
@media (max-width: 768px) {
  .panel-title .collapse-chevron { display: inline-block; }
}

/* Drag & drop widget reorder */
.panel.ae-drag-over { border: 2px dashed #22c55e !important; background: rgba(34,197,94,0.05) !important; }
.panel-title[draggable="true"] { cursor: grab; }
.panel-title[draggable="true"]:active { cursor: grabbing; }

/* Confirmation modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.show { display: flex; }
.modal { background: #1a1f2e; border-radius: 12px; padding: 24px; max-width: 400px; width: 90%; border: 1px solid #f59e0b; }
.modal h3 { margin-bottom: 12px; font-size: 18px; }
.modal p { color: #94a3b8; margin-bottom: 20px; font-size: 14px; }
.modal .btn-row { display: flex; gap: 10px; justify-content: flex-end; }
.modal .btn-cancel { padding: 8px 20px; background: #2a3050; color: #94a3b8; border: none; border-radius: 8px; cursor: pointer; font-size: 13px; }
.modal .btn-confirm { padding: 8px 20px; background: #f59e0b; color: #0a0e17; border: none; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13px; }


/* ================================================================
   RULE ENGINE v3.0.0 — CSS (verbatim from original)
   ================================================================ */

/* ===== TOP BAR ===== */
.topbar { background: #141926; border-bottom: 1px solid #1e293b; padding: 12px 24px; display: flex; align-items: center; gap: 16px; }
.topbar h1 { font-size: 18px; font-weight: 800; }
.topbar h1 .amber { color: #f59e0b; }
.topbar h1 .fox { color: #22c55e; }
.topbar .version { font-size: 11px; color: #64748b; }
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.undo-redo { display: flex; gap: 4px; margin-right: 8px; border-right: 1px solid #334155; padding-right: 12px; }
.undo-redo button { background: transparent; border: 1px solid #334155; color: #94a3b8; border-radius: 6px; padding: 5px 10px; font-size: 14px; cursor: pointer; transition: all 0.15s; line-height: 1; }
.undo-redo button:hover:not(:disabled) { border-color: #64748b; color: #e0e6ed; background: #1e293b; }
.undo-redo button:disabled { opacity: 0.25; cursor: not-allowed; }
.undo-redo .undo-count { font-size: 9px; color: #475569; margin: 0 2px; align-self: center; }

/* ===== BUTTONS ===== */
.btn { padding: 7px 14px; border: none; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.15s; }
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-success { background: #22c55e; color: #fff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-amber { background: #f59e0b; color: #000; }
.btn-ghost { background: transparent; border: 1px solid #334155; color: #94a3b8; }
.btn-ghost:hover { border-color: #64748b; color: #e0e6ed; }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ===== PROFILE BAR (compact — expand on hover) ===== */
.profile-bar { background: #111827; border-bottom: 1px solid #1e293b; padding: 6px 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; transition: padding 0.2s; }
.profile-bar label { font-size: 12px; color: #94a3b8; font-weight: 600; }
.profile-bar select, .profile-bar input[type="text"] { background: #1e293b; color: #e0e6ed; border: 1px solid #334155; border-radius: 6px; padding: 5px 10px; font-size: 12px; }
.profile-bar input[type="text"] { width: 200px; }
.profile-bar .prof-details { display: none; }

/* ===== RULES VIEW — Override dashboard 2-col grid ===== */
.rules-view .main { display: block; padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
.rule-list { display: flex; flex-direction: column; gap: 16px; }

/* ===== RULE CARD ===== */
.rule-card { background: #141926; border: 1px solid #1e293b; border-radius: 10px; overflow: hidden; transition: all 0.2s; }
.rule-card:hover { border-color: #334155; }
.rule-card.disabled { opacity: 0.5; }
.rule-card.drag-over-rule { border-color: #f59e0b; border-style: dashed; }
.rule-card.collapsed .rule-body,
.rule-card.collapsed .rule-footer { display: none; }
.rule-card.collapsed .rule-header { border-radius: 0 0 10px 10px; }

/* Rule Header */
.rule-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #1e293b; cursor: grab; user-select: none; }
.rule-header:active { cursor: grabbing; }
.drag-handle { color: #475569; font-size: 16px; }
.collapse-chevron { color: #64748b; font-size: 14px; cursor: pointer; transition: transform 0.2s; padding: 2px 4px; }
.collapse-chevron:hover { color: #94a3b8; }
.rule-card.collapsed .collapse-chevron { transform: rotate(-90deg); }
.rule-header .mode-badge { font-size: 9px; font-weight: 700; padding: 2px 8px; border-radius: 10px; opacity: 0.7; }
.rule-card.collapsed .cond-summary { font-size: 10px; color: #64748b; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 400px; }

/* Rule Hover Tooltip */
.rule-tooltip { position: fixed; z-index: 200; background: #0f1320; border: 1px solid #334155; border-radius: 8px; padding: 12px 16px; font-family: 'Fira Code','Consolas',monospace; font-size: 11px; line-height: 1.7; color: #e0e6ed; max-width: 600px; pointer-events: none; box-shadow: 0 12px 32px rgba(0,0,0,0.6); white-space: pre-wrap; animation: ttFade 0.15s ease; }
@keyframes ttFade { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }
.rule-priority { background: #3b82f6; color: #fff; font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 10px; }
.rule-name-input { background: transparent; border: none; color: #e0e6ed; font-size: 13px; font-weight: 700; outline: none; width: auto; min-width: 80px; max-width: 300px; }
.rule-name-input:focus { border-bottom: 1px solid #3b82f6; }
.rule-notes { width: 100%; background: #0f172a; border: 1px solid #1e293b; color: #94a3b8; font-size: 12px; border-radius: 6px; padding: 8px 10px; resize: vertical; min-height: 32px; max-height: 120px; outline: none; font-family: inherit; margin-bottom: 10px; }
.rule-notes:focus { border-color: #3b82f6; color: #e0e6ed; }
.rule-notes::placeholder { color: #475569; font-style: italic; }
.header-spacer { flex: 1; min-height: 24px; cursor: pointer; }
.toggle { position: relative; width: 36px; height: 20px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: #475569; border-radius: 20px; cursor: pointer; transition: 0.2s; }
.toggle .slider:before { content: ''; position: absolute; height: 16px; width: 16px; left: 2px; bottom: 2px; background: #fff; border-radius: 50%; transition: 0.2s; }
.toggle input:checked + .slider { background: #22c55e; }
.toggle input:checked + .slider:before { transform: translateX(16px); }

.rule-body { padding: 14px; }

/* ===== SECTION LABELS ===== */
.sec-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.sec-label.if-lbl { color: #a78bfa; }
.sec-label.then-lbl { color: #f59e0b; }

/* ===== CONDITIONS AREA ===== */
.cond-area { background: #0f1320; border: 1px solid #1e293b; border-radius: 8px; padding: 10px; min-height: 50px; margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cond-area.drag-over { background: #1e293b33; border-color: #a78bfa; }

/* Condition Chip */
.cond-chip { display: inline-flex; align-items: center; gap: 4px; background: #1e293b; border: 1px solid #334155; border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: grab; transition: all 0.15s; user-select: none; }
.cond-chip:hover { border-color: #a78bfa; }
.cond-chip.dragging-chip { opacity: 0.3; }
.cond-chip select, .cond-chip input { background: #0f1320; border: 1px solid #334155; color: #e0e6ed; border-radius: 4px; padding: 3px 6px; font-size: 11px; }
.cond-chip select.var-sel { min-width: 130px; }
.cond-chip select.op-sel { min-width: 50px; color: #a78bfa; font-weight: 700; }
.cond-chip input { width: 65px; text-align: center; }
.cond-chip .unit-lbl { font-size: 10px; color: #64748b; }

/* Touch drag support */
.cond-chip.touch-dragging,
.draggable-chip.touch-dragging { touch-action: none; }
.chip-drag-clone { position: fixed; pointer-events: none; z-index: 9000; opacity: 0.8; border: 1px solid #a78bfa; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.cond-chip .x-btn { color: #ef4444; cursor: pointer; font-size: 13px; opacity: 0.5; margin-left: 2px; }
.cond-chip .x-btn:hover { opacity: 1; }

/* Logic Chip */
.logic-chip { display: inline-flex; cursor: grab; user-select: none; }
.logic-chip.dragging-chip { opacity: 0.3; }
.logic-chip select { background: #7c3aed33; border: 1px solid #7c3aed; color: #a78bfa; border-radius: 4px; padding: 3px 8px; font-size: 11px; font-weight: 800; cursor: pointer; }

/* Bracket Chips */
.bracket-chip { display: inline-flex; align-items: center; gap: 2px; cursor: grab; user-select: none; position: relative; }
.bracket-chip.dragging-chip { opacity: 0.3; }
.bracket-sym { font-size: 22px; font-weight: 800; color: #f59e0b; }
.bracket-sym:hover { color: #fbbf24; }

/* Drop Indicator */
.drop-indicator { width: 3px; height: 30px; background: #3b82f6; border-radius: 2px; flex-shrink: 0; animation: dropPulse 0.8s infinite; margin: 0 2px; }
@keyframes dropPulse { 0%,100% { opacity: 1; box-shadow: 0 0 8px #3b82f6; } 50% { opacity: 0.5; box-shadow: 0 0 3px #3b82f6; } }
.bracket-menu { position: fixed; background: #1e293b; border: 1px solid #334155; border-radius: 6px; padding: 4px 0; z-index: 100; min-width: 180px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.bracket-menu-item { padding: 6px 12px; font-size: 11px; cursor: pointer; color: #e0e6ed; white-space: nowrap; }
.bracket-menu-item:hover { background: #334155; }
.bracket-menu-item.danger { color: #ef4444; }

/* Add Buttons Row */
.add-row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.add-btn { padding: 3px 10px; font-size: 10px; font-weight: 700; border: 1px dashed #334155; background: transparent; color: #64748b; border-radius: 4px; cursor: pointer; transition: all 0.15s; }
.add-btn:hover { border-color: #64748b; color: #94a3b8; }
.add-btn.cond-add:hover { border-color: #a78bfa; color: #a78bfa; }
.add-btn.act-add:hover { border-color: #f59e0b; color: #f59e0b; }

/* ===== MODE TAGS ===== */
.mode-tags { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.mode-tag { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 700; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; user-select: none; opacity: 0.5; }
.mode-tag:hover { opacity: 0.8; }
.mode-tag.active { opacity: 1; transform: scale(1.05); }
.mode-tag[data-mode="SelfUse"] { background: #f59e0b22; color: #f59e0b; border-color: #f59e0b44; }
.mode-tag[data-mode="SelfUse"].active { background: #f59e0b; color: #000; border-color: #f59e0b; }
.mode-tag[data-mode="Feedin"] { background: #6366f122; color: #6366f1; border-color: #6366f144; }
.mode-tag[data-mode="Feedin"].active { background: #6366f1; color: #fff; border-color: #6366f1; }
.mode-tag[data-mode="Backup"] { background: #ef444422; color: #ef4444; border-color: #ef444444; }
.mode-tag[data-mode="Backup"].active { background: #ef4444; color: #fff; border-color: #ef4444; }
.mode-tag[data-mode="ForceCharge"] { background: #22c55e22; color: #22c55e; border-color: #22c55e44; }
.mode-tag[data-mode="ForceCharge"].active { background: #22c55e; color: #000; border-color: #22c55e; }
.mode-tag[data-mode="ForceDischarge"] { background: #e879f922; color: #e879f9; border-color: #e879f944; }
.mode-tag[data-mode="ForceDischarge"].active { background: #e879f9; color: #000; border-color: #e879f9; }

/* ===== ACTION ROWS (simple list like original) ===== */
.actions-area { background: #0f1320; border: 1px solid #1e293b; border-radius: 8px; padding: 12px; }
.action-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #141926; border: 1px solid #1e293b; border-radius: 6px; margin-bottom: 6px; }
.action-row:last-child { margin-bottom: 0; }
.action-row select { background: #1e293b; border: 1px solid #334155; color: #e0e6ed; border-radius: 4px; padding: 4px 8px; font-size: 12px; }
.action-row .arrow { color: #f59e0b; font-weight: 800; font-size: 14px; }
.action-row input[type="number"], .action-row input[type="text"] { background: #1e293b; border: 1px solid #334155; color: #e0e6ed; border-radius: 4px; padding: 4px 8px; font-size: 12px; width: 80px; text-align: center; }
.action-row .unit { font-size: 11px; color: #64748b; }
.action-row .act-move { color: #64748b; cursor: pointer; font-size: 11px; opacity: 0.5; padding: 1px 3px; background: none; border: 1px solid transparent; border-radius: 3px; line-height: 1; }
.action-row .act-move:hover { opacity: 1; color: #a78bfa; border-color: #a78bfa44; }
.action-row .x-btn { color: #ef4444; cursor: pointer; font-size: 14px; opacity: 0.5; padding: 2px 4px; }
.action-row .x-btn:hover { opacity: 1; }
.action-row .cond-toggle { font-size: 10px; font-weight: 700; padding: 2px 8px; border: 1px dashed #334155; background: transparent; color: #64748b; border-radius: 4px; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.action-row .cond-toggle:hover { border-color: #a78bfa; color: #a78bfa; }
.action-row .cond-toggle.active { border-color: #a78bfa; color: #a78bfa; border-style: solid; background: #a78bfa11; }

/* Per-action condition bar */
.action-cond { padding: 6px 8px 6px 20px; margin-bottom: 6px; border-left: 3px solid #a78bfa44; }
.action-cond .cond-area { min-height: 36px; padding: 6px 8px; margin-bottom: 4px; }
.action-cond .add-row { margin-top: 4px; }

/* ===== PREVIEW ===== */
.preview-panel { margin-top: 24px; background: #141926; border: 1px solid #1e293b; border-radius: 10px; padding: 16px; }
.preview-panel h3 { font-size: 13px; color: #94a3b8; margin-bottom: 10px; }
.preview-code { background: #0a0e17; border: 1px solid #1e293b; border-radius: 6px; padding: 12px; font-family: 'Fira Code','Consolas',monospace; font-size: 12px; line-height: 1.6; white-space: pre-wrap; color: #e0e6ed; max-height: 400px; overflow-y: auto; }
.pc-if { color: #a78bfa; font-weight: 700; }
.pc-then { color: #f59e0b; font-weight: 700; }
.pc-and { color: #7c3aed; }
.pc-or { color: #ec4899; }
.pc-var { color: #22d3ee; }
.pc-op { color: #f87171; }
.pc-val { color: #4ade80; }
.pc-act { color: #fbbf24; }
.pc-mode { color: #a78bfa; font-weight: 700; }
.pc-bk { color: #f59e0b; font-weight: 800; font-size: 14px; }
.pc-sub { color: #64748b; font-style: italic; }

/* Rule Footer */
.rule-footer { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid #1e293b; flex-wrap: wrap; }
.rule-footer .undo-redo-footer { display: flex; gap: 4px; }
.rule-footer .undo-redo-footer button { background: transparent; border: 1px solid #334155; color: #94a3b8; border-radius: 6px; padding: 3px 8px; font-size: 11px; cursor: pointer; transition: all 0.15s; line-height: 1; }
.rule-footer .undo-redo-footer button:hover:not(:disabled) { border-color: #64748b; color: #e0e6ed; background: #1e293b; }
.rule-footer .undo-redo-footer button:disabled { opacity: 0.25; cursor: not-allowed; }
.rule-footer .desc { flex: 1; font-size: 10px; color: #475569; font-style: italic; }

/* Add Rule */
.add-rule-card { background: transparent; border: 2px dashed #1e293b; border-radius: 10px; padding: 20px; text-align: center; cursor: pointer; transition: all 0.2s; margin-top: 16px; }
.add-rule-card:hover { border-color: #3b82f6; background: #3b82f611; }
.add-rule-card span { color: #3b82f6; font-weight: 700; font-size: 14px; }

/* Bottom global undo/redo */
.bottom-undo-redo-row { display: flex; justify-content: center; gap: 12px; margin: 20px 0; padding: 16px; }
.bottom-undo-redo-row button { background: transparent; border: 1px solid #334155; color: #94a3b8; border-radius: 6px; padding: 7px 14px; font-size: 12px; cursor: pointer; transition: all 0.15s; line-height: 1; }
.bottom-undo-redo-row button:hover:not(:disabled) { border-color: #64748b; color: #e0e6ed; background: #1e293b; }
.bottom-undo-redo-row button:disabled { opacity: 0.25; cursor: not-allowed; }

/* OLD Rules toast — DEPRECATED v3.5.8: replaced by .ae-toast-container.
   SPA uses AE.Toast → .ae-toast-container exclusively.
   Kept commented out as reference only.
*/

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0e17; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
#importFile { display: none; }


/* ===== RULES TOOLBAR ===== */
.rules-toolbar { background: #111827; border-bottom: 1px solid #1e293b; padding: 8px 24px; display: flex; align-items: center; gap: 10px; }
.rules-toolbar .btn { padding: 4px 10px; font-size: 11px; }
.rules-toolbar .btn-preview-scroll { margin-left: auto; }

/* ===== RESPONSIVE ===== */

/* Tablet (< 900px) */
@media (max-width: 900px) {
/* Rules Toolbar */
  .rules-toolbar { padding: 6px 12px; gap: 8px; }
  .rules-toolbar .btn { padding: 3px 8px; font-size: 10px; }

  .main { padding: 14px 12px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .topbar h1 { font-size: 15px; }
  .profile-bar { padding: 6px 12px; gap: 8px; }
  .cond-chip select.var-sel { min-width: 100px; font-size: 10px; }
  .cond-chip select.op-sel { min-width: 40px; }
  .cond-chip input { width: 50px; }
  .cond-chip { padding: 3px 6px; font-size: 11px; }
  .action-row input[type="number"], .action-row input[type="text"] { width: 65px; }
  .preview-code { font-size: 11px; }
}

/* Mobile (< 600px) */
@media (max-width: 600px) {
  /* Rules Toolbar */
  .rules-toolbar { padding: 5px 10px; gap: 6px; flex-wrap: wrap; }
  .rules-toolbar .btn { padding: 3px 6px; font-size: 9px; }
  .rules-toolbar .btn-preview-scroll { display: none; }

  /* Hide topbar extras (Export/Import) on mobile */
  .topbar-extra { display: none !important; }

  .topbar { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .topbar h1 { font-size: 13px; width: 100%; }
  .topbar-right { margin-left: 0; width: 100%; gap: 6px; flex-wrap: wrap; }
  .topbar-right .btn { padding: 5px 8px; font-size: 10px; }
  .undo-redo { margin-right: 4px; padding-right: 8px; }
  .undo-redo button { padding: 4px 8px; font-size: 12px; }

  .profile-bar { padding: 6px 10px; gap: 6px; }
  .profile-bar select { font-size: 11px; max-width: 140px; }
  

  .main { padding: 10px 8px; }
  .rule-list { gap: 12px; }

  /* Rule Header */
  .rule-header { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .rule-name-input { font-size: 12px; min-width: 60px !important; max-width: 180px !important; }
  .header-spacer { min-height: 16px; }
  .collapse-chevron { font-size: 12px; padding: 2px; }
  .drag-handle { font-size: 14px; }
  .rule-priority { font-size: 9px; padding: 2px 6px; }
  .rule-card.collapsed .cond-summary { max-width: 160px; font-size: 9px; }
  .rule-card.collapsed .mode-badge { font-size: 8px; padding: 1px 6px; }

  /* Rule Body */
  .rule-body { padding: 10px 8px; }
  .sec-label { font-size: 10px; margin-bottom: 6px; }

  /* Conditions */
  .cond-area { padding: 8px 6px; gap: 5px; min-height: 40px; }
  .cond-chip { padding: 3px 5px; font-size: 10px; gap: 3px; }
  .cond-chip select.var-sel { min-width: 85px; font-size: 10px; padding: 2px 4px; }
  .cond-chip select.op-sel { min-width: 35px; font-size: 10px; padding: 2px 3px; }
  .cond-chip input { width: 45px; font-size: 10px; padding: 2px 4px; }
  .cond-chip .unit-lbl { font-size: 9px; }
  .cond-chip .x-btn { font-size: 11px; }
  .logic-chip select { font-size: 10px; padding: 2px 6px; }
  .bracket-sym { font-size: 18px; }

  .add-btn { font-size: 9px; padding: 3px 8px; }

  /* Mode Tags */
  .mode-tags { gap: 5px; margin-bottom: 8px; }
  .mode-tag { padding: 4px 10px; font-size: 10px; }

  /* Actions */
  .actions-area { padding: 8px; }
  .action-row { padding: 5px 6px; gap: 5px; flex-wrap: wrap; }
  .action-row select { font-size: 11px; padding: 3px 5px; min-width: 0; max-width: 120px; }
  .action-row .arrow { font-size: 12px; }
  .action-row input[type="number"], .action-row input[type="text"] { width: 55px; font-size: 11px; padding: 3px 5px; }
  .action-row .unit { font-size: 10px; }
  .action-row .x-btn { font-size: 12px; }
  .action-row .cond-toggle { font-size: 9px; padding: 2px 6px; }

  /* Per-action conditions */
  .action-cond { padding: 4px 6px 4px 12px; }
  .action-cond .cond-area { min-height: 30px; padding: 5px 6px; }

  /* Footer */
  .rule-footer { padding: 6px 10px; flex-wrap: wrap; gap: 6px; }
  .rule-footer .desc { font-size: 9px; width: 100%; }
  .rule-footer .btn { padding: 3px 8px; font-size: 10px; }

  /* Preview */
  .preview-panel { padding: 10px; }
  .preview-code { font-size: 10px; padding: 8px; line-height: 1.5; max-height: 250px; }

  /* Tooltip */
  .rule-tooltip { max-width: calc(100vw - 20px); font-size: 10px; padding: 10px 12px; }

  /* Add Rule */
  .add-rule-card { padding: 14px; }
  .add-rule-card span { font-size: 12px; }

  /* OLD toast responsive — removed v3.5.8 (SPA uses .ae-toast-container) */
}

/* Small Mobile (< 400px) */
@media (max-width: 400px) {
  .topbar h1 { font-size: 12px; }
  .topbar-right .btn { font-size: 9px; padding: 4px 6px; }
  .rule-name-input { max-width: 130px !important; font-size: 11px; }
  .cond-chip select.var-sel { min-width: 70px; }
  .action-row select { max-width: 100px; font-size: 10px; }
  .action-row input[type="number"], .action-row input[type="text"] { width: 45px; font-size: 10px; }
  .mode-tag { padding: 3px 8px; font-size: 9px; }
  .profile-bar select { max-width: 110px; font-size: 10px; }
}


/* ============================================================================
 * SHARED COMPONENT LIBRARY (ae-c-*)
 * Reusable across ALL SPA views. Prefix: ae-c- to avoid clash with existing.
 * Added: v1.5.0 — 2026-03-22
 * ============================================================================ */

/* --------------- ae-c-page — View container --------------- */
.ae-c-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.ae-c-page__title {
  font-size: 22px;
  font-weight: 700;
  color: #e0e6ed;
  margin: 0 0 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --------------- ae-c-card — Section card --------------- */
.ae-c-card {
  background: #141926;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}
.ae-c-card:hover {
  border-color: #2a3450;
}
.ae-c-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1e293b;
}
.ae-c-card__icon {
  font-size: 20px;
  flex-shrink: 0;
}
.ae-c-card__title {
  font-size: 15px;
  font-weight: 700;
  color: #e0e6ed;
  margin: 0;
  letter-spacing: 0.3px;
}
.ae-c-card__subtitle {
  font-size: 11px;
  color: #64748b;
  margin: 2px 0 0;
}

/* --------------- ae-c-field — Form field wrapper --------------- */
.ae-c-field {
  margin-bottom: 16px;
}
.ae-c-field:last-child {
  margin-bottom: 0;
}
.ae-c-field__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.ae-c-field__hint {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}
.ae-c-field__status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.3s;
}
.ae-c-field__status.show {
  opacity: 1;
}
.ae-c-field__status--ok { color: #22c55e; }
.ae-c-field__status--err { color: #ef4444; }
.ae-c-field__status--saving { color: #f59e0b; }

/* --------------- ae-c-input — Text/number inputs --------------- */
.ae-c-input {
  width: 100%;
  background: #0d1321;
  border: 1px solid #2a3050;
  color: #e0e6ed;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.ae-c-input:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}
.ae-c-input::placeholder {
  color: #475569;
}
.ae-c-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ae-c-input--sm {
  padding: 7px 10px;
  font-size: 13px;
}

/* --------------- ae-c-select — Styled dropdown --------------- */
.ae-c-select {
  width: 100%;
  background: #0d1321;
  border: 1px solid #2a3050;
  color: #e0e6ed;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.ae-c-select:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}
.ae-c-select option {
  background: #0d1321;
  color: #e0e6ed;
}

/* --------------- ae-c-input-group — Input + button(s) row --------------- */
.ae-c-input-group {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.ae-c-input-group .ae-c-input {
  flex: 1;
  min-width: 0;
}
.ae-c-input-group .ae-c-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* --------------- ae-c-key-field — API key with eye toggle --------------- */
.ae-c-key-field {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.ae-c-key-field__input-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
.ae-c-key-field__input {
  width: 100%;
  background: #0d1321;
  border: 1px solid #2a3050;
  color: #e0e6ed;
  padding: 10px 40px 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.ae-c-key-field__input:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}
.ae-c-key-field__input::placeholder {
  color: #475569;
  font-family: inherit;
}
.ae-c-key-field__eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}
.ae-c-key-field__eye:hover {
  color: #f59e0b;
  background: rgba(245,158,11,0.1);
}
.ae-c-key-field__eye.active {
  color: #f59e0b;
}

/* --------------- ae-c-toggle — Switch toggle --------------- */
.ae-c-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.ae-c-toggle__track {
  position: relative;
  width: 44px;
  height: 24px;
  background: #2a3050;
  border-radius: 12px;
  transition: background 0.25s;
  flex-shrink: 0;
}
.ae-c-toggle__track.on {
  background: #f59e0b;
}
.ae-c-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #e0e6ed;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.ae-c-toggle__track.on .ae-c-toggle__thumb {
  transform: translateX(20px);
}
.ae-c-toggle__label {
  font-size: 13px;
  color: #94a3b8;
  user-select: none;
}
.ae-c-toggle__label.on {
  color: #f59e0b;
}
/* Hidden real checkbox (accessibility) */
.ae-c-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* --------------- ae-c-btn — Buttons --------------- */
.ae-c-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.2;
}
.ae-c-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ae-c-btn--primary {
  background: #f59e0b;
  color: #0a0e17;
}
.ae-c-btn--primary:hover:not(:disabled) {
  background: #d97706;
}
.ae-c-btn--secondary {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #2a3050;
}
.ae-c-btn--secondary:hover:not(:disabled) {
  background: #2a3450;
  color: #e0e6ed;
  border-color: #3a4560;
}
.ae-c-btn--danger {
  background: #991b1b;
  color: #fecaca;
  border: 1px solid #b91c1c;
}
.ae-c-btn--danger:hover:not(:disabled) {
  background: #b91c1c;
  color: #fff;
}
.ae-c-btn--ghost {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #2a3050;
}
.ae-c-btn--ghost:hover:not(:disabled) {
  background: rgba(255,255,255,0.05);
  color: #e0e6ed;
}
.ae-c-btn--sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}
/* Test button states */
.ae-c-btn--testing {
  pointer-events: none;
}
.ae-c-btn--success {
  background: #166534 !important;
  color: #bbf7d0 !important;
  border-color: #22c55e !important;
}
.ae-c-btn--fail {
  background: #991b1b !important;
  color: #fecaca !important;
  border-color: #ef4444 !important;
}

/* --------------- ae-c-badge — Status badges --------------- */
.ae-c-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.ae-c-badge--green {
  background: rgba(34,197,94,0.15);
  color: #4ade80;
}
.ae-c-badge--amber {
  background: rgba(245,158,11,0.15);
  color: #fbbf24;
}
.ae-c-badge--red {
  background: rgba(239,68,68,0.15);
  color: #f87171;
}
.ae-c-badge--gray {
  background: rgba(100,116,139,0.15);
  color: #94a3b8;
}

/* --------------- ae-c-divider --------------- */
.ae-c-divider {
  height: 1px;
  background: #1e293b;
  margin: 16px 0;
  border: none;
}

/* --------------- ae-c-info — Info/hint text --------------- */
.ae-c-info {
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  padding: 10px 14px;
  background: rgba(30,41,59,0.5);
  border-radius: 8px;
  border-left: 3px solid #334155;
}

/* --------------- ae-c-field-row — Two fields side by side --------------- */
.ae-c-field-row {
  display: flex;
  gap: 16px;
}
.ae-c-field-row > .ae-c-field {
  flex: 1;
  min-width: 0;
}

/* --------------- Responsive — Shared components --------------- */
@media (max-width: 768px) {
  .ae-c-page {
    padding: 16px 12px 32px;
  }
  .ae-c-card {
    padding: 16px;
    border-radius: 10px;
  }
  .ae-c-field-row {
    flex-direction: column;
    gap: 0;
  }
  .ae-c-key-field {
    flex-direction: column;
  }
  .ae-c-key-field .ae-c-btn {
    width: 100%;
  }
}
@media (max-width: 480px) {
  .ae-c-page__title {
    font-size: 18px;
  }
  .ae-c-input-group {
    flex-direction: column;
  }
}

/* --------------- v1.6.0: Activity Log max-height (was in .side-by-side-row, now standalone) --------------- */
.log-panel .log-entries { max-height: 420px; overflow-y: auto; }

/* ═══════════════════════════════════════════════════════════════
 * v1.7.0 — USAGE PROFILE WIDGET (Task 8C)
 * ═══════════════════════════════════════════════════════════════ */

/* Loading placeholder */
.up-loading {
    text-align: center;
    padding: 24px;
    color: #94a3b8;
    font-size: 13px;
}

/* Period selector bar */
.up-period-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.up-period-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.up-period-btn:hover { border-color: #f59e0b; color: #f59e0b; }
.up-period-btn--active {
    background: #f59e0b;
    color: #0f172a;
    border-color: #f59e0b;
    font-weight: 600;
}
.up-full-report-link {
    margin-left: auto;
    font-size: 12px;
    color: #60a5fa;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}
.up-full-report-link:hover {
    background: rgba(96,165,250,0.1);
    text-decoration: underline;
}

/* Stats cards row */
.up-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.up-stat-card {
    background: #1e293b;
    border-radius: 10px;
    padding: 14px 12px;
    text-align: center;
    border: 1px solid #334155;
    transition: border-color 0.2s;
}
.up-stat-card:hover { border-color: #475569; }
.up-stat-icon { font-size: 20px; margin-bottom: 4px; }
.up-stat-value { font-size: 18px; font-weight: 700; color: #e2e8f0; }
.up-stat-label { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* Chart sections */
.up-chart-section { margin-bottom: 16px; }
.up-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 8px;
}
.up-chart-wrap {
    background: #0f172a;
    border-radius: 8px;
    padding: 12px;
    height: 240px;
    position: relative;
}

/* Heatmap grid */
.up-heatmap {
    overflow-x: auto;
}
.up-heatmap-row {
    display: grid;
    grid-template-columns: 50px repeat(7, 1fr);
    gap: 2px;
}
.up-heatmap-header { margin-bottom: 2px; }
.up-heatmap-hour-label {
    font-size: 10px;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    font-family: monospace;
}
.up-heatmap-day-label {
    font-size: 10px;
    color: #94a3b8;
    text-align: center;
    font-weight: 600;
    padding: 2px 0;
}
.up-heatmap-cell {
    aspect-ratio: 1;
    min-height: 14px;
    max-height: 22px;
    border-radius: 3px;
    cursor: default;
    transition: transform 0.1s;
}
.up-heatmap-cell:hover { transform: scale(1.3); z-index: 1; }

/* Heatmap legend */
.up-heatmap-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    justify-content: center;
}
.up-heatmap-legend-label { font-size: 10px; color: #64748b; }
.up-heatmap-legend-bar {
    width: 100px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, rgba(34,197,94,0.8), rgba(250,204,21,0.8), rgba(239,68,68,0.8));
}

/* Responsive: 2-col stats on tablet, 1-col on mobile */
@media (max-width: 768px) {
    .up-stats-row { grid-template-columns: repeat(2, 1fr); }
    .up-chart-wrap { height: 200px; }
}
@media (max-width: 480px) {
    .up-stats-row { grid-template-columns: 1fr 1fr; }
    .up-stat-value { font-size: 15px; }
    .up-chart-wrap { height: 180px; }
    .up-heatmap-cell { min-height: 10px; }
}

/* ═══════════════════════════════════════════════════════════════
 * v1.7.0 — USAGE REPORT VIEW (Task 8D)
 * ═══════════════════════════════════════════════════════════════ */

.usage-report-view {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* Header */
.ur-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.ur-header h1 {
    font-size: 22px;
    color: #e2e8f0;
    margin: 0;
}
.ur-export-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.ur-export-btn:hover { border-color: #f59e0b; color: #f59e0b; }

/* Date controls */
.ur-date-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    background: #1e293b;
    border-radius: 10px;
    padding: 12px 16px;
    border: 1px solid #334155;
}
.ur-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.ur-preset {
    background: #0f172a;
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.ur-preset:hover { border-color: #f59e0b; color: #f59e0b; }
.ur-preset--active {
    background: #f59e0b;
    color: #0f172a;
    border-color: #f59e0b;
    font-weight: 600;
}
.ur-custom-range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.ur-date-input {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
}
.ur-date-sep { color: #64748b; font-size: 14px; }
.ur-apply-btn {
    background: #3b82f6;
    border: none;
    color: #fff;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s;
}
.ur-apply-btn:hover { background: #2563eb; }

/* Summary cards */
.ur-summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.ur-stat-card {
    background: #1e293b;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    border: 1px solid #334155;
    transition: border-color 0.2s;
}
.ur-stat-card:hover { border-color: #475569; }
.ur-stat-icon { font-size: 22px; margin-bottom: 4px; }
.ur-stat-value { font-size: 20px; font-weight: 700; color: #e2e8f0; }
.ur-stat-label { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.ur-stat-sub { font-size: 10px; color: #64748b; margin-top: 4px; }

/* Sections */
.ur-section {
    background: #1e293b;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid #334155;
}
.ur-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #e2e8f0;
    margin: 0 0 12px 0;
}
.ur-chart-wrap {
    background: #0f172a;
    border-radius: 8px;
    padding: 12px;
    height: 280px;
    position: relative;
}

/* Daily table */
.ur-table-scroll { overflow-x: auto; }
.ur-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.ur-table thead { position: sticky; top: 0; z-index: 1; }
.ur-table th {
    background: #0f172a;
    color: #94a3b8;
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid #334155;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: color 0.2s;
}
.ur-table th:hover { color: #f59e0b; }
.ur-th-active { color: #f59e0b !important; }
.ur-table td {
    padding: 7px 10px;
    border-bottom: 1px solid rgba(51,65,85,0.5);
    color: #e2e8f0;
    white-space: nowrap;
}
.ur-table tbody tr:hover { background: rgba(248,250,252,0.03); }
.ur-cell-red { color: #ef4444; }
.ur-cell-green { color: #22c55e; }

/* Peaks table */
.ur-peaks-table { max-width: 700px; }

/* Responsive */
@media (max-width: 768px) {
    .ur-summary-row { grid-template-columns: repeat(2, 1fr); }
    .ur-custom-range { margin-left: 0; width: 100%; }
    .ur-chart-wrap { height: 220px; }
    .ur-header { flex-direction: column; gap: 8px; align-items: flex-start; }
}
@media (max-width: 480px) {
    .ur-summary-row { grid-template-columns: 1fr 1fr; }
    .ur-stat-value { font-size: 16px; }
    .ur-date-controls { flex-direction: column; }
    .ur-presets { width: 100%; }
    .ur-custom-range { flex-wrap: wrap; }
}

/* ============================================
 * SETUP WIZARD (restored from v1.0.21, vars → hardcoded)
 * ============================================ */

.ae-setup {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
}

.ae-setup__progress {
    position: relative;
    height: 6px;
    background: #141926;
    border-radius: 3px;
    margin-bottom: 12px;
    overflow: hidden;
}

.ae-setup__progress-bar {
    height: 100%;
    background: #f59e0b;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.ae-setup__progress-text {
    text-align: center;
    font-size: 12px;
    color: #475569;
    margin-bottom: 32px;
}

.ae-setup__container {
    background: #141926;
    border: 1px solid #1e293b;
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 24px;
}

.ae-setup__step h2 {
    font-size: 22px;
    font-weight: 700;
    color: #e0e6ed;
    margin-bottom: 12px;
}

.ae-setup__step p {
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Feature cards (welcome step) */
.ae-setup__features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.ae-setup__feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #0f1219;
    border-radius: 12px;
    border: 1px solid #1e293b;
}

.ae-setup__feature span {
    font-size: 28px;
    flex-shrink: 0;
}

.ae-setup__feature p {
    margin: 0;
    font-size: 14px;
    color: #e0e6ed;
}

/* Form sections */
.ae-setup__section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #1e293b;
}

.ae-setup__section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.ae-setup__section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.ae-setup__section-title span {
    font-size: 20px;
}

.ae-setup__section-title h3 {
    font-size: 16px;
    font-weight: 700;
    color: #e0e6ed;
    margin: 0;
}

.ae-setup__section-subtitle {
    font-size: 12px;
    color: #475569;
    margin-bottom: 16px;
}

/* Form rows */
.ae-setup__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.ae-setup__row--3 {
    grid-template-columns: 100px 1fr;
}

/* Form inputs within setup */
.ae-setup .ae-form-group {
    margin-bottom: 12px;
}

.ae-setup .ae-form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.ae-setup .ae-form-group input,
.ae-setup .ae-form-group select {
    width: 100%;
    padding: 12px 14px;
    background: #0f1219;
    border: 1px solid #1e293b;
    border-radius: 8px;
    color: #e0e6ed;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.ae-setup .ae-form-group input:focus,
.ae-setup .ae-form-group select:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.ae-setup .ae-form-group input::placeholder {
    color: #475569;
}

.ae-setup .ae-form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1.4 0L6 4.6 10.6 0 12 1.4l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.ae-setup .ae-form-group small {
    display: block;
    font-size: 11px;
    color: #475569;
    margin-top: 4px;
}

/* Inline test button */
.ae-setup__input-with-btn {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.ae-setup__input-with-btn input {
    flex: 1;
}

.ae-setup__input-with-btn .ae-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Validation states */
.ae-setup .ae-form-group--error input,
.ae-setup .ae-form-group--error select {
    border-color: #ef4444;
}

.ae-setup .ae-form-group--success input,
.ae-setup .ae-form-group--success select {
    border-color: #22c55e;
}

.ae-setup .ae-field-error {
    color: #ef4444;
    font-size: 11px;
    margin-top: 4px;
}

.ae-setup .ae-field-success {
    color: #22c55e;
    font-size: 11px;
    margin-top: 4px;
}

/* Navigation buttons */
.ae-setup__actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.ae-setup__actions .ae-btn {
    flex: 1;
}

/* Device/site info rows */
.ae-setup__device-info,
.ae-setup__site-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.ae-setup__info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: #0f1219;
    border-radius: 10px;
    border: 1px solid #1e293b;
}

.ae-setup__info-row span {
    color: #94a3b8;
    font-size: 13px;
}

.ae-setup__info-row strong {
    color: #e0e6ed;
}

/* Note text */
.ae-setup__note {
    font-size: 12px;
    color: #475569;
    font-style: italic;
    margin-top: 12px;
}

/* Mandatory indicator */
.ae-setup .ae-required {
    color: #ef4444;
    margin-left: 2px;
}

/* Done / completion step */
.ae-setup__step--complete {
    text-align: center;
}

.ae-setup__done-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}

.ae-setup__next-steps {
    text-align: left;
    margin-top: 24px;
}

.ae-setup__next-steps h3 {
    font-size: 16px;
    color: #e0e6ed;
    margin-bottom: 12px;
}

.ae-setup__next-steps ul {
    list-style: none;
    padding: 0;
}

.ae-setup__next-steps li {
    padding: 10px 0;
    color: #94a3b8;
    font-size: 14px;
    border-bottom: 1px solid #1e293b;
}

.ae-setup__next-steps li:before {
    content: '✅ ';
}

.ae-setup__next-steps li:last-child {
    border-bottom: none;
}

/* Google Places autocomplete dropdown override */
.pac-container {
    background: #141926 !important;
    border: 1px solid #1e293b !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    margin-top: 4px;
    font-family: inherit !important;
}

.pac-item {
    padding: 10px 14px !important;
    border-top: 1px solid #1e293b !important;
    color: #e0e6ed !important;
    font-size: 13px !important;
    cursor: pointer;
}

.pac-item:first-child {
    border-top: none !important;
}

.pac-item:hover,
.pac-item-selected {
    background: #1e293b !important;
}

.pac-item-query {
    color: #f59e0b !important;
    font-weight: 600 !important;
}

.pac-matched {
    color: #f59e0b !important;
    font-weight: 700 !important;
}

.pac-icon {
    display: none !important;
}

/* Setup toggle switch (battery on/off) */
.ae-setup__toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.ae-setup__toggle-track {
    position: relative;
    width: 44px;
    height: 24px;
    background: #374151;
    border-radius: 12px;
    transition: background 0.2s ease;
}

.ae-setup__toggle-track.on {
    background: #f59e0b;
}

.ae-setup__toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.ae-setup__toggle-track.on .ae-setup__toggle-knob {
    transform: translateX(20px);
}

.ae-setup__toggle-label {
    font-size: 14px;
    color: #94a3b8;
    font-weight: 500;
}

.ae-setup__toggle-label.on {
    color: #f59e0b;
}

/* Setup: State <select> styling */
.ae-setup #setup-state {
    width: 100%;
    padding: 10px 14px;
    background: #141926;
    color: #e0e6ed;
    border: 1px solid #1e293b;
    border-radius: 8px;
    font-size: 14px;
    appearance: auto;
}

/* Setup responsive */
@media (max-width: 480px) {
    .ae-setup { padding: 20px 12px; }
    .ae-setup__container { padding: 20px; }
    .ae-setup__step h2 { font-size: 18px; }
    .ae-setup__row { grid-template-columns: 1fr; }
    .ae-setup__row--3 { grid-template-columns: 1fr; }
    .ae-setup__input-with-btn { flex-direction: column; }
}
