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

:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --bg3: #1a1a1a;
  --bg4: #222222;
  --border: #2a2a2a;
  --border2: #333333;
  --text: #f0f0f0;
  --text2: #999999;
  --text3: #555555;
  --accent: #ffffff;
  --danger: #555555;
  --success: #888888;
  --font: 'Inter', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --sidebar-w: 220px;
  --radius: 6px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.6; overflow: hidden; }

#loader-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; z-index: 999; transition: opacity 0.5s ease;
}
#loader-screen.fade-out { opacity: 0; pointer-events: none; }
#loader-canvas { display: block; }
#loader-text {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.4em;
  color: var(--text3); margin-top: 20px; opacity: 0;
  animation: fadeInText 0.8s ease 1.2s forwards;
}
@keyframes fadeInText { to { opacity: 1; color: var(--text2); } }

#app { display: flex; height: 100vh; opacity: 0; transition: opacity 0.4s ease; }
#app.visible { opacity: 1; }
#app.hidden { display: none; }

#auth-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
#auth-screen.hidden { display: none; }

#auth-box {
  width: 360px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 36px 32px;
}
#auth-loader-wrap { display: flex; justify-content: center; margin-bottom: 16px; }
#auth-mini-canvas { display: block; }
#auth-title {
  font-family: var(--mono); font-size: 18px; font-weight: 500;
  text-align: center; margin-bottom: 24px; letter-spacing: 0.1em;
}
#auth-tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1; background: none; border: none; color: var(--text3);
  font-family: var(--font); font-size: 13px; padding: 8px 0;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}
.auth-tab.active { color: var(--text); border-bottom-color: var(--text2); }
.auth-form { display: none; flex-direction: column; gap: 10px; }
.auth-form.active { display: flex; }
.auth-error { color: var(--text2); font-size: 12px; text-align: center; margin-top: 8px; padding: 8px; background: var(--bg3); border-radius: 4px; }
.auth-error.hidden { display: none; }

aside#sidebar {
  width: var(--sidebar-w); background: var(--bg2);
  border-right: 1px solid var(--border); display: flex;
  flex-direction: column; padding: 0; flex-shrink: 0;
  height: 100vh; overflow: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 16px; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 13px; font-weight: 500; letter-spacing: 0.05em;
}
#sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 5px; color: var(--text2);
  text-decoration: none; font-size: 13px; font-weight: 400;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg4); color: var(--text); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 10px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
#user-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text2); overflow: hidden;
  padding: 6px 10px;
}
#user-badge-name { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-size: 11px; }
.badge-role {
  font-size: 10px; padding: 2px 6px; border-radius: 3px;
  background: var(--bg4); color: var(--text3);
  border: 1px solid var(--border2); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-role.dev { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.badge-role.premium { background: var(--bg4); color: var(--text2); border-color: var(--border2); }
.nav-logout {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border-radius: 5px;
  background: none; border: none; color: var(--text3);
  font-family: var(--font); font-size: 13px; cursor: pointer;
  transition: background 0.15s, color 0.15s; text-align: left;
}
.nav-logout:hover { background: var(--bg3); color: #c44; }

main#main-content {
  flex: 1; overflow-y: auto; background: var(--bg);
  padding: 32px 36px; height: 100vh;
}
.page { display: none; animation: pageIn 0.2s ease; }
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }
.page-sub { font-size: 12px; color: var(--text3); margin-top: 2px; display: block; }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px;
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.stat-value { font-family: var(--mono); font-size: 22px; font-weight: 500; color: var(--text); }
.stat-meta { font-size: 11px; color: var(--text3); margin-top: 4px; }

.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 12px;
}
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text3); margin-bottom: 12px; margin-top: 24px;
}
.section-title:first-child { margin-top: 0; }
.section-title-sm { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 14px; }

.field-label { font-size: 11px; color: var(--text3); display: block; margin-bottom: 6px; letter-spacing: 0.04em; }
.badge-hint { font-size: 10px; background: var(--bg4); color: var(--text2); padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border2); margin-left: 6px; }
.field-hint { font-size: 11px; color: var(--text3); margin-top: 6px; font-family: var(--mono); }
.field-group { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .field-group { grid-template-columns: 1fr; } }

