/* ==========================================================================
   Jupiter PRO — Material Design 3 (Material You / M3) Design System
   Passive Optical Network Manager
   Google Material Design 3 Specification Compliance
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&family=Roboto+Mono:wght@400;500;600;700&family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap');

:root {
    /* ======================================================================
       Material Design 3 Design Tokens (Light Theme Palette)
       ====================================================================== */
    --md-sys-color-primary: #00639b;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #cee5ff;
    --md-sys-color-on-primary-container: #001d32;

    --md-sys-color-secondary: #51606f;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #d5e4f7;
    --md-sys-color-on-secondary-container: #0e1d2a;

    --md-sys-color-tertiary: #68587a;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-tertiary-container: #eedcff;
    --md-sys-color-on-tertiary-container: #231533;

    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-error-container: #ffdad6;
    --md-sys-color-on-error-container: #410002;

    --md-sys-color-surface-dim: #d9d9e0;
    --md-sys-color-surface: #f8f9ff;
    --md-sys-color-surface-bright: #f8f9ff;
    --md-sys-color-surface-container-lowest: #ffffff;
    --md-sys-color-surface-container-low: #f2f3fa;
    --md-sys-color-surface-container: #eceef4;
    --md-sys-color-surface-container-high: #e7e8ee;
    --md-sys-color-surface-container-highest: #e1e2e8;

    --md-sys-color-on-surface: #191c20;
    --md-sys-color-on-surface-variant: #41474d;
    --md-sys-color-outline: #72777f;
    --md-sys-color-outline-variant: #c1c7cf;

    --md-sys-color-inverse-surface: #2e3135;
    --md-sys-color-inverse-on-surface: #eff0f7;
    --md-sys-color-inverse-primary: #96ccff;
    --md-sys-color-shadow: rgba(0, 0, 0, 0.2);
    --md-sys-color-scrim: rgba(0, 0, 0, 0.4);

    /* M3 Extended Telecom Status Tones (PON Optical Statuses) */
    --md-sys-color-success: #0f6c34;
    --md-sys-color-on-success: #ffffff;
    --md-sys-color-success-container: #c6f3cb;
    --md-sys-color-on-success-container: #00210b;

    --md-sys-color-warning: #7b5800;
    --md-sys-color-on-warning: #ffffff;
    --md-sys-color-warning-container: #ffdf9e;
    --md-sys-color-on-warning-container: #261900;

    --md-sys-color-critical: #b3261e;
    --md-sys-color-on-critical: #ffffff;
    --md-sys-color-critical-container: #f9dedc;
    --md-sys-color-on-critical-container: #410e0b;

    /* M3 Shape System */
    --md-sys-shape-none: 0px;
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;

    /* M3 Elevation Shadows */
    --md-sys-elevation-0: none;
    --md-sys-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
    --md-sys-elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
    --md-sys-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.30);
    --md-sys-elevation-4: 0px 6px 10px 4px rgba(0, 0, 0, 0.15), 0px 2px 3px 0px rgba(0, 0, 0, 0.30);
    --md-sys-elevation-5: 0px 8px 12px 6px rgba(0, 0, 0, 0.15), 0px 4px 4px 0px rgba(0, 0, 0, 0.30);

    /* M3 Motion & Easing Curves */
    --md-sys-motion-easing-standard: cubic-bezier(0.2, 0.0, 0, 1.0);
    --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0.0, 0, 1.0);
    --md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1.0);
    --md-sys-motion-easing-emphasized-accelerate: cubic-bezier(0.3, 0.0, 0.8, 0.15);
    --md-sys-motion-duration-short: 150ms;
    --md-sys-motion-duration-medium: 250ms;
    --md-sys-motion-duration-long: 400ms;

    /* Backward compatibility mapping with legacy tokens */
    --bg-app: var(--md-sys-color-surface);
    --bg-surface: var(--md-sys-color-surface-container-lowest);
    --bg-surface-elevated: var(--md-sys-color-surface-container-low);
    --bg-sidebar: var(--md-sys-color-surface-container-low);
    --bg-sidebar-hover: var(--md-sys-color-surface-container-high);
    --bg-sidebar-active: var(--md-sys-color-secondary-container);
    --sidebar-text: var(--md-sys-color-on-surface-variant);
    --sidebar-text-active: var(--md-sys-color-on-secondary-container);
    --sidebar-header: var(--md-sys-color-outline);

    --border-color: var(--md-sys-color-outline-variant);
    --border-subtle: rgba(193, 199, 207, 0.4);

    --text-main: var(--md-sys-color-on-surface);
    --text-muted: var(--md-sys-color-on-surface-variant);
    --text-light: var(--md-sys-color-outline);

    --primary: var(--md-sys-color-primary);
    --primary-hover: #004f7c;
    --primary-glow: rgba(0, 99, 155, 0.22);

    --success: var(--md-sys-color-success);
    --success-bg: var(--md-sys-color-success-container);
    --success-text: var(--md-sys-color-on-success-container);

    --warning: var(--md-sys-color-warning);
    --warning-bg: var(--md-sys-color-warning-container);
    --warning-text: var(--md-sys-color-on-warning-container);

    --danger: var(--md-sys-color-error);
    --danger-bg: var(--md-sys-color-error-container);
    --danger-text: var(--md-sys-color-on-error-container);

    --info: var(--md-sys-color-primary);
    --info-bg: var(--md-sys-color-primary-container);
    --info-text: var(--md-sys-color-on-primary-container);

    --card-shadow: var(--md-sys-elevation-1);
    --card-shadow-hover: var(--md-sys-elevation-2);
    --glass-bg: rgba(248, 249, 255, 0.88);
    --glass-border: var(--md-sys-color-outline-variant);

    --font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: 'Roboto Mono', 'JetBrains Mono', monospace;

    --radius-sm: var(--md-sys-shape-corner-small);
    --radius-md: var(--md-sys-shape-corner-medium);
    --radius-lg: var(--md-sys-shape-corner-large);
    --radius-full: var(--md-sys-shape-corner-full);

    --transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

