/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #1a1d2e;
  --bg3: #252840;
  --border: #2d3155;
  --text: #e2e8f0;
  --text-muted: #6b7280;
  --primary: #ee4d2d;
  --primary-hover: #d94429;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, sans-serif; min-height: 100vh; }

a { color: var(--primary); text-decoration: none; }
code { background: var(--bg3); padding: 2px 6px; border-radius: 4px; font-size: 12px; color: #60a5fa; }

/* ===== AUTH PAGE ===== */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 40px; width: 360px; box-shadow: var(--shadow); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 40px; }
.auth-logo h1 { font-size: 20px; margin: 8px 0 4px; }
.auth-logo p { color: var(--text-muted); font-size: 13px; }

/* ===== NAVBAR ===== */
.navbar { background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; gap: 24px; }
.navbar-brand { font-weight: 700; font-size: 15px; flex: 1; }
.navbar-links { display: flex; align-items: center; gap: 16px; }
.navbar-links a { color: var(--text-muted); font-size: 13px; padding: 4px 0; border-bottom: 2px solid transparent; }
.navbar-links a.active { color: var(--text); border-bottom-color: var(--primary); }

/* ===== CONTAINER ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 18px; }

/* ===== CARD ===== */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }

/* ===== FORM ===== */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; outline: none;
  transition: border-color .2s;
  color-scheme: dark; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group input:disabled, .form-group select:disabled {
  opacity: 1; color: var(--text); background: #1b1e2f; cursor: not-allowed; }
.form-group select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-group select option { background: var(--bg2); color: var(--text); }
.form-group .hint, .form-group small.text-muted {
  display: block; margin-top: 6px; font-size: 12px; color: var(--text-muted); text-transform: none; letter-spacing: 0; line-height: 1.4; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-check {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); }
.form-check input[type="checkbox"] {
  width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; accent-color: var(--primary); cursor: pointer; }
.form-check label {
  margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); line-height: 1.4; cursor: pointer; }
@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border: none; border-radius: var(--radius); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #303050; }
.btn-danger { background: #3f1515; color: var(--red); border: 1px solid #5a2020; }
.btn-danger:hover { background: #5a1a1a; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== TABLE ===== */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 12px; text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== BADGE ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-green { background: #052e16; color: var(--green); border: 1px solid #166534; }
.badge-red { background: #2d0a0a; color: var(--red); border: 1px solid #7f1d1d; }
.badge-yellow { background: #422006; color: var(--yellow); border: 1px solid #92400e; }
.badge-blue { background: #1e3a5f; color: #93c5fd; border: 1px solid #1d4ed8; }
.badge-gray { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }

/* ===== STATS ROW ===== */
.stats-row { display: flex; flex-wrap: wrap; gap: 24px; }
.stat-item { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.stat-item strong { font-size: 18px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  padding: 16px; overflow: auto; }
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  width: 560px; max-width: 100%; max-height: min(92vh, 820px);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 22px;
  line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end; flex-shrink: 0;
  padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg2); }

/* ===== KEY DISPLAY ===== */
.key-display { background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 16px; font-family: monospace; font-size: 16px; color: var(--green);
  letter-spacing: 1px; margin: 12px 0; word-break: break-all; }

/* ===== ALERTS ===== */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.alert-info { background: #1e3a5f; color: #93c5fd; border: 1px solid #1d4ed8; }
.alert-success { background: #052e16; color: #86efac; border: 1px solid #166534; }
.alert-error { background: #2d0a0a; color: #fca5a5; border: 1px solid #7f1d1d; }

/* ===== MISC ===== */
.error-msg { color: var(--red); font-size: 12px; margin-top: 6px; min-height: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
