/*
   Carmeyan Power - Gas Telemetry Dashboard Stylesheet
   Theme: "Industrial Command Console" - deep graphite + brand orange
   ------------------------------------------------------------------
   This file is loaded AFTER style.css, so the :root block below
   re-defines the shared design tokens. Functionality is untouched;
   this is purely presentation.
*/

:root {
    /* ---- Brand orange, full tonal ramp ---- */
    --orange-50:   #FFF4EC;
    --orange-100:  #FFE4CE;
    --orange-200:  #FFC9A3;
    --orange-300:  #FFA76D;
    --orange-400:  #FF8A45;
    --orange-500:  #F3711C;
    --orange-600:  #D9580E;
    --orange-700:  #B4450A;
    --orange-800:  #8A3508;
    --orange-900:  #5C2405;

    --orange:        var(--orange-500);   /* primary brand orange (matches logo) */
    --orange-dark:   var(--orange-600);   /* solid hover / pressed backgrounds */
    --orange-on-dark: var(--orange-300);  /* orange TEXT/icons on dark surfaces (contrast-safe) */
    --orange-soft:   rgba(243, 113, 28, 0.14);  /* tinted backgrounds on dark surfaces */
    --orange-ring:   rgba(243, 113, 28, 0.28);

    --orange-ghost:  rgba(243, 113, 28, 0.08);

    /* ---- Secondary accent (data-viz variety, cool counterpoint to orange) ---- */
    --accent-teal:      #35C7B9;
    --accent-teal-soft: rgba(53, 199, 185, 0.14);

    /* ---- Surfaces: 4-layer graphite depth system (Industrial Glass) ---- */
    --color-bg:        #080A0F; /* app background — deepest */
    --color-surface-0: #10131A; /* recessed wells, page base panels */
    --color-surface:   #161B24; /* cards, sidebar, header (surface 1) */
    --color-surface-2: #1C222E; /* table headers, raised fills (surface 2) */
    --color-surface-3: #252C3A; /* hover wells, inputs, top layer (surface 3) */

    /* ---- Glass primitives ---- */
    --glass-bg:       rgba(16, 19, 26, 0.70);
    --glass-bg-2:     rgba(28, 34, 46, 0.55);
    --glass-blur:     blur(14px);
    --glass-edge:     inset 0 1px 0 rgba(255, 255, 255, 0.06);   /* top highlight */
    --glass-edge-lg:  inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    /* Faint film grain, kept as a token so every surface can share one texture */
    --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/%3E%3C/svg%3E");

    /* ---- Re-map inherited tokens from style.css to the new theme ---- */
    --color-primary:    var(--color-surface-3);
    --color-secondary:  var(--orange-soft);      /* avatar background */
    --color-accent:     var(--orange);
    --color-accent-glow: var(--orange-ring);
    --color-white:      #E8ECF1;                 /* text primary (kept name for JS compat) */
    --color-text-main:  #C6CCD8;                 /* body text (between primary/secondary) */
    --color-text-muted: #9CA3B4;                 /* text secondary */
    --color-text-faint: #5E667A;                 /* text tertiary / inactive icons */
    --color-border:      rgba(255, 183, 130, 0.14); /* warm-tinted hairline, not pure gray */
    --color-border-hover: rgba(255, 183, 130, 0.24);
    --glass-border:      rgba(255, 183, 130, 0.09);

    /* App background: deep graphite with faint brand-colour mesh */
    --bg-gradient-dark:
        radial-gradient(1200px 700px at 100% -10%, rgba(243, 113, 28, 0.06), transparent 60%),
        radial-gradient(1000px 620px at -10% 110%, rgba(53, 199, 185, 0.05), transparent 55%),
        linear-gradient(180deg, #080A0F 0%, #0C0F15 100%);

    /* Typography: engineered, distinctive pairing (self-hosted-friendly Google Fonts) */
    --font-heading: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
    --font-body:    'IBM Plex Sans', sans-serif;
    --font-mono:    'IBM Plex Mono', 'Courier New', monospace;

    /* Shapes */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --backdrop-blur: blur(10px);

    /* Motion: one signature easing curve, used everywhere */
    --ease-standard: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out:      cubic-bezier(0.22, 1, 0.36, 1);
    --transition-fast:   0.15s cubic-bezier(0.22, 1, 0.36, 1);
    --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);

    /* Neutral elevation shadows (dark) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.55);

    /* Brand-tinted glow shadows, reserved for interactive/hover states */
    --shadow-glow-orange:    0 10px 28px rgba(243, 113, 28, 0.22);
    --shadow-glow-orange-sm: 0 4px 14px rgba(243, 113, 28, 0.20);

    /* Status colors — spec anchors, brightened just enough to stay legible on #080A0F */
    --c-safe:        #2FD867;   /* success #22C55E, lifted for dark contrast */
    --c-safe-soft:   rgba(34, 197, 94, 0.13);
    --c-safe-border: rgba(34, 197, 94, 0.38);

    --c-warn:        #F5C518;   /* warning #EAB308, lifted */
    --c-warn-soft:   rgba(234, 179, 8, 0.13);
    --c-warn-border: rgba(234, 179, 8, 0.38);

    --c-danger:        #F0463A;   /* danger #DC2626, lifted for life-safety legibility */
    --c-danger-core:   #DC2626;   /* spec value, for solid fills/glows */
    --c-danger-soft:   rgba(220, 38, 38, 0.16);
    --c-danger-border: rgba(240, 70, 58, 0.42);
}

