/* ============================================================
   Remote Server 89 Admin Panel — Premium Dark Theme
   ============================================================ */

:root {
    /* Core palette */
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: rgba(22, 24, 38, 0.75);
    --bg-glass: rgba(30, 32, 48, 0.6);
    --border-color: rgba(99, 102, 241, 0.12);
    --border-glass: rgba(255, 255, 255, 0.06);

    /* Text — improved contrast (WCAG AA compliant) */
    --text-primary: #e8ecf4;
    --text-secondary: #94a3b8;
    --text-muted: #7a8ba6;
    /* bumped from #64748b for 4.5:1 ratio */

    /* Accents */
    --indigo: #6366f1;
    --indigo-light: #818cf8;
    --emerald: #10b981;
    --amber: #f59e0b;
    --rose: #f43f5e;
    --sky: #38bdf8;
    --purple: #a78bfa;
    --warning-color: #f59e0b;

    /* Glow */
    --glow-indigo: rgba(99, 102, 241, 0.15);
    --glow-emerald: rgba(16, 185, 129, 0.15);
    --glow-amber: rgba(245, 158, 11, 0.15);
    --glow-rose: rgba(244, 63, 94, 0.15);
    --glow-sky: rgba(56, 189, 248, 0.15);
    --glow-purple: rgba(167, 139, 250, 0.15);

    /* Spacing */
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Login Screen
   ============================================================ */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
}

.login-card {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    margin-bottom: 20px;
    display: inline-flex;
}

