:root {
 --bg-primary: #ffffff;
 --bg-secondary: #f8f9fa;
 --bg-tertiary: #e9ecef;
 --text-primary: #212529;
 --text-secondary: #6c757d;
 --border: #dee2e6;
 --accent: #0066cc;
 --accent-hover: #0052a3;
 --error: #dc3545;
 --success: #28a745;
 --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
 --bg-primary: #1a1a1a;
 --bg-secondary: #242424;
 --bg-tertiary: #2d2d2d;
 --text-primary: #e0e0e0;
 --text-secondary: #a0a0a0;
 --border: #3a3a3a;
 --accent: #4d9fff;
 --accent-hover: #357ae8;
 --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
 background: var(--bg-primary);
 color: var(--text-primary);
 font-size: 14px;
 line-height: 1.5;
 transition: background 0.2s, color 0.2s;
}

.screen {
 display: none;
}

.screen.active {
 display: block;
}

/* Login */
.login-container {
 max-width: 400px;
 margin: 100px auto;
 padding: 40px;
 background: var(--bg-secondary);
 border-radius: 8px;
 box-shadow: 0 2px 8px var(--shadow);
}

.login-container h1 {
 margin-bottom: 30px;
 text-align: center;
 font-size: 24px;
 font-weight: 600;
}

.login-container input {
 width: 100%;
 padding: 12px;
 margin-bottom: 15px;
 border: 1px solid var(--border);
 border-radius: 6px;
 background: var(--bg-primary);
 color: var(--text-primary);
 font-size: 14px;
}

.login-container button {
 width: 100%;
 padding: 12px;
 background: var(--accent);
 color: white;
 border: none;
 border-radius: 6px;
 font-size: 14px;
 font-weight: 500;
 cursor: pointer;
 transition: background 0.2s;
}

.login-container button:hover {
 background: var(--accent-hover);
}

.error {
 color: var(--error);
 margin-top: 15px;
 font-size: 13px;
 text-align: center;
}

/* Navbar */
.navbar {
 display: flex;
 justify-content: space-between;
 align-items: center;
 padding: 12px 24px;
 background: var(--bg-secondary);
 border-bottom: 1px solid var(--border);
}

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

.nav-btn {
 padding: 8px 16px;
 background: transparent;
 color: var(--text-secondary);
 border: none;
 border-radius: 6px;
 cursor: pointer;
 font-size: 14px;
 font-weight: 500;
 transition: all 0.2s;
}

.nav-btn:hover {
 background: var(--bg-tertiary);
 color: var(--text-primary);
}

.nav-btn.active {
 background: var(--accent);
 color: white;
}

.icon-btn {
 padding: 8px 12px;
 background: transparent;
 border: 1px solid var(--border);
 border-radius: 6px;
 cursor: pointer;
 font-size: 16px;
 transition: all 0.2s;
}

.icon-btn:hover {
 background: var(--bg-tertiary);
}

.btn-primary {
 padding: 8px 16px;
 background: var(--accent);
 color: white;
 border: none;
 border-radius: 6px;
 cursor: pointer;
 font-size: 14px;
 font-weight: 500;
 transition: background 0.2s;
}

.btn-primary:hover {
 background: var(--accent-hover);
}

.btn-secondary {
 padding: 8px 16px;
 background: transparent;
 color: var(--text-primary);
 border: 1px solid var(--border);
 border-radius: 6px;
 cursor: pointer;
 font-size: 14px;
 font-weight: 500;
 transition: all 0.2s;
}

.btn-secondary:hover {
 background: var(--bg-tertiary);
}

/* Content */
.content {
 padding: 24px;
}

.view {
 display: none;
}

.view.active {
 display: block;
}

.view-header {
 margin-bottom: 20px;
}

.view-header h2 {
 font-size: 20px;
 font-weight: 600;
 margin-bottom: 16px;
}

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

