/* ═══════════════════════════════════════════════════════════════
 *  Admin Panel — theme-aware design system (light/dark)
 *  All colors driven by CSS variables so theme toggle works.
 * ═══════════════════════════════════════════════════════════════ */

:root[data-theme="dark"] {
  --ap-bg: #0a0e17;
  --ap-bg-alt: #0e1420;
  --ap-surface: #131a27;
  --ap-surface-2: #1a2332;
  --ap-border: #2a3444;
  --ap-border-soft: #1f2836;
  --ap-text: #e7ecf3;
  --ap-text-dim: #8594aa;
  --ap-text-muted: #596678;
  --ap-accent: #f4a236;
  --ap-accent-dim: #c98623;
  --ap-green: #00d68f;
  --ap-red: #ff6b85;
  --ap-blue: #60a5fa;
  --ap-purple: #c084fc;
  --ap-shadow: 0 8px 28px rgba(0,0,0,.35);
  --ap-shadow-soft: 0 1px 3px rgba(0,0,0,.2);
  --ap-focus: 0 0 0 2px rgba(244,162,54,.4);
}

:root[data-theme="light"] {
  --ap-bg: #f6f7fb;
  --ap-bg-alt: #eef0f5;
  --ap-surface: #ffffff;
  --ap-surface-2: #f9fafc;
  --ap-border: #d6dbe3;
  --ap-border-soft: #e4e7ee;
  --ap-text: #1a2233;
  --ap-text-dim: #5d6b80;
  --ap-text-muted: #95a0b3;
  --ap-accent: #d98800;
  --ap-accent-dim: #b46f00;
  --ap-green: #0a9a5a;
  --ap-red: #d8364e;
  --ap-blue: #2563eb;
  --ap-purple: #8b5cf6;
  --ap-shadow: 0 6px 24px rgba(20,30,50,.06);
  --ap-shadow-soft: 0 1px 3px rgba(20,30,50,.05);
  --ap-focus: 0 0 0 2px rgba(217,136,0,.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', system-ui, sans-serif; }
html, body { background: var(--ap-bg); color: var(--ap-text); min-height: 100vh; }
body { padding-bottom: 40px; }

a { color: var(--ap-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────────── */
.ap-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px;
  background: var(--ap-surface);
  border-bottom: 1px solid var(--ap-border);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.ap-brand { display: flex; align-items: center; gap: 14px; }
.ap-crown { font-size: 28px; filter: drop-shadow(0 2px 6px rgba(244,162,54,.4)); }
.ap-brand-title { font-size: 18px; font-weight: 800; color: var(--ap-text); letter-spacing: .02em; }
.ap-brand-sub { font-size: 12px; color: var(--ap-text-dim); margin-top: 2px; }

.ap-header-right { display: flex; align-items: center; gap: 14px; }
.ap-pill {
  padding: 6px 14px; border-radius: 999px;
  background: rgba(255,107,133,.12); color: var(--ap-red);
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  border: 1px solid rgba(255,107,133,.3);
}
.ap-theme-btn {
  background: var(--ap-surface-2); color: var(--ap-text);
  border: 1px solid var(--ap-border); border-radius: 10px;
  width: 38px; height: 38px; cursor: pointer;
  font-size: 18px; transition: .2s;
}
.ap-theme-btn:hover { border-color: var(--ap-accent); }
.ap-back {
  color: var(--ap-text-dim); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid transparent;
}
.ap-back:hover { border-color: var(--ap-border); color: var(--ap-text); text-decoration: none; }

/* ── Tabs ────────────────────────────────────────────────────── */
.ap-tabs {
  display: flex; gap: 4px; padding: 14px 32px 0 32px;
  border-bottom: 1px solid var(--ap-border);
  background: var(--ap-bg);
  overflow-x: auto;
}
.ap-tab {
  background: transparent; color: var(--ap-text-dim);
  border: none; border-bottom: 2px solid transparent;
  padding: 12px 18px; cursor: pointer; font-size: 13px; font-weight: 600;
  letter-spacing: .02em; white-space: nowrap;
  transition: .15s;
}
.ap-tab:hover { color: var(--ap-text); }
.ap-tab.active { color: var(--ap-accent); border-bottom-color: var(--ap-accent); }

/* ── Main / Sections ─────────────────────────────────────────── */
.ap-main { padding: 28px 32px; max-width: 1400px; margin: 0 auto; }
.ap-section { display: none; }
.ap-section.active { display: block; animation: fade-in .25s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.ap-card {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: 14px;
  margin-bottom: 22px;
  box-shadow: var(--ap-shadow);
  overflow: hidden;
}
.ap-card-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--ap-border-soft);
  gap: 14px; flex-wrap: wrap;
}
.ap-card-head h2 { font-size: 16px; font-weight: 700; color: var(--ap-text); }
.ap-card-sub { font-size: 12px; color: var(--ap-text-dim); margin-top: 4px; }
.ap-card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ap-body { padding: 22px; }

/* ── Stats grid ──────────────────────────────────────────────── */
.ap-statgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.ap-stat {
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: 12px; padding: 18px 20px; box-shadow: var(--ap-shadow-soft);
  transition: .2s;
}
.ap-stat:hover { border-color: var(--ap-accent); transform: translateY(-1px); }
.ap-stat-val { font-size: 26px; font-weight: 800; color: var(--ap-text); line-height: 1.1; }
.ap-stat-lbl { font-size: 11px; color: var(--ap-text-dim); text-transform: uppercase; letter-spacing: .08em; margin-top: 6px; }

/* ── Buttons & inputs ────────────────────────────────────────── */
.ap-btn {
  background: var(--ap-surface-2); color: var(--ap-text);
  border: 1px solid var(--ap-border); border-radius: 8px;
  padding: 8px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: .15s; letter-spacing: .02em;
}
.ap-btn:hover { border-color: var(--ap-accent); color: var(--ap-accent); }
.ap-btn:focus { outline: none; box-shadow: var(--ap-focus); }
.ap-btn:disabled { opacity: .5; cursor: not-allowed; }
.ap-btn-primary { background: var(--ap-accent); color: #0a0e17; border-color: var(--ap-accent); }
.ap-btn-primary:hover { background: var(--ap-accent-dim); color: #000; }
.ap-btn-ghost { background: transparent; }
.ap-btn-danger { background: rgba(255,107,133,.08); color: var(--ap-red); border-color: rgba(255,107,133,.3); }
.ap-btn-danger:hover { background: rgba(255,107,133,.14); border-color: var(--ap-red); color: var(--ap-red); }
.ap-btn-small { padding: 5px 10px; font-size: 11px; }

.ap-input {
  background: var(--ap-surface-2); color: var(--ap-text);
  border: 1px solid var(--ap-border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; font-family: inherit;
  transition: .15s;
  min-width: 160px;
}
.ap-input:focus { outline: none; border-color: var(--ap-accent); box-shadow: var(--ap-focus); }

.ap-textarea {
  background: var(--ap-surface-2); color: var(--ap-text);
  border: 1px solid var(--ap-border); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; font-family: inherit;
  width: 100%; resize: vertical; margin-top: 4px;
}
.ap-textarea:focus { outline: none; border-color: var(--ap-accent); box-shadow: var(--ap-focus); }

.ap-field-label { font-size: 12px; color: var(--ap-text-dim); display: block; margin-top: 18px; font-weight: 600; }

.ap-hint { font-size: 12px; color: var(--ap-text-dim); }

.ap-row-actions { display: flex; gap: 12px; align-items: center; margin-top: 14px; }

/* ── Switch ──────────────────────────────────────────────────── */
.ap-switch-row { display: flex; align-items: center; gap: 14px; }
.ap-switch { position: relative; display: inline-block; width: 52px; height: 28px; }
.ap-switch input { opacity: 0; width: 0; height: 0; }
.ap-switch-slider {
  position: absolute; inset: 0;
  background: var(--ap-surface-2); border: 1px solid var(--ap-border);
  border-radius: 999px; cursor: pointer; transition: .2s;
}
.ap-switch-slider::before {
  content: ""; position: absolute;
  width: 20px; height: 20px; left: 3px; top: 3px;
  background: var(--ap-text-dim); border-radius: 50%; transition: .2s;
}
.ap-switch input:checked + .ap-switch-slider { background: rgba(244,162,54,.2); border-color: var(--ap-accent); }
.ap-switch input:checked + .ap-switch-slider::before { left: 27px; background: var(--ap-accent); }
.ap-switch-label { font-size: 14px; font-weight: 600; color: var(--ap-text); }

/* ── Tables ──────────────────────────────────────────────────── */
.ap-table-wrap { overflow-x: auto; }
.ap-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.ap-table thead th {
  text-align: left; padding: 12px 18px;
  font-size: 11px; color: var(--ap-text-dim); text-transform: uppercase;
  letter-spacing: .06em; border-bottom: 1px solid var(--ap-border);
  background: var(--ap-surface-2);
  position: sticky; top: 0; z-index: 1;
}
.ap-table tbody td {
  padding: 14px 18px; border-bottom: 1px solid var(--ap-border-soft);
  color: var(--ap-text);
}
.ap-table tbody tr:hover td { background: var(--ap-surface-2); }
.ap-table tbody tr:last-child td { border-bottom: none; }
.ap-table .num { font-variant-numeric: tabular-nums; }
.ap-table .muted { color: var(--ap-text-dim); font-size: 12px; }
.ap-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

.ap-empty { text-align: center; color: var(--ap-text-dim); padding: 40px 20px; font-size: 14px; }

/* ── Badges ──────────────────────────────────────────────────── */
.ap-badge {
  display: inline-block; padding: 3px 9px; border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
.ap-badge.tier-free { background: rgba(101, 115, 138, .15); color: var(--ap-text-dim); border: 1px solid rgba(101, 115, 138, .3); }
.ap-badge.tier-pro { background: rgba(96, 165, 250, .15); color: var(--ap-blue); border: 1px solid rgba(96, 165, 250, .3); }
.ap-badge.tier-elite { background: rgba(192, 132, 252, .15); color: var(--ap-purple); border: 1px solid rgba(192, 132, 252, .3); }
.ap-badge.tier-ultra { background: rgba(244, 162, 54, .15); color: var(--ap-accent); border: 1px solid rgba(244, 162, 54, .3); }
.ap-badge.admin { background: rgba(255, 107, 133, .12); color: var(--ap-red); border: 1px solid rgba(255,107,133,.3); }
.ap-badge.verified { background: rgba(0, 214, 143, .12); color: var(--ap-green); border: 1px solid rgba(0,214,143,.3); }
.ap-badge.unverified { background: rgba(255, 180, 84, .12); color: #ffb454; border: 1px solid rgba(255,180,84,.3); }
.ap-badge.danger { background: rgba(255,107,133,.1); color: var(--ap-red); border: 1px solid rgba(255,107,133,.3); }

.ap-days-critical { color: var(--ap-red); font-weight: 700; }
.ap-days-warning { color: #ffb454; font-weight: 700; }
.ap-days-ok { color: var(--ap-green); }

/* ── Modal ──────────────────────────────────────────────────── */
.ap-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.ap-modal-overlay[hidden] { display: none; }
.ap-modal {
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: 14px; width: min(560px, 92vw);
  box-shadow: var(--ap-shadow);
  animation: modal-pop .2s ease-out;
}
@keyframes modal-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.ap-modal header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--ap-border-soft);
}
.ap-modal h3 { font-size: 16px; font-weight: 700; }
.ap-modal-close {
  background: transparent; color: var(--ap-text-dim); border: none;
  cursor: pointer; font-size: 20px; padding: 4px 8px; border-radius: 6px;
}
.ap-modal-close:hover { background: var(--ap-surface-2); color: var(--ap-text); }
.ap-modal-body { padding: 22px; }

.ap-field-group { margin-bottom: 16px; }
.ap-field-group label { display: block; font-size: 12px; color: var(--ap-text-dim); margin-bottom: 6px; font-weight: 600; }
.ap-field-group select,
.ap-field-group input[type="number"],
.ap-field-group input[type="text"] {
  width: 100%; background: var(--ap-surface-2); color: var(--ap-text);
  border: 1px solid var(--ap-border); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; font-family: inherit;
}
.ap-field-group select:focus,
.ap-field-group input:focus { outline: none; border-color: var(--ap-accent); }

/* ── Misc ──────────────────────────────────────────────────── */
.ap-pricing-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--ap-border-soft);
  font-size: 13px;
}
.ap-pricing-row:last-child { border-bottom: none; }
.ap-pricing-row .p-tier { font-weight: 600; color: var(--ap-text); }
.ap-pricing-row .p-val { color: var(--ap-accent); font-weight: 700; }

.ap-kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--ap-border-soft); font-size: 13px; }
.ap-kv:last-child { border-bottom: none; }
.ap-kv .k { color: var(--ap-text-dim); }
.ap-kv .v { color: var(--ap-text); font-weight: 600; }
