:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #252836;
    --border: #2e3142;
    --text: #e4e6f0;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #38bdf8;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===== Custom Scrollbars ===== */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
*::-webkit-scrollbar-track {
    background: transparent;
}
*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
*::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    line-height: 1.5;
    overflow: hidden;
}

/* ===== SVG Icons ===== */
svg {
    vertical-align: middle;
    flex-shrink: 0;
}

/* ===== Text Helpers ===== */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }

/* ===== Layout ===== */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 220px;
    max-height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: width 0.2s ease;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 60px;
    padding: 12px 0;
    align-items: center;
}

/* Sidebar Top (Brand + Collapse Button) */
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 4px;
    min-height: 40px;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
}

.brand-icon {
    flex-shrink: 0;
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.brand-icon svg {
    width: 22px;
    height: 22px;
}

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sidebar-collapse-btn svg {
    width: 16px;
    height: 16px;
}

.sidebar-collapse-btn:hover {
    background: var(--bg-input);
    color: var(--text);
}

.collapse-icon {
    display: inline-block;
    transition: transform 0.2s ease;
}

.sidebar.collapsed .collapse-icon {
    transform: rotate(0deg);
}

.sidebar:not(.collapsed) .collapse-icon {
    transform: rotate(180deg);
}

/* Text visibility transitions */
.sidebar-text {
    opacity: 1;
    transition: opacity 0.15s ease 0.05s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-text {
    opacity: 0;
    width: 0;
    transition: opacity 0.1s ease, width 0s 0.1s;
}

.sidebar.collapsed .sidebar-top {
    justify-content: center;
    gap: 0;
    padding: 4px 0 12px;
    width: 100%;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

.sidebar.collapsed .sidebar-nav,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .sidebar-profile {
    width: 100%;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 8px;
}

.sidebar a, .sidebar button.sidebar-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 9px 10px;
    border-radius: var(--radius);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    position: relative;
    white-space: nowrap;
}

.sidebar a:hover, .sidebar button.sidebar-link:hover {
    background: var(--bg-input);
    color: var(--text);
}

.sidebar a.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    font-weight: 500;
}

/* Collapsed sidebar: center everything */
.sidebar.collapsed a,
.sidebar.collapsed button.sidebar-link {
    justify-content: center;
    padding: 0;
    width: 40px;
    height: 40px;
    gap: 0;
    margin: 0 auto;
}

/* Tooltips for collapsed sidebar */
.sidebar.collapsed [data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-input);
    color: var(--text);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    flex-shrink: 0;
}

