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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0d1117;
    color: #e6edf3;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

.hidden { display: none !important; }

.screen {
    width: 100%;
    height: 100%;
}

/* ============================
   LOGIN SCREEN
   ============================ */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at 50% 40%, #1a2030 0%, #0d1117 65%);
}

.login-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 16px;
    padding: 44px 36px 40px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
}

.login-logo {
    margin-bottom: 20px;
}

.login-logo img {
    width: 88px;
    height: 88px;
    border-radius: 16px;
    object-fit: cover;
    border: 2px solid #30363d;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.login-box h1 {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #f0f6fc;
    letter-spacing: -0.02em;
}

.login-box p {
    font-size: 0.875rem;
    color: #8b949e;
    margin-bottom: 28px;
}

.login-box input {
    width: 100%;
    padding: 10px 14px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #f0f6fc;
    font-size: 1rem;
    outline: none;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.login-box input:focus {
    border-color: #58a6ff;
}

.login-box button {
    width: 100%;
    padding: 10px;
    background: #238636;
    border: 1px solid #2ea043;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background: #2ea043;
}

.form-error {
    margin-top: 12px;
    padding: 8px;
    color: #f85149;
    font-size: 0.85rem;
    background: rgba(248, 81, 73, 0.1);
    border-radius: 6px;
}

/* ============================
   DASHBOARD SCREEN
   ============================ */
#dashboard-screen {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

.dash-header-left h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f0f6fc;
}

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

#dash-user-name {
    font-size: 0.85rem;
    color: #8b949e;
}

#dash-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Tabs */
#dash-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: #161b22;
    border-radius: 8px;
    padding: 4px;
    border: 1px solid #30363d;
}

.tab-btn {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #8b949e;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.tab-btn:hover {
    color: #e6edf3;
    background: #21262d;
}

.tab-btn.active {
    background: #21262d;
    color: #f0f6fc;
    font-weight: 600;
}

/* Panel header */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f0f6fc;
}

/* Cards grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 16px;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: #484f58;
}

.card-clickable {
    cursor: pointer;
}

.card-clickable:hover {
    border-color: #58a6ff;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f0f6fc;
}

.card-subtitle {
    font-size: 0.8rem;
    color: #8b949e;
    margin-bottom: 4px;
}

.card-meta {
    font-size: 0.75rem;
    color: #484f58;
    margin-top: 8px;
}

.card-actions {
    display: flex;
    gap: 6px;
}

/* Status badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-online {
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-offline {
    background: rgba(139, 148, 158, 0.1);
    color: #484f58;
    border: 1px solid #30363d;
}

.badge-admin {
    background: rgba(31, 111, 235, 0.15);
    color: #58a6ff;
    border: 1px solid rgba(31, 111, 235, 0.3);
}

.badge-operator {
    background: rgba(210, 153, 34, 0.15);
    color: #d29922;
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.badge-unregistered {
    background: rgba(210, 100, 20, 0.15);
    color: #e0813a;
    border: 1px solid rgba(210, 100, 20, 0.3);
}

.empty-msg {
    color: #484f58;
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 0;
    font-size: 0.9rem;
}

/* Token display */
.token-display {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: monospace;
    color: #8b949e;
    word-break: break-all;
}

.token-display .btn-copy {
    flex-shrink: 0;
    cursor: pointer;
    background: none;
    border: none;
    color: #58a6ff;
    font-size: 0.75rem;
}

/* Buttons */
.btn-primary {
    padding: 6px 14px;
    background: #238636;
    border: 1px solid #2ea043;
    border-radius: 6px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: #2ea043; }

.btn-small {
    padding: 4px 10px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #8b949e;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-small:hover {
    background: #30363d;
    color: #e6edf3;
}

.btn-danger {
    color: #f85149;
    border-color: rgba(248, 81, 73, 0.3);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
}

/* ============================
   CRUD MODAL
   ============================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-crud {
    max-width: 520px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #30363d;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f0f6fc;
}

.modal-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: #f0f6fc;
}

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

.modal-body label {
    display: block;
    font-size: 0.85rem;
    color: #8b949e;
    margin-bottom: 4px;
    margin-top: 12px;
}

.modal-body label:first-child {
    margin-top: 0;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
    padding: 8px 12px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #f0f6fc;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    border-color: #58a6ff;
}

.modal-body textarea {
    min-height: 100px;
    font-family: monospace;
    resize: vertical;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #30363d;
}

/* ============================
   STREAM SCREEN
   ============================ */
#stream-screen {
    display: flex;
    flex-direction: column;
}

