@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg: #111111;
  --surface: #1a1a1a;
  --surface2: #2d2d2d;
  --input: #202020;
  --border: #2d2d2d;
  --border2: #3a3a3a;
  --text: #e0e0e0;
  --text-muted: #888888;
  --text-dim: #555555;
  --btn: #2d2d2d;
  --btn-hover: #383838;
  --btn-border: #444444;
  --accent: #666666;
  --green: #5aad7a;
  --red: #d05555;
  --admin-accent: #a03030;
  --radius: 8px;
  --radius-sm: 5px;
}

html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); }

/* ---- AUTH PAGE ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.auth-logo {
  width: 90px;
  height: 90px;
  object-fit: contain;
  margin-bottom: 10px;
  border-radius: 12px;
}

.auth-brand {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 2px;
}

.auth-sub {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.auth-form label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 16px;
  display: block;
}

.auth-form label:first-child { margin-top: 0; }

.auth-form input {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-form input:focus { border-color: var(--accent); }
.auth-form input::placeholder { color: var(--text-dim); }

.btn-primary {
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-top: 20px;
  width: 100%;
}

.btn-primary:hover { background: var(--btn-hover); border-color: var(--accent); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover { background: var(--surface2); color: var(--text); }

.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.auth-switch a:hover { text-decoration: underline; }

.error-msg {
  color: var(--red);
  font-size: 12px;
  min-height: 16px;
  margin-top: 8px;
}

/* ---- DASHBOARD ---- */
.dash-page {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 0 18px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  padding: 0 20px;
  margin-bottom: 20px;
}

.sidebar-user {
  padding: 0 20px;
  margin-bottom: 4px;
}