.filters input, .filters select {
 padding: 8px 12px;
 border: 1px solid var(--border);
 border-radius: 6px;
 background: var(--bg-secondary);
 color: var(--text-primary);
 font-size: 14px;
}

.filters input[type="number"] {
 width: 120px;
}

/* Table */
.table-container {
 overflow-x: auto;
 border: 1px solid var(--border);
 border-radius: 8px;
 background: var(--bg-secondary);
}

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

thead {
 background: var(--bg-tertiary);
 position: sticky;
 top: 0;
}

th {
 padding: 10px 12px;
 text-align: left;
 font-weight: 600;
 border-bottom: 1px solid var(--border);
 white-space: nowrap;
}

td {
 padding: 10px 12px;
 border-bottom: 1px solid var(--border);
}

tr:last-child td {
 border-bottom: none;
}

tbody tr {
 transition: background 0.2s;
}

tbody tr:hover {
 background: var(--bg-tertiary);
}

tbody tr.died {
 opacity: 0.5;
}

tbody tr.expandable {
 cursor: pointer;
}

tr.sub-row {
 background: var(--bg-primary);
}

tr.sub-row td {
 padding-left: 40px;
}

.expand-btn {
 background: none;
 border: none;
 cursor: pointer;
 padding: 4px;
 font-size: 16px;
 color: var(--text-secondary);
 transition: transform 0.2s;
}

.expand-btn.expanded {
 transform: rotate(90deg);
}

.clickable {
 color: var(--accent);
 cursor: pointer;
 text-decoration: underline;
}

.clickable:hover {
 color: var(--accent-hover);
}

.copyable {
 cursor: pointer;
 position: relative;
}

.copyable:hover::after {
 content: '📋';
 position: absolute;
 right: -20px;
 top: 50%;
 transform: translateY(-50%);
}

.movie-img {
 width: 60px;
 height: 90px;
 object-fit: cover;
 border-radius: 4px;
}

.json-preview {
 max-width: 200px;
 overflow: hidden;
 text-overflow: ellipsis;
 white-space: nowrap;
 cursor: pointer;
 color: var(--accent);
}

.json-preview:hover {
 text-decoration: underline;
}

.badge {
 display: inline-block;
 padding: 2px 8px;
 border-radius: 12px;
 font-size: 11px;
 font-weight: 500;
 background: var(--bg-tertiary);
 color: var(--text-secondary);
}

.badge.success {
 background: var(--success);
 color: white;
}

.badge.error {
 background: var(--error);
 color: white;
}

/* Modal */
.modal {
 display: none;
 position: fixed;
 z-index: 1000;
 left: 0;
 top: 0;
 width: 100%;
 height: 100%;
 background: rgba(0, 0, 0, 0.5);
 backdrop-filter: blur(4px);
}

.modal.active {
 display: flex;
 align-items: center;
 justify-content: center;
}

.modal-content {
 background: var(--bg-secondary);
 padding: 24px;
 border-radius: 12px;
 max-width: 800px;
 max-height: 80vh;
 overflow-y: auto;
 box-shadow: 0 8px 32px var(--shadow);
 position: relative;
}

.modal-close {
 position: absolute;
 right: 16px;
 top: 16px;
 font-size: 24px;
 cursor: pointer;
 color: var(--text-secondary);
 transition: color 0.2s;
}

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

.info-section {
 margin-bottom: 24px;
}

.info-section h3 {
 font-size: 16px;
 font-weight: 600;
 margin-bottom: 12px;
 color: var(--accent);
}

.info-grid {
 display: grid;
 grid-template-columns: 150px 1fr;
 gap: 8px;
 margin-bottom: 16px;
}

.info-label {
 font-weight: 500;
 color: var(--text-secondary);
}

.info-value {
 color: var(--text-primary);
}

pre {
 background: var(--bg-primary);
 padding: 12px;
 border-radius: 6px;
 overflow-x: auto;
 font-size: 12px;
 border: 1px solid var(--border);
}

