/* IDMS Modern UI - InfoBOXX Design System */
/* Dark/Light Theme Support */

/* ============================================
   CSS Custom Properties (Theme Variables)
   ============================================ */

:root {
    /* Dark Theme (Default) */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-card: #1e1e1e;
    --bg-card-hover: #2a2a2a;
    --bg-input: #2d2d2d;

    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-secondary: #8b5cf6;

    --border-color: #2d2d2d;
    --border-light: #3f3f46;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

    --status-success: #22c55e;
    --status-warning: #eab308;
    --status-error: #ef4444;
    --status-info: #3b82f6;

    --gradient-accent: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-card: linear-gradient(180deg, #1e1e1e 0%, #1a1a1a 100%);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent-primary: #2563eb;
    --accent-primary-hover: #1d4ed8;
    --accent-secondary: #7c3aed;

    --border-color: #e2e8f0;
    --border-light: #cbd5e1;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.1);

    --gradient-card: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* ============================================
   Base Styles
   ============================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-primary-hover);
}

/* ============================================
   Layout Structure
   ============================================ */

#main {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ============================================
   Sidebar Navigation
   ============================================ */

#nav-main {
    width: 260px;
    min-width: 260px;
    background: var(--bg-secondary);
    padding: 24px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.nav-brand-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: white;
}

.nav-brand-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

#nav-main h1 {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 12px 0;
}

.nav-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

#nav-main ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    flex: none;
}

#nav-main li {
    margin-bottom: 4px;
}

#nav-main ul a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

#nav-main ul a:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

#nav-main ul a.active {
    background: var(--gradient-accent);
    color: white;
}

/* Submenu Styles */
#nav-main .has-submenu > a {
    justify-content: space-between;
}

#nav-main .submenu-arrow {
    font-size: 10px;
    transition: transform var(--transition-fast);
}

#nav-main .has-submenu.expanded > a .submenu-arrow {
    transform: rotate(180deg);
}

#nav-main .submenu {
    display: none;
    padding-left: 12px;
    margin-top: 4px;
    border-left: 2px solid var(--border-color);
    margin-left: 12px;
}

#nav-main .has-submenu.expanded .submenu {
    display: block;
}

#nav-main .submenu li {
    margin-bottom: 2px;
}

#nav-main .submenu a {
    font-size: 13px;
    padding: 8px 12px;
    color: var(--text-muted);
}

#nav-main .submenu a:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

#nav-main .submenu a.active {
    background: var(--accent-primary);
    color: white;
}

/* Theme Toggle */
.theme-toggle {
    padding-top: 16px;
    padding-bottom: 16px;
    border-top: 1px solid var(--border-color);
}

.theme-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.theme-toggle-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.theme-icon {
    font-size: 16px;
}

/* Nav Footer */
.nav-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.nav-footer span {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Content Area
   ============================================ */

#content-area {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background: var(--bg-primary);
}

#content-header {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    padding: 20px 24px;
    margin-bottom: 24px;
    border-radius: var(--radius-lg);
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#content-main {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

/* ============================================
   Cards
   ============================================ */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md), var(--shadow-glow);
    border-color: var(--border-light);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-primary);
    display: inline-block;
}

/* ============================================
   Search Container
   ============================================ */

.search-container {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
}

.search-container input[type="text"] {
    flex: 1;
    min-width: 200px;
}

/* ============================================
   Tables
   ============================================ */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

tr {
    transition: background-color var(--transition-fast);
}

td, th {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

tr:last-child td {
    border-bottom: none;
}

/* Column Headers */
.colhead, th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    white-space: nowrap;
}

.colhead a,
th a {
    color: var(--text-primary) !important;
    text-decoration: none;
}

.colhead a:hover,
th a:hover {
    color: var(--accent-primary) !important;
}

/* Row Headers */
.rowhead {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-align: right;
    padding-right: 20px;
    min-width: 180px;
    white-space: nowrap;
}

/* Row Hover */
tr:hover td {
    background: var(--bg-card-hover);
}

tr:hover .rowhead {
    background: var(--bg-tertiary);
}

/* Detail Tables */
table.detail-table {
    max-width: 600px;
    margin: 0 auto;
}

table.detail-table td {
    padding: 12px 16px;
}

/* ============================================
   Monospace Text
   ============================================ */

.mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;
    font-size: 13px;
}

.center {
    text-align: center;
}

/* ============================================
   Page Title
   ============================================ */