/* Layout Structure */
.dash-body {
    background: var(--bg-gradient-dark);
    background-color: var(--color-bg);
    background-attachment: fixed;
    font-family: var(--font-body);
    color: var(--color-text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
}

/* Film-grain overlay: a whisper of texture so large dark surfaces never read
   as flat, dead black. Pointer-events off so it never intercepts clicks. */
.dash-body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 300;            /* above chrome so the texture reads uniformly */
    pointer-events: none;    /* never intercepts clicks */
    background-image: var(--noise);
    background-size: 160px 160px;
    opacity: 0.022;
    mix-blend-mode: overlay;
}

.dash-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar Navigation */
.dash-sidebar {
    width: 280px;
    background: var(--color-surface);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition-smooth);
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.2), var(--shadow-xs);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    background:
        linear-gradient(180deg, rgba(243, 113, 28, 0.07) 0%, transparent 100%);
    overflow: hidden;
}

/* Brand glow: an orange halo bleeding up from behind the mark. */
.sidebar-brand::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    width: 160px;
    height: 160px;
    transform: translateY(-50%);
    background: radial-gradient(circle, rgba(243, 113, 28, 0.22), transparent 68%);
    pointer-events: none;
    filter: blur(4px);
}

.sidebar-brand a {
    display: inline-flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* The source lockup is navy-on-transparent — invisible on dark chrome. Render it
   as a premium monochrome-white mark with a subtle orange brand glow so it feels
   native to the dark UI instead of sitting on a cream chip. */
.sidebar-brand img {
    max-width: 100%;
    height: auto;
    filter: brightness(0) invert(0.93) drop-shadow(0 1px 10px rgba(243, 113, 28, 0.30));
}

.sidebar-menu-container {
    flex-grow: 1;
    padding: var(--spacing-lg) 0;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 16px;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--color-text-muted);
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.1px;
    border-radius: 10px;
    position: relative;
    transition: color var(--transition-fast), background var(--transition-fast);
}

/* Sliding active rail: grows from the item's vertical centre when it activates. */
.sidebar-item a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 0;
    border-radius: 0 3px 3px 0;
    background: var(--orange);
    box-shadow: 0 0 10px rgba(243, 113, 28, 0.6);
    transform: translateY(-50%);
    transition: height var(--transition-smooth);
}

.sidebar-item a i {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    color: var(--color-text-faint);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.sidebar-item a:hover {
    color: var(--color-white);
    background: var(--color-surface-3);
}

.sidebar-item a:hover i {
    color: var(--orange-on-dark);
    transform: scale(1.14);
}

.sidebar-item.active a {
    color: var(--orange-on-dark);
    background: linear-gradient(90deg, var(--orange-soft), rgba(243, 113, 28, 0.02));
    font-weight: 700;
}

.sidebar-item.active a::before { height: 60%; }

.sidebar-item.active a i { color: var(--orange-on-dark); }

.sidebar-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--glass-border);
    background: var(--color-surface-2);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--orange-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--orange-on-dark);
    border: 1px solid rgba(243, 113, 28, 0.3);
    font-weight: 700;
    flex-shrink: 0;
}

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--color-white);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.btn-logout {
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    transition: var(--transition-fast);
}

.btn-logout:hover {
    color: var(--c-danger);
    background: var(--c-danger-soft);
}

/* Main Dashboard Area */
.dash-main-content {
    margin-left: 280px;
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - 280px);
    transition: all var(--transition-smooth);
}

