/* ── CSS Variables — Ink-on-Paper Theme (Fleet Graffs design system) ─────────── */
/* Tokens are HSL triplets consumed as hsl(var(--token)); only the VALUES changed
   from the old Viatec blue theme, so every existing hsl(var(--token)) keeps working
   but now renders ink-on-paper. Blue is reserved exclusively for the AI halo. */
:root {
  /* Core palette */
  --primary:              0 0% 4%;        /* ink #0a0a0a — primary action = ink, not blue */
  --primary-foreground:   0 0% 100%;      /* paper on ink */
  --background:           0 0% 98%;       /* #fafafa */
  --foreground:           0 0% 4%;        /* ink */
  --card:                 0 0% 100%;      /* #ffffff */
  --card-foreground:      0 0% 4%;
  --popover:              0 0% 100%;
  --popover-foreground:   0 0% 4%;
  --secondary:            240 14% 99%;    /* surface-2 #fbfbfb */
  --secondary-foreground: 225 16% 16%;    /* ink-soft #1f2330 */
  --muted:                228 27% 95%;    /* line-soft #f0f1f4 */
  --muted-foreground:     222 7% 57%;     /* muted #8a8f9a */
  --accent:               228 27% 95%;    /* hover wash */
  --accent-foreground:    0 0% 4%;
  --destructive:          0 72% 42%;      /* bad #b91c1c */
  --border:               220 13% 91%;    /* line #e5e7eb */
  --input:                220 13% 91%;
  --ring:                 0 0% 4%;         /* ink focus ring (not blue) */
  --sidebar:              0 0% 100%;

  /* Semantic */
  --success:              160 84% 24%;    /* good #047857 */
  --success-foreground:   0 0% 100%;
  --warning:              32 94% 37%;     /* warn #b45309 */
  --warning-foreground:   0 0% 100%;
  --danger:               0 72% 42%;      /* bad #b91c1c */
  --danger-foreground:    0 0% 100%;

  /* Ink/line helpers + AI accent (blue, halo only) */
  --ink-soft:             225 16% 16%;
  --line-soft:            228 27% 95%;
  --ai:                   213 94% 78%;    /* ≈ blue-300 rgb(147,197,253) */
  --ai-strong:            213 94% 68%;    /* ≈ blue-400 rgb(96,165,250) */

  /* Radius */
  --radius: 0.5rem;

  /* Letter spacing */
  --tracking-heading: -0.03em;

  /* Serif for headlines (system fonts — no web-font fetch) */
  --font-serif: "New York", ui-serif, "Iowan Old Style", "Apple Garamond", Georgia, "Times New Roman", serif;
}

/* ── Dark theme — overrides the same token names; activated by data-theme on <html> ── */
[data-theme="dark"] {
  --primary:              240 5% 96%;     /* ink inverts → light fill */
  --primary-foreground:   220 14% 6%;
  --background:           220 14% 6%;     /* #0c0d10 */
  --foreground:           240 5% 96%;     /* #f4f4f5 */
  --card:                 222 13% 9%;     /* #14161b */
  --card-foreground:      240 5% 96%;
  --popover:              222 13% 9%;
  --popover-foreground:   240 5% 96%;
  --secondary:            222 13% 11%;
  --secondary-foreground: 240 5% 84%;     /* #d4d4d8 */
  --muted:                222 13% 11%;
  --muted-foreground:     222 7% 58%;
  --accent:               222 13% 14%;
  --accent-foreground:    240 5% 96%;
  --destructive:          0 72% 60%;
  --border:               225 12% 17%;    /* #262931 */
  --input:                225 12% 17%;
  --ring:                 240 5% 96%;
  --sidebar:              222 13% 9%;

  --success:              160 60% 45%;
  --warning:              35 90% 55%;
  --danger:               0 72% 60%;

  --ink-soft:             240 5% 84%;
  --line-soft:            222 13% 14%;
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
body {
  background: hsl(var(--background));
  min-height: 100dvh;
  font-family: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--foreground) / 0.08); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--foreground) / 0.18); }