#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: #8b949e;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #484f58;
    flex-shrink: 0;
}

.dot.on { background: #3fb950; }
.dot.off { background: #f85149; }

#fps-display {
    font-variant-numeric: tabular-nums;
    min-width: 60px;
}

.toolbar-btn {
    padding: 4px 10px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #8b949e;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: #30363d;
    color: #e6edf3;
}

.toolbar-btn.active {
    background: #1f6feb;
    border-color: #388bfd;
    color: #fff;
}

.shortcuts-dropdown {
    position: absolute;
    top: 44px;
    left: 0;
    z-index: 200;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 4px;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.shortcuts-group-label {
    font-size: 0.65rem;
    color: #484f58;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 8px 2px;
}

.shortcut-btn {
    background: transparent;
    border: none;
    color: #c9d1d9;
    font-size: 0.8rem;
    padding: 6px 10px;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
}

.shortcut-btn:hover {
    background: #21262d;
    color: #fff;
}

#screen-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    background: #010409;
    cursor: default;
}

#screen-container.mouse-active {
    cursor: crosshair;
}

#screen {
    max-width: 100%;
    max-height: 100%;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: auto;
}

#overlay-offline {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(13, 17, 23, 0.85);
    z-index: 5;
}

#overlay-offline span {
    font-size: 1.4rem;
    color: #8b949e;
    padding: 16px 32px;
    border: 1px solid #30363d;
    border-radius: 8px;
    background: #161b22;
}

#overlay-no-stream {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1117;
    z-index: 5;
}

.no-stream-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.no-stream-icon {
    font-size: 52px;
    opacity: 0.35;
}

.no-stream-box > p {
    color: #c9d1d9;
    font-size: 1.05rem;
}

.no-stream-sub {
    color: #6e7681 !important;
    font-size: 0.85rem !important;
}

.card-connect-bar {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

.btn-nostream {
    color: #8b949e;
    font-size: 0.78rem;
}

.btn-nostream:hover {
    color: #c9d1d9;
}

/* ============================
   TERMINAL PANEL
   ============================ */
#terminal-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 42%;
    min-height: 160px;
    background: #010409;
    border-top: 2px solid #30363d;
    z-index: 20;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 12px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
    gap: 8px;
}

.terminal-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: #c9d1d9;
    font-weight: 600;
}

.terminal-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.terminal-status {
    font-size: 0.72rem;
    font-weight: 400;
    color: #6e7681;
    padding: 2px 8px;
    border-radius: 10px;
    background: #21262d;
}

.terminal-status.connected {
    color: #3fb950;
    background: rgba(63, 185, 80, 0.12);
}

#btn-terminal-panel-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

#btn-terminal-panel-close:hover {
    color: #f0f6fc;
}

#terminal-container {
    flex: 1;
    padding: 4px 8px;
    overflow: hidden;
    min-height: 0;
}

#terminal-container .xterm {
    height: 100%;
}

#terminal-container .xterm-screen {
    height: 100%;
}

#mobile-keyboard-input {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* Actions grid in modal */
.actions-grid {
    padding: 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.actions-empty {
    color: #484f58;
    text-align: center;
    padding: 20px 0;
    font-size: 0.9rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #e6edf3;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
}

.action-btn:hover {
    background: #30363d;
    border-color: #484f58;
}

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

.action-btn.running {
    border-color: #1f6feb;
    opacity: 0.7;
    pointer-events: none;
}

.action-btn .action-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: #8b949e;
}

.action-btn .action-label {
    flex: 1;
}

.action-btn .action-type {
    font-size: 0.7rem;
    color: #484f58;
    text-transform: uppercase;
}

.actions-toast {
    padding: 10px 20px;
    font-size: 0.8rem;
    border-top: 1px solid #30363d;
    text-align: center;
    transition: opacity 0.3s;
}

