/* ── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0b0d14;
  --bg-card:    #111420;
  --bg-hover:   #161926;
  --border:     #1e2235;
  --text:       #e2e8f0;
  --muted:      #94a3b8;
  --purple:     #7c3aed;
  --purple-lt:  #a78bfa;
  --purple-dim: #1e1040;
  --green:      #22c55e;
  --red:        #ef4444;
  --orange:     #f59e0b;
  --blue:       #3b82f6;
  --radius:     12px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
  --sidebar-w:  252px;
}

html { font-size: 14px; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a    { color: inherit; text-decoration: none; }
img  { max-width: 100%; display: block; }

code {
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 12px;
  background: #1e2235;
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--purple-lt);
}

/* ── AUTH PAGE ────────────────────────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.auth-bg { position: fixed; inset: 0; z-index: 0; }
.auth-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: .35;
}
.auth-orb    { position: absolute; border-radius: 50%; filter: blur(90px); }
.auth-orb--1 { width: 420px; height: 420px; background: rgba(124,58,237,.22); top: -120px; right: -100px; }
.auth-orb--2 { width: 300px; height: 300px; background: rgba(59,130,246,.14); bottom: -80px; left: -60px; }

.auth-wrapper {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px; padding: 24px;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
}
.auth-logo      { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; }
.auth-logo-icon {
  width: 42px; height: 42px;
  background: var(--purple-dim);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.auth-logo-text { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.auth-title     { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle  { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.auth-form      { display: flex; flex-direction: column; gap: 16px; }
.auth-footer    { margin-top: 24px; text-align: center; font-size: 11px; color: var(--muted); }
.auth-footer a  { color: var(--purple-lt); }

/* ── FORMS ────────────────────────────────────────────────────────────────── */
.form-group      { display: flex; flex-direction: column; gap: 6px; }
.form-label      { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; }
.form-input-wrap { position: relative; display: flex; align-items: center; }