/* ==========================================================================
   Material Design 3 Dark Theme Palette
   ========================================================================== */
[data-theme="dark"] {
    --md-sys-color-primary: #96ccff;
    --md-sys-color-on-primary: #003353;
    --md-sys-color-primary-container: #004b76;
    --md-sys-color-on-primary-container: #cee5ff;

    --md-sys-color-secondary: #b9c8da;
    --md-sys-color-on-secondary: #243240;
    --md-sys-color-secondary-container: #3a4857;
    --md-sys-color-on-secondary-container: #d5e4f7;

    --md-sys-color-tertiary: #d2bfe6;
    --md-sys-color-on-tertiary: #382a49;
    --md-sys-color-tertiary-container: #4f4061;
    --md-sys-color-on-tertiary-container: #eedcff;

    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffdad6;

    --md-sys-color-surface-dim: #111418;
    --md-sys-color-surface: #111418;
    --md-sys-color-surface-bright: #37393e;
    --md-sys-color-surface-container-lowest: #0c0e12;
    --md-sys-color-surface-container-low: #191c20;
    --md-sys-color-surface-container: #1d2024;
    --md-sys-color-surface-container-high: #272a2f;
    --md-sys-color-surface-container-highest: #32353a;

    --md-sys-color-on-surface: #e1e2e8;
    --md-sys-color-on-surface-variant: #c1c7cf;
    --md-sys-color-outline: #8b9198;
    --md-sys-color-outline-variant: #41474d;

    --md-sys-color-inverse-surface: #e1e2e8;
    --md-sys-color-inverse-on-surface: #2e3135;
    --md-sys-color-inverse-primary: #00639b;
    --md-sys-color-shadow: rgba(0, 0, 0, 0.5);
    --md-sys-color-scrim: rgba(0, 0, 0, 0.7);

    /* M3 Dark Status Tones */
    --md-sys-color-success: #7bd890;
    --md-sys-color-on-success: #003916;
    --md-sys-color-success-container: #005323;
    --md-sys-color-on-success-container: #c6f3cb;

    --md-sys-color-warning: #ffba2f;
    --md-sys-color-on-warning: #422c00;
    --md-sys-color-warning-container: #5e4100;
    --md-sys-color-on-warning-container: #ffdf9e;

    --md-sys-color-critical: #f2b8b5;
    --md-sys-color-on-critical: #601410;
    --md-sys-color-critical-container: #8c1d18;
    --md-sys-color-on-critical-container: #f9dedc;

    --bg-app: var(--md-sys-color-surface);
    --bg-surface: var(--md-sys-color-surface-container-low);
    --bg-surface-elevated: var(--md-sys-color-surface-container);
    --bg-sidebar: var(--md-sys-color-surface-container-low);
    --bg-sidebar-hover: var(--md-sys-color-surface-container-high);
    --bg-sidebar-active: var(--md-sys-color-secondary-container);
    --sidebar-text: var(--md-sys-color-on-surface-variant);
    --sidebar-text-active: var(--md-sys-color-on-secondary-container);
    --sidebar-header: var(--md-sys-color-outline);

    --border-color: var(--md-sys-color-outline-variant);
    --border-subtle: rgba(65, 71, 77, 0.4);

    --text-main: var(--md-sys-color-on-surface);
    --text-muted: var(--md-sys-color-on-surface-variant);
    --text-light: var(--md-sys-color-outline);

    --primary: var(--md-sys-color-primary);
    --primary-hover: #b4dbff;
    --primary-glow: rgba(150, 204, 255, 0.25);

    --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.55);
    --glass-bg: rgba(29, 32, 36, 0.88);
    --glass-border: var(--md-sys-color-outline-variant);
}

/* ==========================================================================
   Global Reset & Material Baseline
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    letter-spacing: 0.2px;
}

/* Material Symbols Integration */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded', sans-serif;
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

/* ==========================================================================
   Layout Shell
   ========================================================================== */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--md-sys-color-surface);
}

/* ==========================================================================
   Material Design 3 Navigation Drawer (Sidebar)
   ========================================================================== */
