/* SPM Energy Command — Engineering Theme v2.1 */
/* Offline: Inter + JetBrains Mono (local woff2) */

@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/public/fonts/inter-regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/public/fonts/inter-semibold.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/public/fonts/inter-bold.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/public/fonts/JetBrainsMono-Regular.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/public/fonts/JetBrainsMono-Medium.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('/public/fonts/JetBrainsMono-Bold.woff2') format('woff2'); }

*, *::before, *::after { box-sizing: border-box; }

body {
    background: #06080f;
    color: #e2e8f0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
    padding-bottom: 40px;
}

.mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* ===== HEADER ===== */
.header {
    background: rgba(8, 10, 18, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    position: sticky;
    top: 0;
    z-index: 40;
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: rgba(15, 18, 30, 0.8);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 14px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}
.stat-card:hover { border-color: rgba(255,255,255,0.08); transform: translateY(-1px); }
.stat-card.green::before { background: linear-gradient(90deg, #10b981, #059669); }
.stat-card.red::before { background: linear-gradient(90deg, #ef4444, #dc2626); }
.stat-card.red { animation: alarm-pulse 2s ease-in-out infinite; }
@keyframes alarm-pulse {
    0%, 100% { background: rgba(15, 18, 30, 0.8); border-color: rgba(239, 68, 68, 0.1); }
    50% { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.25); }
}
.stat-card.blue::before { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.stat-card.amber::before { background: linear-gradient(90deg, #f59e0b, #d97706); }
.stat-card.amber { animation: amber-pulse 3s ease-in-out infinite; }
@keyframes amber-pulse {
    0%, 100% { background: rgba(15, 18, 30, 0.8); border-color: rgba(245, 158, 11, 0.1); }
    50% { background: rgba(245, 158, 11, 0.05); border-color: rgba(245, 158, 11, 0.2); }
}
.stat-card.orange::before { background: linear-gradient(90deg, #f97316, #ea580c); }

.stat-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.stat-icon.green { background: rgba(16,185,129,0.1); color: #10b981; }
.stat-icon.red { background: rgba(239,68,68,0.1); color: #ef4444; }
.stat-icon.blue { background: rgba(59,130,246,0.1); color: #3b82f6; }
.stat-icon.orange { background: rgba(249,115,22,0.1); color: #f97316; }
.stat-icon.amber { background: rgba(245,158,11,0.1); color: #f59e0b; }

.stat-number {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    line-height: 1.1;
}
.stat-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    margin-top: 4px;
}

/* ===== CARD ===== */
.card {
    background: rgba(15, 18, 30, 0.8);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 14px;
}

/* ===== BUTTONS ===== */
.btn-orange {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 7px 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-orange:hover { background: linear-gradient(135deg, #ea580c, #c2410c); transform: translateY(-1px); }

.btn-ghost {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: #94a3b8;
    border-radius: 10px;
    padding: 7px 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; border-color: rgba(255,255,255,0.1); }

.btn-link { text-decoration: none; transition: color 0.2s; }

/* ===== TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
}
.data-table thead th {
    background: rgba(15, 18, 30, 0.9);
    color: #64748b;
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}
.data-table .text-center,
.data-table thead th.text-center,
.data-table tbody td.text-center { text-align: center; }
.data-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.02);
    transition: background 0.15s;
}
.data-table tbody tr:hover { background: rgba(249,115,22,0.04); }
.data-table tbody td {
    padding: 7px 10px;
    color: #cbd5e1;
    white-space: nowrap;
}

/* ===== BADGES ===== */
.badge-active {
    color: #10b981;
    font-size: 0.68rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-active::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #10b981; }
.badge-inactive {
    color: #ef4444;
    font-size: 0.68rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-inactive::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #ef4444; }

/* ===== TARIFF COLORS ===== */
.tariff-ht { color: #f87171; font-weight: 500; }
.tariff-nt { color: #4ade80; font-weight: 500; }

/* ===== FORM CONTROLS ===== */
.search-input {
    background: rgba(15, 18, 30, 0.8);
    border: 1px solid rgba(255,255,255,0.06);
    color: #e2e8f0;
    border-radius: 10px;
    padding: 7px 14px;
    transition: all 0.2s;
    outline: none;
}
.search-input:focus { border-color: #f97316; box-shadow: 0 0 0 2px rgba(249,115,22,0.15); }
.search-input::placeholder { color: #475569; }

.filter-select {
    background: rgba(15, 18, 30, 0.8);
    border: 1px solid rgba(255,255,255,0.06);
    color: #e2e8f0;
    border-radius: 10px;
    padding: 7px 14px;
    transition: all 0.2s;
    outline: none;
    cursor: pointer;
}
.filter-select:focus { border-color: #f97316; box-shadow: 0 0 0 2px rgba(249,115,22,0.15); }

/* ===== NAV CARDS (Dashboard) ===== */
.nav-card {
    background: rgba(15, 18, 30, 0.8);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 14px;
    padding: 24px 20px;
    text-decoration: none;
    display: block;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.nav-card:hover {
    border-color: rgba(249,115,22,0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(249,115,22,0.08);
}
.nav-card-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.nav-card-title { font-weight: 700; font-size: 1.05rem; color: #f1f5f9; }
.nav-card-desc { font-size: 0.75rem; color: #64748b; margin-top: 3px; line-height: 1.4; }
.nav-card-meta { font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; color: #475569; margin-top: 8px; }

/* ===== MODAL ===== */
.modal-backdrop { background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); }
.modal-content {
    background: #0d1017;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

/* ===== EXPORT DROPDOWN ===== */
.export-dropdown {
    position: absolute;
    right: 0;
    margin-top: 6px;
    min-width: 180px;
    background: #0d1017;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    z-index: 50;
    overflow: hidden;
}
.export-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: #94a3b8;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.15s;
}
.export-dropdown a:hover { background: rgba(255,255,255,0.04); color: #e2e8f0; }

/* ===== PAGINATION ===== */
.pagination-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: #94a3b8;
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.pagination-btn:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }

/* ===== PULSE DOT ===== */
.pulse-dot { animation: pulse-glow 2s ease-in-out infinite; }
@keyframes pulse-glow {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(59,130,246,0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ================================================================
   MOBILE RESPONSIVE — only activates on screens ≤768px
   Desktop styles above remain UNTOUCHED
   ================================================================ */

@media (max-width: 768px) {
    /* ===== HEADER — tighter padding ===== */
    .header > div { padding-left: 12px !important; padding-right: 12px !important; }
    .header h1 { font-size: 0.9rem; }

    /* ===== MAIN PADDING ===== */
    main { padding-left: 10px !important; padding-right: 10px !important; }

    /* ===== STAT CARDS — smaller icons/numbers ===== */
    .stat-card { border-radius: 10px; }
    .stat-number { font-size: 1.2rem !important; }
    .stat-label { font-size: 9px; margin-top: 2px; }
    .stat-icon { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }

    /* ===== NAV CARDS (Dashboard) ===== */
    .nav-card { padding: 16px 14px; border-radius: 10px; }
    .nav-card-icon { width: 36px; height: 36px; font-size: 14px; }
    .nav-card-title { font-size: 0.9rem; }
    .nav-card-desc { font-size: 0.7rem; }

    /* ===== FILTER BAR — stack on mobile ===== */
    .filter-bar { flex-wrap: wrap; gap: 8px; }
    .filter-bar .search-input { width: 100% !important; font-size: 14px; }
    .filter-bar .filter-select { font-size: 13px; padding: 6px 10px; flex: 1; min-width: 0; }

    /* ===== TABLE — scroll indicator ===== */
    .table-scroll { position: relative; }
    .table-scroll::after {
        content: '\2190  Scroll  \2192';
        position: sticky;
        left: 0;
        bottom: 0;
        display: block;
        text-align: center;
        font-size: 10px;
        color: #475569;
        padding: 4px;
        background: rgba(15,18,30,0.9);
        border-top: 1px solid rgba(255,255,255,0.04);
    }
    .data-table { font-size: 0.65rem; }
    .data-table thead th {
        font-size: 0.58rem;
        padding: 7px 6px;
        letter-spacing: 0.03em;
    }
    .data-table tbody td { padding: 6px 6px; font-size: 0.62rem; }

    /* ===== BADGES ===== */
    .badge-active, .badge-inactive { font-size: 0.6rem; }

    /* ===== BUTTONS ===== */
    .btn-orange { padding: 6px 10px; font-size: 0.75rem; border-radius: 8px; }
    .btn-ghost { padding: 6px 10px; font-size: 0.72rem; border-radius: 8px; }

    /* ===== FORM CONTROLS — 14px prevents iOS auto-zoom ===== */
    .search-input { padding: 8px 12px; font-size: 14px; }
    .filter-select { padding: 8px 12px; font-size: 14px; }

    /* ===== MODAL ===== */
    .modal-content { border-radius: 12px; }

    /* ===== PAGINATION ===== */
    .pagination-btn { padding: 6px 10px; font-size: 0.72rem; }

    /* ===== EXPORT DROPDOWN ===== */
    .export-dropdown { min-width: 160px; }
    .export-dropdown a { padding: 10px 12px; font-size: 0.75rem; }

    /* ===== TARIFF COLORS ===== */
    .tariff-ht, .tariff-nt { font-size: 0.62rem; }
}

/* Small phones (≤375px) */
@media (max-width: 375px) {
    .stat-number { font-size: 1rem !important; }
    .data-table { font-size: 0.58rem; }
    .data-table thead th { font-size: 0.52rem; padding: 5px 4px; }
    .data-table tbody td { padding: 5px 4px; font-size: 0.55rem; }
}

/* ===== VOLTAGE ALARM ===== */
.alarm-critical {
    background: rgba(239, 68, 68, 0.12) !important;
    border-left: 3px solid #ef4444;
}
.alarm-critical:hover {
    background: rgba(239, 68, 68, 0.2) !important;
}
.alarm-warning {
    background: rgba(249, 115, 22, 0.10) !important;
    border-left: 3px solid #f97316;
}
.alarm-warning:hover {
    background: rgba(249, 115, 22, 0.18) !important;
}
.alarm-icon {
    font-size: 0.65rem;
    margin-right: 2px;
}

/* Footer */
.site-footer {
    width: 100% !important;
    text-align: center !important;
    padding: 10px 16px;
    color: #475569;
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-top: 1px solid rgba(71, 85, 105, 0.08);
    font-family: 'JetBrains Mono', 'Inter', monospace;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    margin-top: auto !important;
}
.site-footer span {
    color: #64748b;
}

