:root {
  --bg: #07080d;
  --bg-2: #0b0d16;
  --panel: rgba(18, 21, 34, 0.72);
  --panel-solid: #121524;
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.14);
  --text: #eef1f8;
  --muted: #8b93ab;
  --brand: #6d8bff;
  --brand-2: #9b6dff;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 16px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select { font-family: inherit; }

/* ── ambient animated background ─────────────────────────────── */
.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5;
  will-change: transform;
}
.b1 { width: 46vw; height: 46vw; background: radial-gradient(circle, #3b4fff, transparent 70%); top: -12vw; left: -8vw; animation: drift1 22s ease-in-out infinite; }
.b2 { width: 40vw; height: 40vw; background: radial-gradient(circle, #9b3bff, transparent 70%); bottom: -14vw; right: -6vw; animation: drift2 26s ease-in-out infinite; }
.b3 { width: 30vw; height: 30vw; background: radial-gradient(circle, #00d4ff, transparent 70%); top: 40%; left: 50%; animation: drift3 30s ease-in-out infinite; }
@keyframes drift1 { 50% { transform: translate(8vw, 6vh) scale(1.1); } }
@keyframes drift2 { 50% { transform: translate(-7vw, -5vh) scale(1.15); } }
@keyframes drift3 { 50% { transform: translate(-10vw, 8vh) scale(0.9); } }
.grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 80%);
}

/* ── login ───────────────────────────────────────────────────── */
.login-wrap {
  position: relative; z-index: 1; min-height: 100vh;
  display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  backdrop-filter: blur(22px);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 28px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 30px -6px rgba(109, 139, 255, 0.6);
}
.brand h1 { font-size: 22px; margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field small { font-size: 11.5px; color: var(--muted); opacity: 0.8; }
.field input, .field select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke-2);
  border-radius: 12px; padding: 13px 14px; color: var(--text);
  font-size: 15px; outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus, .field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(109,139,255,0.15);
  background: rgba(255,255,255,0.06);
}
.field select option { background: var(--panel-solid); }

.btn {
  border: none; border-radius: 12px; padding: 13px 16px; font-size: 15px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; transition: transform .12s, box-shadow .2s, background .2s, opacity .2s;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: 0 12px 30px -10px rgba(109,139,255,0.7);
}
.btn-primary:hover { box-shadow: 0 16px 36px -10px rgba(109,139,255,0.85); }
.btn-ghost { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--stroke); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-danger { background: rgba(251,113,133,0.14); color: var(--bad); border: 1px solid rgba(251,113,133,0.3); }
.btn-ok { background: rgba(52,211,153,0.14); color: var(--ok); border: 1px solid rgba(52,211,153,0.3); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  display: none; animation: spin 0.7s linear infinite;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-label { opacity: 0.7; }
@keyframes spin { to { transform: rotate(360deg); } }

.error { color: var(--bad); font-size: 13px; margin: 4px 0 0; min-height: 0; }
.footnote { color: var(--muted); font-size: 12px; text-align: center; margin: 22px 0 0; }

/* ── admin shell ─────────────────────────────────────────────── */
.admin { position: relative; z-index: 1; min-height: 100vh; animation: fade .5s ease; }
@keyframes fade { from { opacity: 0; } }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 5;
  background: rgba(7,8,13,0.6);
}
.brand.small { margin: 0; gap: 11px; }
.brand.small .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.brand-text span { font-size: 11.5px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.api-badge {
  display: flex; align-items: center; gap: 7px; font-family: var(--mono);
  font-size: 12px; color: var(--muted); background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke); padding: 7px 11px; border-radius: 20px;
}
.api-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 71px); }
.sidebar { border-right: 1px solid var(--stroke); padding: 22px 16px; display: flex; flex-direction: column; gap: 26px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  border-radius: 11px; font-size: 14.5px; font-weight: 500; text-align: left;
  transition: background .18s, color .18s;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: rgba(109,139,255,0.14); color: #cdd6ff; }
.nav-item .pill {
  margin-left: auto; font-size: 11px; background: var(--warn); color: #1a1400;
  border-radius: 20px; padding: 1px 8px; font-weight: 700;
}
.stats { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.stat {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.03); border: 1px solid var(--stroke);
  border-radius: 12px; padding: 11px 14px;
}
.stat-num { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.stat-num.ok { color: var(--ok); } .stat-num.warn { color: var(--warn); }
.stat-label { color: var(--muted); font-size: 12.5px; }

.content { padding: 26px 30px; overflow-x: hidden; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.sub { color: var(--muted); margin: 6px 0 0; font-size: 14px; }

.toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; justify-content: space-between; }
.search {
  display: flex; align-items: center; gap: 9px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke-2); border-radius: 12px; padding: 10px 13px; color: var(--muted);
  min-width: 260px; flex: 1; max-width: 380px;
}
.search input { background: none; border: none; outline: none; color: var(--text); font-size: 14px; width: 100%; }
.filters { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  background: rgba(255,255,255,0.04); border: 1px solid var(--stroke); color: var(--muted);
  padding: 8px 13px; border-radius: 20px; font-size: 13px; cursor: pointer; transition: all .18s;
}
.chip:hover { color: var(--text); border-color: var(--stroke-2); }
.chip.active { background: rgba(109,139,255,0.16); color: #cdd6ff; border-color: rgba(109,139,255,0.4); }

.table-wrap {
  background: var(--panel); backdrop-filter: blur(16px);
  border: 1px solid var(--stroke); border-radius: var(--radius); overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: left; padding: 14px 16px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--stroke); background: rgba(255,255,255,0.02);
}
.table tbody tr { border-bottom: 1px solid var(--stroke); transition: background .15s; }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.03); cursor: pointer; }
.table td { padding: 13px 16px; vertical-align: middle; }
.ta-right { text-align: right; }
.num-cell { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.scope-tag { font-size: 11px; padding: 3px 8px; border-radius: 8px; background: rgba(255,255,255,0.06); color: var(--muted); }

.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.status.pending { background: rgba(251,191,36,0.14); color: var(--warn); }
.status.pending::before { background: var(--warn); }
.status.approved { background: rgba(52,211,153,0.14); color: var(--ok); }
.status.approved::before { background: var(--ok); }
.status.rejected { background: rgba(251,113,133,0.14); color: var(--bad); }
.status.rejected::before { background: var(--bad); }
.status.released { background: rgba(255,255,255,0.06); color: var(--muted); }
.status.released::before { background: var(--muted); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-ring {
  width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 50%;
  border: 3px solid var(--stroke-2); border-top-color: var(--brand);
  animation: spin 1.4s linear infinite;
}
.activity { display: flex; flex-direction: column; gap: 10px; }
.act-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--stroke); border-radius: 12px; padding: 13px 16px;
  animation: rise 0.4s ease;
}
.act-dot { width: 9px; height: 9px; border-radius: 50%; }
.act-main strong { font-family: var(--mono); }
.act-main span { color: var(--muted); font-size: 13px; }
.act-time { color: var(--muted); font-size: 12px; font-family: var(--mono); }

