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

/* Ensure the Home Assistant header/sidebar are visible by not using full viewport height or fixed/absolute positioning for main containers */
.container {
    margin: 0 auto;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
}

body {
    background: none !important;
    min-height: 0 !important;
}

/* CSS Variables - Use Home Assistant theme variables with dark theme fallbacks */
:root,
climate-scheduler-panel {
    --primary-color: var(--primary-color, #03a9f4);
    --primary-dark: var(--dark-primary-color, #0288d1);
    --background: var(--card-background-color, #1e1e1e);
    --surface: var(--card-background-color, #2d2d2d);
    --surface-light: var(--secondary-background-color, #3d3d3d);
    --text-primary: var(--primary-text-color, #ffffff);
    --text-secondary: var(--secondary-text-color, #b0b0b0);
    --border: var(--divider-color, #444444);
    --accent: var(--accent-color, #ff9800);
    --success: var(--success-color, #4caf50);
    --danger: var(--error-color, #f44336);
    --grid-line: var(--divider-color, #444444);
    --node-color: var(--accent-color, #03a9f4);
    --node-hover: var(--accent-color, #29b6f6);
    --line-color: var(--warning-color, #ff9800);
    display: block;
}

/* Light Theme Override - only for explicit fallbacks when HA theme doesn't provide values */
:root[data-theme="light"],
climate-scheduler-panel[data-theme="light"] {
    --primary-color: var(--primary-color, #0288d1);
    --primary-dark: var(--dark-primary-color, #01579b);
    --background: var(--card-background-color, #fafafa);
    --surface: var(--card-background-color, #ffffff);
    --surface-light: var(--secondary-background-color, #f5f5f5);
    --text-primary: var(--primary-text-color, #212121);
    --text-secondary: var(--secondary-text-color, #757575);
    --border: var(--divider-color, #e0e0e0);
    --accent: var(--accent-color, #f57c00);
    --success: var(--success-color, #388e3c);
    --danger: var(--error-color, #d32f2f);
    --grid-line: var(--divider-color, #e0e0e0);
    --node-color: var(--accent-color, #0288d1);
    --node-hover: var(--accent-color, #039be5);
    --line-color: var(--warning-color, #f57c00);
}

climate-scheduler-panel {
    width: 100%;
    height: 100%;
}

/* Base button styles - all buttons inherit from this */
button, .btn {
    padding: 6px 12px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 6px;
    margin: 0;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.2s;
}

/* Schedule buttons */
.schedule-btn {
    min-width: 110px;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--primary-text-color, #ffffff);
    border: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(3, 169, 244, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary-outline:hover {
    background: var(--surface-light);
    border-color: var(--text-secondary);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 60px;
    right: 20px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    min-width: 200px;
    overflow: hidden;
}

.menu-item {
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s;
    text-align: left;
}

.menu-item:hover {
    background: var(--surface);
}

.menu-icon {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.btn-icon {
    background: var(--surface-light);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.2rem;
}

.btn-icon:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.entity-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    overflow-y: visible;
    background: var(--card-background-color);
    padding: 12px;
}

.selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.selector-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 500;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Groups Section */
.groups-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    margin-bottom: 20px;
}

.profiles-section {
    margin-bottom: 20px;
}

.groups-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-container {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.group-header {
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.group-header:hover {
    background: var(--surface-light);
}

.group-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--surface-light);
    padding: 2px 8px;
    border-radius: 12px;
}

.group-actions {
    display: flex;
    gap: 8px;
}

.group-enable-toggle {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    margin-right: 4px;
}

.group-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.group-actions button:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.group-actions .delete-group {
    color: var(--danger);
}

.group-actions .delete-group:hover {
    background: rgba(244, 67, 54, 0.1);
}

.group-entities {
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.group-entities .entity-card {
    background: var(--surface);
}

.group-toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.2s;
    color: var(--text-secondary);
}

.group-toggle-icon.expanded {
    transform: rotate(90deg);
}

.ignored-section {
    margin-bottom: 12px;
}

.ignored-list {
    display: flex;
    flex-direction: column; /* stack filter above grid */
    width: 100%;
    gap: 12px;
}

.filter-box {
    padding: 0 4px 8px 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    grid-column: 1 / -1; /* ensure filter spans full width above grid */
}

.filter-box input {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.filter-box input:focus {
    border-color: var(--primary-color);
}

.filter-box input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

#disabled-entities-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    /* Let container grow to fit; scrolling handled by page */
    overflow: visible;
}

/* Ignored entities list container should fill width under filter */
#ignored-entities-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.entity-card {
    background: var(--surface-light);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    transition: all 0.2s;
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
}

.entity-card.expanded {
    grid-column: 1 / -1;
    flex-direction: column;
    align-items: stretch;
    border-color: var(--primary-color);
}

.close-entity-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s;
    margin-left: auto;
}

.close-entity-btn:hover {
    color: var(--danger);
}

.entity-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.entity-card.selected {
    border-color: var(--primary-color);
    background: var(--primary-dark);
}

.entity-card.excluded {
    opacity: 0.4;
}

.entity-checkbox-wrapper {
    display: flex;
    align-items: center;
}

.entity-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.entity-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.entity-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
}

.entity-temp {
    font-size: 0.95rem;
    color: var(--accent);
    font-weight: 500;
}

/* Schedule Editor */
.schedule-editor {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.editor-header h2 {
    font-size: 1.5rem;
    font-weight: 500;
}

.editor-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.slider {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    background-color: var(--border);
    border-radius: 13px;
    transition: 0.3s;
}

.slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .slider {
    background-color: var(--success);
}

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

.toggle-label {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: var(--primary-text-color, #ffffff);
    border: none;
    font-size: 1rem;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(3, 169, 244, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-size: 0.95rem;
}
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Entity Status */
.entity-status {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
    margin-bottom: 20px;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.status-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent);
}

/* Schedule Mode Selector */
.schedule-mode-selector {
    background: var(--background);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.schedule-mode-selector h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    font-weight: 500;
}

.mode-options {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 5px;
}

.mode-option input[type="radio"] {
    margin: 0;
}

.mode-option label {
    margin: 0;
    cursor: pointer;
}

.day-selector {
    display: none;
    margin-top: 10px;
}

.day-selector.visible {
    display: block;
}

.day-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.day-btn {
    padding: 8px 12px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.day-btn:hover {
    background: var(--surface);
    border-color: var(--primary);
}

.day-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.weekday-selector {
    display: none;
    margin-top: 10px;
}

.weekday-selector.visible {
    display: block;
}

/* Graph Container */
.graph-container {
    margin-top: 20px;
}
}

/* Graph node selection highlight */
#temperature-graph circle.node {
    transition: fill 0.2s ease-out;
}

.graph-instructions {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 15px;
    font-size: 0.9rem;
}

.graph-instructions p {
    margin-bottom: 8px;
}

.graph-instructions p:last-child {
    margin-bottom: 0;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .entity-list {
        grid-template-columns: 1fr;
    }

    .editor-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .editor-controls {
        width: 100%;
        justify-content: space-between;
    }

    .entity-status {
        flex-direction: column;
        gap: 10px;
    }

    .status-item {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }
    
    /* Stack graph top controls on tablet and mobile */
    .graph-top-controls {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
    }
    
    .day-period-selector,
    .graph-quick-actions {
        width: 100%;
        margin: 0;
        padding: 10px;
    }
    
    /* Reduce schedule editor padding on tablets */
    .schedule-editor {
        padding: 12px;
    }
    
    .editor-header {
        margin-bottom: 12px;
        gap: 10px;
    }
    
    .graph-container {
        margin-top: 12px;
    }
    
    /* Reduce 16px padding/margins to 10-12px on tablets */
    .schedule-settings-panel,
    .schedule-editor-inline {
        padding: 10px;
    }
    
    .group-members-container,
    .instructions-container,
    .editor-header-inline {
        margin-bottom: 10px;
    }
}

/* Extra small mobile devices (320px width) */
@media (max-width: 400px) {
    .container {
        padding: 8px;
    }

    header h1 {
        font-size: 1.2rem;
    }

    /* Make buttons more compact */
    button, .btn {
        padding: 4px 8px;
        font-size: 0.85rem;
    }

    .schedule-btn {
        min-width: 80px;
    }

    .btn-quick-action {
        font-size: 0.8rem;
        padding: 4px 6px;
    }

    /* Reduce spacing in group headers */
    .group-header {
        padding: 8px;
        gap: 6px;
    }

    .group-title {
        font-size: 0.9rem;
    }

    .group-count {
        font-size: 0.75rem;
    }

    /* Make profile dropdown more compact */
    .group-profile-selector {
        gap: 4px;
    }

    .group-profile-selector label {
        font-size: 0.8rem;
    }

    .group-profile-dropdown {
        font-size: 0.8rem;
        padding: 4px 6px;
    }

    /* Compact day selector */
    .day-period-btn {
        padding: 3px 6px;
        font-size: 0.8rem;
        min-width: 30px;
    }

    /* Reduce entity status text */
    .entity-status {
        gap: 6px;
    }

    .status-label {
        font-size: 0.75rem;
    }

    .status-value {
        font-size: 0.85rem;
    }

    /* Compact node settings panel */
    .setting-item label {
        font-size: 0.85rem;
    }

    .setting-item input,
    .setting-item select {
        font-size: 0.85rem;
        padding: 4px 6px;
    }

    /* Reduce modal sizes */
    .modal-content {
        min-width: 280px;
        max-width: 95%;
        padding: 12px;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    /* Compact graph controls */
    .graph-controls {
        gap: 4px;
        flex-wrap: wrap;
    }
    
    /* Stack graph top controls on mobile */
    .graph-top-controls {
        flex-direction: column;
        gap: 4px;
        margin-bottom: 4px;
    }
    
    .day-period-selector,
    .graph-quick-actions {
        width: 100%;
        margin: 0;
        padding: 4px;
    }
    
    /* Reduce schedule editor padding */
    .schedule-editor {
        padding: 4px;
        border-radius: 8px;
    }
    
    .editor-header {
        margin-bottom: 6px;
        gap: 4px;
    }
    
    .editor-header h2 {
        font-size: 1.1rem;
    }
    
    .editor-controls {
        gap: 4px;
    }
    
    .graph-container {
        margin-top: 6px;
    }
    
    /* Reduce all padding/margins to 4px */
    .schedule-settings-panel,
    .schedule-editor-inline,
    .group-members-container,
    .instructions-container {
        padding: 4px !important;
        margin-bottom: 4px;
    }
    
    .editor-header-inline {
        margin-bottom: 4px;
    }

    /* Reduce spinner button sizes */
    .spinner-btn {
        padding: 3px 6px;
        font-size: 0.7rem;
        min-width: 20px;
    }

    /* Make input fields more compact */
    .time-input, .temp-input {
        padding: 4px 6px;
        font-size: 0.85rem;
        width: 70px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Node Settings Panel (inline) */
.node-settings-panel {
    margin-top: 20px;
    padding: 0;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.node-settings-panel .settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
}

#climate-dialog-container {
    background: var(--surface-light);
    padding: 20px;
    border-radius: 0 0 8px 8px;
}

.node-settings-panel .settings-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.btn-close-settings {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close-settings:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.btn-nav-node {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.9rem;
}
    font-weight: bold;
}

.btn-nav-node:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 15px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 150px;
}

.setting-item label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.setting-item .setting-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.setting-item select {
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    max-width: 200px;
    width: fit-content;
}

.setting-item select:enabled:hover {
    border-color: var(--primary-color);
}

.setting-item select:enabled:focus {
    border-color: var(--primary-color);
}

.setting-item select:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Input spinner controls */
.input-spinner {
    display: flex;
    align-items: center;
    gap: 4px;
}

.spinner-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.75rem;
    min-width: 24px;
}

.spinner-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.time-input {
    padding: 6px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
    width: 90px;
    text-align: center;
}

.time-input:focus {
    border-color: var(--primary-color);
}

.temp-input {
    padding: 6px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
    width: 70px;
    text-align: center;
}

.temp-input:focus {
    border-color: var(--primary-color);
}

/* Remove number input arrows for temp input */
.temp-input::-webkit-inner-spin-button,
.temp-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.temp-input[type=number] {
    -moz-appearance: textfield;
}

.settings-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-close:hover {
    background: var(--surface-light);
}

.modal-body {
    padding: 20px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.setting-row label {
    font-weight: 600;
    color: var(--text-secondary);
}

.setting-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.setting-row select {
    padding: 6px 10px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    opacity: 0.6;
}

.coming-soon-note {
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    font-size: 0.85rem;
    text-align: center;
}

.modal-actions {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-danger {
    background: #d32f2f;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #b71c1c;
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    font-size: 0.9rem;
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

.btn-secondary-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary-outline:hover {
    background: var(--surface-light);
    border-color: var(--text-secondary);
}

.editor-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    color: var(--text-secondary);
}

.modal-body p {
    margin-bottom: 10px;
}

.modal-body strong {
    color: var(--text-primary);
}

.modal-actions {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Group Members Table */
.schedule-settings-container {
    margin-top: 12px;
    margin-bottom: 16px;
}

.schedule-settings-toggle {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.schedule-settings-toggle:hover {
    background: var(--surface);
}

.schedule-settings-toggle .toggle-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
    display: inline-block;
}

.schedule-settings-toggle .toggle-text {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.schedule-settings-panel {
    background: var(--surface-light);
    border-radius: 0 0 8px 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-top: none;
    margin-top: -1px;
}

.schedule-settings-panel .editor-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.schedule-settings-panel .schedule-mode-selector {
    margin-top: 0;
}

/* Instructions Container */
.instructions-container {
    margin-bottom: 16px;
}

.instructions-toggle {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.instructions-toggle:hover {
    background: var(--surface);
}

.instructions-toggle .toggle-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
    display: inline-block;
}

.instructions-toggle .toggle-text {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.graph-instructions.collapsed {
    display: none;
}

.graph-instructions {
    background: var(--surface-light);
    border-radius: 0 0 8px 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-top: none;
    margin-top: -1px;
}

.timeline-comparison-container {
    margin-bottom: 16px;
}

.timeline-comparison-toggle {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.timeline-comparison-toggle:hover {
    background: var(--surface);
}

.timeline-comparison-toggle .toggle-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
    display: inline-block;
}

.timeline-comparison-toggle .toggle-text {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.timeline-comparison-content.collapsed {
    display: none;
}

.timeline-comparison-content {
    background: var(--surface-light);
    border-radius: 0 0 8px 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-top: none;
    margin-top: -1px;
    overflow: visible;
    min-height: 0;
}

.timeline-comparison-content keyframe-timeline {
    display: block;
}

.group-members-container {
    margin-bottom: 16px;
}

.group-members-toggle {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.group-members-toggle:hover {
    background: var(--surface);
}

.group-members-toggle .toggle-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
    display: inline-block;
}

.group-members-toggle .toggle-text {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.group-members-table {
    background: var(--surface-light);
    border-radius: 0 0 8px 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-top: none;
    margin-top: -1px;
}

.group-members-header {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    gap: 12px;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--secondary-text-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.group-members-header span:nth-child(2),
.group-members-header span:nth-child(3),
.group-members-header span:nth-child(4) {
    width: 80px;
    text-align: right;
}

.group-members-header span:nth-child(5) {
    width: 60px;
    text-align: center;
}

.group-members-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.group-members-row:hover {
    background: var(--surface);
}

.group-members-row span:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

.group-members-row span:nth-child(2),
.group-members-row span:nth-child(3),
.group-members-row span:nth-child(4) {
    width: 80px;
    text-align: right;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
}

.group-members-row span:nth-child(5) {
    width: 60px;
    text-align: center;
}

.group-members-row span:nth-child(2) {
    color: var(--accent-color);
}

.group-members-row span:nth-child(3) {
    color: var(--primary-color);
    font-weight: 600;
}

/* Remove button in group members table */
.btn-icon-small {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.btn-icon-small:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    transform: scale(1.1);
}

.btn-icon-small:active {
    transform: scale(0.95);
}

.remove-entity-btn {
    font-weight: bold;
}

/* Inline Schedule Editor */
.schedule-editor-inline {
    background: var(--surface);
    border-top: 2px solid var(--primary-color);
    border-radius: 0 0 12px 12px;
    padding: 16px;
    animation: slideDown 0.3s ease-out;
    width: 100%;
    box-sizing: border-box;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        overflow: hidden;
    }
    to {
        opacity: 1;
        max-height: 2000px;
    }
}

.editor-header-inline {
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-editor-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    line-height: 1;
}

.close-editor-btn:hover {
    background: var(--surface-light);
    color: var(--danger);
}

.group-container.expanded {
    border-color: var(--primary-color);
}

.group-container.expanded > .schedule-editor-inline {
    border-radius: 0 0 12px 12px;
}

/* Settings Panel */
.settings-panel {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.settings-header {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    user-select: none;
    transition: background 0.2s;
}

.settings-header:hover {
    background: var(--surface-light);
}

.settings-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-header .collapse-indicator {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.settings-panel.expanded .collapse-indicator {
    transform: rotate(0deg) !important;
}

.settings-panel.collapsed .settings-content {
    display: none;
}

.settings-panel.expanded {
    border-color: var(--primary-color);
}

.settings-content {
    padding: 20px;
    background: var(--card-background-color);
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h4 {
    margin-bottom: 8px;
    color: var(--primary-color);
    font-size: 1rem;
}

.settings-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.settings-section .graph-container {
    margin-top: 16px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 0;
    overflow: hidden;
}

.settings-section .temperature-graph {
    width: 100%;
    height: 260px;
    display: block;
    box-sizing: border-box;
}

/* Debug Panel */
.debug-panel {
    margin-top: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
}

.debug-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.debug-content {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
}

.debug-message {
    padding: 4px 8px;
    margin-bottom: 4px;
    border-left: 3px solid var(--border);
    background: var(--background);
    border-radius: 2px;
}

.debug-message.info {
    border-left-color: var(--primary-color);
}

.debug-message.warning {
    border-left-color: #ff9800;
    background: rgba(255, 152, 0, 0.1);
}

.debug-message.error {
    border-left-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
}

.debug-timestamp {
    color: var(--text-secondary);
    margin-right: 8px;
}

.settings-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    min-width: 300px;
    max-width: 500px;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid var(--primary-color);
}

.toast.success {
    border-left-color: var(--success);
}

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

.toast.warning {
    border-left-color: var(--accent);
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--success);
}

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

.toast.warning .toast-icon {
    color: var(--accent);
}

.toast-message {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.4;
}

.toast.hiding {
    animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Profile Selector */
.profile-selector {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.profile-selector h3 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.profile-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.profile-dropdown {
    flex: 1;
    padding: 8px 12px;
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.profile-dropdown:hover {
    border-color: var(--primary-color);
}

.profile-dropdown:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(3, 169, 244, 0.2);
}

.btn-profile {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
}

.btn-profile:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-profile:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Graph Top Controls */
.graph-top-controls {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.day-period-selector {
    flex: 1;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.graph-quick-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 0 auto;
}

.mode-dropdown {
    padding: 6px 10px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    max-width: 200px;
}

.mode-dropdown:hover {
    border-color: var(--primary-color);
    background: var(--surface);
}

.mode-dropdown:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-alpha);
}

.btn-quick-action {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-quick-action:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-quick-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.graph-profile-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-left: auto;
}

.graph-profile-selector label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.graph-profile-dropdown {
    padding: 6px 12px;
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    min-width: 120px;
}

.graph-profile-dropdown:hover {
    border-color: var(--primary-color);
}

.graph-profile-dropdown:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(3, 169, 244, 0.2);
}

/* Day/Period Selector above graph */
.day-period-selector {
    flex: 1;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.day-period-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.day-period-btn {
    padding: 4px 10px;
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    min-width: 40px;
}

.day-period-btn:hover {
    background: var(--surface-hover);
}
    border-color: var(--primary-color);
}

.day-period-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 500;
}