/* Password Modal */
.password-modal {
 max-width: 450px;
}

.password-modal h2 {
 margin-bottom: 24px;
 font-size: 20px;
 font-weight: 600;
}

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

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

.form-group input {
 width: 100%;
 padding: 10px 12px;
 border: 1px solid var(--border);
 border-radius: 6px;
 background: var(--bg-primary);
 color: var(--text-primary);
 font-size: 14px;
 transition: border-color 0.2s;
}

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

.form-actions {
 display: flex;
 gap: 12px;
 margin-top: 24px;
 justify-content: flex-end;
}

.success {
 color: var(--success);
 margin-top: 12px;
 font-size: 13px;
 text-align: center;
 padding: 8px;
 background: rgba(40, 167, 69, 0.1);
 border-radius: 6px;
}

/* Logs Display */
.log-entry, .msg-entry {
 padding: 12px;
 margin-bottom: 8px;
 background: var(--bg-primary);
 border: 1px solid var(--border);
 border-radius: 6px;
 font-size: 12px;
}

.log-entry:last-child, .msg-entry:last-child {
 margin-bottom: 0;
}

.log-header, .msg-header {
 display: flex;
 justify-content: space-between;
 align-items: center;
 margin-bottom: 8px;
 padding-bottom: 8px;
 border-bottom: 1px solid var(--border);
}

.log-action {
 font-weight: 600;
 color: var(--accent);
 text-transform: uppercase;
 font-size: 11px;
 letter-spacing: 0.5px;
}

.log-timestamp, .msg-timestamp {
 color: var(--text-secondary);
 font-size: 11px;
}

.log-details, .msg-details {
 display: grid;
 grid-template-columns: auto 1fr;
 gap: 6px 12px;
}

.log-key, .msg-key {
 color: var(--text-secondary);
 font-weight: 500;
}

.log-value, .msg-value {
 color: var(--text-primary);
 word-break: break-word;
}

.msg-text {
 margin-top: 8px;
 padding: 8px;
 background: var(--bg-secondary);
 border-radius: 4px;
 white-space: pre-wrap;
 word-break: break-word;
 font-family: monospace;
 font-size: 11px;
 line-height: 1.4;
}

.logs-container, .msgs-container {
 max-height: 500px;
 overflow-y: auto;
 padding-right: 8px;
}

.logs-container::-webkit-scrollbar, .msgs-container::-webkit-scrollbar {
 width: 6px;
}

.logs-container::-webkit-scrollbar-track, .msgs-container::-webkit-scrollbar-track {
 background: var(--bg-secondary);
 border-radius: 3px;
}

.logs-container::-webkit-scrollbar-thumb, .msgs-container::-webkit-scrollbar-thumb {
 background: var(--border);
 border-radius: 3px;
}

.logs-container::-webkit-scrollbar-thumb:hover, .msgs-container::-webkit-scrollbar-thumb:hover {
 background: var(--text-secondary);
}

/* Sortable table headers */
th.sortable {
 cursor: pointer;
 user-select: none;
 position: relative;
 padding-right: 24px;
}

th.sortable:hover {
 background: var(--bg-primary);
}

th.sortable::after {
 content: '⇅';
 position: absolute;
 right: 8px;
 color: var(--text-secondary);
 font-size: 12px;
}

th.sortable.asc::after {
 content: '↑';
 color: var(--accent);
}

th.sortable.desc::after {
 content: '↓';
 color: var(--accent);
}

/* Upload Modal */
.upload-modal {
 max-width: 600px;
}

.upload-modal h2 {
 margin-bottom: 24px;
 font-size: 20px;
 font-weight: 600;
}

.file-input-wrapper {
 position: relative;
}

.file-input-wrapper input[type="file"] {
 width: 100%;
 padding: 10px 12px;
 border: 2px dashed var(--border);
 border-radius: 6px;
 background: var(--bg-primary);
 color: var(--text-primary);
 cursor: pointer;
 transition: border-color 0.2s;
}