/* ── modal + drawer ──────────────────────────────────────────── */
.modal, .drawer {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(3,4,8,0.7); backdrop-filter: blur(6px); animation: fade .2s ease;
}
.modal-card {
  width: min(440px, 92vw); background: var(--panel-solid);
  border: 1px solid var(--stroke-2); border-radius: 20px; padding: 26px;
  box-shadow: var(--shadow); animation: rise 0.35s cubic-bezier(0.2,0.9,0.2,1);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h3 { margin: 0; font-size: 19px; font-weight: 700; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.drawer { place-items: stretch; justify-items: end; }
.drawer-card {
  width: min(440px, 94vw); height: 100%; background: var(--panel-solid);
  border-left: 1px solid var(--stroke-2); padding: 30px 26px; position: relative;
  box-shadow: var(--shadow); animation: slideIn 0.35s cubic-bezier(0.2,0.9,0.2,1); overflow-y: auto;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.drawer-close { position: absolute; top: 18px; right: 18px; }
.detail-row { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--stroke); }
.detail-row .k { color: var(--muted); font-size: 13px; }
.detail-row .v { font-size: 14px; text-align: right; word-break: break-all; }
.drawer-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid); border: 1px solid var(--stroke-2); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: all .3s cubic-bezier(0.2,0.9,0.2,1); z-index: 40;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(52,211,153,0.4); }
.toast.bad { border-color: rgba(251,113,133,0.4); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; border-right: none; border-bottom: 1px solid var(--stroke); overflow-x: auto; }
  .stats { margin: 0; flex-direction: row; }
  .nav { flex-direction: row; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--stroke); }
  .table td { padding: 5px 0; border: none; display: flex; justify-content: space-between; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  .row-actions { justify-content: flex-start; margin-top: 8px; }
}