.tag-logged {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.tag-username {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: lowercase;
  word-break: break-all;
}

.sidebar-tag-wrap {
  padding: 6px 20px 8px;
}

.tag-admin {
  display: inline-block;
  background: rgba(160,48,48,0.15);
  border: 1px solid rgba(160,48,48,0.3);
  color: #cc6666;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  border-radius: 3px;
  padding: 2px 8px;
}

.sidebar-nav {
  flex: 1;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

/* Admin section separator */
.sidebar-admin-sep {
  margin: 12px 20px;
  border-top: 1px solid var(--border2);
}

.sidebar-nav-admin {
  flex: none;
  margin-top: 0;
  padding: 0 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.nav-item:hover, .nav-item.active {
  background: var(--surface2);
  color: var(--text);
}

.nav-admin.active {
  background: rgba(160,48,48,0.12);
  color: #cc6666;
}

.nav-admin:hover {
  background: rgba(160,48,48,0.08);
  color: #cc6666;
}

.logout { color: var(--text-muted); }
.logout:hover { background: rgba(208,85,85,0.08); color: var(--red); }

.nav-icon {
  width: 17px;
  height: 17px;
  object-fit: contain;
  filter: brightness(0.7);
  flex-shrink: 0;
}

.nav-icon-admin {
  border-radius: 3px;
  filter: brightness(0.8);
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  filter: brightness(1);
}

.nav-icon-svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-item.active .nav-icon-svg,
.nav-item:hover .nav-icon-svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.credit-block {
  padding: 0 12px;
}

.credit-row { line-height: 1.5; }

.credit-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  display: block;
}

.credit-val {
  font-size: 11px;
  color: var(--text-dim);
}

/* ---- MAIN ---- */
.main-content {
  margin-left: 200px;
  flex: 1;
  padding: 40px 44px;
  min-height: 100vh;
}

.section { display: none; }
.section.active { display: block; }

.section-header {
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.section-header h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

/* Admin header with logo */
.admin-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-panel-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  opacity: 0.3;
}

/* ---- Script Execution ---- */
.exec-panel { display: flex; flex-direction: column; gap: 12px; }

.editor-wrap {
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
}

.exec-actions { display: flex; gap: 10px; }
.exec-actions .btn-primary { margin-top: 0; width: auto; }

.exec-output {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 80px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- CodeMirror dark override ---- */
.CodeMirror {
  background: #1a1a1a;
  color: #d0d0d0;
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.65;
  height: auto;
  border: none;
}

.CodeMirror-scroll {
  min-height: 240px;
}

.CodeMirror-gutters {
  background: #161616;
  border-right: 1px solid #2d2d2d;
  padding-right: 2px;
}

.CodeMirror-linenumber {
  color: #484848;
  font-size: 11px;
  padding: 0 10px 0 6px;
}

.CodeMirror-cursor {
  border-left: 2px solid #aaaaaa !important;
}

.CodeMirror-focused .CodeMirror-cursor {
  border-left-color: #cccccc !important;
}

.CodeMirror-activeline-background {
  background: rgba(255,255,255,0.025) !important;
}

.CodeMirror-selected {
  background: rgba(120,120,120,0.25) !important;
}

.CodeMirror-matchingbracket {
  background: rgba(100,100,100,0.3);
  color: #ffffff !important;
  outline: 1px solid #555;
}

/* Placeholder */
.CodeMirror pre.CodeMirror-placeholder {
  color: #484848;
  font-style: italic;
}

/* Syntax highlight colors — no blue */
.cm-s-default .cm-comment       { color: #5a5a5a; font-style: italic; }
.cm-s-default .cm-string        { color: #c97a50; }
.cm-s-default .cm-string-2      { color: #c97a50; }
.cm-s-default .cm-number        { color: #85b56d; }
.cm-s-default .cm-keyword       { color: #b07acc; font-weight: 500; }
.cm-s-default .cm-variable      { color: #d0d0d0; }
.cm-s-default .cm-variable-2    { color: #d0d0d0; }
.cm-s-default .cm-variable-3    { color: #d0d0d0; }
.cm-s-default .cm-def           { color: #d8c47a; }
.cm-s-default .cm-builtin       { color: #5db5a0; }
.cm-s-default .cm-operator      { color: #c0c0c0; }
.cm-s-default .cm-punctuation   { color: #888888; }
.cm-s-default .cm-atom          { color: #b07acc; }
.cm-s-default .cm-error         { color: var(--red); background: rgba(208,85,85,0.15); }
.cm-s-default .cm-bracket       { color: #aaaaaa; }

/* Autocomplete dropdown */
.CodeMirror-hints {
  background: #1e1e1e !important;
  border: 1px solid #3a3a3a !important;
  border-radius: 6px !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6) !important;
  font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace !important;
  font-size: 12px !important;
  padding: 4px 0 !important;
  overflow-y: auto;
  max-height: 200px;
  z-index: 9999 !important;
}

.CodeMirror-hint {
  padding: 5px 14px !important;
  color: #c0c0c0 !important;
  cursor: pointer;
  border-radius: 0 !important;
}

li.CodeMirror-hint-active {
  background: #2d2d2d !important;
  color: #f0f0f0 !important;
}

/* ---- Profile ---- */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.profile-row label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.profile-val {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

.profile-row input {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.profile-row input:focus { border-color: var(--accent); }
.profile-row .btn-primary { margin-top: 12px; width: auto; }

/* ---- Admin ---- */
.admin-actions { display: flex; gap: 10px; margin-bottom: 24px; }
.admin-actions .btn-primary { margin-top: 0; width: auto; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.key-table thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.key-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.key-table tbody tr:last-child { border-bottom: none; }
.key-table tbody tr:hover { background: var(--surface2); }

.key-table td {
  padding: 12px 18px;
  color: var(--text-muted);
  vertical-align: middle;
}

.key-table td:first-child {
  color: var(--text);
  font-weight: 500;
  font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  font-size: 12px;
}

.status-avail { color: var(--green); font-weight: 600; }
.status-used { color: var(--text-dim); }
.status-expired { color: var(--red); font-weight: 600; }

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

.copy-btn {
  background: var(--btn);
  color: var(--text-muted);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}

.copy-btn:hover { background: var(--btn-hover); color: var(--text); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

.del-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}

.del-btn:hover { background: rgba(208,85,85,0.1); color: var(--red); border-color: var(--red); }
.del-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: none; }