/* Header */
.dash-header {
    height: var(--header-height);
    background: rgba(13, 15, 19, 0.72);
    backdrop-filter: var(--backdrop-blur);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 90;
}

.dash-header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.sidebar-toggle-btn {
    display: none;
    font-size: 1.4rem;
    color: var(--color-white);
    cursor: pointer;
    background: transparent;
    border: none;
}

.dash-header-title h2 {
    font-size: 1.5rem;
    margin-bottom: 0;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--color-white);
    text-transform: none;
    font-family: var(--font-heading);
}

.dash-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-selector {
    background: var(--color-surface-3);
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    padding: 10px 16px;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    box-shadow: var(--shadow-xs);
    transition: var(--transition-fast);
}

.site-selector:hover { border-color: var(--color-border-hover); }

.site-selector:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-ring);
}

.sync-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--c-safe);
    background: var(--c-safe-soft);
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid var(--c-safe-border);
}

.sync-dot {
    width: 8px;
    height: 8px;
    background-color: var(--c-safe);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--c-safe);
    animation: pulseGlow 1.5s infinite;
}

.sync-indicator.offline {
    color: var(--c-warn);
    background: var(--c-warn-soft);
    border-color: var(--c-warn-border);
}

.sync-indicator.offline .sync-dot {
    background-color: var(--c-warn);
    box-shadow: 0 0 8px var(--c-warn);
}

/* Page Containers */
.dash-content {
    padding: var(--spacing-lg);
    flex-grow: 1;
    overflow-y: auto;
}

.dash-module {
    display: none;
    animation: fadeInModule var(--transition-smooth) forwards;
}

.dash-module.active {
    display: block;
}

/* Dashboard Grid & Cards */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.metric-card {
    background:
        linear-gradient(180deg, rgba(37, 44, 58, 0.55) 0%, var(--glass-bg) 100%);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-lg);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md), var(--glass-edge);
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-smooth);
    animation: fadeUpIn var(--transition-smooth) both;
}

/* Frosted radial sheen anchored to the top-right corner of each glass card. */
.metric-card::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05), transparent 70%);
    pointer-events: none;
}

.dash-grid .metric-card:nth-child(1) { animation-delay: 0ms; }
.dash-grid .metric-card:nth-child(2) { animation-delay: 40ms; }
.dash-grid .metric-card:nth-child(3) { animation-delay: 80ms; }
.dash-grid .metric-card:nth-child(4) { animation-delay: 120ms; }

.metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--orange), var(--orange-300));
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.metric-card:hover {
    border-color: rgba(243, 113, 28, 0.35);
    box-shadow: var(--shadow-md), var(--shadow-glow-orange-sm);
    transform: translateY(-3px);
}

.metric-card:hover::before { opacity: 1; }

.metric-data {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.9px;
    font-weight: 600;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 2.8rem;
    font-weight: 600;
    color: var(--color-white);
    font-family: var(--font-mono);
    line-height: 1.05;
    letter-spacing: -0.02em;
    text-shadow: 0 0 24px rgba(232, 236, 241, 0.12);
}

/* Status-tinted glass: JS toggles metric-card--danger / --warn on the card when a
   KPI enters an alarm/warning state, giving the hero cards a conditional glow. */
.metric-card--danger {
    border-color: var(--c-danger-border);
    box-shadow: var(--shadow-md), var(--glass-edge), 0 0 0 1px rgba(240, 70, 58, 0.15), 0 12px 40px rgba(220, 38, 38, 0.22);
    animation: fadeUpIn var(--transition-smooth) both, dangerBreathe 2.4s ease-in-out infinite;
}

.metric-card--danger .metric-icon {
    background: var(--c-danger-soft);
    color: var(--c-danger);
}

.metric-card--warn {
    border-color: var(--c-warn-border);
    box-shadow: var(--shadow-md), var(--glass-edge), 0 10px 34px rgba(234, 179, 8, 0.14);
}

@keyframes dangerBreathe {
    0%, 100% { box-shadow: var(--shadow-md), var(--glass-edge), 0 0 0 1px rgba(240, 70, 58, 0.15), 0 12px 40px rgba(220, 38, 38, 0.18); }
    50%      { box-shadow: var(--shadow-md), var(--glass-edge), 0 0 0 1px rgba(240, 70, 58, 0.30), 0 16px 54px rgba(220, 38, 38, 0.34); }
}

.metric-icon {
    font-size: 1.6rem;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--orange-soft);
    color: var(--orange-on-dark);
    transition: all var(--transition-fast);
}

