/* ============================================================
   Nancy OS — Design System
   ============================================================ */
:root {
  --bg: #0A0A0F;
  --surface: #12121A;
  --surface-2: #1A1A24;
  --surface-3: #22222E;
  --border: #252533;
  --border-strong: #33333F;
  --text: #F4F4F5;
  --text-dim: #A1A1AA;
  --text-faint: #71717A;
  --accent: #10B981;
  --accent-2: #8B5CF6;
  --accent-soft: rgba(16, 185, 129, 0.12);
  --accent-2-soft: rgba(139, 92, 246, 0.12);
  --danger: #F43F5E;
  --warning: #F59E0B;
  --info: #3B82F6;
  --success: #10B981;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

body {
  min-height: 100vh;
  letter-spacing: -0.005em;
}

pre, code, .mono { font-family: var(--font-mono); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Selection */
::selection { background: var(--accent-soft); color: var(--text); }

/* Focus-visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus, input:focus, textarea:focus, select:focus, a:focus { outline: none; }

/* ================ Layout shell ================ */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.sidebar-brand-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}
.nav-section {
  margin-bottom: 14px;
}
.nav-section-title {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 8px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  color: var(--text-dim);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: background 150ms, color 150ms;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-item svg, .nav-item i { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item-badge {
  margin-left: auto;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-2);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-faint); }
.user-card button {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 150ms, color 150ms;
}
.user-card button:hover { background: var(--surface-3); color: var(--danger); }

/* Main */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  flex: 1;
  min-width: 0;
}
.breadcrumbs a { color: var(--text-dim); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs .sep { color: var(--text-faint); }
.breadcrumbs .current { color: var(--text); font-weight: 500; }

.cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}
.cmdk-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.cmdk-trigger kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}
.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.2);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

.content {
  padding: 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 200ms ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.page-subtitle { color: var(--text-dim); font-size: 13.5px; margin-top: 4px; }

/* ================ Cards ================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-weight: 600; font-size: 14px; }
.card-subtle { color: var(--text-dim); font-size: 12.5px; }

/* Stat tile */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: border-color 150ms, transform 150ms;
}
.stat:hover { border-color: var(--border-strong); }
.stat-label {
  font-size: 11.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.stat-accent { color: var(--accent); }
.stat-warn { color: var(--warning); }
.stat-danger { color: var(--danger); }
.stat-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.stat-icon.violet { background: var(--accent-2-soft); color: var(--accent-2); }
.stat-icon.amber { background: rgba(245,158,11,0.12); color: var(--warning); }
.stat-icon.rose { background: rgba(244,63,94,0.12); color: var(--danger); }
.stat-icon.blue { background: rgba(59,130,246,0.12); color: var(--info); }

/* ================ Buttons ================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, transform 80ms, color 150ms;
  text-decoration: none;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn svg, .btn i { width: 14px; height: 14px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #059669);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.1) inset, 0 4px 14px rgba(16,185,129,0.25);
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }

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

.btn-danger {
  background: rgba(244,63,94,0.1);
  color: var(--danger);
  border-color: rgba(244,63,94,0.3);
}
.btn-danger:hover { background: rgba(244,63,94,0.18); border-color: var(--danger); }

.btn-sm { padding: 5px 9px; font-size: 12px; gap: 5px; }
.btn-xs { padding: 3px 7px; font-size: 11px; gap: 4px; border-radius: 6px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

/* ================ Inputs ================ */
.input, .textarea, .select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input.mono { font-family: var(--font-mono); font-size: 12.5px; }
.input.error { border-color: var(--danger); }
.input.success { border-color: var(--success); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}

/* Floating label */
.floating {
  position: relative;
}
.floating input {
  width: 100%;
  padding: 20px 14px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 150ms, box-shadow 150ms;
}
.floating input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.floating label {
  position: absolute;
  left: 14px;
  top: 14px;
  color: var(--text-faint);
  font-size: 14px;
  pointer-events: none;
  transition: all 150ms;
}
.floating input:focus + label,
.floating input:not(:placeholder-shown) + label {
  top: 6px;
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ================ Tables ================ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background 150ms; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.table tbody tr:nth-child(even):hover { background: var(--surface-2); }

/* ================ Badges ================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: rgba(16,185,129,0.12); color: var(--accent); }
.badge-danger { background: rgba(244,63,94,0.14); color: var(--danger); }
.badge-warn { background: rgba(245,158,11,0.14); color: var(--warning); }
.badge-info { background: rgba(59,130,246,0.14); color: var(--info); }
.badge-violet { background: var(--accent-2-soft); color: var(--accent-2); }

/* ================ Tooltip ================ */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11.5px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 50;
  animation: fadeIn 120ms ease-out;
}

/* ================ Toast ================ */
#toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 360px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-dim);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  animation: toastIn 180ms ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast .icon { color: var(--text-dim); flex-shrink: 0; margin-top: 1px; }
.toast.success .icon { color: var(--success); }
.toast.error .icon { color: var(--danger); }
.toast.warning .icon { color: var(--warning); }
.toast.info .icon { color: var(--info); }
.toast.leaving { animation: toastOut 180ms ease-in forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ================ Modal / Drawer ================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: grid;
  place-items: center;
  animation: fadeIn 150ms ease-out;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 540px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
  animation: modalIn 180ms cubic-bezier(.2,.8,.2,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 90;
  animation: fadeIn 150ms ease-out;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(640px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 95;
  display: flex;
  flex-direction: column;
  animation: drawerIn 200ms cubic-bezier(.2,.8,.2,1);
  box-shadow: var(--shadow-lg);
}
@keyframes drawerIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ================ Command Palette ================ */
.cmdk-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  justify-content: center;
  padding-top: 15vh;
  animation: fadeIn 120ms ease-out;
}
.cmdk-panel {
  width: min(600px, 92vw);
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 150ms cubic-bezier(.2,.8,.2,1);
}
.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cmdk-input-wrap i { color: var(--text-faint); }
.cmdk-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
}
.cmdk-input::placeholder { color: var(--text-faint); }
.cmdk-list { overflow-y: auto; padding: 6px; }
.cmdk-section-title {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 12px 6px;
  letter-spacing: 0.06em;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 100ms, color 100ms;
}
.cmdk-item i { width: 15px; height: 15px; color: var(--text-faint); }
.cmdk-item:hover, .cmdk-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.cmdk-item:hover i, .cmdk-item.active i { color: var(--accent); }
.cmdk-item .kbd { margin-left: auto; font-size: 10.5px; color: var(--text-faint); font-family: var(--font-mono); }
.cmdk-empty { padding: 20px; text-align: center; color: var(--text-faint); font-size: 13px; }

kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
}