.sidebar {
    width: 280px;
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--md-sys-color-outline-variant);
    transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 24px 20px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.brand-badge {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-tertiary));
    border-radius: var(--md-sys-shape-corner-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-primary);
    font-weight: 700;
    font-size: 22px;
    box-shadow: var(--md-sys-elevation-2);
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.brand-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.brand-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
}

.brand-title span {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 2px 7px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.brand-tag {
    font-size: 11px;
    color: var(--md-sys-color-on-surface-variant);
    letter-spacing: 0.3px;
    font-weight: 500;
    margin-top: 2px;
}

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

/* M3 Section Subheader */
.menu-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--md-sys-color-primary);
    letter-spacing: 0.8px;
    padding: 16px 16px 6px;
}

/* M3 Navigation Item with Iconic Pill Indicator */
.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
    position: relative;
    user-select: none;
    overflow: hidden;
}

.menu-item:hover {
    background-color: rgba(65, 71, 77, 0.08);
    color: var(--md-sys-color-on-surface);
}

[data-theme="dark"] .menu-item:hover {
    background-color: rgba(193, 199, 207, 0.08);
}

.menu-item.active {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    font-weight: 600;
}

.menu-item.active .menu-icon.material-symbols-rounded {
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
    color: var(--md-sys-color-on-secondary-container);
}

.menu-item.active::before {
    display: none; /* Replaced legacy bar with modern M3 pill container */
}

.menu-icon {
    width: 22px;
    height: 22px;
    font-size: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

/* M3 Tonal Navigation Badges */
.menu-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--md-sys-shape-corner-full);
    letter-spacing: 0.2px;
}

.badge-info {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.badge-warning {
    background-color: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-on-warning-container);
}

.badge-danger {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.badge-success {
    background-color: var(--md-sys-color-success-container);
    color: var(--md-sys-color-on-success-container);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container);
    font-size: 11px;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================================
   Main Content Area & Top App Bar
   ========================================================================== */
.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: var(--md-sys-color-surface);
}

/* M3 Top App Bar */
.navbar {
    height: 68px;
    background-color: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--md-sys-elevation-1);
    transition: background-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* M3 Standard Icon Button for Mobile Drawer Toggle */
.btn-sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.btn-sidebar-toggle:hover {
    background-color: rgba(65, 71, 77, 0.12);
    color: var(--md-sys-color-on-surface);
}

/* ==========================================================================
   Material Design 3 Search Bar
   ========================================================================== */
.search-wrapper {
    position: relative;
    width: 440px;
}

.search-input-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 20px;
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 44px;
    padding: 0 16px 0 44px;
    font-size: 13.5px;
    font-family: var(--font-sans);
    border-radius: var(--md-sys-shape-corner-extra-large);
    border: 1px solid transparent;
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    outline: none;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.search-input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.8;
}

.search-input:hover {
    background-color: var(--md-sys-color-surface-container-highest);
}

.search-input:focus {
    background-color: var(--md-sys-color-surface-container-lowest);
    border-color: var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-2);
}

.search-results-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-3);
    z-index: 1050;
    max-height: 420px;
    overflow-y: auto;
    display: none;
}

.search-results-popup.active {
    display: block;
    animation: m3FadeDown 0.18s var(--md-sys-motion-easing-emphasized-decelerate);
}

.search-result-item {
    padding: 12px 18px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--md-sys-color-surface-container-highest);
}

.search-result-title {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--md-sys-color-on-surface);
}

.search-result-meta {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
}

.search-category-header {
    padding: 8px 16px 6px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
}

.search-badge-fdb {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 6px;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}

.fdb-highlight-row {
    background-color: rgba(99, 102, 241, 0.18) !important;
    animation: fdbGlow 2s ease-in-out infinite alternate;
}

@keyframes fdbGlow {
    from { background-color: rgba(99, 102, 241, 0.12); }
    to { background-color: rgba(99, 102, 241, 0.28); }
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* M3 Assist Chip for Network Telemetry */
.network-stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 6px 14px;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--md-sys-color-success);
    box-shadow: 0 0 0 0 rgba(15, 108, 52, 0.7);
    animation: m3PulseGreen 2s infinite;
}

@keyframes m3PulseGreen {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(123, 216, 144, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(123, 216, 144, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(123, 216, 144, 0); }
}

/* M3 Standard & Tonal Icon Buttons */
.btn-icon {
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant);
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 19px;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.btn-icon:hover {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-sys-elevation-1);
    transform: translateY(-1px);
}

.btn-icon:active {
    transform: translateY(0);
}

/* M3 User Avatar Chip */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--md-sys-color-outline-variant);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-corner-full);
    background: linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-secondary));
    color: var(--md-sys-color-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--md-sys-elevation-1);
}

.user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    line-height: 1.2;
}

.user-role {
    font-size: 11.5px;
    color: var(--md-sys-color-on-surface-variant);
}

/* Role Badges */
.role-tag-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: var(--md-sys-shape-corner-full);
    margin-left: 6px;
    letter-spacing: 0.5px;
}

.role-tag-admin {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    border: 1px solid rgba(186, 26, 26, 0.3);
}

