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

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        h1 {
            color: white;
            text-align: center;
            margin-bottom: 16px;
            font-size: 1.6em;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
        }

        .status {
            background: white;
            border-radius: 10px;
            padding: 15px 20px;
            margin-bottom: 20px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
        }

        .status-left {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 4px;
            min-width: 240px;
        }

        .status-line {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .status-adapter {
            font-size: 0.85em;
            color: #6b7280;
            display: inline-block;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .status-warning {
            font-size: 0.85em;
            font-weight: 700;
            color: #ef4444;
            display: inline-block;
        }

        .ble-status-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            display: inline-block;
            background: #9ca3af;
            box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.2);
        }

        .ble-status-dot.is-ok {
            background: #10b981;
            box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
        }

        .ble-status-dot.is-error {
            background: #ef4444;
            box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
        }

        .status-actions {
            display: flex;
            align-items: center;
            gap: 8px;
            flex: 1;
            margin-left: 24px;
        }

        .status-db {
            display: flex;
            flex-direction: column;
            gap: 2px;
            font-size: 0.72em;
            color: #6b7280;
            padding-left: 10px;
            border-left: 1px solid #e5e7eb;
            line-height: 1.2;
            min-width: 160px;
        }

        .status-db-line {
            white-space: nowrap;
        }

        .status-actions button {
            padding: 8px 12px;
            font-size: 0.8em;
            font-weight: normal;
        }

        .status-actions-left {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .status-actions-right {
            margin-left: auto;
            display: flex;
            align-items: center;
        }

        .status-indicator {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            animation: pulse 2s infinite;
            background: #9ca3af;
        }

        .status-indicator.is-ok {
            background: #10b981;
        }

        .status-indicator.is-warn {
            background: #f59e0b;
        }

        .status-indicator.is-error {
            background: #ef4444;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }

        .sensors-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .sensor-card {
            background: white;
            border-radius: 15px;
            padding: 15px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.2);
            transition: transform 0.2s;
        }

        .sensor-card:hover {
            transform: translateY(-5px);
        }

        .sensor-card--summary {
            padding: 12px;
            font-size: 0.8em;
        }

        .summary-header,
        .summary-row {
            display: grid;
            grid-template-columns: 1fr 60px 60px;
            align-items: center;
            column-gap: 8px;
        }

        .summary-header {
            font-size: 0.85em;
            font-weight: 700;
            color: #6b7280;
            margin-bottom: 6px;
        }

        .summary-title {
            color: #111827;
        }

        .summary-body {
            display: flex;
            flex-direction: column;
            gap: 4px;
            line-height: 1.05;
        }

        .summary-name {
            font-weight: 600;
            color: #111827;
        }

        .summary-col,
        .summary-cell {
            text-align: right;
            font-variant-numeric: tabular-nums;
        }

        .sensor-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid #f3f4f6;
        }

        .sensor-name {
            font-size: 1.3em;
            font-weight: 700;
            color: #1f2937;
        }

        .sensor-mac {
            font-size: 0.8em;
            color: #9ca3af;
            font-family: 'Courier New', monospace;
            margin-top: 2px;
        }

        .sensor-time {
            font-size: 0.85em;
            color: #6b7280;
        }

        .sensor-data {
            display: grid;
            gap: 15px;
        }

        .data-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px;
            background: #f9fafb;
            border-radius: 8px;
        }

        .data-label {
            font-weight: 500;
            color: #6b7280;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .data-value {
            font-size: 1.3em;
            font-weight: 700;
            color: #1f2937;
        }

        .temp { color: #ef4444; }
        .humidity { color: #3b82f6; }
        .battery { color: #10b981; }
        .signal { color: #f59e0b; }

        .icon {
            font-size: 1.2em;
        }

        .no-data {
            text-align: center;
            padding: 60px 20px;
            color: white;
            font-size: 1.2em;
        }

        .view-btn {
            padding: 8px 12px;
            border: 2px solid #e5e7eb;
            border-radius: 8px;
            background: #f9fafb;
            color: #374151;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s, transform 0.15s;
        }

        .view-btn:hover {
            background: #f3f4f6;
            border-color: #d1d5db;
            transform: translateY(-1px);
        }

        .view-btn.active {
            background: #111827;
            border-color: #111827;
            color: white;
        }

        .view-btn:disabled {
            cursor: not-allowed;
            opacity: 0.6;
        }

        .time-btn {
            padding: 8px 12px;
        }

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

        .flow-controls {
            margin-bottom: 12px;
            width: 100%;
            justify-content: space-between;
        }

        .control-group {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .control-spacer {
            flex: 1 1 28px;
            min-width: 20px;
        }

        .control-label {
            font-size: 0.75em;
            font-weight: 600;
            color: #6b7280;
        }

        .flow-energy-start {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 2px 4px;
            border-radius: 8px;
            background: #f3f4f6;
        }

        .flow-date {
            border: 1px solid #d1d5db;
            border-radius: 6px;
            padding: 6px 8px;
            font-size: 0.8em;
            font-weight: 600;
            color: #374151;
            background: #fff;
        }

        .flow-date:focus {
            outline: 2px solid #111827;
            outline-offset: 1px;
        }

        .control-right {
            justify-content: flex-end;
        }

        .graph-controls .control-right {
            margin-left: 0;
        }

        .graph-room-controls {
            flex: 1 1 auto;
            justify-content: center;
        }

        .graph-room-btn.active {
            background: var(--graph-room-color);
            border-color: var(--graph-room-color);
            color: #ffffff;
        }

        .flow-controls .control-right {
            margin-left: auto;
        }

        .heating-controls {
            display: grid;
            grid-template-columns: minmax(0, 1fr) max-content;
            margin-bottom: 0;
        }

        .heating-controls .control-left {
            grid-column: 1;
            grid-row: 1;
        }

        .heating-room-controls {
            grid-column: 2;
            grid-row: 1;
        }

        .heating-source-controls {
            grid-column: 1;
            grid-row: 2;
            justify-content: flex-start;
        }

        .heating-controls .heating-colored-filter-btn.active {
            background: var(--heating-room-color);
            border-color: var(--heating-room-color);
            color: var(--heating-room-text);
        }

        .heating-relay-layout-btn {
            width: 148px;
            flex: 0 0 148px;
        }

        .heating-relay-info {
            display: flex;
            flex-wrap: nowrap;
            align-items: center;
            gap: 16px;
            min-width: 0;
            overflow-x: auto;
            white-space: nowrap;
            color: #fff;
            font-size: 0.8em;
            line-height: 1.2;
            padding: 2px 0;
        }

        .heating-temperatures {
            grid-column: 2;
            grid-row: 2;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 50px;
            height: 35px;
            max-height: 35px;
            color: #fff;
        }

        .heating-temperature-group {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 0 0 auto;
        }

        .heating-temperature-pipes {
            gap: 8px;
        }

        .heating-temperature {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 88px;
            height: 35px;
            border-radius: 0;
            background: #374151;
            color: #fff;
            font-size: 0.95em;
            font-weight: 700;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }

        .heating-temperature.is-supply {
            background: #ef4444;
        }

        .heating-temperature.is-return {
            background: #3b82f6;
        }

        .heating-temperature-label {
            color: #fff;
        }

        .heating-relay-info:has(#heatingRelayStatus:empty) {
            display: none;
        }

        #heatingRelayStatus:empty {
            display: none;
        }

        #heatingRelayStatus {
            flex: 0 0 auto;
        }

        .heating-room-controls {
            justify-content: center;
        }

        .shutdown-btn {
            border: none;
            border-radius: 8px;
            background: #ef4444;
            color: white;
            cursor: pointer;
            transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
            box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35);
        }

        .shutdown-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 6px 14px rgba(239, 68, 68, 0.4);
        }

        .shutdown-btn:disabled {
            cursor: not-allowed;
            opacity: 0.6;
            box-shadow: none;
            transform: none;
        }

        .graph-view {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        #heatingView {
            gap: 4px;
        }

        #graphContainer,
        #heatingGraphContainer {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .graph-row {
            background: white;
            border-radius: 15px;
            padding: 14px 18px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.2);
        }

        #heatingGraphContainer .graph-row {
            padding-top: 4px;
        }

        .graph-title {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.95em;
            font-weight: 700;
            color: #1f2937;
            margin-bottom: 6px;
        }

        .graph-title-main {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .graph-title-left {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .graph-title-center {
            flex: 1;
            text-align: center;
            font-weight: 600;
        }

        .graph-title-energy {
            flex: 1;
            text-align: center;
            font-weight: 600;
            font-size: 0.85em;
            color: #374151;
        }

        .graph-title-latest {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 0.8em;
            font-weight: 600;
        }

        .graph-title--sensor .graph-title-center {
            font-size: 0.85em;
            font-weight: 600;
            color: #6b7280;
        }

        .graph-title--sensor .graph-title-latest {
            font-size: 0.95em;
            font-weight: 700;
        }

        .latest-item {
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .graph-legend {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            font-size: 0.8em;
            color: #6b7280;
            margin-bottom: 6px;
        }

        .legend-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 6px;
        }

        .graph-canvas {
            width: 100%;
            height: 200px;
            display: block;
        }

        .settings-card {
            background: white;
            border-radius: 15px;
            padding: 24px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.2);
            display: flex;
            flex-direction: column;
            gap: 18px;
        }

        .settings-title {
            font-size: 1.3em;
            font-weight: 700;
            color: #111827;
        }

        .settings-subtitle {
            font-size: 0.9em;
            color: #6b7280;
        }

        .settings-row {
            display: grid;
            grid-template-columns: minmax(160px, 220px) 1fr minmax(80px, 110px);
            gap: 12px;
            align-items: center;
            padding-bottom: 18px;
            border-bottom: 1px solid #e5e7eb;
        }

        .settings-label {
            font-weight: 600;
            color: #374151;
        }

        .settings-range {
            width: 100%;
            accent-color: #111827;
        }

        .settings-value {
            font-weight: 700;
            color: #111827;
            text-align: right;
        }

        .station-interval {
            min-width: 0;
            border: 0;
            padding-bottom: 18px;
            border-bottom: 1px solid #e5e7eb;
        }

        .station-interval legend {
            margin-bottom: 10px;
        }

        .station-interval-options {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 12px;
        }

        .station-interval-options--three {
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }

        .station-interval-options--five {
            grid-template-columns: repeat(5, minmax(0, 1fr));
        }

        .station-interval-options--storage {
            display: grid;
            grid-template-columns: repeat(5, 14ch);
            column-gap: 8ch;
            row-gap: 12px;
        }

        .station-interval-options label {
            display: flex;
            align-items: center;
            gap: 8px;
            min-width: 0;
            color: #111827;
            line-height: 1.35;
            cursor: pointer;
        }

        .station-interval-options input {
            flex: 0 0 auto;
            width: 18px;
            height: 18px;
            accent-color: #111827;
        }

        .settings-actions {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .settings-status {
            font-size: 0.85em;
            color: #6b7280;
        }

        .settings-divider {
            width: 100%;
            height: 1px;
            background: #e5e7eb;
        }

        .settings-recovery {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .settings-recovery-title {
            font-size: 1em;
            font-weight: 700;
            color: #111827;
        }

        .settings-recovery-subtitle {
            font-size: 0.85em;
            color: #6b7280;
        }

        .restart-btn {
            background: #ef4444;
            border-color: #ef4444;
            color: #fff;
        }

        .restart-btn:hover {
            background: #dc2626;
            border-color: #dc2626;
        }

        @media (max-width: 720px) {
            .heating-controls {
                grid-template-columns: minmax(0, 1fr);
                overflow-x: auto;
            }

            .heating-controls .control-left,
            .heating-room-controls,
            .heating-source-controls,
            .heating-temperatures {
                grid-column: 1;
                grid-row: auto;
            }

            .heating-room-controls {
                justify-content: flex-start;
            }

            .heating-temperatures {
                justify-content: flex-start;
            }

            .control-spacer {
                display: none;
            }

            .heating-controls {
                align-items: flex-start;
            }

            .settings-row {
                grid-template-columns: 1fr;
                align-items: start;
            }

            .settings-value {
                text-align: left;
            }

            .station-interval-options {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }

            .station-interval-options--storage {
                grid-template-columns: repeat(2, minmax(0, 1fr));
                column-gap: 3ch;
            }
        }