.form-icon {
  position: absolute; left: 12px;
  top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
  display: flex; align-items: center;
}
.form-input {
  width: 100%;
  background: #0f111a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}
.form-input-wrap .form-input  { padding-left: 38px; }
.form-input-wrap .form-input[type="password"] { padding-right: 40px; }

.form-eye {
  position: absolute; right: 10px;
  top: 50%; transform: translateY(-50%);
  background: none; border: none;
  color: var(--muted); cursor: pointer; padding: 4px;
  display: flex; align-items: center;
}

.form-select {
  background: #0f111a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
}
.form-select:focus { outline: none; border-color: var(--purple); }

.form-input--sm,
.form-select--sm { padding: 7px 10px; font-size: 13px; border-radius: 7px; }

/* ── BUTTONS ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; border-radius: 8px;
  border: none; cursor: pointer;
  font-size: 14px; font-weight: 500; font-family: inherit;
  transition: all .15s; white-space: nowrap;
  line-height: 1;
}
.btn--primary       { background: var(--purple); color: #fff; }
.btn--primary:hover { background: #6d28d9; }
.btn--ghost         { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn--ghost:hover   { background: var(--bg-hover); }
.btn--danger        { background: #450a0a; color: var(--red); border: 1px solid #7f1d1d; }
.btn--danger:hover  { background: #7f1d1d; }
.btn--full          { width: 100%; justify-content: center; }
.btn--sm            { padding: 6px 12px; font-size: 12px; border-radius: 6px; }

/* ── ALERTS ───────────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px;
}
.alert--error   { background: #450a0a; border: 1px solid #7f1d1d; color: #fca5a5; }
.alert--success { background: #052e16; border: 1px solid #166534; color: #86efac; }

/* ── APP SHELL ────────────────────────────────────────────────────────────── */
.app-body { display: flex; min-height: 100vh; }

/* ── SIDEBAR ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh;
  position: fixed; left: 0; top: 0; z-index: 100;
  transition: transform .25s ease;
}
.sidebar-header {
  padding: 18px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo      { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700; }
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--purple-dim);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-toggle { background: none; border: none; color: var(--muted); cursor: pointer; display: none; padding: 4px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.sidebar-nav::-webkit-scrollbar       { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.nav-section-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
  padding: 14px 10px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--muted);
  transition: all .15s; cursor: pointer;
}
.nav-item:hover       { background: var(--bg-hover); color: var(--text); }
.nav-item--active     { background: var(--purple-dim); color: var(--purple-lt); }
.nav-item svg         { flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 99px;
  color: #fff; flex-shrink: 0;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--purple);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  display: block; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user-role { display: block; font-size: 11px; color: var(--muted); text-transform: capitalize; }
.sidebar-logout    { color: var(--muted); transition: color .15s; padding: 4px; display: flex; }
.sidebar-logout:hover { color: var(--red); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 99;
}

/* ── MAIN AREA ────────────────────────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh; min-width: 0;
}
.topbar {
  height: 58px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
  flex-shrink: 0;
}
.topbar-menu  { background: none; border: none; color: var(--muted); cursor: pointer; display: none; padding: 4px; }
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.status-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot--online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.55} }

.page-content { padding: 24px; flex: 1; }
.mt-4 { margin-top: 16px; }

/* ── CARDS ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px; flex-wrap: wrap;
}
.card-title   { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.card-title svg { flex-shrink: 0; }
.card-link    { font-size: 12px; color: var(--purple-lt); white-space: nowrap; }
.card-badge   { font-size: 11px; color: var(--muted); }
.card-body    { padding: 20px; }
.card-filters,
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── STAT CARDS ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
}
.stat-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon--blue   { background: rgba(59,130,246,.15);  color: var(--blue); }
.stat-card-icon--green  { background: rgba(34,197,94,.15);   color: var(--green); }
.stat-card-icon--red    { background: rgba(239,68,68,.15);   color: var(--red); }
.stat-card-icon--purple { background: var(--purple-dim);     color: var(--purple-lt); }
.stat-card-body  { min-width: 0; }
.stat-card-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-card-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── DASHBOARD GRID ───────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── TOGGLE SWITCH ────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }

.toggle-info             { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.toggle-info svg         { flex-shrink: 0; }
.toggle-info strong      { display: block; font-size: 13px; font-weight: 600; }
.toggle-info span        { display: block; font-size: 11px; color: var(--muted); }

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
  flex-shrink: 0; margin-left: 12px;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #1e2235;
  border-radius: 99px;
  transition: background .2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle-switch input:checked + .toggle-slider             { background: var(--purple); }
.toggle-switch input:checked + .toggle-slider::before     { transform: translateX(20px); }

.toggle-switch--sm              { width: 36px; height: 20px; }
.toggle-switch--sm .toggle-slider::before { width: 14px; height: 14px; }
.toggle-switch--sm input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── RESOURCE BARS ────────────────────────────────────────────────────────── */
.resource-body { display: flex; flex-direction: column; gap: 16px; }
.resource-item { display: flex; align-items: center; gap: 12px; }
.resource-label {
  width: 52px; flex-shrink: 0;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.resource-bar-wrap {
  flex: 1; height: 6px;
  background: #1e2235;
  border-radius: 99px;
  overflow: hidden;
}
.resource-bar {
  height: 100%; background: var(--purple);
  border-radius: 99px;
  transition: width .5s ease, background .3s;
}
.resource-bar--blue { background: var(--blue); }
.resource-val { width: 130px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }

/* ── MINI BARS ────────────────────────────────────────────────────────────── */
.mini-bar-wrap {
  display: inline-block; vertical-align: middle;
  width: 60px; height: 4px;
  background: #1e2235; border-radius: 99px;
  margin-right: 6px; overflow: hidden;
}
.mini-bar           { height: 100%; border-radius: 99px; transition: width .3s; }
.mini-bar--green    { background: var(--green); }
.mini-bar--orange   { background: var(--orange); }
.mini-bar--red      { background: var(--red); }

/* ── TABLES ───────────────────────────────────────────────────────────────── */
.table-wrap   { overflow-x: auto; }
.data-table   { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 16px; text-align: left;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td     { border-bottom: none; }
.data-table tbody tr:hover td    { background: var(--bg-hover); }
.row--alert td                   { background: rgba(239,68,68,.05); }
.table-empty {
  text-align: center; color: var(--muted);
  padding: 40px 16px !important;
}

/* ── TAGS / BADGES ────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.tag--green  { background: rgba(34,197,94,.12);  color: var(--green); }
.tag--red    { background: rgba(239,68,68,.12);   color: var(--red); }
.tag--blue   { background: rgba(59,130,246,.12);  color: var(--blue); }
.tag--orange { background: rgba(245,158,11,.12);  color: var(--orange); }

/* ── PAGINATION ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.page-btn {
  padding: 5px 11px; border-radius: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer;
  transition: all .15s;
}
.page-btn:hover,
.page-btn--active { background: var(--purple); color: #fff; }

/* ── FILTER / INLINE FORMS ────────────────────────────────────────────────── */
.filter-form,
.inline-form {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* ── SETTINGS ─────────────────────────────────────────────────────────────── */
.settings-section       { margin-bottom: 28px; }
.settings-section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); margin-bottom: 14px;
}

/* ── LOGS TOOLBAR ─────────────────────────────────────────────────────────── */
.logs-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.logs-info    { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar              { transform: translateX(-100%); }
  .sidebar.sidebar--open{ transform: translateX(0); }
  .sidebar-toggle,
  .topbar-menu          { display: flex !important; }
  .sidebar-overlay.overlay--open { display: block; }
  .app-main             { margin-left: 0; }
  .stats-grid           { grid-template-columns: 1fr 1fr; }
  .page-content         { padding: 16px; }
}
@media (max-width: 480px) {
  .stats-grid           { grid-template-columns: 1fr; }
  .topbar               { padding: 0 16px; }
}