.sidebar-icon svg {
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 8px 8px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Sidebar Profile */
.sidebar-profile {
    padding: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-profile {
    justify-content: center;
    padding: 10px 0;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.sidebar-profile-info {
    overflow: hidden;
}

.sidebar-profile-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-email {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-role {
    font-size: 9px;
    padding: 1px 7px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 2px;
    display: inline-block;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

.main {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    min-width: 0;
    height: 100%;
}

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

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-refresh-group {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0;
    overflow: hidden;
    height: 32px;
}

.refresh-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.refresh-icon-btn:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.refresh-icon-btn.spinning svg {
    animation: spin 0.8s linear infinite;
}

.refresh-divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    flex-shrink: 0;
}

.refresh-select {
    background: none;
    color: var(--text);
    border: none;
    padding: 0 10px 0 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    width: auto;
    height: 32px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.refresh-select option {
    background: var(--bg-card);
    color: var(--text);
}

.last-refresh {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.7;
    letter-spacing: 0.2px;
}

.poll-indicator {
    font-size: 11px;
    color: var(--warning);
    font-weight: 500;
}

/* ===== Search Input ===== */
.search-wrap {
    position: relative;
}

.search-wrap .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.search-wrap .search-icon svg {
    width: 16px;
    height: 16px;
}

.search-input {
    padding-left: 36px !important;
    width: 240px;
}

.search-section {
    margin-bottom: 16px;
}

/* ===== Login Page ===== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.login-box p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group-modal {
    margin-top: 12px;
}

input, select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    cursor: pointer;
}

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

.topbar-meta select,
.topbar-meta input {
    width: auto;
}

input:focus, select:focus {
    border-color: var(--primary);
}

input[type="checkbox"] {
    width: auto;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    gap: 6px;
}

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

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { opacity: 0.85; }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-input); color: var(--text); }
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-form-submit { margin-top: 12px; }

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: all 0.15s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-close svg {
    width: 22px;
    height: 22px;
}

.btn-close:hover {
    background: var(--bg-input);
    color: var(--text);
}

/* ===== Stats Bar ===== */
.stats-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: border-color 0.2s;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.stat-number {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 500;
}

.stat-card.stat-success .stat-number { color: var(--success); }
.stat-card.stat-danger .stat-number { color: var(--danger); }
.stat-card.stat-primary .stat-number { color: var(--primary); }

/* ===== VM Cards Grid ===== */
.vm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.vm-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 18px;
    transition: all 0.2s;
    cursor: pointer;
}

.vm-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(99, 102, 241, 0.1);
}

.vm-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary), 0 4px 20px rgba(99, 102, 241, 0.15);
}

.vm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.vm-card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.vm-id {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== Status Badge ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-running { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-stopped { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-unknown { background: rgba(139, 143, 163, 0.15); color: var(--text-muted); }
.badge-paused { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-admin { background: rgba(99, 102, 241, 0.15); color: var(--primary); }
.badge-user { background: rgba(139, 143, 163, 0.15); color: var(--text-muted); }

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-running .badge-dot {
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== Usage Bars ===== */
.usage-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.usage-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.usage-label {
    width: 40px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.usage-bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--primary);
    transition: width 0.5s ease;
}

.usage-bar-fill.high { background: var(--warning); }
.usage-bar-fill.critical { background: var(--danger); }

.usage-value {
    width: 50px;
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Network Stats ===== */
.net-stats {
    display: flex;
    gap: 20px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.net-stat {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.net-stat span {
    color: var(--text);
    font-weight: 500;
}

/* ===== Circular Gauges ===== */
/* Detail: Metrics row (Gauges + Network side by side) */
.detail-metrics-row {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 16px;
}

.detail-metrics-row .gauges-row {
    flex-shrink: 0;
}

.detail-metrics-row .net-detail-grid {
    flex: 1;
}

/* Detail: Bottom row (Backups + Logs side by side) */
.detail-bottom-row {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.detail-bottom-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.gauges-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 0;
    flex-wrap: wrap;
}

.gauge {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: conic-gradient(
        var(--gauge-color, var(--primary)) calc(var(--percent, 0) * 3.6deg),
        var(--bg-input) calc(var(--percent, 0) * 3.6deg)
    );
    transition: background 0.5s;
}

.gauge::after {
    content: '';
    position: absolute;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--bg-card);
}

.gauge-inner {
    position: relative;
    z-index: 1;
    text-align: center;
}

.gauge-value {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.gauge-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== VM Detail Modal ===== */
.vm-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.vm-detail-overlay.hidden {
    display: none;
}

.vm-detail {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 24px;
    width: 94vw;
    max-width: 1400px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.vm-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.vm-detail-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.vm-detail-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vm-action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
}

.vm-action-btns .btn.hidden {
    display: none;
}

.vm-detail-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.vm-detail-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.vm-detail-section {
    margin-top: 16px;
}

.vm-detail-section h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.net-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.net-detail-item {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 10px;
    text-align: center;
}

.net-detail-value {
    font-size: 15px;
    font-weight: 600;
}

.net-detail-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Tables ===== */
.table-wrap {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

th, td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td { font-size: 14px; }

tbody tr {
    transition: background 0.1s;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 16px;
}

.input-inline {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 4px 8px;
    font-size: 12px;
    width: 140px;
    font-family: 'Inter', sans-serif;
}
.input-inline:focus {
    outline: none;
    border-color: var(--primary);
}

.backup-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.table-actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
}

.tab:hover { color: var(--text); }

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    animation: fadeIn 0.15s ease;
}

/* ===== Inline Form ===== */
.inline-form {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.inline-form h3 { margin-bottom: 16px; }

.inline-form-spaced { margin-top: 24px; }

.inline-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.inline-form-header h3 { margin-bottom: 0; }

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

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

.form-row-checks {
    align-items: center;
    gap: 24px;
    margin-top: 8px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.px-status {
    margin-top: 12px;
}

.px-status svg {
    width: 16px;
    height: 16px;
}

/* ===== Logs ===== */
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.log-search-input {
    width: 100%;
    max-width: 280px;
    padding: 6px 12px;
    font-size: 13px;
}

.log-viewer {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    flex: 1;
    min-height: 80px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.8;
}

.log-entry {
    display: flex;
    gap: 12px;
    padding: 2px 4px;
    border-radius: 3px;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.03);
}

.log-time {
    color: var(--text-muted);
    white-space: nowrap;
}

/* ===== Alert ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}

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

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.25s ease forwards;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 420px;
    border-left: 3px solid var(--text-muted);
}

.toast.removing {
    animation: toastOut 0.2s ease forwards;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--info); }

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toast-icon svg {
    width: 18px;
    height: 18px;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

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

.modal-title {
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: all 0.15s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-close:hover {
    background: var(--bg-input);
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

/* Wide modal variant for tickets */
.modal-box.modal-wide {
    max-width: 680px;
}
.modal-box.modal-wide .modal-body {
    padding: 28px 32px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Loading Skeleton ===== */
.skeleton {
    background: var(--bg-input);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
    animation: shimmer 1.5s infinite;
}

.skeleton-card {
    height: 200px;
    border-radius: 12px;
}

.skeleton-row {
    height: 48px;
    margin-bottom: 8px;
}

@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

/* ===== Empty State ===== */
.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-icon svg {
    width: 48px;
    height: 48px;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Spinner ===== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 220px !important;
        transform: translateX(-100%);
    }

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

    .sidebar.open .sidebar-text {
        opacity: 1;
        width: auto;
    }

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

    .sidebar-toggle {
        display: flex;
    }

    .main {
        padding: 20px;
        padding-top: 68px;
    }

    .vm-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
    }

    .stats-bar {
        flex-wrap: wrap;
    }

    .stat-card {
        flex: 1;
        min-width: 100px;
    }

    .gauges-row {
        gap: 16px;
    }

    .gauge {
        width: 100px;
        height: 100px;
    }

    .gauge::after {
        width: 74px;
        height: 74px;
    }

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

    .topbar-meta {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-input {
        width: 100% !important;
    }

    .log-search-input {
        max-width: 100%;
    }

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

    .toast {
        min-width: auto;
    }

    .modal-box {
        max-width: 100%;
    }

    .table-actions {
        flex-direction: column;
        gap: 4px;
    }

    .tabs {
        gap: 0;
    }

    .tab {
        padding: 10px 14px;
        font-size: 13px;
    }

    .net-stats {
        flex-wrap: wrap;
        gap: 12px;
    }
}

/* ===== Impersonation Banner ===== */
.impersonation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    background: var(--warning);
    color: #1a1d27;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 13px;
    font-weight: 500;
}

.impersonation-banner ~ .app {
    height: calc(100vh - 37px);
}

.impersonation-back {
    color: #1a1d27 !important;
    border-color: rgba(0, 0, 0, 0.3) !important;
    font-weight: 600;
}

.impersonation-back:hover {
    background: rgba(0, 0, 0, 0.15) !important;
}

/* ===== Metrics Chart ===== */
.detail-charts-row {
    margin: 16px 0;
}

.chart-container {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 16px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.chart-header h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 0;
}

.chart-range-btns {
    display: flex;
    gap: 4px;
}

.chart-range {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.chart-range:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.chart-range.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chart-canvas-wrap {
    position: relative;
    height: 200px;
}

#metrics-chart {
    width: 100% !important;
    height: 100% !important;
}

/* ===== Console Overlay ===== */
.console-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #000;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.15s ease;
}

.console-overlay.hidden {
    display: none;
}

.console-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.console-title {
    font-weight: 600;
    font-size: 14px;
}

.console-toolbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.console-cad-info {
    cursor: help;
    color: var(--text-muted);
    opacity: 0.6;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
}

.console-cad-info:hover {
    opacity: 1;
    color: var(--accent);
}

.console-toolbar-actions .btn-close svg {
    width: 20px;
    height: 20px;
}

.console-screen {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.console-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    gap: 16px;
}

.console-status {
    white-space: nowrap;
}

.console-metrics {
    display: flex;
    gap: 16px;
    align-items: center;
}

.console-metric {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.console-metric-label {
    color: var(--text-muted);
    font-weight: 500;
}

.console-metric-bar {
    width: 80px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.console-metric-fill {
    height: 100%;
    border-radius: 4px;
    min-width: 3px;
    background: #3b82f6;
    transition: width 0.5s ease;
}

.console-metric-fill.high {
    background: #f59e0b;
}

.console-metric-fill.critical {
    background: #ef4444;
}

.console-metric-value {
    min-width: 32px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ===== Bug Reports ===== */
.bug-report-list {
    max-height: 240px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.bug-report-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
}

.bug-report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.bug-report-desc {
    font-size: 13px;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

.bug-report-note {
    font-size: 13px;
    margin-top: 6px;
    padding: 8px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 4px;
    color: var(--text);
}

.bug-report-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Bug screenshots in existing reports */
.bug-screenshots-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.bug-screenshot-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.bug-screenshot-thumb:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

/* Bug screenshot upload zone */
.bug-screenshot-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 12px;
    transition: border-color 0.2s, background 0.2s;
}

.bug-screenshot-upload.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
}

.bug-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    transition: color 0.2s;
}

.bug-upload-placeholder:hover {
    color: var(--primary);
}

.bug-screenshot-preview {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.bug-preview-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bug-preview-item img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.bug-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.bug-preview-item:hover .bug-preview-remove {
    opacity: 1;
}

.bug-preview-name {
    font-size: 10px;
    color: var(--text-muted);
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* Ticket create layout */
.ticket-create-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.ticket-create-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ticket-create-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.ticket-field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: -4px;
}
.ticket-field-hint {
    font-weight: 400;
    color: var(--text-muted);
    opacity: 0.7;
    font-size: 12px;
}

/* Category card grid */
.ticket-category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.ticket-cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 600;
}
.ticket-cat-card svg {
    overflow: visible;
}
.ticket-cat-card:hover {
    border-color: var(--text-muted);
    color: var(--text);
}
.ticket-cat-card.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
}
.ticket-cat-card.active svg {
    stroke: var(--primary);
}
.ticket-cat-card[data-cat="bug"].active { border-color: #ef4444; color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.ticket-cat-card[data-cat="bug"].active svg { stroke: #ef4444; }
.ticket-cat-card[data-cat="feature"].active { border-color: #22c55e; color: #22c55e; background: rgba(34, 197, 94, 0.08); }
.ticket-cat-card[data-cat="feature"].active svg { stroke: #22c55e; }
.ticket-cat-card[data-cat="request"].active { border-color: #3b82f6; color: #3b82f6; background: rgba(59, 130, 246, 0.08); }
.ticket-cat-card[data-cat="request"].active svg { stroke: #3b82f6; }
.ticket-cat-card[data-cat="question"].active { border-color: #f59e0b; color: #f59e0b; background: rgba(245, 158, 11, 0.08); }
.ticket-cat-card[data-cat="question"].active svg { stroke: #f59e0b; }

/* Existing tickets list in create modal */
.ticket-create-existing {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.ticket-existing-list {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

/* Category badges */
.badge-cat-bug { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-cat-feature { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.badge-cat-request { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-cat-question { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

/* Bug status badges */
.badge-bug-open { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-bug-in_progress { background: rgba(56, 189, 248, 0.15); color: var(--info); }
.badge-bug-closed { background: rgba(34, 197, 94, 0.15); color: var(--success); }

/* Clickable ticket items */
.bug-report-clickable {
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}
.bug-report-clickable:hover {
    border-color: var(--primary);
    transform: translateX(2px);
}

/* Ticket message count badge */
.ticket-msg-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
}

/* Claimed indicator */
.ticket-claimed {
    font-size: 12px;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}
.ticket-unclaimed {
    font-size: 12px;
    color: var(--text-muted);
}
.admin-bug-claim {
    margin: 6px 0;
}

/* Ticket detail modal */
.ticket-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.ticket-detail-desc {
    font-size: 14px;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

/* Chat thread */
.ticket-chat-section {
    border-top: 1px solid var(--border);
    margin-top: 12px;
}
.ticket-chat {
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}
.chat-message {
    padding: 10px 14px;
    border-radius: 10px;
    max-width: 85%;
    font-size: 13px;
}
.chat-msg-other {
    background: var(--bg-input);
    border: 1px solid var(--border);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}
.chat-msg-self {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}
/* Legacy compat */
.chat-msg-user { background: var(--bg-input); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 2px; }
.chat-msg-admin { background: rgba(99, 102, 241, 0.12); border: 1px solid rgba(99, 102, 241, 0.25); align-self: flex-end; border-bottom-right-radius: 2px; }
/* Admin role badge */
.chat-role-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
}
.chat-msg-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-muted);
}
.chat-msg-header strong {
    color: var(--text);
    font-size: 12px;
}
.chat-msg-body {
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Chat input row */
.chat-input-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

/* Admin bug cards */
.admin-bugs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-bug-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color 0.15s;
}

.admin-bug-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.admin-bug-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.admin-bug-title {
    font-size: 15px;
}

.admin-bug-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.admin-bug-desc {
    font-size: 13px;
    color: var(--text-muted);
    word-break: break-word;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.admin-bug-note {
    font-size: 13px;
    padding: 8px 10px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 4px;
    margin-bottom: 10px;
}

.admin-bug-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-bug-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.bug-filter-row,
.audit-filter-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.badge-action {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
}

.audit-details {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-muted);
}

.form-input-sm {
    padding: 6px 10px;
    font-size: 13px;
    width: auto;
}

textarea.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: vertical;
    transition: border-color 0.15s;
}

textarea.form-input:focus {
    border-color: var(--primary);
}

/* ===== File Manager Overlay ===== */
.fm-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.15s ease;
}

.fm-overlay.hidden {
    display: none;
}

.fm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.fm-title {
    font-weight: 600;
    font-size: 14px;
}

.fm-toolbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.fm-breadcrumb {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.fm-crumb {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.fm-crumb:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.fm-crumb-sep {
    color: var(--text-muted);
    opacity: 0.4;
}

.fm-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

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

.fm-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    padding: 10px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.fm-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.1s;
}

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

.fm-table td {
    padding: 8px 16px;
    font-size: 13px;
}

.fm-icon {
    width: 36px;
    text-align: center;
}

.fm-name {
    font-weight: 500;
}

.fm-item-dir .fm-name {
    color: #f59e0b;
    cursor: pointer;
}

.fm-item-dir .fm-name:hover {
    text-decoration: underline;
}

.fm-size, .fm-date {
    color: var(--text-muted);
    white-space: nowrap;
}

.fm-actions {
    display: flex;
    gap: 4px;
    white-space: nowrap;
}

.fm-actions .btn {
    padding: 3px 8px;
    font-size: 13px;
    min-width: unset;
}

/* ===== SSH Login Modal ===== */
#ssh-login-modal .modal {
    max-width: 480px;
}

#ssh-login-modal .modal h3 {
    margin-bottom: 16px;
}

/* ===== Sidebar Badge ===== */
.sidebar-badge {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
    z-index: 1;
}
.sidebar.collapsed .sidebar-badge {
    top: 0px;
    transform: none;
    right: -4px;
}
.sidebar.collapsed button.sidebar-link,
.sidebar.collapsed a {
    overflow: visible;
}

/* ===== Ticket Overlay ===== */
.ticket-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--bg);
    display: flex;
    animation: fadeIn 0.15s ease;
}
.ticket-overlay.hidden {
    display: none;
}

.ticket-overlay-sidebar {
    width: 380px;
    min-width: 380px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ticket-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ticket-overlay-header h2 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.ticket-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ticket-tab {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.ticket-tab:hover {
    color: var(--text);
    background: rgba(255,255,255,0.03);
}
.ticket-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.ticket-tab-count {
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
}
.ticket-tab-count:empty {
    display: none;
}

.ticket-overlay-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.ticket-overlay-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ticket-detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Ticket list in overlay */
.ticket-list-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ticket-list-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.ticket-list-item:hover {
    border-color: var(--primary);
    transform: translateX(2px);
}
.ticket-list-item.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}
.ticket-list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.ticket-list-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.ticket-list-item-desc {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ticket-list-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Ticket detail panel in overlay */
.ticket-detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ticket-detail-panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ticket-detail-panel-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text);
}
.ticket-detail-panel-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.ticket-detail-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}
.ticket-detail-panel-desc {
    font-size: 14px;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    padding: 14px;
    background: var(--bg-input);
    border-radius: var(--radius);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Screenshots in detail panel */
.ticket-screenshots-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.ticket-screenshots-row img {
    max-height: 100px;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.15s;
}
.ticket-screenshots-row img:hover {
    transform: scale(1.05);
}

/* Screenshot Lightbox */
.screenshot-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.screenshot-lightbox.hidden {
    display: none;
}
.screenshot-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}
.screenshot-lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.screenshot-lightbox-close:hover {
    opacity: 1;
}

/* Ticket close info */
.ticket-close-info {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.ticket-close-reason {
    margin-top: 6px;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ===== Uptime Section ===== */
.uptime-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
}
.uptime-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.uptime-summary {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.uptime-percent {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.uptime-percent.uptime-good { color: #22c55e; }
.uptime-percent.uptime-warn { color: #f59e0b; }
.uptime-percent.uptime-bad { color: #ef4444; }
.uptime-percent.uptime-nodata { color: var(--text-muted); }
.uptime-label {
    font-size: 13px;
    color: var(--text-muted);
}
.uptime-range-btns {
    display: flex;
    gap: 4px;
}
.uptime-range {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.uptime-range:hover {
    border-color: var(--primary);
    color: var(--text);
}
.uptime-range.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.uptime-bar {
    display: flex;
    gap: 2px;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
}
.uptime-day {
    flex: 1;
    min-width: 2px;
    border-radius: 2px;
    cursor: pointer;
    transition: opacity 0.15s;
    position: relative;
}
.uptime-day:hover {
    opacity: 0.75;
}
.uptime-day.up { background: #22c55e; }
.uptime-day.partial { background: #f59e0b; }
.uptime-day.down { background: #ef4444; }
.uptime-day.no-data { background: var(--bg-input); }
.uptime-incidents {
    margin-top: 10px;
    max-height: 120px;
    overflow-y: auto;
}
.uptime-incident {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}
.uptime-incident:last-child { border-bottom: none; }
.uptime-incident-duration {
    color: #ef4444;
    font-weight: 600;
}

/* Chat in detail panel */
.ticket-chat-panel {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.ticket-chat-panel-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.ticket-chat-panel-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

/* Chat input fixed at bottom */
.ticket-detail-panel-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.ticket-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.ticket-chat-input-row .form-input {
    flex: 1;
}

/* Create form in overlay */
.ticket-create-overlay-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.ticket-create-overlay-form .ticket-category-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* ===== Floating Action Button (Bug Report) ===== */
.fab-bug {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}
.fab-bug:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text);
}
.fab-bug:active {
    transform: scale(0.93);
}

/* ===== Hidden ===== */
.hidden {
    display: none !important;
}
