/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }
img { display: block; max-width: 100%; }

/* ── CSS Variables ─────────────────────────────────────────────────────── */
:root {
  --bg:           #18181c;
  --sidebar-bg:   #141418;
  --card:         #222228;
  --card-hover:   #26262e;
  --border:       rgba(255,255,255,0.06);
  --border-focus: rgba(6,221,117,0.4);
  --green:        #06DD75;
  --green-dim:    rgba(6,221,117,0.12);
  --blue:         #1153b0;
  --blue-dim:     rgba(17,83,176,0.15);
  --red:          #e05252;
  --red-dim:      rgba(224,82,82,0.12);
  --yellow:       #f0b429;
  --yellow-dim:   rgba(240,180,41,0.12);
  --text:         #e8e8f0;
  --text-muted:   #8a8a94;
  --text-faint:   #55555f;
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --radius:       8px;
  --radius-sm:    4px;
  --radius-lg:    12px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --transition:   0.15s ease;
}

/* ── Dark Theme Layout ─────────────────────────────────────────────────── */
.dark-theme {
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;

  /* carbon fiber grid */
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ── App Shell ─────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  padding: 0;
}

.sidebar__logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar__logo-mark {
  width: 32px;
  height: 32px;
  background: var(--green);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #000;
  flex-shrink: 0;
}

.sidebar__logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.sidebar__logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar__nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar__section-label {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
  border-radius: 0;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

.nav-item.active {
  color: var(--green);
  background: var(--green-dim);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--green);
  border-radius: 0 2px 2px 0;
}

.nav-item__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-item__icon { opacity: 1; }

.sidebar__footer {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

/* ── Main Area ─────────────────────────────────────────────────────────── */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar__title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

/* ── Grid helpers ──────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 900px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .sidebar { transform: translateX(-100%); }
  .main-area { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Utilities ─────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Sidebar Collapse ──────────────────────────────────────────────────── */
.sidebar {
  transition: width 0.2s ease;
}
.sidebar--collapsed {
  width: 60px;
}
.sidebar--collapsed .nav-item span,
.sidebar--collapsed .sidebar__logo-text,
.sidebar--collapsed .sidebar__logo-sub,
.sidebar--collapsed .sidebar__section-label {
  display: none;
}
.sidebar--collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}
.sidebar--collapsed .sidebar__logo {
  justify-content: center;
  padding: 16px 0;
}
.sidebar--collapsed .sidebar__logo img {
  height: 28px;
  max-width: 40px;
  object-fit: contain;
}
.main-area {
  transition: margin-left 0.2s ease;
}
.main-area.sidebar-collapsed {
  margin-left: 60px;
}

/* ── Card helpers ──────────────────────────────────────────────────────── */
.card__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.card__value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.card__sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
