/* ============================================================
   Bot Shop Admin — Design System
   Dark, data-dense, violet accent
   ============================================================ */

:root {
  /* Surfaces (dark) */
  --bg-0: #0A0A0B;
  --bg-1: #111114;
  --bg-2: #16161A;
  --bg-3: #1C1C22;
  --bg-4: #24242C;
  --bg-hover: #1F1F26;

  /* Borders */
  --border-1: #1F1F26;
  --border-2: #2A2A33;
  --border-3: #383842;

  /* Text */
  --text-1: #F4F4F5;
  --text-2: #A1A1AA;
  --text-3: #71717A;
  --text-4: #52525B;

  /* Accent (violet) */
  --accent: #7C5CFF;
  --accent-hover: #8E72FF;
  --accent-soft: rgba(124, 92, 255, 0.12);
  --accent-border: rgba(124, 92, 255, 0.32);

  /* Semantic */
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --info: #3B82F6;
  --info-soft: rgba(59, 130, 246, 0.12);

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);

  /* Layout */
  --sidebar-w: 232px;
  --topbar-h: 52px;
}

[data-theme='light'] {
  --bg-0: #FAFAFA;
  --bg-1: #FFFFFF;
  --bg-2: #F5F5F5;
  --bg-3: #EEEEEF;
  --bg-4: #E4E4E7;
  --bg-hover: #F0F0F1;
  --border-1: #E4E4E7;
  --border-2: #D4D4D8;
  --border-3: #A1A1AA;
  --text-1: #09090B;
  --text-2: #52525B;
  --text-3: #71717A;
  --text-4: #A1A1AA;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root { height: 100%; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); background-clip: padding-box; border: 2px solid transparent; }

/* ============================================================
   App Shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

.app.no-chrome { grid-template-columns: 1fr; }

/* Sidebar */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-1);
  height: var(--topbar-h);
}
.sidebar-brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent) 0%, #5B3FE8 100%);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.4);
}
.sidebar-brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.sidebar-brand-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: -1px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 80ms, color 80ms;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.nav-item-badge {
  margin-left: auto;
  background: var(--bg-3);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.nav-item.active .nav-item-badge { background: rgba(124, 92, 255, 0.2); color: var(--accent); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-3);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}
.avatar.violet { background: linear-gradient(135deg, #7C5CFF, #5B3FE8); color: white; }
.avatar.green { background: linear-gradient(135deg, #10B981, #059669); color: white; }
.avatar.blue { background: linear-gradient(135deg, #3B82F6, #1E40AF); color: white; }
.avatar.amber { background: linear-gradient(135deg, #F59E0B, #D97706); color: white; }
.avatar.pink { background: linear-gradient(135deg, #EC4899, #BE185D); color: white; }

.user-chip-info { min-width: 0; }
.user-chip-name { font-size: 12.5px; font-weight: 500; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-role { font-size: 11px; color: var(--text-3); }

/* Main */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-0);
}

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  background: var(--bg-1);
}
.topbar-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.topbar-breadcrumbs .sep { color: var(--text-4); }
.topbar-breadcrumbs .current { color: var(--text-1); font-weight: 500; }
.topbar-search {
  margin-left: auto;
  position: relative;
}
.topbar-search input {
  width: 280px;
  height: 30px;
  padding: 0 10px 0 30px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: 12.5px;
  outline: none;
  transition: border-color 80ms;
}
.topbar-search input:focus { border-color: var(--accent-border); }
.topbar-search input::placeholder { color: var(--text-4); }
.topbar-search .icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-4);
}
.topbar-search .kbd {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
}
.kbd-key {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text-3);
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  transition: background 80ms, color 80ms;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.icon-btn .icon { width: 15px; height: 15px; }
.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg-1);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 64px;
}

/* ============================================================
   Page header & layout
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 3px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text-1);
  cursor: pointer;
  transition: background 80ms, border-color 80ms;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-3); }
.btn .icon { width: 14px; height: 14px; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-1); border-color: transparent; }
.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-lg { height: 36px; padding: 0 14px; font-size: 13px; }

/* ============================================================
   Cards / Surfaces
   ============================================================ */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-1);
}
.card-title { font-size: 14px; font-weight: 600; margin: 0; }
.card-subtitle { font-size: 12px; color: var(--text-3); }
.card-body { padding: 18px; }

.surface {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
}

/* ============================================================
   Stat cards
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.stat-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-label .icon { width: 13px; height: 13px; }
.stat-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}
.stat-spark {
  position: absolute;
  right: 12px;
  bottom: 12px;
  opacity: 0.7;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 500;
  font-size: 11.5px;
}
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta-bg { padding: 1px 5px; border-radius: 4px; }
.delta-bg.up { background: var(--success-soft); }
.delta-bg.down { background: var(--danger-soft); }

/* ============================================================
   Badges & status
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-3);
  color: var(--text-2);
  white-space: nowrap;
  line-height: 1.6;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.violet { background: var(--accent-soft); color: var(--accent); }
.badge.neutral { background: var(--bg-3); color: var(--text-2); }
.badge.outline { background: transparent; border: 1px solid var(--border-2); color: var(--text-2); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-1);
}
.table-toolbar .grow { flex: 1; }

.tbl-search {
  position: relative;
  width: 260px;
}
.tbl-search input {
  width: 100%;
  height: 28px;
  padding: 0 10px 0 28px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: 12px;
  outline: none;
}
.tbl-search input:focus { border-color: var(--accent-border); }
.tbl-search .icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--text-4);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-1);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  user-select: none;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text-1); }
thead th .sort-icon { margin-left: 4px; opacity: 0.5; }
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-1);
  vertical-align: middle;
  color: var(--text-1);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr {
  transition: background 60ms;
}
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg-hover); }
tbody td.muted { color: var(--text-3); }
tbody td.mono { font-family: var(--font-mono); font-size: 11.5px; }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.checkbox-col { width: 36px; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border-1);
  font-size: 12px;
  color: var(--text-3);
}
.pagination {
  display: flex;
  gap: 4px;
}

/* ============================================================
   Forms
   ============================================================ */
.form-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border-1);
}
.form-row:last-child { border-bottom: none; }
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-1);
}
.form-help {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 4px;
  line-height: 1.5;
}
.form-control {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: 12.5px;
  outline: none;
  transition: border-color 80ms, box-shadow 80ms;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.form-control {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
textarea.form-control.mono { font-family: var(--font-mono); font-size: 11.5px; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%2371717A' d='M3 5l3 3 3-3z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.input-group { display: flex; gap: 8px; align-items: center; }
.input-prefix {
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-right: none;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  color: var(--text-3);
  font-size: 12px;
  font-family: var(--font-mono);
}
.input-prefix + .form-control { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* Toggle */
.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-4);
  border-radius: 999px;
  transition: background 120ms;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: transform 120ms;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); }

/* Checkbox */
.checkbox {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-3);
  border-radius: 3px;
  background: var(--bg-2);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text-1); }
