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

:root {
  --base:       #0b0d14;
  --surface:    #0f1221;
  --overlay:    #141828;
  --card:       #181d2e;
  --card-hover: #1d2438;
  --border:     rgba(148,163,184,.07);
  --border-md:  rgba(148,163,184,.13);
  --border-lg:  rgba(148,163,184,.22);

  --accent:     #6366f1;
  --accent-h:   #4f46e5;
  --accent-dim: rgba(99,102,241,.12);
  --accent-glow:rgba(99,102,241,.3);

  --green:      #22c55e;
  --green-dim:  rgba(34,197,94,.12);
  --amber:      #f59e0b;
  --amber-dim:  rgba(245,158,11,.12);
  --red:        #ef4444;
  --red-dim:    rgba(239,68,68,.12);

  --t1: #f0f4ff;
  --t2: #8892a4;
  --t3: #3d4a60;

  --sidebar-w: 240px;
  --r:   10px;
  --r-sm: 7px;
  --shadow: 0 8px 32px rgba(0,0,0,.5);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--base); color: var(--t1); line-height: 1.55; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a    { color: var(--accent); text-decoration: none; }
code { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: .82em; background: rgba(148,163,184,.08); padding: .15em .45em; border-radius: 5px; color: #a5b4fc; }

/* ─── Layout ────────────────────────────────────────────────────── */
.app  { display: flex; min-height: 100vh; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ─── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-glow);
}
.brand-name { font-size: .88rem; font-weight: 700; color: var(--t1); letter-spacing: -.01em; line-height: 1.2; }
.brand-sub  { font-size: .68rem; color: var(--t3); line-height: 1; }