.role-tag-operator {
    background-color: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-on-warning-container);
    border: 1px solid rgba(123, 88, 0, 0.3);
}

.role-tag-engineer {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: 1px solid rgba(0, 99, 155, 0.3);
}

/* ==========================================================================
   RBAC UI Access Control Visibility Rules (Скрытие кнопок без прав)
   ========================================================================== */
body.role-engineer .action-admin-only,
body.role-engineer .action-operator-only,
body.role-engineer .action-manage,
body.role-engineer .action-poll,
body.role-engineer .action-reboot,
body.role-engineer .action-bind,
body.role-engineer .btn-engineer-hide,
body.role-engineer #oltSelectionBar,
body.role-engineer #colHeaderOltSelect,
body.role-engineer .olt-select-checkbox {
    display: none !important;
}

body.role-operator .action-admin-only,
body.role-operator .section-admin-only {
    display: none !important;
}

/* ==========================================================================
   Content Body & Views
   ========================================================================== */
.content-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 28px;
    background-color: var(--md-sys-color-surface);
}

.view-section {
    display: none;
    animation: m3FadeIn var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized-decelerate);
}

.view-section.active {
    display: block;
}

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

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

/* ==========================================================================
   Material Design 3 Cards (Filled, Elevated, Outlined)
   ========================================================================== */
.card {
    background-color: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-1);
    margin-bottom: 24px;
    overflow: hidden;
    transition: box-shadow var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
                border-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.card:hover {
    box-shadow: var(--md-sys-elevation-2);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--md-sys-color-surface-container);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--md-sys-color-on-surface);
    letter-spacing: 0.1px;
}

.card-body {
    padding: 24px;
}

/* ==========================================================================
   M3 Metric Stats Grid
   ========================================================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background-color: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--md-sys-elevation-1);
    transition: transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
    cursor: default;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--md-sys-elevation-2);
    background-color: var(--md-sys-color-surface-container);
}

.metric-icon-box {
    width: 48px;
    height: 48px;
    border-radius: var(--md-sys-shape-corner-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.metric-icon-box.primary {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.metric-icon-box.success {
    background: var(--md-sys-color-success-container);
    color: var(--md-sys-color-on-success-container);
}

.metric-icon-box.warning {
    background: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-on-warning-container);
}

.metric-icon-box.danger {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

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

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    line-height: 1.1;
    font-family: var(--font-mono);
    letter-spacing: -0.5px;
}

.metric-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
}

/* ==========================================================================
   Pinned OLT Selection Bar
   ========================================================================== */
#oltSelectionBar {
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-primary);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 14px 22px;
    margin-bottom: 20px;
    box-shadow: var(--md-sys-elevation-2);
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    animation: m3FadeDown 0.2s var(--md-sys-motion-easing-emphasized-decelerate);
}

#oltSelectionBar.pinned {
    position: sticky;
    top: 76px;
    z-index: 85;
    box-shadow: var(--md-sys-elevation-3);
}

.olt-selection-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    font-size: 13.5px;
    color: var(--md-sys-color-on-surface);
}

.olt-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--md-sys-color-surface-container);
    padding: 4px 10px;
    border-radius: var(--md-sys-shape-corner-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    font-size: 12.5px;
}

.olt-stat-chip strong {
    font-family: var(--font-mono);
}

.olt-selection-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   Material Design 3 Buttons (Filled, Tonal, Outlined, Danger, Ripple)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 22px;
    font-size: 13.5px;
    font-family: var(--font-sans);
    font-weight: 500;
    letter-spacing: 0.1px;
    border-radius: var(--md-sys-shape-corner-full);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

/* M3 Filled Button */
.btn-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-sys-elevation-1);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--md-sys-elevation-2);
}

/* M3 Tonal Button */
.btn-secondary {
    background-color: var(--md-sys-color-secondary-container);
    border-color: transparent;
    color: var(--md-sys-color-on-secondary-container);
}

.btn-secondary:hover {
    background-color: rgba(65, 71, 77, 0.16);
    box-shadow: var(--md-sys-elevation-1);
}

[data-theme="dark"] .btn-secondary:hover {
    background-color: rgba(193, 199, 207, 0.18);
}

/* M3 Error Button */
.btn-danger {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    box-shadow: var(--md-sys-elevation-1);
}

.btn-danger:hover {
    background-color: #93000a;
    box-shadow: var(--md-sys-elevation-2);
}

[data-theme="dark"] .btn-danger:hover {
    background-color: #ffb4ab;
    color: #690005;
}

/* Small Button (32px height) */
.btn-sm {
    height: 32px;
    padding: 0 14px;
    font-size: 12px;
}

/* Material Click Ripple Effect */
.md-ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: mdRippleAnimation 0.6s linear;
    background-color: rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

.btn-secondary .md-ripple {
    background-color: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .btn-secondary .md-ripple {
    background-color: rgba(255, 255, 255, 0.25);
}

@keyframes mdRippleAnimation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ==========================================================================
   Material Design 3 Tables
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

.table th {
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    white-space: nowrap;
}

.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    vertical-align: middle;
    color: var(--md-sys-color-on-surface);
}