.tab.active {
  color: var(--text-1);
  border-bottom-color: var(--accent);
}
.tab-count {
  background: var(--bg-3);
  color: var(--text-3);
  padding: 0 5px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  min-width: 16px;
  text-align: center;
}

/* Filter chip */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}
.filter-chip:hover { border-color: var(--border-3); color: var(--text-1); }
.filter-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}
.filter-chip .icon { width: 12px; height: 12px; }
.filter-chip-count {
  background: var(--bg-3);
  color: var(--text-2);
  font-size: 10.5px;
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ============================================================
   Modal / Drawer
   ============================================================ */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 90;
  animation: fadeIn 120ms ease;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 640px;
  background: var(--bg-1);
  border-left: 1px solid var(--border-1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0;
}
.drawer-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.drawer-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-1);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-1);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 520px;
  max-width: 92vw;
  max-height: 90vh;
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border-1); }
.modal-title { font-size: 15px; font-weight: 600; margin: 0; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border-1); display: flex; justify-content: flex-end; gap: 8px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes scaleIn { from { transform: translate(-50%, -50%) scale(0.96); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* ============================================================
   Misc utilities
   ============================================================ */
.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 12.5px;
}
.kv-key { color: var(--text-3); }
.kv-val { color: var(--text-1); }

.divider { height: 1px; background: var(--border-1); margin: 14px 0; }
.divider-v { width: 1px; background: var(--border-1); }

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty-icon { color: var(--text-4); margin-bottom: 12px; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }

.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row-tight { display: flex; align-items: center; gap: 6px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.tag-emoji { width: 22px; height: 22px; display: grid; place-items: center; background: var(--bg-3); border-radius: 6px; flex-shrink: 0; font-size: 13px; }
.tag-img { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; object-fit: cover; background: var(--bg-3); }

.placeholder-img {
  background:
    repeating-linear-gradient(45deg, var(--bg-2) 0 6px, var(--bg-3) 6px 12px);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-4);
  font-family: var(--font-mono);
  font-size: 9px;
}

/* Spark line, mini chart */
.spark { display: block; }

/* Toast */
.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  animation: slideInRight 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  min-width: 280px;
}
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast.info .toast-icon { color: var(--info); }

/* Login */
.login-shell {
  flex: 1;
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at top, rgba(124, 92, 255, 0.15), transparent 50%),
    radial-gradient(ellipse at bottom, rgba(124, 92, 255, 0.08), transparent 50%),
    var(--bg-0);
  position: relative;
  overflow: hidden;
}
.login-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border-1) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-1) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 70%);
  opacity: 0.4;
}
.login-card {
  position: relative;
  width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login-brand-logo {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #5B3FE8);
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 14px;
  box-shadow: 0 6px 20px rgba(124, 92, 255, 0.5);
}
.login-title { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.login-subtitle { font-size: 13px; color: var(--text-3); margin: 4px 0 0; }
.login-form > * + * { margin-top: 14px; }
.login-field-label { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; display: block; }
.login-foot { margin-top: 20px; font-size: 11.5px; color: var(--text-4); text-align: center; }
.login-meta { position: absolute; bottom: 24px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text-4); font-family: var(--font-mono); }

/* Animation utility */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.pulse-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease infinite;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