/* ── Glass / Surface ─────────────────────────────────────────────────────────── */
.glass {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.04), 0 1px 2px -1px rgb(0 0 0 / 0.04);
}

/* Elevated surfaces — flat token surfaces (dark-safe; no baked white) */
.glass-elevated {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.07), 0 1px 4px rgb(0 0 0 / 0.04);
}

.glass-subtle {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.05);
}

.glass-topbar {
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
}

.glass-sidebar {
  background: hsl(var(--sidebar));
  border-right: 1px solid hsl(var(--border));
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0.5rem 1rem; border-radius: 999px; font-size: 0.875rem;
  font-weight: 600; cursor: pointer; transition: all 0.2s cubic-bezier(0.22,1,0.36,1);
  border: 1px solid transparent; outline: none; white-space: nowrap;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* Primary = ink */
.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.btn-primary:hover { background: hsl(var(--ink-soft)); border-color: hsl(var(--ink-soft)); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: hsl(var(--card)); color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.btn-secondary:hover { background: hsl(var(--accent)); border-color: hsl(var(--foreground) / 0.25); color: hsl(var(--foreground)); }

.btn-ghost { background: transparent; color: hsl(var(--foreground)); border-radius: var(--radius); }
.btn-ghost:hover { background: hsl(var(--accent)); }

/* Destructive = solid bad */
.btn-danger {
  background: hsl(var(--danger));
  color: #fff; border-color: hsl(var(--danger));
}
.btn-danger:hover { background: hsl(var(--danger) / 0.88); }

.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; border-radius: 999px; }
.btn-icon { padding: 0.5rem; width: 2.25rem; height: 2.25rem; border-radius: 999px; }

/* AI button — paper with the reserved blue halo (the only blue in the system) */
.btn-ai {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
  animation: fleet-ask-glow 2800ms ease-in-out infinite;
}
.btn-ai:hover { transform: translateY(-1px); animation-duration: 2000ms; }
@keyframes fleet-ask-glow {
  0%, 100% { box-shadow: 0 0 0 1px hsl(var(--ai) / 0.18), 0 0 10px -2px hsl(var(--ai-strong) / 0.20); }
  50%      { box-shadow: 0 0 0 1px hsl(var(--ai) / 0.32), 0 0 16px 0 hsl(var(--ai-strong) / 0.30); }
}

/* View button — outlined; ink wash on hover */
.btn-view {
  padding: 0.3rem 0.75rem; font-size: 0.75rem; border-radius: 999px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  gap: 5px;
}
.btn-view:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--foreground) / 0.25);
  color: hsl(var(--foreground));
}

/* Delete button — subtle icon button with red hover */
.btn-delete {
  padding: 0.35rem; width: 2rem; height: 2rem; border-radius: 999px;
  background: transparent;
  color: hsl(var(--muted-foreground) / 0.6);
}
.btn-delete:hover {
  background: hsl(var(--danger) / 0.10);
  color: hsl(var(--danger));
}

/* Close modal button — outlined, prominent */
.btn-close-modal {
  padding: 0.45rem 1.25rem; font-size: 0.8125rem; border-radius: 999px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  font-weight: 600;
}
.btn-close-modal:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--foreground) / 0.25);
}

/* ── Pagination — quiet paper pill ───────────────────────────────────────────── */
.pg-dock {
  display: inline-flex; align-items: center; gap: 2px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.05);
  padding: 6px 8px;
  border-radius: 999px;
}
.pg-divider {
  width: 1px; height: 20px; margin: 0 3px;
  background: hsl(var(--border));
  border-radius: 9999px; flex-shrink: 0;
}
.pg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 999px;
  border: none; background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer; transition: all 0.15s ease;
}
.pg-btn:hover:not(:disabled) {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}
.pg-btn:active:not(:disabled) { transform: scale(0.92); }
.pg-btn:disabled { opacity: 0.3; cursor: default; }

.pg-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 0.5rem; border-radius: 999px;
  border: none; background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 13px; font-weight: 500; letter-spacing: -0.02em;
  cursor: pointer; transition: all 0.15s ease;
}
.pg-num:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }

/* Active page — ink fill */
.pg-num-active,
.pg-num-active:hover {
  font-weight: 620;
  color: hsl(var(--primary-foreground));
  background: hsl(var(--primary));
  border: none;
}

/* ── Inputs ──────────────────────────────────────────────────────────────────── */
.input {
  width: 100%; height: 2.5rem; padding: 0 0.75rem;
  border-radius: var(--radius); border: 1px solid hsl(var(--input));
  background: hsl(var(--secondary));
  font-size: 13px; color: hsl(var(--foreground));
  transition: all 0.2s ease; outline: none;
  font-family: inherit;
  box-shadow: none;
}
.input:hover { border-color: hsl(var(--foreground) / 0.25); }
.input:focus {
  border-color: hsl(var(--ring) / 0.6);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
  background: hsl(var(--card));
}
.input::placeholder { color: hsl(var(--muted-foreground)); font-size: 13px; }

.input-label {
  display: block; font-size: 12px; font-weight: 600;
  color: hsl(var(--secondary-foreground)); margin-bottom: 0.375rem;
}

/* ── Textarea ────────────────────────────────────────────────────────────────── */
textarea.input {
  height: auto; min-height: 4rem; padding: 0.5rem 0.75rem;
  resize: vertical; line-height: 1.5;
  font-size: 13px; color: hsl(var(--foreground));
}

/* ── Select (hidden, replaced by custom dropdown) ────────────────────────── */
select.input {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background: hsl(var(--secondary)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8f9a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.75rem center !important;
  padding-right: 2.25rem;
  font-size: 13px;
  color: hsl(var(--foreground));
  cursor: pointer;
}
select.input:focus {
  background-color: hsl(var(--card)) !important;
  outline: none !important;
}

/* ── Custom Dropdown ─────────────────────────────────────────────────────── */
.custom-select {
  position: relative;
}
.custom-select-trigger {
  width: 100%; height: 2.5rem; padding: 0 2.25rem 0 0.75rem;
  border-radius: var(--radius); border: 1px solid hsl(var(--input));
  background: hsl(var(--secondary));
  font-size: 13px; color: hsl(var(--foreground));
  cursor: pointer; outline: none;
  display: flex; align-items: center;
  transition: all 0.15s ease;
  position: relative;
}
.custom-select-trigger::after {
  content: '';
  position: absolute; right: 0.75rem; top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid hsl(var(--muted-foreground));
  transition: transform 0.15s ease;
}
.custom-select-trigger.open::after {
  transform: translateY(-50%) rotate(180deg);
}
.custom-select-trigger:hover,
.custom-select-trigger.open {
  border-color: hsl(var(--ring) / 0.6);
  background: hsl(var(--card));
}
.custom-select-trigger.open {
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
  border-radius: var(--radius) var(--radius) 0 0;
}
.custom-select-trigger .placeholder {
  color: hsl(var(--muted-foreground));
}
.custom-select-menu {
  position: absolute; top: 100%; left: 0; right: 0;
  z-index: 60;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  max-height: 15rem; overflow-y: auto;
  padding: 0.25rem 0;
}
.custom-select-menu::-webkit-scrollbar { width: 4px; }
.custom-select-menu::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 2px; }
.custom-select-option {
  padding: 0.4rem 0.75rem;
  font-size: 13px;
  color: hsl(var(--secondary-foreground));
  cursor: pointer;
  transition: all 0.1s ease;
  display: flex; align-items: center; gap: 0.5rem;
}
.custom-select-option:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}
.custom-select-option.selected {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
  font-weight: 600;
}
.custom-select-option.selected::before {
  content: '✓';
  font-size: 11px;
  color: hsl(var(--foreground));
  font-weight: 700;
}

