:root {
  --bg:       #0f0f11;
  --surface:  #18181b;
  --surface2: #1f1f23;
  --border:   #27272a;
  --primary:  #3b82f6;
  --primary-h:#2563eb;
  --green:    #22c55e;
  --red:      #ef4444;
  --yellow:   #f59e0b;
  --text:     #f4f4f5;
  --muted:    #71717a;
  --radius:   10px;
}

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

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 15px;
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────── */
body { display: flex; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 16px;
  position: fixed; height: 100%; top: 0; left: 0;
  z-index: 10;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 4px; margin-bottom: 32px;
  font-size: .9rem; color: var(--primary);
}
.sidebar-brand i { font-size: 1.6rem; flex-shrink: 0; }
.sidebar-brand strong { display: block; font-size: 1rem; color: var(--text); }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none;
  font-size: .88rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,.12); color: var(--primary); }
.nav-item i { font-size: 1.1rem; }

.sidebar-logout {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); text-decoration: none; font-size: .85rem;
  padding: 10px 12px; border-radius: 8px;
  transition: color .15s;
}
.sidebar-logout:hover { color: var(--red); }

.main {
  margin-left: 220px; flex: 1;
  padding: 32px; min-height: 100vh;
  overflow-y: auto;
}

/* ── Views ──────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Page header ─────────────────────────────────────── */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 28px;
}
.page-header h1 { font-size: 1.4rem; font-weight: 800; }
.page-sub { color: var(--muted); font-size: .82rem; margin-top: 3px; }

/* ── Stats ──────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: linear-gradient(145deg, var(--surface), #1c1c1f);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 24px;
  display: flex; align-items: center; gap: 20px;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  position: relative; overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.03), transparent 70%);
  pointer-events: none;
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; flex-shrink: 0;
  position: relative;
  transition: transform .3s;
}
.stat-card:hover .stat-icon { transform: scale(1.1); }

.icon-blue  { 
  background: rgba(59,130,246,0.1); color: #60a5fa;
  box-shadow: 0 0 20px rgba(59,130,246,0.1);
}
.icon-green { 
  background: rgba(34,197,94,0.1);  color: #4ade80;
  box-shadow: 0 0 20px rgba(34,197,94,0.1);
}
.icon-red   { 
  background: rgba(239,68,68,0.1);  color: #f87171;
  box-shadow: 0 0 20px rgba(239,68,68,0.1);
}

.stat-info { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--text); }

/* ── Integrations Grid ──────────────────────────────── */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .integrations-grid { grid-template-columns: 1fr; }
}

/* ── Card ───────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .9rem;
}

/* ── Toolbar ─────────────────────────────────────────── */
.toolbar {
  display: flex; gap: 12px; align-items: center; margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  flex: 1; min-width: 220px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0 14px;
  transition: border-color .2s;
}
.search-wrap:focus-within { border-color: var(--primary); }
.search-wrap i { color: var(--muted); font-size: 1rem; flex-shrink: 0; }
.search-wrap input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: .88rem; padding: 10px 0;
  font-family: inherit;
}
.filter-tabs { display: flex; gap: 6px; }
.ftab {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); padding: 8px 14px; border-radius: 7px;
  font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.ftab:hover { border-color: #444; color: var(--text); }
.ftab.active { background: rgba(59,130,246,.1); border-color: rgba(59,130,246,.4); color: var(--primary); }

/* ── Table ──────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 13px 16px; font-size: .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,.02); }
.td-loading, .td-empty {
  text-align: center; padding: 40px; color: var(--muted); font-size: .88rem;
}
.td-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .72rem; font-weight: 700;
}
.badge-green  { background: rgba(34,197,94,.1);  color: #22c55e; }
.badge-red    { background: rgba(239,68,68,.1);  color: #ef4444; }
.badge-yellow { background: rgba(245,158,11,.1); color: #f59e0b; }
.badge-blue   { background: rgba(99,102,241,.1); color: #6366f1; }
.badge-muted  { background: var(--surface2);     color: var(--muted); }

.token-pill {
  font-family: monospace; font-size: .78rem; color: var(--muted);
  background: var(--surface2); padding: 3px 8px; border-radius: 5px;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff;
  border: none; padding: 9px 18px; border-radius: 8px;
  font-size: .86rem; font-weight: 600; cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover { background: var(--primary-h); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary.full { width: 100%; justify-content: center; padding: 12px; }

.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 9px 18px; border-radius: 8px; font-size: .86rem; cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: var(--surface2); }

.btn-sm {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); padding: 6px 12px; border-radius: 6px;
  font-size: .78rem; cursor: pointer; transition: color .15s;
}
.btn-sm:hover { color: var(--text); }

.btn-icon {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); width: 34px; height: 34px;
  border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; transition: background .15s, color .15s, border-color .15s;
}
.btn-icon:hover     { background: var(--surface2); color: var(--text); }
.btn-warn:hover     { border-color: var(--yellow); color: var(--yellow); }
.btn-success:hover  { border-color: var(--green);  color: var(--green); }
.btn-danger:hover   { border-color: var(--red);    color: var(--red); }
.btn-pix:hover      { border-color: #6366f1;       color: #6366f1; }

.btn-danger-sm {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25);
  color: #ef4444; padding: 6px 12px; border-radius: 6px;
  font-size: .78rem; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-danger-sm:hover { background: rgba(239,68,68,.15); }

.link { color: var(--primary); text-decoration: none; font-size: .82rem; }
.link:hover { text-decoration: underline; }

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.7); z-index: 100;
  align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 500px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1rem; font-weight: 700; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  padding: 16px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Form fields ─────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select, .field textarea {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 12px; border-radius: 8px;
  font-family: inherit; font-size: .88rem; outline: none;
  transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 60px; }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.input-addon { display: flex; align-items: center; }
.input-addon input { flex: 1; border-radius: 8px 0 0 8px; }
.addon {
  background: var(--surface2); border: 1px solid var(--border); border-left: none;
  color: var(--muted); padding: 10px 10px; border-radius: 0 8px 8px 0;
  font-size: .78rem; white-space: nowrap;
}
.req { color: var(--red); }

/* ── User section ────────────────────────────────────── */
.user-section { display: flex; flex-direction: column; gap: 12px; }
.section-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0;
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.section-divider span {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
}

/* ── Token section ───────────────────────────────────── */
.token-section {
  background: rgba(59,130,246,.06); border: 1px solid rgba(59,130,246,.2);
  border-radius: 8px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.token-label {
  font-size: .78rem; font-weight: 700; color: #3b82f6;
  display: flex; align-items: center; gap: 6px;
}
.token-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; padding: 10px 12px;
}
.token-row code { flex: 1; font-family: monospace; font-size: .8rem; word-break: break-all; }
.token-hint {
  font-size: .75rem; color: var(--muted); line-height: 1.8;
}
.token-hint code {
  background: var(--surface2); padding: 1px 5px; border-radius: 4px;
  font-size: .74rem; color: #7dd3fc;
}

/* ── Login page ─────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 6px; font-size: 1.1rem; font-weight: 700; color: var(--primary);
}
.login-logo i { font-size: 1.8rem; }
.login-sub { color: var(--muted); font-size: .82rem; margin-bottom: 28px; }
.login-card .field { margin-bottom: 16px; }
.alert-error {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5; border-radius: 7px; padding: 10px 14px;
  font-size: .82rem; margin-bottom: 16px;
  display: flex; align-items: center; gap: 7px;
}
