:root {
  --bg: #0b0d12;
  --panel: #12151c;
  --card: #161a23;
  --border: #242938;
  --text: #e6e8ec;
  --muted: #8b93a3;
  --accent: #e8495f;
  --accent-dim: rgba(232, 73, 95, 0.12);
  --accent2: #3ecf8e;
  --accent2-dim: rgba(62, 207, 142, 0.12);
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Segoe UI', Arial, sans-serif; }
.hidden { display: none !important; }
h1, h2, h3 { font-weight: 600; }

.icon { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }
.icon-lg { width: 34px; height: 34px; }
h3 .icon, .panel-head h2 .icon { width: 15px; height: 15px; margin-right: 2px; }

#login-screen, #register-screen, #apikey-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #1a1f2b 0%, var(--bg) 60%); }
.login-box { background: var(--panel); border: 1px solid var(--border); padding: 36px; border-radius: var(--radius); width: 380px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.brand-mark { text-align: center; margin-bottom: 4px; color: var(--accent); }
.login-box h1 { margin: 0; font-size: 20px; text-align: center; }
.login-box .subtitle { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.login-box input { padding: 11px 12px; border-radius: 8px; border: 1px solid var(--border); background: #0e1117; color: var(--text); font-size: 14px; }
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box button { padding: 11px; border-radius: 8px; border: none; background: var(--accent); color: white; font-weight: 600; cursor: pointer; font-size: 14px; transition: filter 0.15s; }
.login-box button:hover { filter: brightness(1.1); }
.login-box p { font-size: 13px; color: var(--muted); margin: 4px 0; }
.switch { text-align: center; }
.switch a { color: var(--accent2); text-decoration: none; }
.switch a:hover { text-decoration: underline; }
.error { color: var(--accent); min-height: 18px; font-size: 13px; margin: 0; }
.apikey-box { display: block; background: #0e1117; border: 1px solid var(--border); padding: 12px; border-radius: 8px; word-break: break-all; font-size: 13px; margin: 8px 0; font-family: 'Consolas', monospace; }
.hint { font-size: 12px; color: var(--muted); }

#app-screen { display: flex; min-height: 100vh; }

.sidebar { width: 220px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; padding: 0 8px 20px; }
.brand-icon { font-size: 18px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.tab-btn { display: flex; align-items: center; gap: 10px; background: transparent; border: none; color: var(--muted); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; text-align: left; transition: background 0.15s, color 0.15s; }
.tab-btn .icon { vertical-align: middle; }
.tab-btn:hover { background: #1b2029; color: var(--text); }
.tab-btn.active { background: var(--accent-dim); color: var(--accent); }
#logout-btn { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
#logout-btn:hover { border-color: var(--accent); color: var(--accent); }

main { flex: 1; padding: 28px 32px; max-width: 1100px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 19px; }
.panel-head input { padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); min-width: 220px; }
.panel-head button, #refresh-logs { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; font-size: 13px; }
.panel-head button.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
.panel-head button:hover { filter: brightness(1.1); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px; margin-bottom: 20px; }
.card h3 { padding-top: 12px; }
.settings-card { padding: 20px; }
.settings-card p { margin: 6px 0; }

h3 { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

button.action { background: #1b2029; border: 1px solid var(--border); color: var(--text); padding: 6px 11px; border-radius: 6px; cursor: pointer; margin-right: 4px; font-size: 12px; transition: filter 0.15s; }
button.action:hover { filter: brightness(1.2); }
button.action.danger { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
button.action.ok { border-color: var(--accent2); color: var(--accent2); background: var(--accent2-dim); }

.inline-form { display: flex; gap: 8px; margin: 12px 0; }
.inline-form input { flex: 1; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: #0e1117; color: var(--text); }
.inline-form button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 8px; border: none; background: var(--accent2); color: #06231a; font-weight: 600; cursor: pointer; }
.inline-form button:hover { filter: brightness(1.1); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-3 ul { list-style: none; padding: 0; margin: 0; max-height: 220px; overflow-y: auto; }
.grid-3 li { display: flex; justify-content: space-between; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.grid-3 li:last-child { border-bottom: none; }
.grid-3 li button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; }

.config-card { margin-bottom: 18px; padding: 16px 18px; }
.config-card h3 { margin-bottom: 4px; }

.field-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: none; }
.field-row.stacked { flex-direction: column; align-items: stretch; }
.field-label { font-size: 13.5px; color: var(--text); }
.field-row input[type="text"] { width: 220px; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--border); background: #0e1117; color: var(--text); font-size: 13px; }
.list-textarea { width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border); background: #0e1117; color: var(--text); font-size: 12.5px; font-family: 'Consolas', monospace; resize: vertical; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; background: #262b38; border-radius: 999px; cursor: pointer; transition: background 0.15s; }
.switch-slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #cfd3db; border-radius: 50%; transition: transform 0.15s; }
.switch input:checked + .switch-slider { background: var(--accent2); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); background: #06231a; }

.slider-wrap { display: flex; align-items: center; gap: 12px; width: 260px; }
.slider-wrap input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--pct, 0%), #232838 var(--pct, 0%), #232838 100%);
  outline: none;
  cursor: pointer;
  transition: background 0.1s;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: pointer; transition: transform 0.12s;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider-wrap input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: pointer; transition: transform 0.12s;
}
.slider-wrap input[type="range"]::-moz-range-thumb:hover { transform: scale(1.15); }
.slider-wrap input[type="range"]::-moz-range-track { background: transparent; }
.slider-value { font-size: 12.5px; color: var(--text); min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; background: #1b2029; border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }

.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-btn { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; font-size: 12.5px; transition: all 0.15s; }
.filter-btn:hover { color: var(--text); }
.filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 20px; }
.check-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; transition: opacity 0.15s; }
.check-card.disabled { opacity: 0.5; }
.check-card-header { display: flex; align-items: center; justify-content: space-between; }
.check-card-title { font-size: 14px; font-weight: 600; }
.check-card-body { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.check-card-body .field-row { padding: 6px 0; }
.check-card-body .field-label { color: var(--muted); font-size: 12.5px; }
.check-card-body .slider-wrap { width: auto; flex: 1; margin-left: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 16px 18px; margin-bottom: 0; }
.stat-card h3 { margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }

.console-output { margin: 0; padding: 14px; max-height: 560px; overflow-y: auto; font-family: 'Consolas', monospace; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; color: var(--muted); }

button.secondary { background: #1b2029; border: 1px solid var(--border); color: var(--text); }

.modal-overlay { position: fixed; inset: 0; background: rgba(5,6,9,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.modal-box h3 { margin: 0 0 6px; color: var(--text); font-size: 15px; text-transform: none; letter-spacing: normal; }
.modal-box input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: #0e1117; color: var(--text); font-size: 14px; margin-top: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions button { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.modal-actions .primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }

.ban-thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; }

.live-box { width: 640px; max-width: 92vw; }
.live-frame-wrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #05060a; border-radius: 8px; border: 1px solid var(--border); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.live-frame-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.live-frame-wrap img[src=""], .live-frame-wrap img:not([src]) { display: none; }
.live-placeholder { position: absolute; color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  #app-screen { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 20px; }
  .grid-3 { grid-template-columns: 1fr; }
}