.sidebar-nav   { flex: 1; padding: .6rem .65rem; display: flex; flex-direction: column; gap: .05rem; }
.nav-section   { margin-bottom: .6rem; }
.nav-label {
  font-size: .65rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--t3);
  padding: .5rem .5rem .3rem;
}
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .52rem .7rem; border-radius: var(--r-sm);
  color: var(--t2); font-size: .83rem; font-weight: 450;
  transition: color .14s, background .14s;
}
.nav-item:hover  { color: var(--t1); background: rgba(255,255,255,.04); }
.nav-item.active { color: var(--t1); background: var(--accent-dim); font-weight: 500; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { font-size: .95rem; flex-shrink: 0; transition: color .14s; width: 16px; text-align: center; }

.sidebar-user {
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem .9rem;
  border-top: 1px solid var(--border);
}
.user-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-info   { flex: 1; min-width: 0; }
.user-name   { display: block; font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.user-role   { display: block; font-size: .68rem; color: var(--t3); line-height: 1.2; }
.logout-btn  {
  color: var(--t3); font-size: .95rem; padding: .3rem;
  border-radius: 6px; display: flex; transition: color .14s, background .14s;
}
.logout-btn:hover { color: var(--red); background: var(--red-dim); }

/* ─── Topbar ────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.breadcrumb  { display: flex; align-items: center; gap: .4rem; font-size: .8rem; }
.bc-root     { color: var(--t3); }
.bc-sep      { color: var(--t3); font-size: .65rem; }
.bc-page     { color: var(--t2); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.status-pill {
  display: flex; align-items: center; gap: .4rem;
  font-size: .75rem; color: #4ade80;
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.18);
  padding: .25rem .65rem; border-radius: 99px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(34,197,94,.7);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:.45 } }

/* ─── Content ───────────────────────────────────────────────────── */
.content { padding: 1.6rem; flex: 1; }
.page-header { margin-bottom: 1.5rem; }
.page-title  { font-size: 1.3rem; font-weight: 700; letter-spacing: -.025em; }
.page-sub    { font-size: .78rem; color: var(--t2); margin-top: .25rem; }

/* ─── Cards ─────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); gap: .75rem;
}
.card-title { font-size: .88rem; font-weight: 600; }
.card-body  { padding: 1.1rem; }

/* ─── Stats ─────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .85rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1.1rem; display: flex; align-items: center; gap: .9rem;
  transition: border-color .15s, transform .15s, box-shadow .15s; cursor: default;
}
.stat-card:hover { border-color: var(--border-md); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.stat-label { font-size: .7rem; color: var(--t2); margin-top: .2rem; }

/* ─── Table ─────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.table thead th {
  padding: .6rem 1rem; text-align: left;
  font-size: .68rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--t3); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ─── Badges ────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .22em .65em; border-radius: 99px; font-size: .7rem; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--green-dim); color: #4ade80; border: 1px solid rgba(34,197,94,.2); }
.badge-warning { background: var(--amber-dim); color: #fbbf24; border: 1px solid rgba(245,158,11,.2); }
.badge-danger  { background: var(--red-dim);   color: #f87171; border: 1px solid rgba(239,68,68,.2);  }
.badge-neutral { background: rgba(148,163,184,.07); color: var(--t2); border: 1px solid var(--border-md); }
.badge-role    { background: var(--accent-dim); color: #a5b4fc; border: 1px solid rgba(99,102,241,.2); font-size: .7rem; padding: .15em .5em; border-radius: 5px; }

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--r-sm);
  font-family: var(--font); font-size: .8rem; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: all .15s; white-space: nowrap; line-height: 1;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  color: #fff; box-shadow: 0 2px 10px rgba(99,102,241,.35);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-h) 0%, var(--accent) 100%); box-shadow: 0 4px 18px rgba(99,102,241,.5); transform: translateY(-1px); }
.btn-danger  { background: var(--red-dim);   color: #f87171; border-color: rgba(239,68,68,.25); }
.btn-danger:hover  { background: rgba(239,68,68,.2); }
.btn-warning { background: var(--amber-dim); color: #fbbf24; border-color: rgba(245,158,11,.25); }
.btn-warning:hover { background: rgba(245,158,11,.2); }
.btn-ghost   { background: rgba(255,255,255,.04); color: var(--t2); border-color: var(--border-md); }
.btn-ghost:hover { background: rgba(255,255,255,.08); color: var(--t1); border-color: var(--border-lg); }
.btn-sm { padding: .35rem .7rem;  font-size: .77rem; }
.btn-xs { padding: .2rem  .5rem;  font-size: .72rem; }

.btn-discord {
  background: var(--accent); color: #fff;
  width: 100%; justify-content: center;
  padding: .8rem 1rem; font-size: .88rem;
  border-radius: var(--r); box-shadow: 0 4px 20px var(--accent-glow);
  border: none;
}
.btn-discord:hover { background: var(--accent-h); box-shadow: 0 6px 28px var(--accent-glow); transform: translateY(-1px); }
.btn-discord svg { vertical-align: middle; }

/* ─── Forms ─────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.col-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .5rem; }

label { font-size: .76rem; font-weight: 500; color: var(--t2); }
label small { font-weight: 400; opacity: .7; }
.form-hint { font-size: .7rem; color: var(--t3); }

input[type=text], input[type=number], input[type=email], textarea, select {
  background: var(--overlay); border: 1px solid var(--border-md); color: var(--t1);
  border-radius: var(--r-sm); padding: .52rem .75rem;
  font-family: var(--font); font-size: .82rem; width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--t3); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
textarea { resize: vertical; }
select option { background: var(--overlay); }

.color-input-wrap { display: flex; align-items: center; gap: .6rem; }
.color-picker { width: 38px; height: 38px; padding: 3px; border: 1px solid var(--border-md); border-radius: var(--r-sm); cursor: pointer; background: var(--overlay); flex-shrink: 0; }
.color-text { flex: 1; }
.input-search { max-width: 260px; }
.select-sm { width: auto; }
.filter-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ─── Tabs ──────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .1rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; }
.tab {
  padding: .55rem 1rem; font-size: .8rem; font-weight: 500; color: var(--t2);
  background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .14s, border-color .14s;
  display: flex; align-items: center; gap: .4rem;
}
.tab:hover  { color: var(--t1); }
.tab.active { color: var(--t1); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem; backdrop-filter: blur(6px); }
.modal-backdrop.open { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
.modal { background: var(--card); border: 1px solid var(--border-md); border-radius: 14px; width: 100%; max-width: 600px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slideUp .2s ease; }
@keyframes slideUp { from { transform:translateY(10px);opacity:0 } to { transform:translateY(0);opacity:1 } }
.modal-sm { max-width: 400px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: .92rem; font-weight: 600; }
.modal-close { background: rgba(255,255,255,.05); border: 1px solid var(--border-md); color: var(--t2); cursor: pointer; font-size: .8rem; width: 26px; height: 26px; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: all .14s; }
.modal-close:hover { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,.3); }
.modal-body   { padding: 1.1rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: .85rem 1.15rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

/* ─── Alerts / Toasts ───────────────────────────────────────────── */
.alert { padding: .7rem 1rem; border-radius: var(--r-sm); font-size: .82rem; display: flex; align-items: center; gap: .5rem; }
.alert-success { background: var(--green-dim); border: 1px solid rgba(34,197,94,.2);  color: #4ade80; }
.alert-danger  { background: var(--red-dim);   border: 1px solid rgba(239,68,68,.2);  color: #f87171; }

#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: .5rem; z-index: 300; }
.toast { padding: .65rem 1rem; border-radius: var(--r-sm); font-size: .8rem; font-weight: 500; box-shadow: var(--shadow); max-width: 300px; display: flex; align-items: center; gap: .5rem; animation: toastIn .2s ease; }
@keyframes toastIn { from { transform:translateX(110%);opacity:0 } to { transform:translateX(0);opacity:1 } }
.toast-success { background: #0d2318; border: 1px solid rgba(34,197,94,.25); color: #4ade80; }
.toast-error   { background: #200d0d; border: 1px solid rgba(239,68,68,.25);  color: #f87171; }

/* ─── Misc ──────────────────────────────────────────────────────── */
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--t3); font-size: .82rem; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.empty-state i { font-size: 2rem; opacity: .4; }
.info-row { display: flex; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: .77rem; color: var(--t2); }
.drag-handle { cursor: grab; color: var(--t3); user-select: none; }
.cat-emoji { font-size: .9em; }
.env-row { display: flex; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--border); gap: 1rem; }
.env-row:last-child { border-bottom: none; }
.env-key { display: flex; align-items: center; gap: .6rem; }
.env-label { font-size: .75rem; color: var(--t2); }
.env-val { display: flex; align-items: center; gap: .5rem; }
.env-preview { color: var(--t3); font-size: .75rem; }
.text-muted { color: var(--t2); }
.text-sm { font-size: .78rem; }
.text-xs { font-size: .72rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: .75rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media(max-width:800px) { .grid-2 { grid-template-columns: 1fr; } }

/* ─── Login ─────────────────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(99,102,241,.2) 0%, transparent 60%), var(--base);
}
.login-wrap { width: 100%; max-width: 360px; padding: 1rem; }
.login-card {
  background: var(--card); border: 1px solid var(--border-md); border-radius: 16px;
  padding: 2.5rem 2rem; text-align: center;
  box-shadow: var(--shadow), 0 0 60px rgba(99,102,241,.08);
}
.login-logo {
  width: 56px; height: 56px; border-radius: 15px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; margin-bottom: 1.1rem;
  box-shadow: 0 0 28px var(--accent-glow);
}
.login-logo svg { display: block; }
.login-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .3rem; }
.login-sub   { color: var(--t2); font-size: .8rem; margin-bottom: 1.6rem; }
.login-error { background: var(--red-dim); border: 1px solid rgba(239,68,68,.25); color: #f87171; border-radius: var(--r-sm); padding: .6rem .9rem; font-size: .8rem; margin-bottom: 1rem; }
.login-note  { font-size: .7rem; color: var(--t3); margin-top: 1rem; }
