:root {
  --bg: #0b0f1a;
  --bg-2: #121829;
  --panel: #141b2d;
  --panel-2: #1a2238;
  --border: #26304b;
  --text: #e7ecf7;
  --muted: #8692a8;
  --muted-2: #5b6680;
  --accent: #7c8cff;
  --accent-2: #5b6eff;
  --accent-glow: rgba(124, 140, 255, 0.45);
  --ok: #3fd6a7;
  --err: #ff6b7a;
  --warn: #ffb74d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

body.app {
  display: flex;
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  top: -30vh;
  left: -20vw;
  width: 90vw;
  height: 90vh;
  background: radial-gradient(circle at 30% 30%, rgba(124, 140, 255, 0.25), transparent 60%),
              radial-gradient(circle at 80% 80%, rgba(63, 214, 167, 0.15), transparent 60%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  animation: glow-drift 18s ease-in-out infinite alternate;
}

@keyframes glow-drift {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(8vw, 6vh) scale(1.05); }
}

/* ---- Sidebar ---- */
.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 2;
}
.brand { display:flex; align-items:center; gap:12px; padding: 4px 8px 24px; }
.logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  font-size: 20px;
  box-shadow: 0 8px 22px var(--accent-glow);
}
.brand-title { font-weight: 700; letter-spacing: .3px; }
.brand-sub { color: var(--muted); font-size: 12px; }

nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display:flex; align-items:center; gap:10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: background .2s, color .2s, transform .2s;
}
.nav-item span { opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,0.03); color: var(--text); transform: translateX(2px); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(124,140,255,0.18), rgba(124,140,255,0.06));
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.admin-name { font-weight: 600; margin-bottom: 8px; }

/* ---- Content ---- */
.content { flex: 1; padding: 28px 36px; position: relative; z-index: 1; max-width: 100%; }
.content-centered { flex: 1; display: grid; place-items: center; padding: 40px 20px; position: relative; z-index: 1; }

.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px; gap: 20px;
}
.page-header h1 { margin: 0 0 4px 0; font-size: 26px; font-weight: 700; }
.page-actions { display: flex; gap: 8px; }

/* ---- Cards ---- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.card h2 { margin: 0 0 14px 0; font-size: 16px; font-weight: 600; }
.card-header { display:flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-footer { margin-top: 12px; display:flex; gap: 8px; justify-content: flex-end; }

/* ---- Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.stat-card::before {
  content:""; position:absolute; inset:auto -30% -60% auto; width: 180px; height: 180px;
  background: radial-gradient(circle, var(--accent-glow), transparent 60%);
  opacity: .35; filter: blur(20px);
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 12px 30px rgba(124, 140, 255, 0.15); }
.stat-icon { font-size: 18px; color: var(--accent); margin-bottom: 6px; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; }
.stat-label { color: var(--muted); font-size: 13px; }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 0; }
.table thead tr { border-bottom: 1px solid var(--border); }
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Sortable column headers */
.sort-th {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  padding: 2px 0;
  transition: color .18s;
}
.sort-th:hover { color: var(--text); }
.sort-th.sort-active { color: var(--accent); }
.sort-arrow { font-size: 10px; opacity: .9; }
.sort-arrow-idle { opacity: .3; }
.sort-th:hover .sort-arrow-idle { opacity: .7; }
.table-hover tbody tr { transition: background .2s; }
.table-hover tbody tr:hover { background: rgba(124, 140, 255, 0.06); }
tr.row-clickable { cursor: default; }
tr.row-clickable:hover { cursor: pointer; }
.nowrap { white-space: nowrap; }
.mono { font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; font-size: 12.5px; }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.center { text-align: center; }
.truncate { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---- Badges / pills ---- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-ok { background: rgba(63, 214, 167, 0.15); color: var(--ok); }
.badge-err { background: rgba(255, 107, 122, 0.15); color: var(--err); }
.pill {
  display: inline-block;
  padding: 3px 9px;
  background: rgba(124, 140, 255, 0.12);
  border: 1px solid rgba(124, 140, 255, 0.3);
  border-radius: 6px;
}
.pill.secret { letter-spacing: 2px; }

/* ---- Forms ---- */
label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 14px 0 6px;
  font-weight: 600;
}