.metric-card:hover .metric-icon {
    background: var(--orange);
    color: #fff;
}

.metric-status {
    font-size: 0.75rem;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.metric-status.status-safe { color: var(--c-safe); }
.metric-status.status-warning { color: var(--c-warn); }
.metric-status.status-danger { color: var(--c-danger); }

/* Large Layout Grid */
.layout-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.layout-row.full-width {
    grid-template-columns: 1fr;
}

.panel-card {
    background: var(--color-surface);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    padding-bottom: 14px;
    border-bottom: 1px solid var(--glass-border);
}

.panel-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--color-white);
    font-family: var(--font-heading);
    text-transform: none;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title::before {
    content: '';
    width: 4px;
    height: 18px;
    border-radius: 4px;
    background: var(--orange);
}

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

/* High-Density Data Tables */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* Frosted sticky header: stays pinned while telemetry rows scroll beneath it. */
.data-table th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: rgba(28, 34, 46, 0.82);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 13px 16px;
    color: var(--color-text-muted);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table th:first-child { border-top-left-radius: 10px; }
.data-table th:last-child { border-top-right-radius: 10px; }

.data-table td {
    padding: 13px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--color-text-main);
    vertical-align: middle;
}

.data-table tr {
    transition: background var(--transition-fast);
}

/* Zebra first (lowest priority), then critical, then hover last so hover always
   wins and critical rows stay red regardless of their zebra position. */
.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.018);
}

.data-table tbody tr.critical-row {
    background: var(--c-danger-soft);
}

.data-table tbody tr:hover {
    background: var(--orange-ghost);
}

.data-table tbody tr.critical-row:hover {
    background: rgba(220, 38, 38, 0.24);
}

/* td strong-text accents that used --color-white inline */
.data-table td[style*="--color-white"],
.metric-value,
.site-stat-val { color: var(--color-white); }

/* Status Badges */
.badge-status {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    padding: 4px 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-safe {
    background: var(--c-safe-soft);
    color: var(--c-safe);
    border-color: var(--c-safe-border);
}

.badge-warning {
    background: var(--c-warn-soft);
    color: var(--c-warn);
    border-color: var(--c-warn-border);
}

.badge-danger {
    background: var(--c-danger-soft);
    color: var(--c-danger);
    border-color: var(--c-danger-border);
    animation: flashCritical 3s infinite;
}

.badge-offline {
    background: var(--color-surface-3);
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

/* SOS / Panic — the most urgent state: solid red, white text, pulsing. */
.badge-sos {
    background: #C41E14;
    color: #FFFFFF;
    border-color: #8C170F;
    box-shadow: 0 0 0 2px rgba(196, 30, 20, 0.2);
    animation: flashCritical 1.2s infinite;
}

/* Dashboard Forms & Controls */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.4px;
}

.form-control {
    width: 100%;
    background: var(--color-surface-3);
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    padding: 11px 14px;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-fast);
}

.form-control::placeholder { color: var(--color-text-faint); }

.form-control:hover { border-color: var(--color-border-hover); }

.form-control:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-ring);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.btn-dash {
    background: linear-gradient(180deg, var(--orange-400) 0%, var(--orange) 100%);
    border: 1px solid var(--orange);
    color: #fff;
    padding: 11px 22px;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-smooth), background var(--transition-smooth);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(243, 113, 28, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

/* Premium shine: a diagonal highlight that sweeps across on hover. */
.btn-dash::before {
    content: '';
    position: absolute;
    top: 0;
    left: -120%;
    width: 60%;
    height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-18deg);
    transition: left 0.6s var(--ease-out);
    pointer-events: none;
}

.btn-dash:hover {
    background: linear-gradient(180deg, var(--orange-300) 0%, var(--orange-dark) 100%);
    border-color: var(--orange-dark);
    color: #fff;
    box-shadow: var(--shadow-glow-orange), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-dash:hover::before { left: 140%; }

/* Click compression for a tactile, physical press. */
.btn-dash:active { transform: translateY(0) scale(0.975); }

.btn-dash-danger {
    background: var(--color-surface);
    border-color: var(--c-danger-border);
    color: var(--c-danger);
    box-shadow: var(--shadow-xs);
}

.btn-dash-danger::before { display: none; }

.btn-dash-danger:hover {
    background: var(--c-danger);
    border-color: var(--c-danger);
    color: #fff;
    box-shadow: 0 8px 22px rgba(240, 70, 58, 0.3);
}

/* Ghost / secondary button — quiet, for lower-priority actions. */
.btn-ghost,
.site-access-btn {
    background: transparent !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text-main) !important;
    box-shadow: none !important;
    font-weight: 600 !important;
}

