/* ══════════════════════════════════════════════════
   Shared admin styles — used by /admin and all sub-pages
   ══════════════════════════════════════════════════ */

.admin-page {
    padding: 16px;
    color: #e6edf3;
    min-height: 100vh;
}

.admin-header {
    background: linear-gradient(135deg, #161b22, #0d1117);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #e6edf3;
}

.admin-back {
    color: #8b949e;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border: 1px solid #30363d;
    border-radius: 4px;
    transition: color 0.15s, border-color 0.15s;
}

.admin-back:hover {
    color: #e6edf3;
    border-color: #8b949e;
}

/* ── Sections ── */

.admin-section {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.2rem;
}

.admin-section-header {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.admin-section-header.history {
    background: linear-gradient(90deg, #1a4a2e, #0d1117);
    color: #6fdd8b;
    border-bottom: 2px solid #2ea043;
}

.admin-section-header.modbus {
    background: linear-gradient(90deg, #1a3a5c, #0d1117);
    color: #79c0ff;
    border-bottom: 2px solid #388bfd;
}

.admin-section-header.config {
    background: linear-gradient(90deg, #3d2b00, #0d1117);
    color: #f0883e;
    border-bottom: 2px solid #d29922;
}

.admin-section-header.interlocks {
    background: linear-gradient(90deg, #5c1a1a, #0d1117);
    color: #f85149;
    border-bottom: 2px solid #da3633;
}

.admin-section-body {
    padding: 1rem;
}

/* ── Stats grid ── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-label {
    color: #8b949e;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-value {
    color: #e6edf3;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Consolas', 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
}

.stat-value.dim {
    font-size: 0.85rem;
    color: #8b949e;
    font-weight: 400;
}

/* ── Modbus table ── */

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-bottom: 1rem;
}

.admin-table th {
    text-align: left;
    color: #8b949e;
    font-weight: 700;
    font-size: 0.68rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #30363d;
}

.admin-table td {
    padding: 0.45rem 0.6rem;
    color: #c9d1d9;
    border-bottom: 1px solid #21262d;
}

.admin-table .channel-name {
    font-weight: 700;
    color: #e6edf3;
}

.admin-table .mono {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.78rem;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.running {
    background: #2ea043;
    box-shadow: 0 0 4px #2ea043;
}

.status-dot.stopped {
    background: #da3633;
    box-shadow: 0 0 4px #da3633;
}

/* ── Config section ── */

.config-warning {
    background: #2d1b00;
    border: 1px solid #d29922;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: #f0883e;
    margin-bottom: 1rem;
}

.config-section-divider {
    font-size: 0.68rem;
    font-weight: 700;
    color: #8b949e;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0.5rem 0 0.25rem;
    margin-top: 0.5rem;
    border-top: 1px solid #21262d;
}

.config-section-divider:first-child {
    margin-top: 0;
    border-top: none;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 0;
}

.config-key {
    color: #c9d1d9;
    font-size: 0.8rem;
    min-width: 200px;
    font-family: 'Consolas', 'Courier New', monospace;
}

.config-input {
    flex: 1;
    max-width: 400px;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #e6edf3;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.82rem;
    font-family: 'Consolas', 'Courier New', monospace;
}

.config-input:focus {
    border-color: #388bfd;
    box-shadow: 0 0 0 2px rgba(56, 139, 253, 0.25);
    outline: none;
}

.config-modified {
    font-size: 0.65rem;
    font-weight: 700;
    color: #d29922;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ── Shared action bar & buttons ── */

.admin-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.75rem;
    flex-wrap: wrap;
}

.action-separator {
    color: #30363d;
    font-size: 1rem;
    user-select: none;
}

.admin-btn {
    background: #21262d;
    border: 1px solid #30363d;
    color: #c9d1d9;
    border-radius: 4px;
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.admin-btn:hover:not(:disabled) {
    background: #30363d;
    border-color: #8b949e;
    color: #e6edf3;
}

.admin-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.admin-btn.danger {
    border-color: #da3633;
    color: #f85149;
}

.admin-btn.danger:hover:not(:disabled) {
    background: #3d1214;
    border-color: #f85149;
}

.admin-btn.primary {
    background: #1a4a2e;
    border-color: #2ea043;
    color: #6fdd8b;
}

.admin-btn.primary:hover:not(:disabled) {
    background: #2ea043;
    color: #ffffff;
}

.admin-label {
    font-size: 0.75rem;
    color: #8b949e;
}

.admin-select {
    background: #0d1117;
    border: 1px solid #30363d;
    color: #c9d1d9;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
}

.admin-select:focus {
    border-color: #388bfd;
    outline: none;
}

.admin-select-narrow {
    max-width: 200px;
}

.admin-result {
    margin-top: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #8b949e;
    font-family: 'Consolas', 'Courier New', monospace;
}

.admin-muted {
    color: #484f58;
    font-size: 0.82rem;
    padding: 0.5rem 0;
}

.admin-confirm {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #3d1214;
    border: 1px solid #da3633;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #f85149;
}

/* ── Interlocks ── */

.interlock-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #8b949e;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0.6rem 0 0.25rem;
    margin-top: 0.5rem;
    border-top: 1px solid #21262d;
}

.interlock-group-label:first-child {
    margin-top: 0;
    border-top: none;
}

.interlock-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
    flex-wrap: wrap;
}

.interlock-row.disabled { opacity: 0.5; }

.interlock-label {
    color: #e6edf3;
    font-size: 0.82rem;
    font-weight: 600;
    min-width: 180px;
}

.interlock-threshold {
    width: 80px;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #e6edf3;
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    font-size: 0.78rem;
    font-family: 'Consolas', 'Courier New', monospace;
    text-align: right;
}

.interlock-threshold:focus {
    border-color: #388bfd;
    box-shadow: 0 0 0 2px rgba(56, 139, 253, 0.25);
    outline: none;
}

.interlock-threshold:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.interlock-unit {
    color: #8b949e;
    font-size: 0.72rem;
    min-width: 50px;
}

.interlock-desc {
    color: #484f58;
    font-size: 0.7rem;
    flex: 1;
    min-width: 200px;
}

/* Toggle switch */

.interlock-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}

.interlock-toggle input { opacity: 0; width: 0; height: 0; }

.interlock-slider {
    position: absolute;
    inset: 0;
    background: #30363d;
    border-radius: 20px;
    transition: background 0.2s;
}

.interlock-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: #8b949e;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.interlock-toggle input:checked + .interlock-slider {
    background: #1a4a2e;
}

.interlock-toggle input:checked + .interlock-slider::before {
    transform: translateX(16px);
    background: #2ea043;
}

/* ── Admin nav grid (hub page) ── */

.admin-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.admin-nav-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 1.2rem;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.admin-nav-card:hover {
    border-color: #8b949e;
    background: #1c2128;
}

.admin-nav-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.admin-nav-icon.interlocks { color: #f85149; }
.admin-nav-icon.config { color: #f0883e; }
.admin-nav-icon.modbus { color: #79c0ff; }
.admin-nav-icon.history { color: #6fdd8b; }

.admin-nav-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e6edf3;
}

.admin-nav-desc {
    font-size: 0.75rem;
    color: #8b949e;
    line-height: 1.3;
}

/* ── VFD / Actuator / Sensor section headers ── */

.admin-section-header.vfd {
    background: linear-gradient(90deg, #1a3a5c, #0d1117);
    color: #79c0ff;
    border-bottom: 2px solid #388bfd;
}

.admin-section-header.actuator {
    background: linear-gradient(90deg, #3d2b00, #0d1117);
    color: #f0883e;
    border-bottom: 2px solid #d29922;
}

.admin-section-header.sensor-system {
    background: linear-gradient(90deg, #2d1a4e, #0d1117);
    color: #d2a8ff;
    border-bottom: 2px solid #8b5cf6;
}

.admin-section-header.sensor-bin {
    background: linear-gradient(90deg, #1a4a2e, #0d1117);
    color: #6fdd8b;
    border-bottom: 2px solid #2ea043;
}

.admin-nav-icon.vfds { color: #79c0ff; }
.admin-nav-icon.actuators { color: #f0883e; }
.admin-nav-icon.sensors { color: #d2a8ff; }

/* ── Device config grid (channel/profile rows) ── */

.device-config-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.device-config-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.device-config-label {
    color: #8b949e;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 80px;
}

.config-input-narrow {
    max-width: 200px;
}

/* ── Measurement point blocks ── */

.mp-block {
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.mp-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #e6edf3;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #21262d;
}

.mp-sensor-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.mp-sensor-column {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mp-role {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    width: fit-content;
}

.mp-role.primary {
    background: #1a4a2e;
    color: #6fdd8b;
}

.mp-role.backup {
    background: #3d2b00;
    color: #f0883e;
}

.mp-role.floor {
    background: #1a3a5c;
    color: #79c0ff;
}

.mp-role.exhaust {
    background: #2d1a4e;
    color: #d2a8ff;
}

.mp-sensor-id-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mp-sensor-id-label {
    color: #8b949e;
    font-size: 0.72rem;
    font-weight: 600;
    min-width: 60px;
}

.mp-sensor-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0.25rem;
}

.mp-field-label {
    color: #484f58;
    font-size: 0.72rem;
    min-width: 60px;
}

/* Plenum sub-header within bin blocks */

.mp-plenum-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #8b949e;
    padding: 0.5rem 0 0.15rem;
    border-top: 1px solid #21262d;
    margin-top: 0.5rem;
}

.mp-plenum-label:first-of-type {
    margin-top: 0;
    border-top: none;
}

/* Sensor enabled toggle (compact) */

.sensor-toggle {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
}

.sensor-toggle input { opacity: 0; width: 0; height: 0; }

.sensor-toggle-slider {
    position: absolute;
    inset: 0;
    background: #30363d;
    border-radius: 18px;
    transition: background 0.2s;
}

.sensor-toggle-slider::before {
    content: '';
    position: absolute;
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background: #8b949e;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.sensor-toggle input:checked + .sensor-toggle-slider {
    background: #1a4a2e;
}

.sensor-toggle input:checked + .sensor-toggle-slider::before {
    transform: translateX(14px);
    background: #2ea043;
}

/* Disabled sensor fields */

.mp-sensor-field.sensor-disabled {
    opacity: 0.4;
    pointer-events: none;
}