.actions-toast.success { color: #3fb950; }
.actions-toast.error { color: #f85149; }

.action-output {
    border-top: 1px solid #30363d;
    display: flex;
    flex-direction: column;
    max-height: 260px;
}

.action-output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    font-size: 0.75rem;
    color: #8b949e;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

.action-output-header button {
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 4px;
}

.action-output-header button:hover { color: #e6edf3; }

#action-output-content {
    margin: 0;
    padding: 10px 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #e6edf3;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
    flex: 1;
    background: #0d1117;
}

/* ============================
   CLIPBOARD MODAL
   ============================ */
.modal-clipboard {
    max-width: 460px;
}

.clipboard-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.clipboard-body textarea {
    width: 100%;
    min-height: 160px;
    max-height: 40vh;
    padding: 10px 12px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #f0f6fc;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.clipboard-body textarea:focus {
    border-color: #58a6ff;
}

.clipboard-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.clipboard-status {
    font-size: 0.8rem;
    min-height: 1.2em;
}

.clipboard-status.success {
    color: #3fb950;
}

.clipboard-status.error {
    color: #f85149;
}

/* ============================
   FILES SIDEBAR
   ============================ */
#files-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 340px;
    height: 100%;
    background: #161b22;
    border-left: 1px solid #30363d;
    z-index: 20;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

.files-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f0f6fc;
}

.files-breadcrumb {
    padding: 8px 16px;
    font-size: 0.75rem;
    color: #8b949e;
    border-bottom: 1px solid #21262d;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.files-breadcrumb a {
    color: #58a6ff;
    text-decoration: none;
    cursor: pointer;
}

.files-breadcrumb a:hover {
    text-decoration: underline;
}

.files-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.files-empty {
    color: #484f58;
    text-align: center;
    padding: 24px 16px;
    font-size: 0.85rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #21262d;
}

.file-item:hover {
    background: #21262d;
}

.file-item .file-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: #8b949e;
}

.file-item .file-icon.dir {
    color: #58a6ff;
}

.file-item .file-info {
    flex: 1;
    min-width: 0;
}

.file-item .file-name {
    font-size: 0.85rem;
    color: #e6edf3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .file-meta {
    font-size: 0.7rem;
    color: #484f58;
    margin-top: 1px;
}

.file-item .file-actions {
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.file-item:hover .file-actions {
    opacity: 1;
}

.file-item .btn-download {
    padding: 2px 8px;
    background: #238636;
    border: 1px solid #2ea043;
    border-radius: 4px;
    color: #fff;
    font-size: 0.7rem;
    cursor: pointer;
}

.file-item .btn-download:hover {
    background: #2ea043;
}

/* Drop zone */
.files-drop-zone {
    padding: 16px;
    border-top: 1px solid #30363d;
    text-align: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.files-drop-zone span {
    display: block;
    font-size: 0.8rem;
    color: #484f58;
    margin-bottom: 8px;
}

.files-drop-zone.drag-over {
    background: rgba(88, 166, 255, 0.1);
    border-color: #58a6ff;
}

.btn-upload {
    font-size: 0.8rem;
    padding: 6px 14px;
}

/* Progress bar */
.files-progress {
    padding: 12px 16px;
    border-top: 1px solid #30363d;
    flex-shrink: 0;
}

.files-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #8b949e;
    margin-bottom: 6px;
}

.files-progress-bar {
    height: 4px;
    background: #21262d;
    border-radius: 2px;
    overflow: hidden;
}

.files-progress-fill {
    height: 100%;
    background: #58a6ff;
    border-radius: 2px;
    transition: width 0.2s;
    width: 0%;
}

.files-progress-fill.success {
    background: #3fb950;
}

.files-progress-fill.error {
    background: #f85149;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 600px) {
    #status-bar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 8px;
    }

    .status-left, .status-right {
        gap: 8px;
    }

    .toolbar-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    #dash-content {
        padding: 12px;
    }

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

    #dash-tabs {
        flex-wrap: wrap;
    }

    #files-sidebar {
        width: 100%;
    }
}

/* Fullscreen */
body.fullscreen #status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    transition: opacity 0.3s;
}

body.fullscreen #status-bar:hover {
    opacity: 1;
}

body.fullscreen #screen-container {
    height: 100vh;
}

/* Logs table */
.table-wrapper {
    overflow-x: auto;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.logs-table th,
.logs-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #2a2a2a;
    white-space: nowrap;
}

.logs-table th {
    background: #1a1a1a;
    color: #aaa;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.logs-table tr.log-row {
    cursor: pointer;
}

.logs-table tr.log-row:hover td {
    background: #1e2433;
}