.btn-ghost::before,
.site-access-btn::before { display: none; }

.btn-ghost:hover,
.site-access-btn:hover {
    border-color: var(--orange) !important;
    color: var(--orange-on-dark) !important;
    background: var(--orange-ghost) !important;
    box-shadow: none !important;
    transform: translateY(-1px);
}

/* Incidents Alarms Layout */
.alarms-banner {
    background: var(--c-danger-soft);
    border: 1px solid var(--c-danger-border);
    border-left: 4px solid var(--c-danger);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    animation: alarmBreathe 2.2s ease-in-out infinite;
}

/* Scanning sweep — a radar-style line travelling across the banner, so a live
   alarm reads as an active, moving alert rather than a static coloured box. */
.alarms-banner::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 45%;
    left: -45%;
    background: linear-gradient(100deg, transparent, rgba(240, 70, 58, 0.16), transparent);
    animation: alarmScan 2.6s linear infinite;
    pointer-events: none;
}

@keyframes alarmBreathe {
    0%, 100% {
        background: var(--c-danger-soft);
        box-shadow: var(--shadow-sm), 0 0 0 rgba(220, 38, 38, 0);
    }
    50% {
        background: rgba(220, 38, 38, 0.22);
        box-shadow: var(--shadow-md), 0 0 34px rgba(220, 38, 38, 0.3);
    }
}

@keyframes alarmScan {
    0%   { left: -45%; }
    100% { left: 100%; }
}

.alarms-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.alarms-banner-icon {
    font-size: 1.5rem;
    color: var(--c-danger);
}

.alarms-banner-text {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--c-danger);
}

/* SOS / Panic banner — deeper red than a gas alarm so it's unmistakable. */
.alarms-banner--sos {
    background: rgba(196, 30, 20, 0.2);
    border-color: rgba(196, 30, 20, 0.45);
    border-left: 5px solid #8C170F;
}

.alarms-banner--sos .alarms-banner-icon,
.alarms-banner--sos .alarms-banner-text {
    color: #FF9C8F;
}

/* Active alarm detail cards (readings, time, serial, type, location) */
.active-alarms-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-md);
}

.alarm-cards-empty {
    color: var(--c-safe);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 2px;
}

.alarm-card {
    border: 1px solid var(--c-danger-border);
    border-left: 4px solid var(--c-danger);
    background: var(--c-danger-soft);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-sm);
    animation: fadeUpIn var(--transition-smooth) both;
}

.active-alarms-cards .alarm-card:nth-child(1) { animation-delay: 0ms; }
.active-alarms-cards .alarm-card:nth-child(2) { animation-delay: 40ms; }
.active-alarms-cards .alarm-card:nth-child(3) { animation-delay: 80ms; }
.active-alarms-cards .alarm-card:nth-child(4) { animation-delay: 120ms; }
.active-alarms-cards .alarm-card:nth-child(5) { animation-delay: 160ms; }
.active-alarms-cards .alarm-card:nth-child(6) { animation-delay: 200ms; }

.alarm-card--sos {
    border-color: rgba(196, 30, 20, 0.5);
    border-left-color: #8C170F;
    background: rgba(196, 30, 20, 0.22);
}

.alarm-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.alarm-card-code {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--c-danger);
    background: rgba(240, 70, 58, 0.14);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.alarm-card-device {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-white);
}

.alarm-card-reason {
    font-weight: 700;
    color: var(--c-danger);
    font-size: 0.9rem;
}

.alarm-card-readings {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 14px;
    font-size: 0.85rem;
    color: var(--color-text-main);
    background: var(--color-surface-2);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 10px 12px;
}

.alarm-card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.alarm-card-meta i { color: var(--c-danger); width: 14px; text-align: center; }

.alarm-map-link {
    color: var(--orange-on-dark);
    font-weight: 700;
    text-decoration: none;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.alarm-map-link:hover { text-decoration: underline; }

/* Charts / Canvas Panel */
.chart-wrapper {
    height: 350px;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Monospace Log Outputs */
.log-display {
    background: var(--color-surface-3);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    height: 300px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-text-main);
    line-height: 1.6;
}

.log-entry {
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--color-border);
    padding-bottom: 4px;
}

.log-time {
    color: var(--orange-on-dark);
    font-weight: 700;
}

