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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    min-height: 100vh;
}

header {
    background: #1a1a2e;
    padding: 16px 24px;
    border-bottom: 1px solid #2a2a4a;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

.conn-status {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #757575;
}

.conn-dot.connected { background: #00e676; }

.main-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
    padding: 16px 24px;
    height: calc(100vh - 64px);
}

.panel {
    background: #1a1a2e;
    border-radius: 8px;
    border: 1px solid #2a2a4a;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a4a;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Player Table */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    text-transform: uppercase;
    color: #888;
    border-bottom: 1px solid #2a2a4a;
    position: sticky;
    top: 0;
    background: #1a1a2e;
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: #ccc;
}

td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid #1f1f35;
}

tr:hover { background: #22223a; }

tr.clickable { cursor: pointer; }

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-online .status-dot { background: #00e676; }
.status-warning .status-dot { background: #ffea00; }
.status-danger .status-dot { background: #ff1744; }
.status-offline .status-dot { background: #757575; }

/* Action Buttons */
.btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-right: 4px;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.8; }
.btn-rescan { background: #1976d2; color: #fff; }
.btn-screenshot { background: #7b1fa2; color: #fff; }
.btn-clear { background: #444; color: #fff; font-size: 11px; padding: 3px 8px; }
.btn-debug { background: #37474f; color: #b0bec5; }
.btn-debug.active { background: #ff6f00; color: #fff; }
.btn-unload { background: #b71c1c; color: #fff; }
.player-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Alert Filters */
.alert-filters {
    padding: 8px 12px;
    border-bottom: 1px solid #2a2a4a;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.severity-toggles {
    display: flex;
    gap: 4px;
}

.sev-btn {
    padding: 2px 8px;
    border: 1px solid #333;
    border-radius: 3px;
    background: transparent;
    color: #666;
    font-size: 11px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: 600;
    transition: all 0.15s;
}

.sev-btn.active[data-sev="critical"] { background: #ff1744; color: #fff; border-color: #ff1744; }
.sev-btn.active[data-sev="high"] { background: #c62828; color: #fff; border-color: #c62828; }
.sev-btn.active[data-sev="medium"] { background: #e65100; color: #fff; border-color: #e65100; }
.sev-btn.active[data-sev="low"] { background: #37474f; color: #b0bec5; border-color: #546e7a; }

.sev-btn:hover { opacity: 0.85; }

#alertPlayerFilter, #alertTextFilter {
    background: #12121f;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 12px;
    padding: 4px 8px;
}

#alertPlayerFilter { min-width: 120px; }
#alertTextFilter { flex: 1; }

/* Alerts */
.alert-item {
    padding: 10px 14px;
    border-bottom: 1px solid #1f1f35;
    font-size: 13px;
}

.alert-item:last-child { border-bottom: none; }

.alert-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.alert-player { font-weight: 600; }

.alert-time {
    font-size: 11px;
    color: #888;
}

.alert-message { margin-bottom: 2px; }

.alert-details {
    font-size: 11px;
    color: #999;
    word-break: break-all;
}

.severity-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 6px;
}

.severity-low { background: #37474f; color: #b0bec5; }
.severity-medium { background: #e65100; color: #fff; }
.severity-high { background: #c62828; color: #fff; }
.severity-critical { background: #ff1744; color: #fff; animation: pulse 1s infinite; }

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

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

.modal {
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 12px;
    width: 800px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 { font-size: 16px; }

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
}

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

.modal-tabs {
    display: flex;
    border-bottom: 1px solid #2a2a4a;
}

.modal-tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 2px solid transparent;
    color: #888;
}

.modal-tab:hover { color: #e0e0e0; }
.modal-tab.active { color: #fff; border-bottom-color: #1976d2; }

.modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    max-height: 60vh;
}

.detail-table {
    width: 100%;
    font-size: 12px;
    table-layout: auto;
}

.detail-table .col-pid { width: 1%; white-space: nowrap; }

.detail-table th {
    background: #16213e;
    font-size: 11px;
}

.detail-table td {
    padding: 6px 10px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    word-break: break-all;
}

.no-data {
    text-align: center;
    color: #666;
    padding: 40px;
    font-size: 13px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

.game-yes { color: #00e676; }
.game-no { color: #757575; }

.alert-count-badge {
    background: #d32f2f;
    color: #fff;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    color: #555;
    padding: 60px 20px;
}

/* File tree */
.file-tree { font-family: 'Consolas', monospace; font-size: 12px; }

.tree-dir {
    cursor: pointer;
    user-select: none;
    padding: 3px 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.tree-dir:hover { color: #fff; }

.tree-toggle { width: 12px; display: inline-block; color: #888; }

.tree-dir-name { color: #64b5f6; }
.tree-file-count { color: #666; font-size: 11px; margin-left: 4px; }

.tree-file {
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-file-name { color: #e0e0e0; }
.tree-file-hash { color: #666; font-size: 11px; }
.tree-file-size { color: #888; font-size: 11px; min-width: 60px; text-align: right; }

.tree-file-download {
    cursor: pointer;
    color: #546e7a;
    margin-left: 8px;
    font-size: 12px;
    min-width: 20px;
    text-align: center;
}
.tree-file-download:hover { color: #29b6f6; }
.tree-file-download.loading { color: #ffd740; animation: pulse 1s infinite; }

.tree-children.collapsed { display: none; }

.file-suspicious .tree-file-name { color: #ff1744; font-weight: 600; }
.file-suspicious .tree-file-hash { color: #ff5252; }

/* Save data */
.save-section { margin-bottom: 12px; }

.save-header {
    cursor: pointer;
    user-select: none;
    padding: 8px 12px;
    background: #16213e;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #64b5f6;
    display: flex;
    align-items: center;
    gap: 6px;
}
.save-header:hover { color: #90caf9; }

.save-toggle { width: 12px; color: #888; }

.save-json {
    background: #12121f;
    border: 1px solid #2a2a4a;
    border-radius: 0 0 4px 4px;
    padding: 12px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre;
    color: #e0e0e0;
}
.save-json.collapsed { display: none; }

.json-key { color: #64b5f6; }
.json-string { color: #81c784; }
.json-number { color: #ffb74d; }
.json-bool { color: #ce93d8; }
.json-null { color: #757575; }

/* Reference diff highlighting — files */
.file-match .tree-file-name { color: #69f0ae; }
.file-modified .tree-file-name { color: #ffd740; }
.file-modified .tree-file-hash { color: #ffab40; }
.file-extra .tree-file-name { color: #ff1744; font-weight: 600; }
.file-extra .tree-file-hash { color: #ff5252; }

/* Reference diff highlighting — modules */
tr.file-match td:first-child { color: #69f0ae; }
tr.file-modified td:first-child { color: #ffd740; }
tr.file-modified td:nth-child(4) { color: #ffab40; }
tr.file-extra td:first-child { color: #ff1744; font-weight: 600; }
tr.file-extra { background: rgba(255, 23, 68, 0.08); }
tr.file-modified { background: rgba(255, 215, 64, 0.06); }

.btn-reference { background: #37474f; color: #b0bec5; }
.btn-reference.active { background: #00c853; color: #fff; }

.ref-badge { color: #69f0ae; font-size: 11px; margin-left: 4px; }

/* Screenshots */
.screenshot-controls { margin-bottom: 16px; }
.screenshot-gallery { display: flex; flex-direction: column; gap: 12px; }
.screenshot-item { border: 1px solid #2a2a4a; border-radius: 6px; overflow: hidden; }
.screenshot-item img { width: 100%; display: block; cursor: pointer; }
.screenshot-item img:hover { opacity: 0.9; }
.screenshot-meta { padding: 6px 10px; font-size: 11px; color: #888; display: flex; justify-content: space-between; background: #16213e; }

/* Lightbox */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

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

.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
}

.lightbox-close {
    position: absolute;
    top: 16px; right: 24px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 36px;
    cursor: pointer;
    z-index: 2001;
    line-height: 1;
}

.lightbox-close:hover { color: #fff; }

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #ccc;
    font-size: 48px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    line-height: 1;
    z-index: 2001;
}

.lightbox-nav:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

/* Auth screen */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 12px;
    padding: 40px;
    width: 360px;
}

.auth-title {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    text-align: center;
    margin-bottom: 24px;
}

.auth-error {
    background: rgba(255, 23, 68, 0.15);
    border: 1px solid #ff1744;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    color: #ff5252;
    margin-bottom: 16px;
}

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.auth-field input {
    width: 100%;
    padding: 10px 12px;
    background: #12121f;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.auth-field input:focus {
    border-color: #1976d2;
}

.auth-submit {
    width: 100%;
    padding: 10px;
    background: #1976d2;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

.auth-submit:hover { background: #1565c0; }
.auth-submit:disabled { background: #333; cursor: not-allowed; }

/* Header right section */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-logout {
    background: #37474f;
    color: #b0bec5;
    font-size: 12px;
    padding: 4px 12px;
}

.btn-logout:hover { background: #455a64; }

/* Settings button */
.btn-settings { background: #1976d2; color: #fff; font-size: 12px; padding: 4px 12px; }
.btn-settings:hover { background: #1565c0; }

/* Settings modal */
.settings-modal { width: 640px; }

.settings-field { margin-bottom: 16px; }

.settings-field label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
    font-weight: 600;
}

.settings-textarea {
    width: 100%;
    min-height: 100px;
    background: #12121f;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #e0e0e0;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    padding: 10px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.settings-textarea:focus { border-color: #1976d2; }

.interval-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.interval-item label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
}

.interval-item input {
    width: 100%;
    padding: 10px 12px;
    background: #12121f;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.interval-item input:focus { border-color: #1976d2; }

.settings-footer {
    padding: 12px 20px;
    border-top: 1px solid #2a2a4a;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-footer .status-ok { color: #00e676; font-size: 13px; }
.settings-footer .status-err { color: #ff5252; font-size: 13px; }

.btn-save {
    background: #00c853;
    color: #fff;
    padding: 8px 24px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save:hover { background: #00b248; }

@media (max-width: 900px) {
    .main-layout { grid-template-columns: 1fr; }
    .interval-grid { grid-template-columns: 1fr; }
}
