/* Admin Portal Styles - EC Production Intelligence */
/* External CSS only for CSP compliance */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f1e;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(30, 30, 46, 0.8);
    --bg-input: rgba(30, 30, 46, 0.8);
    --table-header-bg: var(--bg-secondary);
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --text-muted: #666;
    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border-color: rgba(255, 255, 255, 0.05);
    --border-accent: rgba(99, 102, 241, 0.3);
    --sidebar-width: 250px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-accent);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.form-help {
    font-size: 12px;
    color: var(--text-muted, #888);
    margin-top: -4px;
}

.card-description {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 14px;
}

.card-description code {
    background: var(--bg-input, #2a2a2a);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="tel"],
select,
textarea {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-accent);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Checkbox */
.checkbox-group {
    flex-direction: row;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.checkbox-label span {
    user-select: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border: 1px solid var(--border-accent);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.2);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

/* Error Message */
.error-message {
    color: var(--danger);
    font-size: 14px;
    min-height: 20px;
    text-align: center;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.mobile-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.hamburger span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 101;
    transition: transform 0.25s ease;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

/* Sidebar toggle button (desktop only) */
.sidebar-toggle-btn {
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 9999px;
    background: rgba(30, 30, 46, 0.9);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
}

.sidebar-toggle-btn:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.18);
    border-color: var(--border-accent);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    color: var(--text-primary);
}

.sidebar-toggle-btn:focus-visible {
    outline: 2px solid rgba(99, 102, 241, 0.6);
    outline-offset: 2px;
}

.sidebar-toggle-icon {
    width: 18px;
    height: 18px;
    display: block;
}

.sidebar-collapse-btn {
    display: none; /* Desktop only */
    position: fixed;
    top: 50%;
    left: var(--sidebar-width);
    transform: translate(-50%, -50%);
    z-index: 103;
}

.sidebar-expand-btn {
    display: none; /* Desktop only */
    position: fixed;
    top: 50%;
    left: 0;
    transform: translate(50%, -50%);
    z-index: 103;
}

/* Desktop: allow collapsing the fixed sidebar */
@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0;
    }

    .sidebar-collapse-btn {
        display: inline-flex;
    }

    body.sidebar-collapsed .sidebar-collapse-btn {
        display: none;
    }

    body.sidebar-collapsed .sidebar-expand-btn {
        display: inline-flex;
    }
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid var(--border-accent);
    border-radius: 8px;
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: rgba(99, 102, 241, 0.25);
    color: var(--text-primary);
}

.sidebar-link .nav-icon {
    font-size: 14px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 16px 24px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-timezone {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.sidebar-timezone-label {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-timezone .form-select-sm {
    width: 100%;
    min-width: 0;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 24px;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

.view {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    max-height: calc(100vh - 48px);
    min-height: 0;
    flex-direction: column;
    overflow: auto;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.view-header h1 {
    font-size: 28px;
    font-weight: 700;
}

.view-header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.inline-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-select-sm {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-accent);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    min-width: 150px;
}

.view-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 24px;
    min-height: 0;
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-success {
    border-bottom: 3px solid var(--success);
}
.stat-success .stat-value {
    color: var(--success);
}

.stat-warning {
    border-bottom: 3px solid var(--warning);
}
.stat-warning .stat-value {
    color: var(--warning);
}

.stat-danger {
    border-bottom: 3px solid var(--danger);
}
.stat-danger .stat-value {
    color: var(--danger);
}

.stat-info {
    border-bottom: 3px solid var(--accent-primary);
}
.stat-info .stat-value {
    color: var(--accent-primary);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.sticky-table-container {
    flex: 0 1 auto;
    height: auto;
    min-height: 0;
    max-height: var(--admin-table-max-height, calc(100vh - 240px));
    overflow: auto;
    position: relative;
    --sticky-header-height: 42px;
}

.sticky-table-container .data-table {
    border-collapse: separate;
    border-spacing: 0;
}

.sticky-table-container:has(.data-table)::before {
    content: "";
    display: block;
    height: var(--sticky-header-height);
    margin-bottom: calc(var(--sticky-header-height) * -1);
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--table-header-bg);
    box-shadow: inset 0 -1px 0 var(--border-color);
}

.sticky-table-container .data-table thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

.sticky-table-container .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--table-header-bg);
    box-shadow: inset 0 -1px 0 var(--border-color);
}

.sticky-table-container .data-table tbody td {
    position: relative;
    z-index: 0;
}

#view-device-fleet .view-content {
    gap: 16px;
}

.device-fleet-policy-card {
    padding: 14px 16px;
}

.device-fleet-policy-card h3 {
    font-size: 14px;
    margin-bottom: 10px;
}

.device-fleet-policy-card .filter-row {
    gap: 10px;
}

.device-fleet-policy-card .update-policy-row .form-group {
    flex: 1 1 126px;
    gap: 4px;
    min-width: 120px;
}

.device-fleet-policy-card .update-policy-row .form-group:nth-child(5) {
    flex-basis: 180px;
}

.device-fleet-policy-card .form-group label {
    font-size: 10px;
    letter-spacing: 0.7px;
    line-height: 1.2;
}

.device-fleet-policy-card .update-policy-row .form-select,
.device-fleet-policy-card .update-policy-row .form-input {
    height: 34px;
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.device-fleet-policy-card .quick-actions {
    gap: 8px;
}

.device-fleet-policy-card .btn {
    min-height: 34px;
    padding: 8px 12px;
    font-size: 12px;
}

.device-fleet-policy-card .update-policy-actions {
    margin-top: 10px;
}

.device-fleet-table-card {
    flex: 0 1 auto;
    min-height: 0;
}

.card:has(.sticky-table-container) {
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    min-height: 0;
}

.card:has(.sticky-table-container) .card-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

#view-badge-scans {
    gap: 24px;
}

#view-badge-scans .view-header,
#badgeScansStats {
    flex: 0 0 auto;
}

#badgeScansList {
    flex: 0 1 auto;
    min-height: 0;
}