/* All text-like inputs share the dark, subtle style. Selector covers inputs
   without an explicit type attribute (which default to text) via :not(). */
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=file]),
textarea,
select {
  width: 100%;
  background: linear-gradient(180deg, rgba(10, 14, 25, 0.6), rgba(10, 14, 25, 0.9));
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease, transform .05s ease;
  -webkit-appearance: none;
  appearance: none;
}
input:not([type=checkbox]):not([type=radio])::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}
input:not([type=checkbox]):not([type=radio]):hover,
textarea:hover,
select:hover {
  border-color: rgba(124, 140, 255, 0.45);
}
input:not([type=checkbox]):not([type=radio]):focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.18), 0 4px 14px rgba(0, 0, 0, 0.35) inset;
  background: linear-gradient(180deg, rgba(20, 27, 45, 0.95), rgba(10, 14, 25, 0.95));
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
textarea:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px rgba(10, 14, 25, 0.95) inset !important;
  box-shadow: 0 0 0 1000px rgba(10, 14, 25, 0.95) inset !important;
  caret-color: var(--text) !important;
  border: 1px solid var(--border) !important;
  background-color: transparent !important;
  background-image: none !important;
  transition: background-color 9999s ease-in-out 0s, color 9999s ease-in-out 0s;
}
input:-webkit-autofill:focus,
textarea:-webkit-autofill:focus {
  border-color: var(--accent) !important;
}
textarea { resize: vertical; min-height: 72px; }

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%238692a8' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
.form-row .check { margin-top: 0; align-self: center; }
.form-actions { margin-top: 22px; display: flex; gap: 8px; justify-content: flex-end; }

/* Custom check — replaces the default OS checkbox with a themed square. */
.check {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); font-size: 13px;
  text-transform: none; letter-spacing: 0; font-weight: 500;
  margin-top: 18px; cursor: pointer; user-select: none;
}
.check input[type=checkbox] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  transition: background .18s, border-color .18s, box-shadow .18s;
  flex-shrink: 0;
}
.check input[type=checkbox]:hover { border-color: var(--accent); }
.check input[type=checkbox]:checked {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.check input[type=checkbox]:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600; font-size: 13px;
  cursor: pointer;
  transition: transform .15s, background .2s, box-shadow .2s, border-color .2s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(124, 140, 255, 0.55); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.04); border-color: var(--accent); }
.btn-danger-ghost { background: transparent; color: var(--err); border-color: rgba(255,107,122,0.4); }
.btn-danger-ghost:hover { background: rgba(255,107,122,0.08); border-color: var(--err); }
.btn-danger {
  background: linear-gradient(135deg, #ff5a6f, #c0324a);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(255, 90, 111, 0.35);
}
.btn-danger:hover { box-shadow: 0 8px 22px rgba(255, 90, 111, 0.55); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 14px; }
.btn-icon {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  width: 28px; height: 28px; border-radius: 6px;
  display: inline-grid; place-items: center; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.btn-icon:hover { color: var(--accent); border-color: var(--accent); background: rgba(124,140,255,0.08); }

/* ---- Alerts ---- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: rgba(255,107,122,0.1); color: var(--err); border-color: rgba(255,107,122,0.3); }
.alert-success { background: rgba(63,214,167,0.1); color: var(--ok); border-color: rgba(63,214,167,0.3); }
.alert-warn { background: rgba(255,183,77,0.08); color: var(--warn); border-color: rgba(255,183,77,0.3); }

/* ---- Login ---- */
.login-card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 380px;
  text-align: center;
}
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.login-card .muted { margin: 0 0 22px; }
.login-card form { text-align: left; }
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 16px;
  display:grid; place-items:center;
  font-size: 32px;
  box-shadow: 0 12px 30px var(--accent-glow);
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---- Grid/Layout helpers ---- */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.search-bar { display:flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; }

.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * { margin-left: 6px; vertical-align: middle; }
.row-actions > *:first-child { margin-left: 0; }
.inline { display: inline-block; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px; padding: 8px 0; align-items: center; }
.kv .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.kv .v { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6,9,16,0.7); backdrop-filter: blur(4px); animation: fade .2s ease-out; }
.modal-body { position: relative; width: 520px; max-width: 92vw; margin: 20px; }
.confirm-modal { width: 440px; text-align: center; padding: 28px 28px 22px; }
.confirm-modal h2 { margin: 6px 0 8px; font-size: 18px; }
.confirm-modal #confirmText { font-size: 14px; margin-bottom: 22px; line-height: 1.45; }
.confirm-modal .form-actions { justify-content: center; }
.confirm-icon {
  width: 56px; height: 56px; margin: 0 auto 6px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 90, 111, 0.12);
  color: #ff5a6f;
  font-size: 28px; font-weight: 700;
  border: 1px solid rgba(255, 90, 111, 0.3);
  animation: pulse-danger 1.8s ease-in-out infinite;
}
@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 111, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(255, 90, 111, 0); }
}

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 200;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Animations ---- */
.fade-in { opacity: 0; transform: translateY(6px); animation: fade-in .45s ease-out forwards; animation-delay: var(--d, 0ms); }
@keyframes fade-in { to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.shake { animation: shake .45s ease; }
@keyframes shake { 0%,100% { transform: translateX(0);} 20%,60% { transform: translateX(-4px);} 40%,80% { transform: translateX(4px);} }

/* ---- Misc ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border); }