.table tbody tr {
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.table tbody tr:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

.table tbody tr.selected {
    background-color: var(--md-sys-color-secondary-container) !important;
}

/* ==========================================================================
   SFP Port Spoiler & Tiles (Jupiter Signature)
   ========================================================================== */
.sfp-spoiler-toggle {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--md-sys-color-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    margin-right: 8px;
    transition: color var(--md-sys-motion-duration-short);
}

.sfp-spoiler-toggle:hover {
    text-decoration: underline;
}

.sfp-dots-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.sfp-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.sfp-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-outline-variant);
    display: inline-block;
    transition: var(--transition);
}

.sfp-dot.danger {
    background-color: var(--md-sys-color-error);
    box-shadow: 0 0 6px rgba(186, 26, 26, 0.6);
}

.sfp-dot.active {
    background-color: var(--md-sys-color-success);
}

.sfp-tiles-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 0 6px;
}

.sfp-tile {
    display: block;
    flex: 0 0 auto;
    width: 56px;
    padding: 6px 4px;
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    text-align: center;
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
    transition: transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.sfp-tile:hover {
    border-color: var(--md-sys-color-primary);
    transform: translateY(-2px);
    box-shadow: var(--md-sys-elevation-2);
}

.sfp-tile-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}

.sfp-tile-count {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--md-sys-color-on-surface-variant);
    margin: 2px 0;
}

.sfp-tile-percent {
    font-size: 10px;
    font-weight: 600;
    color: var(--md-sys-color-primary);
}

.sfp-tile.danger {
    background-color: var(--md-sys-color-error-container);
    border-color: rgba(186, 26, 26, 0.35);
}

.sfp-tile.danger .sfp-tile-label,
.sfp-tile.danger .sfp-tile-count,
.sfp-tile.danger .sfp-tile-percent {
    color: var(--md-sys-color-on-error-container);
}

/* Статусы EPON SFP-портов (UP: тонкая зеленая рамка, DOWN: тонкая красная рамка) */
.sfp-tile.port-up {
    border: 1.5px solid #22c55e !important;
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25) !important;
}

.sfp-tile.port-down {
    border: 1.5px solid #ef4444 !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2) !important;
}

.sfp-tile.port-up:hover {
    border-color: #22c55e !important;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5) !important;
}

.sfp-tile.port-down:hover {
    border-color: #ef4444 !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5) !important;
}

/* Кнопки-вкладки SFP-портов в карточке OLT (#oltSfpTabs) */
.sfp-port-tab.port-up {
    border: 1.5px solid #22c55e !important;
}

.sfp-port-tab.port-down {
    border: 1.5px solid #ef4444 !important;
}

.sfp-port-tab.port-up:hover {
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4) !important;
}

.sfp-port-tab.port-down:hover {
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4) !important;
}

/* Точки индикаторов SFP в списке OLT */
.sfp-dot.port-up {
    background-color: #22c55e !important;
    box-shadow: 0 0 5px rgba(34, 197, 94, 0.7) !important;
}

.sfp-dot.port-down {
    background-color: #ef4444 !important;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.7) !important;
}

/* M3 Linear Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: var(--md-sys-color-surface-container-highest);
    border-radius: var(--md-sys-shape-corner-full);
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--md-sys-color-primary);
    border-radius: var(--md-sys-shape-corner-full);
    transition: width 0.6s var(--md-sys-motion-easing-emphasized);
}

.progress-bar-fill.danger {
    background-color: var(--md-sys-color-error);
}

/* ==========================================================================
   Material Design 3 Badges & Optical Signal Chips
   ========================================================================== */
.signal-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--md-sys-shape-corner-full);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.signal-excellent {
    background-color: var(--md-sys-color-success-container);
    color: var(--md-sys-color-on-success-container);
    border: 1px solid rgba(15, 108, 52, 0.3);
}

.signal-good {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: 1px solid rgba(0, 99, 155, 0.3);
}

.signal-warning {
    background-color: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-on-warning-container);
    border: 1px solid rgba(123, 88, 0, 0.3);
}

.signal-critical {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    border: 1px solid rgba(186, 26, 26, 0.3);
}

.signal-offline {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
}

/* Generic M3 Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ==========================================================================
   Optical Calculator & Tools
   ========================================================================== */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.calc-result-box {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 28px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--md-sys-elevation-1);
}

.calc-result-value {
    font-size: 40px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--md-sys-color-primary);
    line-height: 1.1;
    margin: 10px 0;
    letter-spacing: -1px;
}

.fiber-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.fiber-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--md-sys-shape-corner-small);
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container);
}

.fiber-swatch {
    width: 22px;
    height: 22px;
    border-radius: var(--md-sys-shape-corner-full);
    flex-shrink: 0;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.3);
}

/* ==========================================================================
   Network Topology Map
   ========================================================================== */
.map-canvas-container {
    width: 100%;
    height: 540px;
    background: radial-gradient(circle at 50% 50%, var(--md-sys-color-surface-container-high), var(--md-sys-color-surface-container-lowest));
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    position: relative;
    overflow: hidden;
    box-shadow: var(--md-sys-elevation-1);
}

