* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        .header {
            text-align: center;
            color: white;
            margin-bottom: 40px;
        }
        .header h1 {
            font-size: 3em;
            margin-bottom: 10px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
        }
        .header p {
            font-size: 1.2em;
            opacity: 0.9;
        }
	        .nav-links {
	            margin-top: 14px;
	            display: flex;
	            justify-content: center;
	            gap: 12px;
	            flex-wrap: wrap;
	        }
	        .nav-links a {
	            display: inline-block;
	            padding: 10px 14px;
	            border-radius: 10px;
	            text-decoration: none;
	            color: #fff;
	            font-weight: 800;
	            background: rgba(255,255,255,0.15);
	            border: 1px solid rgba(255,255,255,0.25);
	        }
	        .nav-links a:hover {
	            background: rgba(255,255,255,0.25);
	        }
        .nav-links button {
            display: inline-block;
            padding: 10px 14px;
            border-radius: 10px;
            text-decoration: none;
            color: #fff;
            font-weight: 800;
            background: rgba(255,255,255,0.15);
            border: 1px solid rgba(255,255,255,0.25);
            cursor: pointer;
        }
        .nav-links button:hover {
            background: rgba(255,255,255,0.25);
        }
        .cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        .card {
            background: white;
            border-radius: 12px;
            padding: 25px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            transition: transform 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
        }
        .card h2 {
            color: #667eea;
            margin-bottom: 15px;
            font-size: 1.5em;
        }
        .stat {
            display: flex;
            justify-content: space-between;
            margin: 10px 0;
            padding: 10px;
            background: #f7f7f7;
            border-radius: 6px;
        }
        .stat-label {
            font-weight: 600;
            color: #555;
        }
        .stat-value {
            color: #667eea;
            font-weight: 700;
        }
        .status-indicator {
            display: inline-block;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            margin-right: 8px;
            animation: pulse 2s infinite;
        }
        .status-online {
            background: #22c55e;
        }
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }
        .loading {
            text-align: center;
            color: white;
            font-size: 1.2em;
        }
        .error {
            background: #ef4444;
            color: white;
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
        }
        .is-hidden {
            display: none !important;
        }
        .section-header {
            color: white;
            font-size: 2em;
            margin: 40px 0 8px 0;
            text-align: center;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
        }
        .section-desc {
            color: rgba(255,255,255,0.82);
            font-size: 0.98em;
            text-align: center;
            margin: 0 0 28px 0;
            line-height: 1.5;
        }
        .subsection-header {
            color: white;
            font-size: 1.15em;
            font-weight: 700;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            margin: 28px 0 6px 0;
            padding-bottom: 6px;
            border-bottom: 2px solid rgba(255,255,255,0.18);
        }
        .subsection-desc {
            color: rgba(255,255,255,0.75);
            font-size: 0.9em;
            margin: 0 0 14px 0;
            line-height: 1.5;
        }
        .subsection-desc code {
            background: rgba(255,255,255,0.12);
            border-radius: 4px;
            padding: 1px 5px;
            font-size: 0.92em;
        }
        .upload-zone {
            background: white;
            border: 3px dashed #667eea;
            border-radius: 12px;
            padding: 40px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-bottom: 20px;
        }
        .upload-zone:hover {
            background: #f7f7ff;
            border-color: #764ba2;
        }
        .upload-zone.dragover {
            background: #e0e7ff;
            border-color: #4f46e5;
            transform: scale(1.02);
        }
        .upload-icon {
            font-size: 4em;
            color: #667eea;
            margin-bottom: 15px;
        }
        .upload-text {
            color: #555;
            font-size: 1.1em;
            margin-bottom: 10px;
        }
        .upload-limit {
            color: #999;
            font-size: 0.9em;
        }
        .file-input {
            display: none;
        }
        .file-list {
            display: grid;
            gap: 15px;
        }
        .file-item {
            background: white;
            border-radius: 8px;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            transition: all 0.2s ease;
        }
        .file-item:hover {
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
            transform: translateX(5px);
        }
        .file-info {
            flex: 1;
        }
        .file-name {
            font-weight: 600;
            color: #333;
            margin-bottom: 5px;
            font-size: 1.05em;
        }
        .file-meta {
            color: #999;
            font-size: 0.85em;
        }
        .file-actions {
            display: flex;
            gap: 10px;
        }
        .btn {
            padding: 8px 16px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.9em;
            font-weight: 600;
            transition: all 0.2s ease;
        }
        .btn-download {
            background: #667eea;
            color: white;
        }
        .btn-download:hover {
            background: #5568d3;
        }
        .btn-delete {
            background: #ef4444;
            color: white;
        }
        .btn-delete:hover {
            background: #dc2626;
        }
        .btn-upload {
            background: #22c55e;
            color: white;
            padding: 12px 24px;
            font-size: 1em;
            margin-top: 10px;
        }
        .btn-upload:hover {
            background: #16a34a;
        }
        .success {
            background: #22c55e;
            color: white;
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
            display: none;
        }
        .progress-bar {
            width: 100%;
            height: 4px;
            background: #e5e7eb;
            border-radius: 2px;
            overflow: hidden;
            margin-top: 10px;
            display: none;
        }
        .progress-fill {
            height: 100%;
            background: #667eea;
            transition: width 0.3s ease;
            width: 0%;
        }
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin-bottom: 20px;
        }
        .stat-card {
            background: white;
            border-radius: 8px;
            padding: 15px;
            text-align: center;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        .stat-card-value {
            font-size: 2em;
            font-weight: 700;
            color: #667eea;
            margin-bottom: 5px;
        }
        .stat-card-label {
            color: #666;
            font-size: 0.9em;
        }

        /* ─── Compact gateway status card ─────────────────────────────── */
        .header { margin-bottom: 20px; }
        .section-header { margin: 22px 0 6px 0; font-size: 1.5em; }
        .section-desc { margin: 0 0 14px 0; }
        .subsection-header { margin: 14px 0 4px 0; }
        .subsection-desc { margin: 0 0 8px 0; }
        .cards {
            gap: 14px;
            margin-bottom: 16px;
            align-items: start;
        }

        .gw-status-card { padding: 18px 20px; }
        .gw-card-title {
            color: #667eea;
            font-size: 1.1em;
            font-weight: 700;
            margin-bottom: 12px;
            padding-bottom: 8px;
            border-bottom: 1px solid #eee;
        }
        .gateway-status-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px 12px;
            align-items: start;
        }
        .gw-group {
            padding: 10px 12px;
            border: 1px solid #eceffc;
            border-radius: 10px;
            background: #fafbff;
            margin-bottom: 0;
            min-width: 0;
        }
        .gw-group:last-child { padding-right: 12px; }
        .gw-group-label {
            font-size: 0.68em;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.07em;
            color: #bbb;
            margin-bottom: 6px;
            padding-bottom: 4px;
            border-bottom: 1px solid #f2f2f2;
        }
        .gw-row {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            gap: 8px;
            padding: 2px 0;
            font-size: 0.82em;
        }
        .gw-row .stat-label {
            color: #888;
            font-weight: 500;
            flex: 0 0 auto;
        }
        .gw-row .stat-value {
            color: #667eea;
            font-weight: 700;
            font-size: 0.98em;
            text-align: right;
            word-break: break-word;
        }
        .inventory-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 12px;
        }
        .inventory-panel {
            background: #fafafa;
            border: 1px solid #eee;
            border-radius: 10px;
            padding: 12px 14px;
        }
        .inventory-list {
            margin-top: 10px;
            display: grid;
            gap: 8px;
        }
        .inventory-item {
            border: 1px solid #ececec;
            border-radius: 8px;
            padding: 8px 10px;
            background: white;
        }
        .inventory-item-title {
            color: #334155;
            font-weight: 700;
            font-size: 0.92em;
        }
        .inventory-item-meta {
            color: #64748b;
            font-size: 0.8em;
            margin-top: 3px;
            line-height: 1.35;
        }
        .inventory-empty {
            color: #94a3b8;
            font-size: 0.85em;
        }
        .inventory-empty-error {
            color: #ef4444;
        }
        .inventory-item-title-reader {
            color: #0f766e;
            font-weight: 700;
        }
        .inventory-item-title-boot {
            color: #22c55e;
            font-weight: 700;
        }
        .inventory-item-title-vault {
            color: #a855f7;
            font-weight: 700;
        }
        .inventory-item-title-default-target {
            color: #3b82f6;
            font-weight: 700;
        }
        .inventory-item-title-empty {
            color: #94a3b8;
            font-weight: 700;
        }
        .inventory-item-meta-strong {
            font-weight: 600;
        }
        .inventory-item-meta-default-target {
            color: #3b82f6;
            font-weight: 600;
        }
        .inventory-item-meta-empty-slot {
            color: #94a3b8;
            font-weight: 600;
        }
        .inventory-item-warning {
            color: #92400e;
            font-style: italic;
        }
        .process-card {
            padding: 18px 20px;
        }
        .process-controls {
            display: grid;
            grid-template-columns: minmax(280px, 420px) 1fr;
            gap: 12px;
        }
        .service-panel,
        .process-tree-panel {
            background: #fafafa;
            border: 1px solid #eee;
            border-radius: 10px;
            padding: 12px 14px;
        }
        .service-list,
        .process-tree-list {
            margin-top: 10px;
            display: grid;
            gap: 8px;
        }
        .service-item,
        .process-row-card {
            border: 1px solid #ececec;
            border-radius: 8px;
            background: white;
            padding: 10px 12px;
        }
        .service-item-head {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .process-row-head {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 10px;
        }
        .service-title,
        .process-title {
            color: #334155;
            font-weight: 700;
            font-size: 0.92em;
        }
        .service-meta,
        .process-meta,
        .process-cmd {
            color: #64748b;
            font-size: 0.8em;
            margin-top: 3px;
            line-height: 1.35;
        }
        .process-cmd {
            word-break: break-all;
        }
        .service-actions {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            justify-content: flex-start;
        }
        .process-actions {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            justify-content: flex-end;
        }
        .process-tree-toolbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
        }
        .process-tree-summary {
            color: #64748b;
            font-size: 0.82em;
        }
        .btn-service {
            background: #4f46e5;
            color: white;
        }
        .btn-service:hover {
            background: #4338ca;
        }
        .btn-reload {
            background: #0891b2;
        }
        .btn-reload:hover {
            background: #0e7490;
        }
        .btn-restart {
            background: #7c3aed;
        }
        .btn-restart:hover {
            background: #6d28d9;
        }
        .btn-warn {
            background: #f59e0b;
            color: white;
        }
        .btn-warn:hover {
            background: #d97706;
        }
        .service-item-down {
            border-color: #fca5a5;
            background: #fef2f2;
        }
        .service-depends-hint {
            color: #92400e;
            font-style: italic;
        }
        .service-state {
            font-weight: 700;
        }
        .service-state-active {
            color: #22c55e;
        }
        .service-state-down {
            color: #ef4444;
        }
        @media (max-width: 900px) {
            .gateway-status-grid {
                grid-template-columns: 1fr;
            }
            .process-controls {
                grid-template-columns: 1fr;
            }
        }

        /* ─── Hardware reference collapsible ──────────────────────────── */
        .hw-reference-details {
            background: rgba(255,255,255,0.07);
            border: 1px solid rgba(255,255,255,0.16);
            border-radius: 10px;
            margin-bottom: 14px;
        }
        .hw-reference-details summary {
            color: rgba(255,255,255,0.62);
            font-size: 0.83em;
            font-weight: 600;
            cursor: pointer;
            padding: 9px 15px;
            list-style: none;
            -webkit-user-select: none;
            user-select: none;
            letter-spacing: 0.01em;
        }
        .hw-reference-details summary::-webkit-details-marker { display: none; }
        .hw-reference-details summary::marker { display: none; }
        .hw-reference-details summary::before { content: '▶\00a0'; font-size: 0.7em; }
        .hw-reference-details[open] summary::before { content: '▼\00a0'; }
        .hw-reference-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 12px;
            padding: 10px 15px 14px;
            border-top: 1px solid rgba(255,255,255,0.1);
        }
        .hw-group-label {
            font-size: 0.7em;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.07em;
            color: rgba(255,255,255,0.45);
            margin-bottom: 5px;
        }
        .hw-reference-grid .gw-row { font-size: 0.83em; }
        .hw-reference-grid .stat-label { color: rgba(255,255,255,0.5); font-weight: 500; }
        .hw-reference-grid .stat-value { color: rgba(255,255,255,0.88); font-weight: 600; }

        /* ─── SPI two-panel layout ─────────────────────────────────────── */
        .spi-panels {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
            gap: 14px;
            margin-bottom: 14px;
        }
        .spi-sub-divider {
            border: none;
            border-top: 1px solid #eee;
            margin: 10px 0 8px;
        }
        .spi-sub-label {
            font-size: 0.72em;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.07em;
            color: #bbb;
            margin-bottom: 6px;
        }
        .usb-mode-btns {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-top: 6px;
        }
        .btn-reset-usb {
            margin-top: 8px;
            width: 100%;
            background: #dc2626;
        }
        .spi-action-result {
            font-size: 0.85em;
            font-weight: 600;
            color: #475569;
        }
        .spi-note {
            font-size: 0.78em;
            color: #888;
            margin-top: 8px;
            line-height: 1.4;
        }

        /* ─── Compact storage stats ────────────────────────────────────── */
        .storage-chips-grid {
            grid-template-columns: repeat(auto-fill, minmax(100px, auto)) !important;
            gap: 8px !important;
            margin-bottom: 14px;
        }
        .storage-chip {
            background: rgba(255,255,255,0.13);
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: 18px;
            padding: 6px 14px;
            text-align: center;
            min-width: 90px;
        }
        .storage-chip-val {
            font-size: 1.1em;
            font-weight: 700;
            color: #fff;
            display: block;
            line-height: 1.2;
        }
        .storage-chip-lbl {
            font-size: 0.75em;
            color: rgba(255,255,255,0.6);
            display: block;
            margin-top: 2px;
        }
        .gw-stat-emphasis {
            font-weight: 700;
        }
        .dashboard-link-card {
            cursor: pointer;
            text-decoration: none;
            color: inherit;
            display: block;
        }
        .dashboard-link-title {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .dashboard-link-icon {
            font-size: 1.3em;
        }
        .gw-group-top {
            margin-top: 10px;
        }
        .section-top-gap {
            margin-top: 14px;
        }
        .gw-group-label-top {
            margin-top: 16px;
        }
        .gw-group-label-toolbar {
            margin: 0;
            padding: 0;
            border: 0;
        }
        .link-button {
            display: inline-block;
            padding: 7px 18px;
            border-radius: 8px;
            background: #764ba2;
            color: #fff;
            font-weight: 700;
            text-decoration: none;
            font-size: 0.9em;
        }
        .hw-reference-panel {
            padding: 10px 15px 14px;
            border-top: 1px solid rgba(255,255,255,0.1);
        }
        .hw-reference-table {
            width: 100%;
            border-collapse: collapse;
            background: rgba(255,255,255,0.96);
            border-radius: 10px;
            overflow: hidden;
            font-size: 0.9em;
        }
        .hw-reference-table thead tr {
            background: #eef2ff;
        }
        .hw-reference-table tbody tr:nth-child(even) {
            background: #fafbff;
        }
        .hw-reference-table th,
        .hw-reference-table td {
            padding: 10px 12px;
            text-align: left;
            color: #334155;
            border-bottom: 1px solid #e5e7eb;
        }
        .hw-reference-table th {
            border-bottom-color: #dbeafe;
        }
        .hw-reference-table tbody tr:last-child td {
            border-bottom: none;
        }
        .hw-reference-table .hw-reference-board {
            color: #0f172a;
            font-weight: 700;
        }
        .spi-details-toggle {
            font-size: 0.5em;
            padding: 8px 12px;
            margin-left: 15px;
            background: rgba(255,255,255,0.2);
            border: 1px solid rgba(255,255,255,0.4);
            color: white;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 700;
        }
        .spi-details-card {
            background: white;
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }
        .spi-details-title {
            color: #667eea;
            margin-top: 0;
        }
        .spi-details-subtitle {
            color: #667eea;
            margin-top: 20px;
            margin-bottom: 10px;
        }
        .spi-details-copy {
            color: #555;
            line-height: 1.6;
        }
        .spi-details-list {
            color: #555;
            line-height: 1.8;
        }
        .spi-details-list-top {
            margin: 15px 0;
        }
        .spi-details-list-bottom {
            margin: 10px 0;
        }
        .spi-details-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.95em;
        }
        .spi-details-table thead tr {
            background: #f7f7f7;
        }
        .spi-details-table th,
        .spi-details-table td {
            padding: 10px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }
        .spi-details-table th {
            border-bottom: 2px solid #ddd;
        }
        .spi-details-table tbody tr:last-child td {
            border-bottom: none;
        }
        .spi-details-code {
            background: #f3f4f6;
            padding: 2px 6px;
            border-radius: 4px;
        }
        .spi-details-code-ok {
            background: #dcfce7;
            color: #166534;
        }
        .spi-details-code-error {
            background: #fee2e2;
            color: #991b1b;
        }
        .cell-strong {
            font-weight: 600;
        }
        .full-width {
            width: 100%;
        }
        .btn-tight-top {
            margin-top: 8px;
        }
        .btn-micro-top {
            margin-top: 4px;
        }
        .form-control {
            width: 100%;
            padding: 7px;
            border-radius: 6px;
            border: 1px solid #ddd;
        }
        .form-control-spacious {
            padding: 9px;
            margin-bottom: 8px;
        }
        .form-control-block {
            display: block;
            width: 100%;
            margin-bottom: 4px;
            font-weight: 600;
            color: #555;
            font-size: 0.9em;
        }
        .preset-description {
            margin-top: 10px;
            padding: 8px 10px;
            background: #f7f7f7;
            border-radius: 6px;
            font-size: 0.9em;
            color: #555;
        }
        .form-grid {
            display: grid;
            gap: 8px;
        }
        .status-value-compact {
            font-size: 0.85em;
        }
        .usb-mode-button {
            border: none;
            padding: 10px;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 700;
            font-size: 0.88em;
            color: white;
        }
        .usb-mode-button-host {
            background: #22c55e;
        }
        .usb-mode-button-vcom {
            background: #f59e0b;
        }
        .inline-code-light {
            background: rgba(255,255,255,0.12);
            border-radius: 4px;
            padding: 1px 5px;
            font-size: 0.93em;
        }
        .empty-state-center {
            text-align: center;
            color: #999;
            padding: 20px;
        }

        /* ─── Runtime state color utilities ──────────────────────────── */
        .clr-success { color: #22c55e; }
        .clr-error   { color: #ef4444; }
        .clr-warn    { color: #f59e0b; }
        .clr-info    { color: #667eea; }
        .clr-muted   { color: #6b7280; }
        .clr-sky     { color: #0ea5e9; }
        .clr-slate   { color: #475569; }
        .clr-danger  { color: #dc2626; }
        .clr-purple  { color: #a78bfa; }

        /* ─── Runtime display utilities ──────────────────────────────── */
        .d-none  { display: none; }
        .d-block { display: block; }
        .d-grid  { display: grid; }
