:root {
  --bg: #ffffff;
  --bg-2: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --sidebar: #f7f7f8;
  --border: #e5e5e5;
  --border-strong: #d4d4d8;
  --text: #1a1a1a;
  --text-dim: #6e6e80;
  --text-faint: #8e8ea0;
  --brand: #10a37f;
  --brand-2: #0e8e6f;
  --gold: #f59e0b;
  --success: #10a37f;
  --danger: #ef4444;
  --warning: #f59e0b;
  --grad-brand: linear-gradient(135deg, #10a37f 0%, #0e8e6f 100%);
  --grad-gold: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  --grad-card: linear-gradient(
    160deg,
    rgba(16, 163, 127, 0.08) 0%,
    rgba(16, 163, 127, 0.03) 100%
  );

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* The `hidden` HTML attribute must always win over the explicit
   `display: grid/flex/...` rules below, otherwise modals and drawers
   render on top of each other on first load. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 {
  margin: 8px 0 6px;
  font-size: 28px;
  letter-spacing: -0.6px;
}

h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.3px;
}

h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.dim {
  color: var(--text-dim);
  font-size: 13px;
}

.muted {
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 4px;
}

code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
}

.view {
  min-height: 100vh;
}

/* ---------------- Login ---------------- */

.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-card {
  width: 420px;
  max-width: 100%;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  background-image: var(--grad-card);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--grad-brand);
  display: grid;
  place-items: center;
  font-size: 20px;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.field {
  margin: 14px 0;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--brand);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--grad-brand);
  border: none;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.45);
}

.btn.gold {
  background: var(--grad-gold);
  color: #231300;
  border: none;
}

.btn.ghost {
  background: transparent;
  color: var(--text-dim);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn.success {
  background: rgba(16, 185, 129, 0.18);
  color: #0e8e6f;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.btn.block {
  width: 100%;
  margin-top: 8px;
}

.btn.compact {
  padding: 6px 10px;
  font-size: 12px;
}

.error {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 10px 12px;
  border-radius: 10px;
  margin-top: 12px;
  font-size: 12px;
}

/* ---------------- Dashboard ---------------- */

.dashboard-view {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand.small .brand-icon {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.brand.small .brand-name {
  font-size: 16px;
}

.nav {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

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

.nav-link.active {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
}

.nav-link .icon {
  font-size: 16px;
}

.spacer {
  flex: 1;
}

.signed-as {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.main {
  padding: 24px 28px 40px;
  min-width: 0;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.header h2 {
  letter-spacing: -0.4px;
}

.actions input[type='search'] {
  width: 260px;
  padding: 8px 12px;
  font-size: 13px;
}

.tab {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

@media (max-width: 900px) {
  .chart-row {
    grid-template-columns: 1fr;
  }
}

.chart {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-top: 12px;
}

.chart .bar {
  flex: 1;
  background: var(--grad-brand);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  position: relative;
}

.chart .bar span {
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
}

.chart.area {
  align-items: stretch;
  position: relative;
}

.chart.area svg {
  width: 100%;
  height: 100%;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  background-image: var(--grad-card);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card .label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}

.stat-card .value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.stat-card .delta {
  font-size: 12px;
  color: var(--text-faint);
}

.stat-card.big {
  background-image: none;
  gap: 6px;
}

.stat-card.big .value {
  font-size: 28px;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 16px;
}

.delta.up {
  color: var(--success);
  font-weight: 700;
}

.geneo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.geneo-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 700;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
}

.badge.active {
  background: rgba(16, 185, 129, 0.2);
  color: #0e8e6f;
}

.badge.banned {
  background: rgba(239, 68, 68, 0.2);
  color: #b91c1c;
}

.badge.admin {
  background: rgba(124, 58, 237, 0.2);
  color: #e9d5ff;
}

.badge.hidden {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
}

.badge.published {
  background: rgba(6, 182, 212, 0.2);
  color: #a5f3fc;
}

.avatar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.avatar .circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--grad-brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

/* ---------------- Drawer ---------------- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: flex-end;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.drawer-card {
  position: relative;
  width: 480px;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
  margin: 0;
  font-size: 16px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.kv .key {
  color: var(--text-faint);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.kv .val {
  color: var(--text);
}

/* ---------------- Modal ---------------- */

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 100;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: 420px;
  max-width: calc(100% - 32px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 24px;
  z-index: 1;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  z-index: 200;
}

/* Mobile */
@media (max-width: 720px) {
  .dashboard-view {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 0;
  }
  .spacer {
    display: none;
  }
  .signed-as {
    flex: 1;
  }
  .btn.block {
    width: auto;
    margin-top: 0;
  }
  .actions input[type='search'] {
    width: 160px;
  }
}