/* ── Badge — same compact pill as the ADMIN role chip in the topbar ─────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 9999px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  line-height: 1.4;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; }
/* Status pill chips — soft state tint + state-ink text, all token-driven (dark-safe). */
.badge-success   { background: hsl(var(--success) / 0.12);   color: hsl(var(--success));   border-color: hsl(var(--success) / 0.3); }
.badge-warning   { background: hsl(var(--warning) / 0.12);   color: hsl(var(--warning));   border-color: hsl(var(--warning) / 0.3); }
.badge-danger    { background: hsl(var(--danger) / 0.12);    color: hsl(var(--danger));    border-color: hsl(var(--danger) / 0.3); }
/* "primary" (e.g. Running) → neutral ink chip; the Running spinner still signals activity. */
.badge-primary   { background: hsl(var(--foreground) / 0.06); color: hsl(var(--foreground)); border-color: hsl(var(--foreground) / 0.18); }
.badge-secondary { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); border-color: hsl(var(--border)); }
/* Role palettes (Users page): admin→success, user→neutral ink, viewer→secondary (no purple). */
.badge-role-admin  { background: hsl(var(--success) / 0.12); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.3); }
.badge-role-user   { background: hsl(var(--foreground) / 0.06); color: hsl(var(--foreground)); border-color: hsl(var(--foreground) / 0.18); }
.badge-role-viewer { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); border-color: hsl(var(--border)); }

/* ── Card (matches dashboard card styling) ───────────────────────────────────── */
.card {
  border-radius: 12px; padding: 1.25rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.04), 0 1px 2px -1px rgb(0 0 0 / 0.04);
  transition: all 0.25s cubic-bezier(0.22,1,0.36,1);
  overflow-x: auto;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* ── Table (clean, refined) ───────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; table-layout: auto; overflow-x: auto; }
.table td:last-child, .table th:last-child { white-space: nowrap; }
.table th {
  text-align: left; padding: 0.65rem 1rem; font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border) / 0.6);
}
.table td {
  padding: 0.75rem 1rem; border-bottom: 1px solid hsl(var(--border) / 0.4);
  color: hsl(var(--foreground));
  font-variant-numeric: tabular-nums;
}
.table tbody tr:nth-child(even) td { background: hsl(var(--muted) / 0.4); }
.table tr:hover td { background: hsl(var(--accent) / 0.7); }
.table tr:last-child td { border-bottom: none; }

/* ── Sidebar Nav ─────────────────────────────────────────────────────────────── */
.nav-item {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.75rem;
  border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
  color: hsl(var(--muted-foreground)); cursor: pointer;
  transition: all 0.15s ease; text-decoration: none;
}
.nav-item:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.nav-item.active {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  box-shadow: none;
}

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; background: hsl(var(--muted)); padding: 3px; border-radius: var(--radius); }
.tab {
  flex: 1; padding: 0.45rem 1rem; border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  color: hsl(var(--muted-foreground)); transition: all 0.18s ease; text-align: center;
}
.tab.active { background: hsl(var(--card)); color: hsl(var(--foreground)); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,15,30,0.3);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal {
  width: 100%; max-width: 28rem;
  border-radius: 12px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow:
    0 24px 64px rgba(0,0,0,0.15),
    0 8px 24px rgba(0,0,0,0.08);
  padding: 0;
  margin: auto 0;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  flex-shrink: 0;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  display: flex; align-items: center; gap: 0.75rem;
}
.modal-header-icon {
  width: 2.25rem; height: 2.25rem; border-radius: 0.625rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-header h3 {
  font-family: var(--font-serif);
  font-size: 1.0625rem; font-weight: 500;
  color: hsl(var(--foreground));
  letter-spacing: -0.3px;
}
.modal-header p {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 1px;
}
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid hsl(var(--border));
  display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem;
}

/* Input label refinement for modals */
.modal .input-label {
  font-size: 12px; font-weight: 600;
  color: hsl(var(--secondary-foreground));
  margin-bottom: 0.375rem;
  display: flex; align-items: center; gap: 0.375rem;
}
.modal .input-label .label-hint {
  font-weight: 400; font-size: 11px;
  color: hsl(var(--muted-foreground));
}
/* All modal inputs — unified styling */
.modal .input,
.modal .input-sql-editor,
.modal .input-json-editor,
.modal textarea.input {
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--input));
  color: hsl(var(--foreground));
  font-size: 13px;
}
.modal .input:focus,
.modal .input-sql-editor:focus,
.modal .input-json-editor:focus,
.modal textarea.input:focus {
  background: hsl(var(--card));
  border-color: hsl(var(--ring) / 0.6);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
}
/* Code textareas keep monospace + smaller size */
.modal .input-sql-editor,
.modal .input-json-editor {
  font-size: 11px;
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', monospace;
  line-height: 1.55;
}
/* Regular textarea */
.modal textarea.input {
  line-height: 1.5;
  font-size: 13px;
}