.login-logo-img {
    height: 48px;
    max-height: 48px;
    max-width: 200px;
    width: auto;
    object-fit: contain;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--indigo-light), var(--sky));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.input-group {
    text-align: left;
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(15, 17, 23, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px var(--glow-indigo);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.error-msg {
    color: var(--rose);
    font-size: 0.8rem;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--glow-rose);
    border-radius: var(--radius-sm);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--indigo), #7c3aed);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.15s, box-shadow 0.2s;
    margin-top: 8px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary.btn-sm {
    width: auto;
    padding: 8px 16px;
    font-size: 0.8rem;
}

/* ============================================================
   Dashboard Layout
   ============================================================ */

.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: width var(--transition-normal);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .user-details {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-header {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 4px;
    gap: 6px;
}

.sidebar.collapsed .sidebar-toggle {
    margin-left: 0;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .user-info {
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
    flex-direction: column;
    gap: 8px;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-logo {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.sidebar.collapsed .sidebar-logo-img {
    max-width: 36px;
    max-height: 36px;
    width: 36px;
    height: auto;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-glass);
}

.sidebar-toggle {
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-toggle svg {
    transition: transform var(--transition-normal);
}

.sidebar-logo img,
.sidebar-logo svg {
    display: block;
}

.sidebar-logo-img {
    height: 28px;
    max-height: 28px;
    max-width: 32px;
    width: auto;
    object-fit: contain;
    display: block;
}

.sidebar-title {
    font-weight: 700;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--indigo-light), var(--sky));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.nav-link:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--glow-indigo);
    color: var(--indigo-light);
}

.nav-link svg {
    flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--indigo), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: rgba(244, 63, 94, 0.1);
    color: var(--rose);
}

/* ============================================================
   Main Content
   ============================================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    transition: margin-left var(--transition-normal);
}

.sidebar.collapsed~.main-content {
    margin-left: var(--sidebar-collapsed);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.content-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--emerald);
    background: rgba(16, 185, 129, 0.08);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--emerald);
    display: inline-block;
}

.status-dot.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ============================================================
   KPI Cards
   ============================================================ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-card.glow-indigo::before {
    background: linear-gradient(90deg, var(--indigo), var(--indigo-light));
}

.kpi-card.glow-emerald::before {
    background: linear-gradient(90deg, var(--emerald), #34d399);
}

.kpi-card.glow-amber::before {
    background: linear-gradient(90deg, var(--amber), #fbbf24);
}

.kpi-card.glow-rose::before {
    background: linear-gradient(90deg, var(--rose), #fb7185);
}

.kpi-card:hover {
    transform: translateY(-2px);
}

.kpi-card.glow-indigo:hover {
    box-shadow: 0 8px 32px var(--glow-indigo);
}

.kpi-card.glow-emerald:hover {
    box-shadow: 0 8px 32px var(--glow-emerald);
}

.kpi-card.glow-amber:hover {
    box-shadow: 0 8px 32px var(--glow-amber);
}

.kpi-card.glow-rose:hover {
    box-shadow: 0 8px 32px var(--glow-rose);
}

/* Sky & Purple glow variants */
.kpi-card.glow-sky::before {
    background: linear-gradient(90deg, var(--sky), #7dd3fc);
}

.kpi-card.glow-sky .kpi-icon {
    color: var(--sky);
}

.kpi-card.glow-sky:hover {
    box-shadow: 0 8px 32px var(--glow-sky);
}

.kpi-card.glow-purple::before {
    background: linear-gradient(90deg, var(--purple), #c4b5fd);
}

.kpi-card.glow-purple .kpi-icon {
    color: var(--purple);
}

.kpi-card.glow-purple:hover {
    box-shadow: 0 8px 32px var(--glow-purple);
}

.kpi-icon {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.kpi-card.glow-indigo .kpi-icon {
    color: var(--indigo-light);
}

.kpi-card.glow-emerald .kpi-icon {
    color: var(--emerald);
}

.kpi-card.glow-amber .kpi-icon {
    color: var(--amber);
}

.kpi-card.glow-rose .kpi-icon {
    color: var(--rose);
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================================
   Glass Panels
   ============================================================ */

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
}

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.panel {
    padding: 20px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.badge {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.badge-live {
    background: var(--glow-emerald);
    color: var(--emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-live .status-dot {
    width: 6px;
    height: 6px;
}

.badge-online {
    background: var(--glow-emerald);
    color: var(--emerald);
}

.badge-offline {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

.badge-admin {
    background: var(--glow-indigo);
    color: var(--indigo-light);
}

.badge-user {
    background: rgba(56, 189, 248, 0.1);
    color: var(--sky);
}

/* Event Feed */
.event-feed {
    max-height: 360px;
    overflow-y: auto;
}

.event-feed::-webkit-scrollbar {
    width: 4px;
}

.event-feed::-webkit-scrollbar-track {
    background: transparent;
}

.event-feed::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.event-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-glass);
    animation: fadeIn 0.3s ease-out;
    font-size: 0.85rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.event-item:last-child {
    border-bottom: none;
}

.event-time {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-right: 8px;
}

.event-type {
    font-weight: 600;
    margin-right: 4px;
}

.event-type.peer {
    color: var(--indigo-light);
}

.event-type.connection {
    color: var(--emerald);
}

.event-type.relay {
    color: var(--amber);
}

.event-type.auth {
    color: var(--sky);
}

.event-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.85rem;
}

/* Device List */
.device-list {
    max-height: 360px;
    overflow-y: auto;
}

.device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-glass);
}

.device-item:last-child {
    border-bottom: none;
}

.device-id {
    font-weight: 600;
    font-size: 0.85rem;
    font-family: 'Roboto Mono', monospace;
}

.device-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================================
   Data Tables
   ============================================================ */

.page {
    display: none;
    animation: pageFadeIn 0.25s ease-out;
}

.page.active {
    display: block;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    flex: 1;
    max-width: 320px;
}

.search-box input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Search clear button */
.search-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.85rem;
    line-height: 1;
    border-radius: 4px;
    display: none;
    transition: color var(--transition-fast);
}

.search-clear:hover {
    color: var(--text-primary);
}

.search-clear.visible {
    display: inline;
}

.table-container {
    overflow-x: auto;
    padding: 4px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-glass);
}

.data-table td {
    padding: 12px 16px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Action buttons in tables */
.action-btns {
    display: flex;
    gap: 4px;
}

.btn-action {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.15s;
}

.btn-action.edit {
    background: var(--glow-indigo);
    color: var(--indigo-light);
}

.btn-action.edit:hover {
    background: rgba(99, 102, 241, 0.25);
}

.btn-action.delete {
    background: var(--glow-rose);
    color: var(--rose);
}

.btn-action.delete:hover {
    background: rgba(244, 63, 94, 0.25);
}

/* Sortable column headers */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 22px;
}

.data-table th.sortable::after {
    content: '\2195';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    font-size: 0.7rem;
}

.data-table th.sortable.sort-asc::after {
    content: '\25B2';
    opacity: 0.8;
    color: var(--indigo-light);
}

.data-table th.sortable.sort-desc::after {
    content: '\25BC';
    opacity: 0.8;
    color: var(--indigo-light);
}

/* Password mask */
.password-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.password-cell .pw-text {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.82rem;
}

.password-cell .btn-icon {
    padding: 2px 4px;
    font-size: 0.75rem;
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal {
    width: 100%;
    max-width: 440px;
    padding: 24px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    font-size: 1rem;
    padding: 4px 8px;
    color: var(--text-muted);
}

.modal-body .input-group {
    margin-bottom: 14px;
}

.modal-body .btn-primary {
    margin-top: 12px;
}

/* Modal close on overlay click */
.modal {
    position: relative;
    z-index: 201;
}

/* ============================================================
   Toast Notifications
   ============================================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    backdrop-filter: blur(16px);
    animation: toastSlideIn 0.3s ease-out;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
}

.toast.hiding {
    animation: toastSlideOut 0.25s ease-in forwards;
}

.toast-success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.25);
}

.toast-error {
    background: rgba(244, 63, 94, 0.15);
    color: #fda4af;
    border-color: rgba(244, 63, 94, 0.25);
}

.toast-info {
    background: rgba(56, 189, 248, 0.15);
    color: #7dd3fc;
    border-color: rgba(56, 189, 248, 0.25);
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    font-size: 0.9rem;
    padding: 2px 4px;
}

.toast-dismiss:hover {
    opacity: 1;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ============================================================
   Custom Confirm Dialog
   ============================================================ */

.confirm-overlay {
    z-index: 250;
}

.confirm-modal {
    max-width: 380px;
    text-align: center;
    padding: 32px 28px 24px !important;
}

.confirm-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.confirm-modal h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.confirm-message {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-actions button {
    flex: 1;
    max-width: 140px;
}

.btn-danger {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--rose), #e11d48);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow 0.2s;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--glow-rose);
}

/* ============================================================
   Skeleton Loading
   ============================================================ */

.skeleton {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg,
            var(--bg-card) 25%,
            rgba(99, 102, 241, 0.06) 50%,
            var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton.skeleton-wide {
    width: 80%;
}

.skeleton.skeleton-med {
    width: 50%;
}

.skeleton.skeleton-sm {
    width: 30%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ============================================================
   Empty States (for table pages)
   ============================================================ */

.table-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.table-empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.table-empty-state p {
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ============================================================
   Toolbar & Filters
   ============================================================ */

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-filter {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    min-width: 160px;
    transition: border-color 0.2s;
}

.select-filter:focus {
    border-color: var(--indigo);
}

.select-filter option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary {
    padding: 8px 16px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: var(--radius-sm);
    color: var(--sky);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: rgba(56, 189, 248, 0.18);
    border-color: rgba(56, 189, 248, 0.3);
}

.btn-secondary.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

/* Address Book Split Layout */
.ab-split {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    min-height: calc(100vh - 150px);
}

.ab-user-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ab-user-panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
}

.ab-user-panel-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.ab-user-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.ab-user-list::-webkit-scrollbar {
    width: 4px;
}

.ab-user-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.ab-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
}

.ab-user-item:hover {
    background: rgba(99, 102, 241, 0.06);
}

.ab-user-item.active {
    background: var(--glow-indigo);
    border-left-color: var(--indigo);
}

.ab-user-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ab-user-item-info .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.7rem;
    border-radius: 8px;
}

.ab-user-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.ab-user-item-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.ab-count-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--indigo-light);
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.ab-detail-panel {
    display: flex;
    flex-direction: column;
}

.ab-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-glass);
}

.ab-detail-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ab-detail-user-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.ab-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
}