.log-user { color: var(--color-text-muted); }

.log-action {
    color: var(--color-white);
    font-weight: bold;
}

/* Keyframe Animations */
@keyframes pulseGlow {
    0%, 100% {
        opacity: 0.6;
        box-shadow: 0 0 4px currentColor;
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 12px currentColor;
    }
}

@keyframes flashCritical {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

@keyframes flashCriticalBanner {
    0%, 100% { background: var(--c-danger-soft); }
    50% { background: rgba(240, 70, 58, 0.22); }
}

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

@keyframes fadeUpIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rotateClockwise {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Map Simulation */
.map-simulation {
    background-color: var(--color-surface-3);
    border: 1px solid var(--glass-border);
    height: 350px;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.map-node {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
}

.map-node::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px solid currentColor;
    animation: rotateClockwise 3s linear infinite;
}

.map-node.safe {
    background-color: var(--c-safe);
    color: rgba(52, 211, 153, 0.4);
}

.map-node.alarm {
    background-color: var(--c-danger);
    color: rgba(240, 70, 58, 0.4);
    animation: flashCritical 1.5s infinite;
}

.map-tooltip {
    position: absolute;
    background: var(--color-surface);
    border: 1px solid var(--orange);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    z-index: 10;
    display: none;
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

/* Site Hierarchy Grid */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.site-card {
    background: var(--color-surface);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
    animation: fadeUpIn var(--transition-smooth) both;
}

.site-grid .site-card:nth-child(1) { animation-delay: 0ms; }
.site-grid .site-card:nth-child(2) { animation-delay: 40ms; }
.site-grid .site-card:nth-child(3) { animation-delay: 80ms; }
.site-grid .site-card:nth-child(4) { animation-delay: 120ms; }
.site-grid .site-card:nth-child(5) { animation-delay: 160ms; }
.site-grid .site-card:nth-child(6) { animation-delay: 200ms; }

/* Status accent rail down the left edge — instantly readable site health. */
.site-card { position: relative; overflow: hidden; }

.site-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-text-faint);
}

.site-card--safe::before  { background: linear-gradient(180deg, var(--c-safe), transparent); }
.site-card--alarm::before { background: linear-gradient(180deg, var(--c-danger), transparent); }

.site-card--alarm {
    border-color: var(--c-danger-border);
    box-shadow: var(--shadow-sm), 0 0 26px rgba(220, 38, 38, 0.10);
}

.site-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), var(--shadow-glow-orange-sm);
    border-color: rgba(243, 113, 28, 0.3);
}

/* Live telemetry pulse dot next to the site name. */
.site-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    position: relative;
}

.site-pulse--safe  { background: var(--c-safe); box-shadow: 0 0 8px var(--c-safe); }
.site-pulse--alarm { background: var(--c-danger); box-shadow: 0 0 8px var(--c-danger); }

.site-pulse::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px solid currentColor;
    color: inherit;
    animation: sitePing 1.8s ease-out infinite;
}

.site-pulse--safe::after  { border-color: var(--c-safe); }
.site-pulse--alarm::after { border-color: var(--c-danger); animation-duration: 1s; }

@keyframes sitePing {
    0%   { transform: scale(0.8); opacity: 0.9; }
    100% { transform: scale(2.4); opacity: 0; }
}

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

.site-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--color-white);
}

.site-card-meta {
    font-size: 0.83rem;
    color: var(--color-text-muted);
}

.site-card-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    background: var(--color-surface-2);
    border-radius: 10px;
    padding: 12px 14px;
}

.site-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.site-stat-val {
    font-weight: 700;
    color: var(--color-white);
    font-family: var(--font-heading);
}

/* Refinery grant checkboxes (user create form) */
.refinery-grant-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 12px;
    background: var(--color-surface-2);
}

.refinery-grant {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.refinery-grant .text-muted { margin-left: auto; font-size: 0.75rem; }

/* Accent the native checkboxes/date inputs */
input[type="checkbox"] { accent-color: var(--orange); }
input[type="date"] { color-scheme: dark; }

/* Small icon action buttons (user management table) */
.btn-icon {
    background: var(--color-surface-3);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-right: 4px;
}

.btn-icon:hover {
    color: var(--orange-on-dark);
    border-color: var(--orange);
    background: var(--orange-soft);
}

.u-delete:hover { color: var(--c-danger); border-color: var(--c-danger-border); background: var(--c-danger-soft); }

/* Utility classes */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--c-danger); }
.status-warning { color: var(--c-warn); }
.cell-sub { font-size: 0.75rem; color: var(--color-text-muted); }