#networkCanvas {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#networkCanvas:active {
    cursor: grabbing;
}

.map-floating-overlay {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 10px 18px;
    font-size: 12px;
    display: flex;
    gap: 16px;
    z-index: 10;
    box-shadow: var(--md-sys-elevation-2);
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--md-sys-color-on-surface);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ==========================================================================
   Material Design 3 Dialogs / Modals
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--md-sys-color-scrim);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-backdrop.active {
    display: flex;
    animation: m3FadeIn 0.2s var(--md-sys-motion-easing-emphasized-decelerate);
}

.modal-card {
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-3);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: m3DialogScaleUp 0.25s var(--md-sys-motion-easing-emphasized-decelerate);
}

@keyframes m3DialogScaleUp {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 24px 28px 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    letter-spacing: -0.2px;
}

.modal-body {
    padding: 24px 28px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 28px 24px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background-color: var(--md-sys-color-surface-container-high);
}

/* ==========================================================================
   Material Design 3 Form Controls
   ========================================================================== */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 6px;
    letter-spacing: 0.1px;
}

.form-control, .form-select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font-size: 13.5px;
    font-family: var(--font-sans);
    border-radius: var(--md-sys-shape-corner-small);
    border: 1px solid var(--md-sys-color-outline);
    background-color: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    outline: none;
    transition: border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

textarea.form-control {
    height: auto;
    padding: 10px 14px;
}

.form-control:hover, .form-select:hover {
    border-color: var(--md-sys-color-on-surface);
}

.form-control:focus, .form-select:focus {
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 0 13px; /* Keep layout stable with 2px border */
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-hint {
    font-size: 11.5px;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
    letter-spacing: 0.2px;
}

/* ==========================================================================
   Material Design 3 Snackbars (Toast Notifications)
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 3000;
    pointer-events: none;
}

.toast {
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    border-radius: var(--md-sys-shape-corner-small);
    padding: 14px 20px;
    box-shadow: var(--md-sys-elevation-3);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: m3SlideInRight 0.3s var(--md-sys-motion-easing-emphasized-decelerate);
    min-width: 290px;
    border: none;
}

@keyframes m3SlideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success {
    border-left: 5px solid var(--md-sys-color-success);
}

.toast.danger {
    border-left: 5px solid var(--md-sys-color-error);
}

.toast.info {
    border-left: 5px solid var(--md-sys-color-primary);
}

/* ==========================================================================
   Base Mobile Elements (Hidden on Desktop)
   ========================================================================== */
.sidebar-backdrop {
    display: none;
}

.mobile-sidebar-close {
    display: none;
}

.mobile-brand-pill {
    display: none;
}

.brand-badge-sm {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-tertiary));
    color: var(--md-sys-color-on-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.mobile-brand-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
}

.mobile-brand-title strong {
    color: var(--md-sys-color-primary);
}

.mobile-search-btn {
    display: none;
}

.mobile-search-bar {
    display: none;
}

.mobile-bottom-nav {
    display: none;
}

/* ==========================================================================
   Responsive Adjustments: Tablet & Below (<= 992px)
   ========================================================================== */
@media (max-width: 992px) {
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 1150;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 290px;
        max-width: 82vw;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: none;
        z-index: 1200;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.7);
    }

    .sidebar-header {
        justify-content: space-between;
    }

    .mobile-sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: none;
        background: rgba(255, 255, 255, 0.08);
        color: var(--md-sys-color-on-surface);
        cursor: pointer;
        transition: background 0.2s ease;
    }

    .mobile-sidebar-close:active {
        background: rgba(255, 255, 255, 0.18);
    }

    .search-wrapper {
        width: 240px;
    }
}