/* SQL editor textarea — paper code surface (tokenized; flips in dark) */
.input-sql-editor {
  width: 100%; min-height: 5rem; resize: vertical;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', monospace;
  font-size: 11px;
  line-height: 1.55;
  tab-size: 2;
  outline: none;
  letter-spacing: -0.01em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input-sql-editor:focus {
  border-color: hsl(var(--ring) / 0.6);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
  background: hsl(var(--card));
}
.input-sql-editor::placeholder { color: hsl(var(--muted-foreground)); font-size: 11px; }
.input-sql-editor::selection { background: hsl(var(--ring) / 0.18); }

/* JSON/Widget config editor textarea — paper code surface (tokenized; flips in dark) */
.input-json-editor {
  width: 100%; min-height: 4rem; resize: vertical;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', monospace;
  font-size: 11px;
  line-height: 1.55;
  tab-size: 2;
  outline: none;
  letter-spacing: -0.01em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input-json-editor:focus {
  border-color: hsl(var(--ring) / 0.6);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
  background: hsl(var(--card));
}
.input-json-editor::placeholder { color: hsl(var(--muted-foreground)); font-size: 11px; }
.input-json-editor::selection { background: hsl(var(--ring) / 0.18); }

/* SQL preview cell in tables — dark mini code block */
.sql-preview-cell {
  display: block;
  max-width: 200px;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', monospace;
  font-size: 0.6875rem;
  line-height: 1.4;
  background: #1e1e2e;
  color: #cdd6f4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(255,255,255,0.04);
}
/* Highlight keywords inline */
.sql-preview-cell .kw { color: #cba6f7; font-weight: 600; }
.sql-preview-cell .fn { color: #89b4fa; }
.sql-preview-cell .str { color: #a6e3a1; }
.sql-preview-cell .num { color: #fab387; }

/* ── Stat Tiles (white card + colored icon square) — sized to match graffs dashboard density ── */
.tile {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.04);
  transition: all 0.2s cubic-bezier(0.22,1,0.36,1);
}
.tile:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.tile-icon {
  display: flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 0.5rem; flex-shrink: 0;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.12);
}
.tile-icon i, .tile-icon svg {
  color: #fff !important; stroke: #fff;
  width: 1rem; height: 1rem;
}
.tile-content { min-width: 0; }
.tile-value {
  font-family: var(--font-serif);
  font-size: 1.5rem; font-weight: 500;
  letter-spacing: -0.4px;
  line-height: 1.1;
  color: hsl(var(--foreground));
  font-variant-numeric: tabular-nums;
}
.tile-label {
  font-size: 0.625rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
  margin-top: 3px;
}

/* Icon square colors — monochrome ink + state tints (no blue/purple) */
.tile-primary .tile-icon { background: hsl(var(--foreground)); }
.tile-success .tile-icon { background: hsl(var(--success)); }
.tile-warning .tile-icon { background: hsl(var(--warning)); }
.tile-danger  .tile-icon { background: hsl(var(--danger)); }
.tile-muted   .tile-icon { background: hsl(var(--muted-foreground)); }
.tile-purple  .tile-icon { background: hsl(var(--foreground) / 0.7); }

/* ── Misc ────────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: hsl(var(--border)); margin: 0.75rem 0; }

[x-cloak] { display: none !important; }

.fade-in { animation: fadeIn 0.35s cubic-bezier(0.22,1,0.36,1) forwards; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

.spinner {
  width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Running/executing state pulse for buttons (ink, no blue) */
.btn-primary:disabled {
  opacity: 0.85;
  background: hsl(var(--primary));
  animation: btn-pulse 2s ease-in-out infinite;
}
@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 2px 8px hsl(var(--foreground) / 0.2); }
  50% { box-shadow: 0 2px 20px hsl(var(--foreground) / 0.35); }
}

/* Code block — always-dark terminal (do NOT tokenize; stays dark in both themes) */
.code-block {
  background: #14161b; color: #e4e4e7;
  border-radius: var(--radius); padding: 0.75rem 1rem;
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', 'Cascadia Code', monospace; font-size: 0.8rem;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

/* ── SQL/JSON syntax highlighting (Prism.js overrides) ───────────────────── */
.sql-editor {
  border-radius: 0.375rem; padding: 0.25rem 0.5rem;
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', monospace;
  font-size: 10px !important; line-height: 1.35;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  max-height: 36rem; overflow-y: auto;
  tab-size: 2;
  letter-spacing: -0.02em;
}
.sql-editor code { font-family: inherit; font-size: 10px !important; background: none; padding: 0; }
.sql-editor code * { font-size: 10px !important; }
/* Dark theme (generated SQL) */
.sql-editor-dark {
  background: #1e1e2e; color: #cdd6f4;
  border: 1px solid rgba(255,255,255,0.06);
}
.sql-editor-dark .token.keyword { color: #cba6f7; font-weight: 600; }
.sql-editor-dark .token.function { color: #89b4fa; }
.sql-editor-dark .token.string { color: #a6e3a1; }
.sql-editor-dark .token.number { color: #fab387; }
.sql-editor-dark .token.operator { color: #89dceb; }
.sql-editor-dark .token.punctuation { color: #6c7086; }
.sql-editor-dark .token.comment { color: #585b70; font-style: italic; }
.sql-editor-dark .token.property { color: #89b4fa; }
.sql-editor-dark .token.boolean { color: #fab387; }
.sql-editor-dark .token.null { color: #f38ba8; }

/* Light theme (expected SQL) */
.sql-editor-light {
  background: #f8f9fc; color: #1e1e2e;
  border: 1px solid hsl(var(--border));
}
.sql-editor-light .token.keyword { color: #7c3aed; font-weight: 600; }
.sql-editor-light .token.function { color: #2563eb; }
.sql-editor-light .token.string { color: #16a34a; }
.sql-editor-light .token.number { color: #ea580c; }
.sql-editor-light .token.operator { color: #0891b2; }
.sql-editor-light .token.punctuation { color: #94a3b8; }
.sql-editor-light .token.comment { color: #94a3b8; font-style: italic; }
.sql-editor-light .token.property { color: #2563eb; }
.sql-editor-light .token.boolean { color: #ea580c; }
.sql-editor-light .token.null { color: #dc2626; }

/* ── Toast ────────────────────────────────────────────────────────────────────── */
.toast {
  border-radius: var(--radius); padding: 0.75rem 1rem;
  font-size: 0.875rem; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: slideIn 0.3s cubic-bezier(0.22,1,0.36,1) forwards;
}
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }

/* ── Focus ring (accessibility) ─────────────────────────────────────────────── */
.focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.app-layout { display: flex; flex-direction: row; height: 100dvh; overflow: hidden; }
.main-content { flex: 1; overflow-y: auto; min-width: 0; }
.page {
  padding: 1.25rem 1.5rem 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ── Left Sidebar (design-system shell) ──────────────────────────────────────── */
.sidebar {
  width: 248px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px;
  background: hsl(var(--sidebar));
  border-right: 1px solid hsl(var(--border));
  height: 100dvh; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid hsl(var(--border));
}
.sidebar-brand-title {
  font-family: var(--font-serif);
  font-size: 15px; font-weight: 500; letter-spacing: -0.2px;
  color: hsl(var(--foreground)); line-height: 1.1;
}
.sidebar-brand-sub {
  font-size: 10px; color: hsl(var(--muted-foreground)); margin-top: 2px; letter-spacing: 0.2px;
}
.sidebar-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  padding: 12px 12px 4px;
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid hsl(var(--border));
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-identity { padding: 4px 12px 8px; }
.sidebar-identity-name {
  font-size: 12px; color: hsl(var(--secondary-foreground)); font-weight: 500;
  margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-count {
  margin-left: auto; font-size: 11px; font-weight: 600; opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* ── Floating Dock Nav (matches dashboard glassmorphic pill) ──────────────── */
.nav-dock {
  position: relative;
  display: flex; align-items: center; gap: 3px;
  background:
    linear-gradient(170deg, rgba(255,255,255,0.72) 0%, rgba(255,255,255,0.48) 40%, rgba(235,242,255,0.54) 100%);
  backdrop-filter: blur(56px) saturate(220%) brightness(1.16);
  -webkit-backdrop-filter: blur(56px) saturate(220%) brightness(1.16);
  border: 1px solid;
  border-color: rgba(255,255,255,0.9) rgba(200,215,255,0.28) rgba(180,200,255,0.2) rgba(255,255,255,0.72);
  box-shadow:
    0 1.5px 0 rgba(255,255,255,0.96) inset,
    1.5px 0 0 rgba(255,255,255,0.42) inset,
    0 -1px 0 rgba(180,205,255,0.18) inset,
    0 2px 6px rgba(0,0,0,0.06),
    0 6px 20px rgba(0,0,0,0.08),
    0 12px 32px rgba(0,0,0,0.05);
  padding: 10px 11px;
  border-radius: 30px;
}
/* Inner border glow — disabled to avoid z-index issues with Alpine.js template rendering */

/* Divider between nav groups */
.nav-dock-divider {
  flex-shrink: 0; width: 0.5px; height: 26px; margin: 0 3px;
  background: linear-gradient(transparent, rgba(110,145,255,0.26) 50%, transparent);
  border-radius: 9999px;
}

/* Nav items */
.nav-dock-item {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 44px; min-width: 44px; padding: 0 15px 0 11px;
  border-radius: 16px;
  font-size: 13px; font-weight: 500; letter-spacing: -0.02em;
  color: rgba(48,72,158,0.62); cursor: pointer;
  transition: all 0.2s cubic-bezier(0.22,1,0.36,1);
  white-space: nowrap; text-decoration: none;
}
.nav-dock-item i {
  width: 18px; height: 18px; flex-shrink: 0;
  color: rgba(48,72,158,0.46);
  stroke-width: 1.65;
}
.nav-dock-item:hover {
  color: rgba(48,72,158,0.80);
}
.nav-dock-item:hover i { color: rgba(48,72,158,0.65); }
.nav-dock-item:active { filter: brightness(0.9); }

/* Active item — glass pill with blue text */
.nav-dock-item.active {
  font-weight: 620;
  color: rgba(22,67,210,0.92);
}
.nav-dock-item.active i {
  color: rgba(22,67,210,0.92);
  stroke-width: 2.1;
}
/* Active background — glass pill effect */
.nav-dock-item.active::before {
  content: '';
  position: absolute; inset: 0; border-radius: 16px;
  background:
    radial-gradient(150% 90% at 15% 8%, rgba(255,255,255,0.9) 0%, transparent 50%),
    linear-gradient(158deg, rgba(255,255,255,0.55) 0%, rgba(210,228,255,0.3) 100%);
  backdrop-filter: blur(18px) saturate(180%) brightness(1.08);
  -webkit-backdrop-filter: blur(18px) saturate(180%) brightness(1.08);
  border: 0.75px solid;
  border-color: rgba(255,255,255,0.98) rgba(185,210,255,0.28) rgba(165,195,255,0.22) rgba(255,255,255,0.82);
  box-shadow: 0 1.5px 0 rgba(255,255,255,0.94) inset;
  z-index: 0;
}
.nav-dock-item.active > * { position: relative; z-index: 1; }

.nav-dock-item .nav-count {
  font-size: 11px; font-weight: 600;
  margin-left: 1px; opacity: 0.7;
}

/* Role pill styles now use Tailwind classes directly in the template */

/* ── Page Header (in-content) ────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.page-header h2 {
  font-family: var(--font-serif);
  font-size: 1.375rem; font-weight: 500;
  color: hsl(var(--foreground));
  letter-spacing: -0.5px;
}