/* Action Levels panel (rendered from THRESHOLDS) */
.action-levels {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.85rem;
}

.action-level-row {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
}

.action-level-row--last { border-bottom: none; padding-bottom: 0; }

.action-level-head {
    font-weight: 700;
    color: var(--color-white);
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.action-level-danger { color: var(--c-danger); white-space: nowrap; }

.action-level-desc {
    font-size: 0.78rem;
    margin: 4px 0 0;
    color: var(--color-text-muted);
}

.action-level-warn { color: var(--c-warn); }

/* Login Page */
.login-wrap {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(900px 560px at 100% 0%, rgba(243, 113, 28, 0.18), transparent 60%),
        radial-gradient(720px 560px at 0% 100%, rgba(53, 199, 185, 0.13), transparent 55%),
        linear-gradient(180deg, #080A0F 0%, #0C0F15 100%);
}

/* Signature industrial motif: a faint telemetry grid with a slow drift, evoking
   pipeline schematics behind the glass sign-in card. */
.login-wrap::before {
    content: '';
    position: absolute;
    inset: -2px;
    background-image:
        linear-gradient(rgba(156, 163, 180, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(156, 163, 180, 0.05) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
    mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
    animation: gridDrift 24s linear infinite;
    pointer-events: none;
}

@keyframes gridDrift {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(46px, 46px); }
}

.login-card { position: relative; z-index: 1; }

.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    box-shadow: var(--shadow-lg), var(--glass-edge-lg);
    border-top: 4px solid var(--orange);
    animation: fadeUpIn var(--transition-smooth) both;
}

.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-sm);
    position: relative;
}

.login-brand::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 220px;
    height: 120px;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse, rgba(243, 113, 28, 0.20), transparent 70%);
    pointer-events: none;
    filter: blur(6px);
}

.login-brand img {
    position: relative;
    filter: brightness(0) invert(0.95) drop-shadow(0 2px 14px rgba(243, 113, 28, 0.35));
}

.login-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-white);
    text-align: center;
    margin: 0;
    font-family: var(--font-heading);
}

.login-sub {
    font-size: 0.85rem;
    text-align: center;
    margin: 0 0 var(--spacing-sm);
    background: linear-gradient(100deg, var(--color-text-muted) 30%, var(--color-white) 50%, var(--color-text-muted) 70%);
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: taglineShimmer 4.5s linear infinite;
}

@keyframes taglineShimmer {
    0%   { background-position: 180% center; }
    100% { background-position: -80% center; }
}

.login-btn {
    justify-content: center;
    padding: 13px;
    margin-top: var(--spacing-xs);
    font-size: 0.9rem;
}

.login-error {
    background: var(--c-danger-soft);
    border: 1px solid var(--c-danger-border);
    color: var(--c-danger);
    font-size: 0.85rem;
    padding: 10px 14px;
    border-radius: 10px;
}

.login-back {
    text-align: center;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    text-decoration: none;
    margin-top: var(--spacing-xs);
    transition: color var(--transition-fast);
}

.login-back:hover { color: var(--orange-on-dark); }

/* Trends: one honestly-scaled mini chart per gas (small multiples) */
.trends-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
}

.trend-chart-card {
    background: var(--color-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: fadeUpIn var(--transition-smooth) both;
}

.trends-grid .trend-chart-card:nth-child(1) { animation-delay: 0ms; }
.trends-grid .trend-chart-card:nth-child(2) { animation-delay: 60ms; }
.trends-grid .trend-chart-card:nth-child(3) { animation-delay: 120ms; }
.trends-grid .trend-chart-card:nth-child(4) { animation-delay: 180ms; }

.trend-chart-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.trend-chart-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--color-white);
}

.trend-chart-unit {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

.trend-chart-latest {
    font-size: 0.82rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.trend-canvas-wrap {
    height: 150px;
    position: relative;
}

.trend-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    cursor: crosshair;
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 150px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Chart hover tooltip (drawn by drawGasChart in js/dashboard.js) */
.chart-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--color-surface-2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--color-white);
    box-shadow: var(--shadow-md);
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, -100%);
    transition: opacity 0.1s ease;
    z-index: 5;
}

.chart-tooltip.visible { opacity: 1; }

.chart-crosshair-line {
    position: absolute;
    top: 0;
    bottom: 20px;
    width: 1px;
    background: var(--color-border-hover);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s ease;
    z-index: 4;
}