input.input-mono, textarea.input-mono {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: var(--mono); font-size: 12px;
  padding: 9px 12px; outline: none; transition: border-color 0.15s;
}
input.input-mono:focus, textarea.input-mono:focus { border-color: var(--border2); }
input.input-mono::placeholder, textarea.input-mono::placeholder { color: var(--text3); }
textarea.input-mono { resize: vertical; min-height: 100px; }

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--text); color: var(--bg); font-family: var(--font);
  font-size: 12px; font-weight: 500; padding: 9px 16px;
  border: none; border-radius: 4px; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s; white-space: nowrap;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary.w-full { width: 100%; justify-content: center; }

.btn-ghost-sm {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--text3);
  font-family: var(--font); font-size: 12px; cursor: pointer;
  padding: 5px 6px; border-radius: 4px; transition: color 0.15s, background 0.15s;
}
.btn-ghost-sm:hover { color: var(--text2); background: var(--bg3); }

.btn-danger-sm {
  background: none; border: 1px solid var(--border2); color: var(--text3);
  font-family: var(--font); font-size: 11px; padding: 4px 10px;
  border-radius: 4px; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.btn-danger-sm:hover { border-color: #666; color: var(--text); }

.btn-outline-sm {
  background: none; border: 1px solid var(--border); color: var(--text2);
  font-family: var(--font); font-size: 11px; padding: 4px 10px;
  border-radius: 4px; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.btn-outline-sm:hover { border-color: var(--border2); color: var(--text); }

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

.item-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.item-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; gap: 12px;
}
.item-row-left { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: hidden; }
.item-row-title { font-size: 12px; font-family: var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row-sub { font-size: 11px; color: var(--text3); }
.item-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.item-empty { text-align: center; padding: 24px; color: var(--text3); font-size: 12px; }

.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 12px; }
.progress-bar-track { height: 3px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin-bottom: 14px; }
.progress-bar-fill { height: 100%; background: var(--text2); border-radius: 2px; transition: width 1s linear; }
.status-log { font-family: var(--mono); font-size: 11px; color: var(--text3); display: flex; flex-direction: column; gap: 4px; max-height: 120px; overflow-y: auto; }
.status-log-entry { display: flex; gap: 10px; }
.log-time { color: var(--text3); flex-shrink: 0; }
.log-msg { color: var(--text2); }

.mono-sm { font-family: var(--mono); font-size: 11px; color: var(--text3); }

.result-card { border-color: var(--border2); }
.result-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; font-weight: 500; }
.result-body { font-family: var(--mono); font-size: 12px; color: var(--text2); line-height: 1.7; }

.reply-card { border-left: 2px solid var(--border2); }
#fix-reply-body { font-family: var(--mono); font-size: 11px; color: var(--text2); line-height: 1.8; white-space: pre-wrap; word-break: break-all; }

.dev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .dev-grid { grid-template-columns: 1fr; } }
.dev-section {}

.modal-overlay-active { background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); }
#modal-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
#modal-overlay.hidden { display: none; }
#modal-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 24px; width: 400px; max-width: 90vw;
}
#modal-title { font-size: 14px; font-weight: 500; margin-bottom: 16px; }
#modal-body { font-size: 12px; color: var(--text2); margin-bottom: 20px; line-height: 1.7; }
#modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 10px 16px;
  font-size: 12px; color: var(--text2); font-family: var(--mono);
  animation: toastIn 0.2s ease; max-width: 280px;
}
.toast.out { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

.tag-active { font-size: 10px; background: var(--bg4); color: var(--text); padding: 2px 7px; border-radius: 3px; border: 1px solid var(--border2); }
.tag-inactive { font-size: 10px; background: var(--bg3); color: var(--text3); padding: 2px 7px; border-radius: 3px; border: 1px solid var(--border); }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 2px; }

.hidden { display: none !important; }