.ab-entry-count {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.ab-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

/* Tag badges */
.tag-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--glow-indigo);
    color: var(--indigo-light);
    font-weight: 500;
    margin-right: 3px;
    margin-bottom: 2px;
}

/* Textarea for modals */
.modal-body textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(15, 17, 23, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.82rem;
    outline: none;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s;
}

.modal-body textarea:focus {
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px var(--glow-indigo);
}

/* View All link */
.panel-view-all {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--indigo-light);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
}

.panel-view-all:hover {
    opacity: 1;
}

/* ============================================================
   Audit Log Viewer
   ============================================================ */

.audit-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 0;
}

.audit-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: -1px;
}

.audit-tab:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.04);
}

.audit-tab.active {
    color: var(--indigo-light);
    border-bottom-color: var(--indigo);
}

.audit-filters {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-input {
    padding: 7px 10px;
    background: rgba(15, 17, 23, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s;
    min-width: 120px;
}

.filter-input:focus {
    border-color: var(--indigo);
    box-shadow: 0 0 0 2px var(--glow-indigo);
}

.filter-input option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.filter-actions {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

.audit-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding: 12px 0;
}

.pagination-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    min-width: 120px;
    text-align: center;
}

.audit-total {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.table-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Event type badges */
.badge-event {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-login_ok {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

.badge-login_fail {
    background: rgba(244, 63, 94, 0.15);
    color: #fda4af;
}

.badge-logout {
    background: rgba(56, 189, 248, 0.15);
    color: #7dd3fc;
}

.badge-session_ip_change {
    background: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
}

/* Admin action badges */
.badge-create_user,
.badge-create_group {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

.badge-delete_user,
.badge-delete_group {
    background: rgba(244, 63, 94, 0.15);
    color: #fda4af;
}

.badge-update_user,
.badge-change_password {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .panel-grid {
        grid-template-columns: 1fr;
    }

    .ab-split {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }

    .sidebar-title,
    .nav-link span,
    .user-details {
        display: none;
    }

    .sidebar-toggle {
        display: none;
    }

    .sidebar-header {
        justify-content: center;
    }

    .nav-link {
        justify-content: center;
        padding: 12px;
    }

    .user-info {
        justify-content: center;
    }

    .sidebar-footer {
        justify-content: center;
    }

    .main-content {
        margin-left: var(--sidebar-collapsed);
        padding: 16px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .toolbar-group {
        flex-wrap: wrap;
    }

    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: 100%;
    }

    .modal {
        max-width: calc(100vw - 32px);
        margin: 16px;
    }

    .toast-container {
        left: 16px;
        right: 16px;
    }

    .toast {
        min-width: unset;
        max-width: 100%;
    }

    /* Tables: horizontal scroll with shadow indicator */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    .data-table {
        min-width: 600px;
    }

    .content-header h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .ab-detail-header {
        flex-direction: column;
        gap: 12px;
    }

    .toolbar-group {
        width: 100%;
    }

    .toolbar-group button {
        flex: 1;
    }
}