/* ── TOKENS ────────────────────────────────────────────────────── */
:root {
  --purple:   #7C3AED;
  --purple-d: #5B21B6;
  --purple-l: #EDE9FE;
  --bg:       #0F0F1A;
  --surface:  #1A1A2E;
  --surface2: #16213E;
  --border:   #2D2D4E;
  --text:     #E2E8F0;
  --muted:    #94A3B8;
  --success:  #22C55E;
  --danger:   #EF4444;
  --sidebar-w: 240px;
}

/* ── RESET ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: monospace; background: var(--border); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ── LAYOUT ────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── SIDEBAR ───────────────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: var(--purple);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 15px; display: block; }
.brand-sub  { font-size: 10px; color: var(--muted); display: block; }

.sidebar-nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  transition: background .15s, color .15s;
  font-weight: 500;
}
.nav-item:hover { background: var(--border); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--purple); color: #fff; }
.nav-item--danger { color: var(--danger); }
.nav-item--danger:hover { background: rgba(239,68,68,.12); color: var(--danger); }
.nav-divider { height: 1px; background: var(--border); margin: 8px 0; }
.nav-section-label { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding: 10px 12px 2px; }

/* ── TOPBAR ────────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 90;
}
.topbar-toggle { display: none; background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer; }
.topbar-title  { font-weight: 600; font-size: 16px; flex: 1; }
.topbar-user   { color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ── FLASH ─────────────────────────────────────────────────────── */
.flash-wrap { padding: 0 24px; }
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 13px;
}
.alert--success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert--danger  { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert--info    { background: rgba(124,58,237,.15); border: 1px solid rgba(124,58,237,.3); color: #c4b5fd; }
.alert-close    { margin-left: auto; background: none; border: none; color: inherit; cursor: pointer; font-size: 16px; }

/* ── PAGE CONTENT ──────────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ── CARDS ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.card--form { max-width: 800px; }
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 18px; }
.card-body.p0 { padding: 0; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); }

/* ── KPI ───────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.kpi-icon--blue   { background: rgba(59,130,246,.15); color: #93C5FD; }
.kpi-icon--green  { background: rgba(34,197,94,.15);  color: #86EFAC; }
.kpi-icon--red    { background: rgba(239,68,68,.15);  color: #FCA5A5; }
.kpi-icon--purple { background: rgba(124,58,237,.15); color: #C4B5FD; }
.kpi-value { display: block; font-size: 28px; font-weight: 700; line-height: 1; }
.kpi-label { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── TWO-COLUMN ROW ────────────────────────────────────────────── */
.row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* ── PLAN BARS ─────────────────────────────────────────────────── */
.plan-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.plan-name { width: 80px; font-size: 13px; text-transform: capitalize; }
.plan-bar-wrap { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.plan-bar { height: 100%; background: var(--purple); border-radius: 4px; transition: width .4s; }
.plan-count { width: 24px; text-align: right; font-size: 13px; color: var(--muted); }

/* ── TABLE ─────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,.02); }
.table td small.d-block { display: block; color: var(--muted); }
.actions { width: 1%; white-space: nowrap; display: flex; gap: 6px; }

/* ── BADGES ────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge--success { background: rgba(34,197,94,.15);  color: #86EFAC; }
.badge--danger  { background: rgba(239,68,68,.15);  color: #FCA5A5; }
.badge--plan    { background: rgba(124,58,237,.15); color: #C4B5FD; }
.badge--gold    { background: rgba(201,168,76,.15); color: #C9A84C; }
.badge--green   { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge--yellow  { background: rgba(234,179,8,.15);  color: #facc15; }
.badge--red     { background: rgba(239,68,68,.15);  color: #f87171; }

/* ── BUTTONS ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--border); }
.btn-block   { width: 100%; justify-content: center; }
.btn-sm      { padding: 5px 10px; font-size: 12px; }

/* ── TOOLBAR ───────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-form { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }

/* ── FORMS ─────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 16px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-label  { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--purple); }
.form-control--sm   { max-width: 160px; }
.form-control--mono { font-family: monospace; font-size: 13px; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon .form-control { padding-left: 32px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.checkbox-group  { display: flex; gap: 16px; flex-wrap: wrap; }
.checkbox-item   { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.checkbox-item input { accent-color: var(--purple); }

/* ── COLOR PICKER ──────────────────────────────────────────────── */
.color-input-wrap { display: flex; align-items: center; gap: 8px; }
.color-swatch     { width: 36px; height: 36px; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; background: none; padding: 0; }

/* ── DETAIL PAGE ───────────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.detail-meta   { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-actions{ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.info-list { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin-bottom: 16px; }
.info-list dt { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; align-self: center; }
.info-list dd { font-size: 14px; }
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; margin-right: 4px; border: 1px solid var(--border); }

/* ── TEXT UTILS ────────────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-center { text-align: center; }
.text-sm     { font-size: 12px; }

/* ── PAGE HEADER ────────────────────────────────────────────────── */
.page-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title   { font-size: 20px; font-weight: 700; }
.page-subtitle{ color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ── FILTER ROW ─────────────────────────────────────────────────── */
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input-sm { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: 13px; outline: none; }
.input-sm:focus { border-color: var(--purple); }

/* ── TABLE HEADER ───────────────────────────────────────────────── */
.table-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }

/* ── ACTION GROUP ───────────────────────────────────────────────── */
.action-group { display: flex; align-items: center; gap: 4px; }
.btn-icon { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 12px; transition: all .15s; }
.btn-icon:hover { color: var(--text); background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.15); }
.btn-icon--danger:hover { color: var(--danger); border-color: var(--danger); background: rgba(239,68,68,.08); }

/* ── CARD UTILS ─────────────────────────────────────────────────── */
.p-0 { padding: 0 !important; }
.btn--primary { background: var(--purple); color: #fff; }
.btn--outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* ── LOGIN ─────────────────────────────────────────────────────── */
body.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
}
.login-logo {
  width: 56px; height: 56px;
  background: var(--purple);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  margin: 0 auto 20px;
}
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-sub   { color: var(--muted); text-align: center; margin-bottom: 28px; font-size: 13px; }

/* ── ERRORS ────────────────────────────────────────────────────── */
body.error-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.error-card    { text-align: center; padding: 48px 32px; }
.error-code    { font-size: 96px; font-weight: 900; color: var(--purple); line-height: 1; }
.error-title   { font-size: 24px; font-weight: 700; margin: 16px 0 8px; }
.error-msg     { color: var(--muted); margin-bottom: 28px; }

/* ── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid  { grid-template-columns: 1fr 1fr; }
  .row-2col  { grid-template-columns: 1fr; }
  .form-row  { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: block; }
  .kpi-grid { grid-template-columns: 1fr; }
}