.logs-table .log-sep {
    color: #444;
    margin: 0 3px;
}

/* Session history modal */
.modal-session {
    max-width: 620px;
}

.session-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.session-event {
    display: grid;
    grid-template-columns: 24px 80px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: 6px;
    font-size: 13px;
}

.session-event-action { border-left: 3px solid #58a6ff; }
.session-event-file_download { border-left: 3px solid #3fb950; }
.session-event-file_upload { border-left: 3px solid #d29922; }

.ev-icon {
    font-size: 14px;
    text-align: center;
}

.ev-type {
    color: #8b949e;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ev-desc {
    color: #c9d1d9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ev-size {
    color: #8b949e;
    font-size: 11px;
}

.ev-time {
    color: #6e7681;
    font-size: 11px;
    white-space: nowrap;
}

/* ============================
   CHAT SIDEBAR
   ============================ */
#chat-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: #161b22;
    border-left: 1px solid #30363d;
    z-index: 20;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

.chat-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f0f6fc;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.chat-msg.from-ctrl {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg.from-host {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-bubble {
    padding: 7px 11px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.from-ctrl .chat-bubble {
    background: #1f6feb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.from-host .chat-bubble {
    background: #21262d;
    color: #e6edf3;
    border: 1px solid #30363d;
    border-bottom-left-radius: 4px;
}

.chat-ts {
    font-size: 0.68rem;
    color: #484f58;
    margin-top: 3px;
    padding: 0 2px;
}

.chat-input-row {
    display: flex;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid #30363d;
    flex-shrink: 0;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    resize: none;
    height: 60px;
    padding: 8px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #f0f6fc;
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: #58a6ff;
}

#btn-chat-send {
    padding: 8px 14px;
    background: #238636;
    border: 1px solid #2ea043;
    border-radius: 8px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

#btn-chat-send:hover {
    background: #2ea043;
}

.chat-unread {
    display: inline-block;
    background: #f85149;
    color: #fff;
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
    vertical-align: middle;
}

@media (max-width: 600px) {
    #chat-sidebar { width: 100%; }
}

/* ============================
   DEVICE VIEW TOGGLE
   ============================ */
.panel-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-toggle {
    display: flex;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    overflow: hidden;
}

.view-btn {
    padding: 5px 12px;
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.view-btn:hover { color: #e6edf3; background: #21262d; }
.view-btn.active { background: #21262d; color: #f0f6fc; font-weight: 600; }

.devices-org-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #8b949e;
}

.filter-select, .filter-date {
    padding: 6px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:focus, .filter-date:focus { border-color: #58a6ff; }
.filter-date::-webkit-calendar-picker-indicator { filter: invert(0.6); }

.devices-org-section {
    margin-bottom: 24px;
}

.devices-org-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: #58a6ff;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 2px;
    margin-bottom: 10px;
    border-bottom: 1px solid #21262d;
}

/* ============================
   DASHBOARD / STATS TAB
   ============================ */
.stats-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 20px 16px;
    text-align: center;
    transition: border-color 0.2s, transform 0.2s;
}

.stat-card:hover {
    border-color: #58a6ff;
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #58a6ff;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 0.75rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 12px;
    margin-bottom: 12px;
}

.charts-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.chart-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 240px;
}

.chart-wide {
    /* spans full column in the grid */
}

.chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #8b949e;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Stats table card */
.stats-table-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.table-search {
    padding: 4px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 0.8rem;
    outline: none;
    width: 160px;
}

.table-search:focus { border-color: #58a6ff; }

.table-scroll {
    flex: 1;
    overflow-y: auto;
    margin-top: 8px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.stats-table thead th {
    position: sticky;
    top: 0;
    background: #0d1117;
    color: #8b949e;
    text-align: left;
    padding: 7px 10px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #21262d;
}

.stats-table tbody td {
    padding: 7px 10px;
    color: #e6edf3;
    border-bottom: 1px solid #21262d;
}

.stats-table tbody tr:hover { background: #21262d; }
.stats-table tbody tr:last-child td { border-bottom: none; }

/* Responsive */
@media (max-width: 900px) {
    .charts-row { grid-template-columns: 1fr; }
    .charts-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .stats-filters { flex-direction: column; align-items: stretch; }
    .filter-select, .filter-date { width: 100%; }
}