.page-title {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    padding: 16px 0;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.page-title a {
    color: var(--accent-primary);
}

/* ============================================
   Form Elements
   ============================================ */

input[type=button],
input[type=submit],
button.btn {
    padding: 10px 20px;
    background: var(--accent-primary);
    color: white;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    font-family: inherit;
}

input[type=button]:hover,
input[type=submit]:hover,
button.btn:hover {
    background: var(--accent-primary-hover);
    box-shadow: var(--shadow-md);
}

input[type=text],
input[type=date],
input[type=number],
select {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
    font-family: inherit;
}

input[type=text]:focus,
input[type=date]:focus,
input[type=number]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.expandnum,
.expandtext {
    width: 100%;
}

/* ============================================
   Links
   ============================================ */

a.main,
a.main:visited {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a.main:hover {
    color: var(--accent-primary-hover);
    text-decoration: underline;
}

/* ============================================
   Status Badges
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

.badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

.badge-success::before {
    background: var(--status-success);
    box-shadow: 0 0 8px var(--status-success);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.15);
    color: var(--status-warning);
}

.badge-warning::before {
    background: var(--status-warning);
    box-shadow: 0 0 8px var(--status-warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.badge-error::before {
    background: var(--status-error);
    box-shadow: 0 0 8px var(--status-error);
}

/* Legacy problem links */
a.problem {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
}

a.problem::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

a.problem:hover {
    text-decoration: none;
    opacity: 0.9;
}

a.problem.green {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

a.problem.green::before {
    background: var(--status-success);
    box-shadow: 0 0 8px var(--status-success);
}

a.problem.yellow {
    background: rgba(234, 179, 8, 0.15);
    color: var(--status-warning);
}

a.problem.yellow::before {
    background: var(--status-warning);
    box-shadow: 0 0 8px var(--status-warning);
}

a.problem.red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

a.problem.red::before {
    background: var(--status-error);
    box-shadow: 0 0 8px var(--status-error);
}

/* ============================================
   Status Colors
   ============================================ */

.green {
    color: var(--status-success) !important;
}

.yellow {
    color: var(--status-warning) !important;
}

.red {
    color: var(--status-error) !important;
}

/* ============================================
   Sort Arrows
   ============================================ */

.arrow {
    border: solid var(--text-primary);
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
    margin-left: 6px;
}

.up {
    transform: rotate(-135deg);
}

.down {
    transform: rotate(45deg);
}

/* ============================================
   Pagination
   ============================================ */

.pagination a,
.pagination span {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    text-decoration: none;
}

.pagination a {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.pagination a:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.pagination span {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   Checkbox Styling
   ============================================ */

input[type=checkbox] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

label {
    cursor: pointer;
    margin-right: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ============================================
   Error Messages
   ============================================ */

.error-message {
    padding: 16px 24px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--status-error);
    color: #fca5a5;
    text-align: center;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

/* ============================================
   Dashboard Cards
   ============================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

/* .stat-card defined in Dashboard Stats section below */

.stat-card-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    #nav-main {
        width: 220px;
        min-width: 220px;
        padding: 16px;
    }

    #content-area {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    #main {
        flex-direction: column;
    }

    #nav-main {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-brand {
        padding-bottom: 16px;
        margin-bottom: 16px;
    }

    #nav-main ul {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    #nav-main li {
        margin-bottom: 0;
    }

    #nav-main h1 {
        display: none;
    }

    .theme-toggle {
        padding-top: 12px;
        padding-bottom: 0;
    }

    .nav-footer {
        display: none;
    }

    #content-area {
        padding: 16px;
    }

    #content-header {
        font-size: 20px;
        padding: 16px 20px;
    }

    #content-main {
        padding: 16px;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .rowhead {
        min-width: 120px;
        font-size: 11px;
    }
}

/* ============================================
   Animations
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

#content-main {
    animation: fadeIn 300ms ease;
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   Selection
   ============================================ */

::selection {
    background: var(--accent-primary);
    color: white;
}

/* ============================================
   Smooth Scrolling
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* ============================================
   Utility Classes
   ============================================ */

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

.font-mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    color: white;
}

.btn-danger {
    background: var(--status-error);
    color: white;
}

.btn-danger:hover {
    background: color-mix(in srgb, var(--status-error) 80%, black);
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================================
   Search Bar
   ============================================ */

.search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}