/* ================ Skeletons ================ */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ================ Loading bar ================ */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 999;
  width: 0;
  transition: width 200ms ease-out, opacity 200ms;
  box-shadow: 0 0 10px var(--accent);
}

/* ================ Chat ================ */
.chat-shell { display: flex; flex-direction: column; height: calc(100vh - 130px); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.chat-msg { display: flex; gap: 12px; align-items: flex-start; max-width: 860px; }
.chat-msg.user { margin-left: auto; flex-direction: row-reverse; }
.chat-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
}
.chat-msg.user .chat-avatar { background: var(--surface-3); color: var(--text-dim); }
.chat-msg.assistant .chat-avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: break-word;
  max-width: 100%;
}
.chat-msg.user .chat-bubble {
  background: var(--accent-soft);
  border-color: rgba(16,185,129,0.3);
  border-top-right-radius: 4px;
}
.chat-msg.assistant .chat-bubble { border-top-left-radius: 4px; }
.chat-bubble pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  overflow-x: auto;
  margin: 8px 0;
}
.chat-bubble code { font-size: 12.5px; }
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-input-wrap {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  transition: border-color 150ms, box-shadow 150ms;
}
.chat-input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.chat-input-row textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 8px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
  outline: none;
  min-height: 24px;
  max-height: 200px;
}

.thinking {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  color: var(--text-dim);
  font-size: 12px;
}
.thinking span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: dot 1.2s infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ================ Login page (split) ================ */
.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.login-hero {
  position: relative;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.login-hero::before {
  content: '';
  position: absolute;
  inset: -50%;
  background:
    radial-gradient(600px circle at 30% 30%, rgba(16,185,129,0.18), transparent 60%),
    radial-gradient(500px circle at 70% 70%, rgba(139,92,246,0.16), transparent 60%);
  animation: drift 18s ease-in-out infinite alternate;
  filter: blur(20px);
}
@keyframes drift {
  0% { transform: translate(0,0) rotate(0); }
  100% { transform: translate(-5%, 5%) rotate(8deg); }
}
.login-hero > * { position: relative; z-index: 1; }
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 600;
  font-size: 20px;
}
.login-tagline {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: 440px;
}
.login-tagline .grad {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-foot { font-size: 12px; color: var(--text-faint); }

.login-form-wrap {
  display: grid;
  place-items: center;
  padding: 48px;
  background: var(--bg);
}
.login-form {
  width: 100%;
  max-width: 380px;
}
.login-form h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.login-form p.sub {
  color: var(--text-dim);
  font-size: 13.5px;
  margin: 0 0 28px;
}

.alert {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-error { background: rgba(244,63,94,0.08); border: 1px solid rgba(244,63,94,0.3); color: #FCA5B1; }
.alert-info { background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.3); color: #93C5FD; }
.alert-success { background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.3); color: #6EE7B7; }
.alert-warn { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.3); color: #FCD34D; }

/* ================ Grids ================ */
.grid-stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; transform: translateX(-100%); transition: transform 200ms; width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 20px 16px; }
  .topbar { padding: 10px 16px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

/* Activity list */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--surface-3);
  color: var(--text-dim);
}
.activity-icon.success { background: var(--accent-soft); color: var(--accent); }
.activity-icon.danger { background: rgba(244,63,94,0.12); color: var(--danger); }
.activity-icon.info { background: rgba(59,130,246,0.12); color: var(--info); }
.activity-icon.violet { background: var(--accent-2-soft); color: var(--accent-2); }
.activity-meta { flex: 1; min-width: 0; }
.activity-action { color: var(--text); font-weight: 500; }
.activity-target { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; }
.activity-time { color: var(--text-faint); font-size: 11.5px; margin-top: 2px; }

/* Quick action tile */
.quick-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.quick-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: border-color 150ms, transform 150ms, background 150ms;
}
.quick-tile:hover { border-color: var(--accent); background: var(--surface-2); }
.quick-tile .icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.quick-tile .t { font-size: 13.5px; font-weight: 500; }
.quick-tile .s { font-size: 11.5px; color: var(--text-dim); }

/* Utility */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.ml-auto { margin-left: auto; }
.flex-1 { flex: 1; min-width: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-xs { font-size: 11.5px; }
.text-sm { font-size: 13px; }
.text-lg { font-size: 16px; }
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.break-all { word-break: break-all; }

/* Prose */
.prose { color: var(--text); font-size: 14px; line-height: 1.6; }
.prose h1, .prose h2, .prose h3 { font-weight: 600; letter-spacing: -0.01em; margin-top: 1.2em; margin-bottom: 0.5em; }
.prose h1 { font-size: 22px; }
.prose h2 { font-size: 18px; }
.prose h3 { font-size: 15px; }
.prose a { color: var(--accent); }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.prose pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; }
.prose pre code { background: transparent; padding: 0; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