.badge-scans-table-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.badge-scans-table-shell .sticky-table-container {
    width: 100%;
}

.badge-scans-table-shell .pagination {
    flex: 0 0 auto;
    margin-top: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
    background: var(--table-header-bg);
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.compact-table th,
.compact-table td {
    padding: 10px 12px;
    white-space: nowrap;
}

.compact-table td:nth-child(4) {
    max-width: 360px;
    white-space: normal;
}

.muted-cell {
    color: var(--text-secondary);
}

.loading-cell {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

.placeholder-text {
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
}

/* Warning Card */
.warning-card {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.warning-card h3 {
    color: var(--warning);
}

/* Production Data Cleanup */
.danger-zone-card {
    border-color: rgba(239, 68, 68, 0.45);
}

.danger-zone-card h3 {
    color: var(--danger);
}

.card-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.cleanup-preserve-note {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.08);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}

.admin-tools-note {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.10);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}

.admin-tools-note.is-enabled {
    border-color: rgba(34, 197, 94, 0.38);
    background: rgba(34, 197, 94, 0.10);
}

.admin-tools-note strong {
    color: var(--text-primary);
}

.admin-tools-note code {
    display: block;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    white-space: normal;
    overflow-wrap: anywhere;
}

.cleanup-confirm-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin-top: 18px;
}

.cleanup-row-count {
    color: var(--text-primary);
    font-weight: 700;
}

.cleanup-row-count.has-rows {
    color: var(--danger);
}

/* Logs Container */
.logs-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

.logs-container {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    overflow-y: auto;
    max-height: 600px;
}