.search-form {
    display: flex;
    gap: 12px;
    flex: 1;
    min-width: 300px;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.filter-toggle {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

/* ============================================
   Data Tables
   ============================================ */

.table-container {
    overflow-x: auto;
    margin: 0 -4px;
    padding: 0 4px;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.data-table thead {
    background: var(--bg-tertiary);
}

.data-table th {
    padding: 14px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

.data-table th a {
    color: var(--text-primary);
    text-decoration: none;
}

.data-table th a:hover {
    color: var(--accent-primary);
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.text-center {
    text-align: center;
}

/* Sort indicators */
.sort-asc::after,
.sort-desc::after {
    display: inline-block;
    margin-left: 6px;
    border: solid var(--text-primary);
    border-width: 0 2px 2px 0;
    padding: 3px;
}

.sort-asc::after {
    content: '';
    transform: rotate(-135deg);
    margin-bottom: -2px;
}

.sort-desc::after {
    content: '';
    transform: rotate(45deg);
    margin-bottom: 2px;
}

/* ============================================
   Pagination
   ============================================ */

.pagination-top,
.pagination-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-top {
    margin-bottom: 16px;
}

.pagination-bottom {
    margin-top: 16px;
}

.results-count {
    color: var(--text-muted);
    font-size: 13px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination .btn {
    min-width: 36px;
}

/* ============================================
   Status Colors
   ============================================ */

.status-success {
    color: var(--status-success);
    font-weight: 600;
}

.status-warning {
    color: var(--status-warning);
    font-weight: 600;
}

.status-error {
    color: var(--status-error);
    font-weight: 600;
}

/* ============================================
   Badges for Device Status
   ============================================ */

.badge-in-service {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

.badge-in-service::before {
    background: var(--status-success);
    box-shadow: 0 0 8px var(--status-success);
}

.badge-out-of-service {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.badge-out-of-service::before {
    background: var(--status-error);
    box-shadow: 0 0 8px var(--status-error);
}

.badge-dev {
    background: rgba(59, 130, 246, 0.15);
    color: var(--status-info);
}

.badge-dev::before {
    background: var(--status-info);
    box-shadow: 0 0 8px var(--status-info);
}

.badge-disabled {
    background: rgba(113, 113, 122, 0.15);
    color: var(--text-muted);
}

.badge-disabled::before {
    background: var(--text-muted);
}

/* ============================================
   Page Headers
   ============================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.page-header h2 a {
    color: var(--accent-primary);
}

/* ============================================
   Detail Pages
   ============================================ */

.detail-page,
.vends-page,
.cycles-page {
    animation: fadeIn 300ms ease;
}

.detail-grid {
    display: grid;
    gap: 0;
}

.detail-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row:hover {
    background: var(--bg-card-hover);
}

.detail-label {
    padding: 14px 16px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
}

.detail-value {
    padding: 14px 16px;
    color: var(--text-primary);
}

/* ============================================
   Cards with Headers
   ============================================ */

.card-header {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2,
.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 0;
}

/* ============================================
   Forms
   ============================================ */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.form-input {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-actions {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.select-input {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.select-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ============================================
   Alerts
   ============================================ */

.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--status-error);
    color: var(--status-error);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--status-success);
    color: var(--status-success);
}

.alert-warning {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid var(--status-warning);
    color: var(--status-warning);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state p {
    margin: 0;
    font-size: 16px;
}

/* ============================================
   Filter Chips
   ============================================ */

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--accent-primary);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.filter-chip-remove {
    cursor: pointer;
    opacity: 0.7;
    font-size: 14px;
}

.filter-chip-remove:hover {
    opacity: 1;
}

/* ============================================
   Dashboard
   ============================================ */

.dashboard-welcome {
    animation: fadeIn 300ms ease;
}

.dashboard-welcome .card {
    margin-bottom: 32px;
}

.dashboard-welcome .card-header h2 {
    font-size: 18px;
    margin: 0;
}

.dashboard-welcome .card-body p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.dashboard-welcome .card-body p:last-child {
    margin-bottom: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 24px;
    text-align: center;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    box-shadow: var(--shadow-md), var(--shadow-glow);
    border-color: var(--border-light);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Relay Table
   ============================================ */

.relay-table {
    font-size: 13px;
}

.relay-table th {
    text-align: center;
}

.relay-table .row-label {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: right;
    padding-right: 16px;
    white-space: nowrap;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 768px) {
    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form {
        min-width: 100%;
    }

    .detail-row {
        grid-template-columns: 1fr;
    }

    .detail-label {
        border-bottom: none;
        padding-bottom: 4px;
    }

    .detail-value {
        padding-top: 4px;
        padding-bottom: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Login Page
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 24px;
}

.login-card {
    width: 400px;
    max-width: calc(100% - 48px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .form-input {
    width: 100%;
}

.login-remember {
    flex-direction: row !important;
    align-items: center;
}

.login-btn {
    width: 100%;
    padding: 12px 20px !important;
    font-size: 15px !important;
    margin-top: 4px;
}

.login-sso-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.6;
}

.login-sso-btn {
    width: 100%;
    padding: 12px 20px !important;
    font-size: 15px !important;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    gap: 10px;
}

.login-sso-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.login-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-footer .theme-toggle-btn {
    width: 100%;
}

/* ============================================
   Nav User Info & Logout
   ============================================ */

.nav-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-bottom: 8px;
}

.nav-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-user-role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-logout {
    display: block;
    text-align: center;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary) !important;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error) !important;
}

/* ============================================
   Activity Logs
   ============================================ */

.activity-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.activity-filters .search-input {
    flex: 1;
    min-width: 200px;
}

.badge-action {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-action.action-edit,
.badge-action.action-status_change {
    background: rgba(59, 130, 246, 0.15);
    color: var(--status-info);
}

.badge-action.action-create,
.badge-action.action-upload {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

.badge-action.action-delete {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.badge-action.action-login,
.badge-action.action-logout {
    background: rgba(113, 113, 122, 0.15);
    color: var(--text-muted);
}

.badge-action.action-sync,
.badge-action.action-expire {
    background: rgba(234, 179, 8, 0.15);
    color: var(--status-warning);
}

.activity-detail {
    font-size: 13px;
    color: var(--text-secondary);
}

.activity-detail .field-change {
    color: var(--text-muted);
    font-size: 12px;
}

.activity-detail .field-change strong {
    color: var(--text-secondary);
}