.file-input-wrapper input[type="file"]:hover {
 border-color: var(--accent);
}

.file-input-info {
 margin-top: 6px;
 font-size: 12px;
 color: var(--text-secondary);
}

.files-list {
 margin: 16px 0;
 padding: 12px;
 background: var(--bg-primary);
 border: 1px solid var(--border);
 border-radius: 6px;
 max-height: 200px;
 overflow-y: auto;
 display: none;
}

.files-list.active {
 display: block;
}

.file-item {
 display: flex;
 align-items: center;
 padding: 8px;
 margin-bottom: 4px;
 background: var(--bg-secondary);
 border-radius: 4px;
 font-size: 13px;
}

.file-item:last-child {
 margin-bottom: 0;
}

.file-icon {
 margin-right: 8px;
 font-size: 16px;
}

.file-name {
 flex: 1;
 overflow: hidden;
 text-overflow: ellipsis;
 white-space: nowrap;
}

.file-size {
 margin-left: 8px;
 color: var(--text-secondary);
 font-size: 11px;
}

.upload-progress {
 margin: 16px 0;
}

.progress-bar {
 width: 100%;
 height: 8px;
 background: var(--bg-tertiary);
 border-radius: 4px;
 overflow: hidden;
}

.progress-fill {
 height: 100%;
 background: var(--accent);
 transition: width 0.3s ease;
 width: 0%;
}

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

.upload-results {
 margin: 16px 0;
 padding: 12px;
 background: var(--bg-primary);
 border: 1px solid var(--border);
 border-radius: 6px;
 display: none;
 max-height: 300px;
 overflow-y: auto;
}

.upload-results.active {
 display: block;
}

.result-item {
 padding: 8px;
 margin-bottom: 6px;
 border-radius: 4px;
 font-size: 13px;
 display: flex;
 align-items: center;
}

.result-item:last-child {
 margin-bottom: 0;
}

.result-item.success {
 background: rgba(40, 167, 69, 0.1);
 border-left: 3px solid var(--success);
}

.result-item.error {
 background: rgba(220, 53, 69, 0.1);
 border-left: 3px solid var(--error);
}

.result-icon {
 margin-right: 8px;
 font-size: 16px;
}

.result-text {
 flex: 1;
}

.result-details {
 font-size: 11px;
 color: var(--text-secondary);
 margin-top: 4px;
}

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

.view-header h2 {
 margin-bottom: 0;
}

/* Table Actions */
.table-actions {
 display: flex;
 gap: 8px;
 align-items: center;
}

.btn-small {
 padding: 6px 12px;
 font-size: 12px;
 border-radius: 4px;
 border: none;
 cursor: pointer;
 font-weight: 500;
 transition: all 0.2s;
 white-space: nowrap;
}

.btn-apply {
 background: var(--accent);
 color: white;
}

.btn-apply:hover {
 background: var(--accent-hover);
}

.btn-delete {
 background: transparent;
 color: var(--error);
 border: 1px solid var(--error);
}

.btn-delete:hover {
 background: var(--error);
 color: white;
}

.redirect-count {
 display: inline-block;
 padding: 2px 6px;
 background: var(--bg-tertiary);
 border-radius: 4px;
 font-size: 11px;
 color: var(--text-secondary);
 margin-left: 8px;
}

/* Toast notification */
.toast {
 position: fixed;
 bottom: 24px;
 right: 24px;
 padding: 16px 24px;
 background: var(--bg-secondary);
 border: 1px solid var(--border);
 border-radius: 8px;
 box-shadow: 0 4px 12px var(--shadow);
 z-index: 2000;
 animation: slideIn 0.3s ease;
 max-width: 400px;
}

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

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

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

.toast-title {
 font-weight: 600;
 margin-bottom: 4px;
 font-size: 14px;
}

.toast-message {
 font-size: 13px;
 color: var(--text-secondary);
}