.logs-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.log-line {
    white-space: pre-wrap;
    word-break: break-all;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.log-line:hover {
    background: rgba(255, 255, 255, 0.05);
}

.logs-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.logs-status.connected {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.logs-status.disconnected {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.logs-status.connecting {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-secondary {
    background: rgba(148, 163, 184, 0.18);
    color: var(--text-secondary);
}

.badge-info {
    background: rgba(59, 130, 246, 0.18);
    color: #60a5fa;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.toast {
    padding: 16px 24px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

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

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-accent);
}

.modal.modal-wide {
    max-width: 820px;
}

.modal.modal-terminal {
    max-width: min(1120px, calc(100vw - 40px));
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .btn {
    margin-top: 8px;
}

.pi-terminal-shell {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pi-terminal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.pi-terminal-toolbar .btn {
    margin-top: 0;
}

.pi-terminal-status {
    color: var(--text-secondary);
    font-size: 13px;
}

.pi-terminal-output {
    width: 100%;
    height: min(58vh, 560px);
    min-height: 320px;
    margin: 0;
    padding: 14px;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #05070b;
    color: #e5f0ff;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    outline: none;
}

.pi-terminal-output:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.terminal-action-btn {
    white-space: nowrap;
}

.terminal-access-cell {
    min-width: 220px;
}

.terminal-access-status {
    margin-bottom: 6px;
}

.terminal-access-meta {
    font-size: 11px;
    line-height: 1.35;
    margin-bottom: 8px;
}

.terminal-access-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.terminal-settings-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.terminal-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.terminal-settings-grid .form-group {
    margin-bottom: 0;
}

.input-action-row {
    display: flex;
    gap: 8px;
}

.input-action-row .form-input {
    flex: 1 1 auto;
    min-width: 0;
}

.input-action-row .btn {
    flex: 0 0 auto;
    margin-top: 0;
}

.terminal-settings-status {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
}

.terminal-settings-actions {
    gap: 8px;
}

.terminal-audit-log h3 {
    font-size: 14px;
    margin-bottom: 8px;
}

.terminal-audit-list {
    display: grid;
    gap: 6px;
}

.terminal-audit-row {
    display: grid;
    grid-template-columns: 150px 100px 150px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
}

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

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

.sensor-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sensor-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid var(--border-accent);
    font-size: 12px;
    line-height: 1.3;
}

.sensor-pill strong {
    color: var(--accent-primary);
    font-weight: 700;
}

.sensor-empty {
    color: var(--text-muted);
    font-size: 13px;
}

.sensor-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.sensor-editor-card {
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
}

.sensor-editor-card h3 {
    font-size: 15px;
    margin-bottom: 12px;
}

/* Token Display */
.token-display {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    word-break: break-all;
    font-family: monospace;
    font-size: 14px;
}

.token-warning {
    color: var(--warning);
    font-size: 12px;
    margin-top: 8px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 80px 16px 24px;
    }

    .view {
        max-height: calc(100vh - 104px);
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .view-header h1 {
        font-size: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 28px;
    }

    .quick-actions {
        flex-direction: column;
    }

    .quick-actions .btn {
        width: 100%;
    }

    .data-table th,
    .data-table td {
        padding: 8px 12px;
        font-size: 14px;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        max-width: 100%;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================
   PBOM Light Theme (Overrides)
   ============================ */

html.theme-pbom {
    --bg-primary: #f8fafc;
    --bg-secondary: #f3f4f6;
    --bg-card: rgba(255, 255, 255, 0.98);
    --bg-input: #ffffff;
    --table-header-bg: rgba(17, 24, 39, 0.04);
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent-primary: #2563eb;
    --accent-secondary: #1d4ed8;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --border-color: rgba(17, 24, 39, 0.10);
    --border-accent: rgba(37, 99, 235, 0.28);
}

html.theme-pbom .card,
html.theme-pbom .stat-card,
html.theme-pbom .sidebar,
html.theme-pbom .mobile-header,
html.theme-pbom .login-card,
html.theme-pbom .toast,
html.theme-pbom .modal {
    backdrop-filter: none;
}

html.theme-pbom input:focus,
html.theme-pbom select:focus,
html.theme-pbom textarea:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

html.theme-pbom .btn-primary {
    background: var(--accent-primary);
}

html.theme-pbom .btn-primary:hover:not(:disabled) {
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
}

html.theme-pbom .btn-secondary {
    background: rgba(37, 99, 235, 0.08);
}

html.theme-pbom .btn-secondary:hover:not(:disabled) {
    background: rgba(37, 99, 235, 0.12);
}

html.theme-pbom .btn-ghost:hover:not(:disabled) {
    background: rgba(17, 24, 39, 0.04);
}

html.theme-pbom .sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(17, 24, 39, 0.12);
    box-shadow: 0 10px 22px rgba(16, 24, 40, 0.12);
}

html.theme-pbom .sidebar-toggle-btn:hover:not(:disabled) {
    background: rgba(37, 99, 235, 0.10);
    border-color: rgba(37, 99, 235, 0.28);
    box-shadow: 0 14px 26px rgba(16, 24, 40, 0.14);
}

html.theme-pbom .sidebar-toggle-btn:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.55);
}

html.theme-pbom .sidebar-link {
    background: rgba(37, 99, 235, 0.10);
    border-color: rgba(37, 99, 235, 0.22);
    color: var(--accent-primary);
}

html.theme-pbom .sidebar-link:hover {
    background: rgba(37, 99, 235, 0.14);
    color: var(--text-primary);
}

html.theme-pbom .nav-item:hover {
    background: rgba(37, 99, 235, 0.06);
}

html.theme-pbom .nav-item.active {
    background: rgba(37, 99, 235, 0.08);
}

html.theme-pbom .data-table th {
    background: var(--table-header-bg);
}

html.theme-pbom .data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.06);
}

html.theme-pbom .card {
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 18px 38px rgba(16, 24, 40, 0.10);
}

html.theme-pbom .toast {
    box-shadow: 0 10px 22px rgba(16, 24, 40, 0.14);
}

html.theme-pbom .modal {
    box-shadow: 0 22px 60px rgba(16, 24, 40, 0.18);
}

html.theme-pbom .logs-container {
    background: rgba(17, 24, 39, 0.04);
    border: 1px solid rgba(17, 24, 39, 0.08);
}

html.theme-pbom .log-line {
    border-bottom: 1px solid rgba(17, 24, 39, 0.06);
}

html.theme-pbom .log-line:hover {
    background: rgba(17, 24, 39, 0.04);
}

html.theme-pbom .token-display {
    background: rgba(17, 24, 39, 0.04);
}

/* Filter Row Styles */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-row .form-group {
    flex: 1;
    min-width: 150px;
}

.filter-row .form-group-btn {
    flex: 0 0 auto;
    min-width: auto;
}

.form-select,
.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.update-policy-row .form-group {
    flex: 1 1 160px;
}

.update-policy-row .form-select,
.update-policy-row .form-input {
    height: 44px;
    min-height: 44px;
    line-height: 20px;
}

.update-policy-row select.form-select {
    appearance: auto;
}

.update-policy-actions {
    margin-top: 20px;
}

/* Small stats grid for data summary */
.stats-grid-sm {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stats-grid-sm .stat-card {
    padding: 16px;
}

.stats-grid-sm .stat-value {
    font-size: 24px;
}

.stats-grid-sm .stat-label {
    font-size: 11px;
}

.stats-grid-fleet {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.stats-grid-fleet .stat-card {
    padding: 12px 10px;
    min-width: 0;
}

.stats-grid-fleet .stat-value {
    font-size: 22px;
    line-height: 1.1;
    margin-bottom: 4px;
}

.stats-grid-fleet .stat-label {
    font-size: 10px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
    }

    .filter-row .form-group {
        width: 100%;
    }

    .stats-grid-sm {
        grid-template-columns: repeat(3, 1fr);
    }

    .stats-grid-fleet {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* 2FA / TOTP Styles */
.hidden {
    display: none !important;
}

.totp-input {
    font-size: 24px;
    letter-spacing: 8px;
    text-align: center;
    font-family: monospace;
}

.totp-hint {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 8px;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    display: block;
    text-align: center;
    margin-top: 16px;
    cursor: pointer;
}

.back-link:hover {
    color: var(--accent-primary);
}

.setup-info {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--border-accent);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.qr-container {
    text-align: center;
    margin: 16px 0;
}

.qr-container img {
    max-width: 200px;
    border-radius: 8px;
    background: white;
    padding: 8px;
}

.secret-display {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    font-family: monospace;
    font-size: 14px;
    letter-spacing: 2px;
    text-align: center;
    word-break: break-all;
}

.backup-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 16px 0;
}

.backup-codes code {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 4px;
    font-family: monospace;
    text-align: center;
    font-size: 14px;
}

/* Clock Events Styles */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
}

.filter-group label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
}

.filter-actions {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
}

.pagination {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pagination-info {
    color: #888;
    font-size: 14px;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.status-success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.review-reason {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 320px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
}

.review-reason-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: 0 0 auto;
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
}

.review-reason-text {
    color: var(--text-primary);
    white-space: normal;
}

.status-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

#workersCount {
    font-weight: normal;
    color: #888;
    font-size: 14px;
}

.worker-search-group {
    min-width: 260px;
}

.workers-table td {
    vertical-align: middle;
}

.worker-identity-cell {
    min-width: 220px;
}

.worker-name {
    color: var(--text-primary);
    font-weight: 700;
}

.worker-subtext {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 12px;
}

.worker-position-cell {
    max-width: 320px;
    white-space: normal;
}

.worker-training-cell {
    min-width: 220px;
    max-width: 320px;
    white-space: normal;
}

.worker-training-summary {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.worker-training-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.worker-training-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.14);
    color: #2563eb;
    font-size: 12px;
    font-weight: 700;
}

.worker-training-chip-muted {
    background: rgba(148, 163, 184, 0.18);
    color: var(--text-secondary);
}

.worker-training-empty,
.worker-training-context {
    color: var(--text-secondary);
    font-size: 12px;
}

.workers-table code {
    white-space: nowrap;
}

#clockEventsCount {
    font-weight: normal;
    color: #888;
    font-size: 14px;
}