/* ==========================================================================
   Responsive Adjustments: Mobile Phones (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* Layout and Content Area */
    .app-container {
        height: 100vh;
        overflow: hidden;
    }

    .main-wrapper {
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .content-body {
        flex: 1;
        overflow-y: auto;
        padding: 12px 12px calc(78px + env(safe-area-inset-bottom, 0px)) 12px !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Top App Bar (Navbar) */
    .navbar {
        height: 56px !important;
        min-height: 56px;
        padding: 0 10px !important;
        gap: 6px;
    }

    .btn-sidebar-toggle {
        display: none !important;
    }

    .mobile-brand-pill {
        display: flex !important;
    }

    .search-wrapper {
        display: none !important;
    }

    .mobile-search-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 50%;
        border: none;
        background: transparent;
        color: var(--md-sys-color-on-surface-variant);
        cursor: pointer;
    }

    .mobile-search-btn:active {
        background-color: var(--md-sys-color-surface-container-high);
    }

    .network-stat-pill {
        padding: 4px 8px !important;
        font-size: 11px !important;
        gap: 5px !important;
    }

    .stat-pill-online {
        display: none !important;
    }

    .btn-header-poll {
        padding: 6px 10px !important;
    }

    .btn-poll-text {
        display: none !important;
    }

    .user-profile-info {
        display: none !important;
    }

    .user-profile-badge {
        padding: 3px !important;
        border: none !important;
        background: transparent !important;
    }

    .user-avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 13px !important;
    }

    /* Expandable Mobile Search Bar */
    .mobile-search-bar {
        position: relative;
        width: 100%;
        padding: 8px 12px 10px 12px;
        background: var(--md-sys-color-surface-container);
        border-bottom: 1px solid var(--md-sys-color-outline-variant);
        z-index: 1050;
        box-shadow: var(--md-sys-elevation-2);
    }

    .mobile-search-bar.active {
        display: block !important;
        animation: m3SlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mobile-search-inner {
        display: flex;
        align-items: center;
        gap: 8px;
        background: var(--md-sys-color-surface-container-high);
        border: 1px solid var(--md-sys-color-outline-variant);
        border-radius: 20px;
        padding: 5px 12px;
    }

    .mobile-search-icon {
        color: var(--md-sys-color-primary);
        font-size: 20px;
    }

    .mobile-search-input {
        flex: 1;
        background: transparent;
        border: none;
        outline: none;
        font-size: 13.5px;
        color: var(--md-sys-color-on-surface);
    }

    .mobile-search-close {
        border: none;
        background: transparent;
        color: var(--md-sys-color-on-surface-variant);
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        cursor: pointer;
        padding: 0;
    }

    .mobile-search-results {
        position: absolute;
        top: 100%;
        left: 12px;
        right: 12px;
        margin-top: 4px;
        max-height: 60vh;
        z-index: 1100;
    }

    /* Mobile Bottom Navigation Bar (Material Design 3) */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(62px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(18, 22, 34, 0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    }

    [data-theme="light"] .mobile-bottom-nav {
        background: rgba(245, 247, 252, 0.94);
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    }

    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: none;
        border: none;
        color: var(--md-sys-color-on-surface-variant);
        padding: 4px 0;
        cursor: pointer;
        position: relative;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.2s ease;
    }

    .mobile-nav-icon-wrapper {
        position: relative;
        width: 48px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 14px;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mobile-nav-item .material-symbols-rounded {
        font-size: 21px;
        transition: transform 0.2s ease;
    }

    .mobile-nav-label {
        font-size: 10.5px;
        font-weight: 500;
        letter-spacing: 0.2px;
        transition: color 0.2s ease, font-weight 0.2s ease;
    }

    .mobile-nav-item.active {
        color: var(--md-sys-color-primary);
    }

    .mobile-nav-item.active .mobile-nav-icon-wrapper {
        background-color: var(--md-sys-color-primary-container);
        color: var(--md-sys-color-on-primary-container);
    }

    .mobile-nav-item.active .material-symbols-rounded {
        font-variation-settings: 'FILL' 1;
        transform: scale(1.06);
    }

    .mobile-nav-item.active .mobile-nav-label {
        color: var(--md-sys-color-primary);
        font-weight: 700;
    }

    .mobile-nav-item:active .mobile-nav-icon-wrapper {
        transform: scale(0.92);
    }

    .mobile-nav-badge {
        position: absolute;
        top: -1px;
        right: 6px;
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        border-radius: 9px;
        background: var(--md-sys-color-error);
        color: #ffffff;
        font-size: 10px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
        box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
    }

    /* Metrics 2x2 Grid */
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        margin-bottom: 14px !important;
    }

    .metric-card {
        padding: 10px 12px !important;
        border-radius: 12px !important;
        gap: 8px !important;
    }

    .metric-icon-box {
        width: 36px !important;
        height: 36px !important;
        border-radius: 9px !important;
    }

    .metric-icon-box .material-symbols-rounded {
        font-size: 19px !important;
    }

    .metric-value {
        font-size: 18px !important;
    }

    .metric-label {
        font-size: 10.5px !important;
    }

    /* Transform OLT Table into Modern High-Tech Cards */
    #oltsTable,
    #oltsTable tbody,
    #oltsTable tr.olt-row {
        display: block !important;
        width: 100% !important;
    }

    #oltsTable thead {
        display: none !important;
    }

    #oltsTable tr.olt-row {
        background: var(--md-sys-color-surface-container);
        border: 1px solid var(--md-sys-color-outline-variant);
        border-radius: 16px;
        margin-bottom: 14px;
        padding: 14px 16px;
        box-shadow: var(--md-sys-elevation-1);
        transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    }

    #oltsTable tr.olt-row:active {
        transform: scale(0.995);
    }

    #oltsTable tr.olt-row.selected {
        border-color: var(--md-sys-color-primary);
        box-shadow: 0 0 16px rgba(150, 204, 255, 0.16);
    }

    #oltsTable tr.olt-row > td {
        display: block !important;
        width: 100% !important;
        padding: 6px 0 !important;
        border: none !important;
    }

    /* Header row inside card: Checkbox + IP */
    #oltsTable tr.olt-row > td:first-child:has(input[type="checkbox"]) {
        display: flex !important;
        align-items: center;
        gap: 8px;
        padding-bottom: 2px !important;
    }

    #oltsTable .olt-select-checkbox {
        width: 18px;
        height: 18px;
    }

    /* SFP spoiler toggle and dots */
    .sfp-spoiler-toggle {
        display: inline-flex;
        padding: 5px 10px;
        border-radius: 8px;
        background: var(--md-sys-color-surface-container-high);
        border: 1px solid var(--md-sys-color-outline-variant);
        font-size: 11.5px;
        font-weight: 600;
        cursor: pointer;
    }

    .sfp-dots-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .sfp-dots {
        max-width: 100%;
        overflow-x: auto;
        padding: 3px 0;
    }

    /* Actions row at the bottom of the OLT card */
    #oltsTable tr.olt-row > td:last-child {
        margin-top: 8px;
        padding-top: 10px !important;
        border-top: 1px solid var(--md-sys-color-outline-variant) !important;
    }

    #oltsTable tr.olt-row > td:last-child > div:last-child {
        display: flex !important;
        gap: 6px !important;
        flex-wrap: wrap;
    }

    #oltsTable tr.olt-row > td:last-child .btn {
        flex: 1;
        justify-content: center;
        min-height: 38px;
        font-size: 12px;
    }

    /* Selection bar on mobile */
    #oltSelectionBar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 12px 14px !important;
        border-radius: 14px !important;
    }

    .olt-selection-stats {
        flex-wrap: wrap;
        gap: 4px !important;
    }

    .olt-selection-actions {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .olt-selection-actions .btn {
        flex: 1;
        justify-content: center;
        min-height: 40px;
    }

    /* SFP Tabs in OLT Detail View */
    #oltSfpTabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 6px !important;
        padding-bottom: 6px !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    #oltSfpTabs::-webkit-scrollbar {
        display: none;
    }

    #oltSfpTabs .btn {
        flex-shrink: 0;
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* ==========================================================================
   Responsive Adjustments: Modals & Bottom Sheets (<= 640px)
   ========================================================================== */