.chart-crosshair-line.visible { opacity: 1; }

.chart-hover-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--orange);
    border: 2px solid var(--color-surface);
    box-shadow: 0 0 0 1px var(--orange);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.1s ease;
    z-index: 6;
}

.chart-hover-dot.visible { opacity: 1; }

/* Custom scrollbars to match the dark theme */
.sidebar-menu-container::-webkit-scrollbar,
.table-container::-webkit-scrollbar,
.log-display::-webkit-scrollbar,
.refinery-grant-list::-webkit-scrollbar,
.dash-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.sidebar-menu-container::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb,
.log-display::-webkit-scrollbar-thumb,
.refinery-grant-list::-webkit-scrollbar-thumb,
.dash-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.sidebar-menu-container::-webkit-scrollbar-thumb:hover,
.dash-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
    background-clip: padding-box;
}

@media (max-width: 768px) {
    .trends-grid { grid-template-columns: 1fr; }
}

/* Responsive Overrides */
@media (max-width: 1200px) {
    .dash-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .dash-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .dash-sidebar.active {
        transform: translateX(0);
    }

    .dash-main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-toggle-btn {
        display: block;
    }

    .layout-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .dash-grid {
        grid-template-columns: 1fr;
    }

    .dash-header-right {
        gap: 10px;
    }

    .sync-indicator span {
        display: none;
    }

    .site-selector {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Skeleton shimmer for loading / empty states */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
    color: transparent !important;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
    transform: translateX(-100%);
    animation: skeletonSweep 1.4s ease-in-out infinite;
}

@keyframes skeletonSweep {
    100% { transform: translateX(100%); }
}

/* Respect reduced-motion preferences: keep state changes, drop the choreography */
@media (prefers-reduced-motion: reduce) {
    .metric-card,
    .metric-card--danger,
    .alarm-card,
    .site-card,
    .trend-chart-card,
    .dash-module,
    .login-card {
        animation: none !important;
    }

    .sync-dot,
    .badge-danger,
    .badge-sos,
    .alarms-banner,
    .alarms-banner::after,
    .site-pulse::after,
    .login-wrap::before,
    .login-sub,
    .skeleton::after,
    .map-node::after,
    .map-node.alarm {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
    }

    .btn-dash::before { transition-duration: 0.001ms !important; }

    * {
        transition-duration: 0.001ms !important;
    }
}

/* ============================================================
 *  Alarm Log + acknowledgement
 * ============================================================ */

/* Sidebar "pending" count pill */
.nav-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    margin-left: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    color: #fff;
    background: var(--c-danger-core, #DC2626);
    border-radius: 999px;
    vertical-align: middle;
}

/* Acknowledge button row inside a pending card */
.alarm-card-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}
.alarm-card-actions .ack-btn { font-size: 0.8rem; }

/* ---- Modal ---- */
.ack-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;                 /* toggled with inline style display:none/flex */
    align-items: center;
    justify-content: center;
    background: rgba(4, 6, 10, 0.72);
    backdrop-filter: var(--backdrop-blur, blur(10px));
    padding: 20px;
}
.ack-modal {
    width: 100%;
    max-width: 440px;
    background: var(--color-surface, #161B24);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 20px);
    box-shadow: var(--shadow-md, 0 12px 28px rgba(0,0,0,0.45));
    padding: 22px 24px 20px;
    animation: ackpop 0.2s var(--ease-out, ease-out);
}
@keyframes ackpop {
    from { transform: translateY(8px) scale(0.98); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
.ack-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ack-modal-head h3 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    color: var(--color-white);
}
.ack-modal-head h3 i { color: var(--c-danger); margin-right: 6px; }
.ack-modal-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.ack-modal-close:hover { color: var(--color-white); }
.ack-modal-sub {
    margin: 8px 0 16px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.ack-field { display: block; margin-bottom: 14px; }
.ack-field span {
    display: block;
    margin-bottom: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.ack-field input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.95rem;
    color: var(--color-white);
    background: var(--color-surface-3, #252C3A);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 8px);
    outline: none;
    transition: border-color var(--transition-fast, 0.15s);
}
.ack-field input:focus { border-color: var(--color-accent, #F3711C); }
.ack-form-msg {
    margin: 4px 0 12px;
    padding: 8px 10px;
    font-size: 0.82rem;
    color: var(--c-danger);
    background: var(--c-danger-soft);
    border: 1px solid var(--c-danger-border);
    border-radius: var(--radius-sm, 8px);
}
.ack-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}
.ack-modal-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