@media (max-width: 640px) {
    .modal-backdrop {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-top-left-radius: 24px !important;
        border-top-right-radius: 24px !important;
        max-height: 86vh !important;
        border-bottom: none !important;
        position: relative;
        animation: m3BottomSheetUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    /* Sheet handle grab indicator */
    .modal-card::before {
        content: '';
        display: block;
        width: 38px;
        height: 4px;
        background-color: var(--md-sys-color-outline-variant);
        border-radius: 2px;
        margin: 10px auto 4px auto;
        opacity: 0.9;
    }

    .modal-header {
        padding: 10px 18px 12px 18px !important;
    }

    .modal-body {
        padding: 14px 18px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px)) 18px !important;
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100% !important;
        min-height: 44px !important;
        justify-content: center;
        font-size: 14px;
    }

    .profile-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 18px;
    }

    .profile-hero-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 380px) {
    .metrics-grid {
        grid-template-columns: 1fr !important;
    }
}

@keyframes m3BottomSheetUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

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

/* ==========================================================================
   User Profile & Personal Settings
   ========================================================================== */
.profile-hero {
    background: linear-gradient(135deg, var(--md-sys-color-surface-container-high), var(--md-sys-color-surface-container));
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px 28px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    box-shadow: var(--md-sys-elevation-1);
}

.profile-hero-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-avatar-large {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-tertiary));
    color: var(--md-sys-color-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    box-shadow: var(--md-sys-elevation-2);
    border: 3px solid rgba(255, 255, 255, 0.1);
}

.profile-theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.theme-card-option {
    border: 2px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 14px 16px;
    background: var(--md-sys-color-surface-container-low);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.theme-card-option:hover {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface-container);
}

.theme-card-option.active {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.user-profile-badge {
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.user-profile-badge:hover {
    background-color: var(--md-sys-color-surface-container-highest);
    border-color: var(--md-sys-color-primary);
    transform: translateY(-1px);
}

/* ==========================================================================
   Mobile Touch & Form Refinements
   ========================================================================== */
@media (max-width: 768px) {
    /* Prevent iOS auto-zoom on form inputs */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Headings scaling */
    h1, .view-title {
        font-size: 19px !important;
        line-height: 1.3 !important;
    }

    /* Card padding optimization */
    .card {
        padding: 14px !important;
        border-radius: 16px !important;
        margin-bottom: 14px !important;
    }

    .card-header {
        padding-bottom: 10px !important;
        margin-bottom: 12px !important;
    }

    .card-title {
        font-size: 14px !important;
    }

    /* Responsive tables */
    .table-responsive {
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .table th,
    .table td {
        padding: 10px 12px !important;
        font-size: 12.5px !important;
    }

    /* Action buttons touch target */
    .btn {
        min-height: 38px;
        touch-action: manipulation;
    }

    .btn-sm {
        min-height: 34px;
        padding: 5px 10px;
    }

    .btn-icon {
        min-width: 38px;
        min-height: 38px;
    }

    /* Toast container placement above bottom nav */
    .toast-container {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
        left: 12px !important;
        right: 12px !important;
        max-width: none !important;
    }

    .toast {
        width: 100% !important;
        font-size: 13px !important;
        padding: 12px 14px !important;
    }
}

