/* ==========================================================================
   Susano — design system
   Dark gray base with a dark purple accent. Restrained, not busy.
   ========================================================================== */

:root {
  /* Surfaces — near-black gray, layered */
  --bg: #0b0b0f;
  --bg-2: #101014;
  --surface: #141419;
  --surface-2: #1a1a21;
  --surface-3: #202028;
  --border: #26262f;
  --border-2: #32323d;

  /* Purple accent scale */
  --purple: #7c3aed;
  --purple-bright: #9d5cff;
  --purple-dim: #6d28d9;
  --purple-deep: #2a1b45;
  --purple-glow: rgba(124, 58, 237, 0.35);

  /* Text */
  --text: #ececf1;
  --text-2: #a1a1ae;
  --text-3: #6e6e7d;

  /* Status */
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
  --blue: #4493f8;

  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 7px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;

  --nav-h: 64px;
  --sidebar-w: 244px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }

::selection { background: var(--purple); color: #fff; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3d3d4a; }

/* ── Typography ───────────────────────────────────────────────────────── */

h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); }
h3 { font-size: 1.15rem; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.mono { font-family: var(--mono); }
.grad {
  background: linear-gradient(120deg, #fff 10%, var(--purple-bright) 55%, var(--purple) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ── Layout helpers ───────────────────────────────────────────────────── */

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ── Buttons ──────────────────────────────────────────────────────────── */

/**
 * Flat, restrained buttons. No gradients or coloured glows: depth comes from
 * a subtle border and a one-step surface change, which reads as a tool rather
 * than a landing-page promo.
 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--surface-3); border-color: #3f3f4c; }
.btn:active { background: #1c1c24; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }

.btn svg { flex-shrink: 0; opacity: .85; }

.btn-primary {
  background: var(--purple-dim);
  border-color: #7c3aed;
  color: #fff;
  font-weight: 550;
}
.btn-primary:hover { background: var(--purple); border-color: var(--purple-bright); }
.btn-primary:active { background: #6023c4; }
.btn-primary svg { opacity: 1; }

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

.btn-danger {
  background: transparent;
  border-color: rgba(248, 81, 73, 0.35);
  color: #ff8b84;
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.1); border-color: rgba(248, 81, 73, 0.6); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 6px; gap: 6px; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; border-radius: 5px; gap: 4px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 8px; }
.btn-icon { padding: 6px; width: 30px; height: 30px; }
.btn-block { width: 100%; }

/* ── Forms ────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.label { font-size: 13px; font-weight: 550; color: var(--text-2); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--purple);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--purple-glow);
}
.textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.select {
  appearance: none; cursor: pointer;
  background-image: 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='%23a1a1ae' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.select option { background: var(--surface-2); }

/* Checkbox / toggle */
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 14px; }
.check input { appearance: none; width: 17px; height: 17px; border: 1.5px solid var(--border-2); border-radius: 5px; background: var(--bg-2); cursor: pointer; position: relative; transition: all .16s var(--ease); flex-shrink: 0; }
.check input:checked { background: var(--purple); border-color: var(--purple); }
.check input:checked::after { content: ''; position: absolute; left: 5px; top: 1.5px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* ── Toggle ──────────────────────────────────────────────────────────── */

/**
 * A switch that reads clearly at a glance: a larger track, a visible knob,
 * and an obvious on state. Text sits in a block beside it.
 */
.toggle {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  padding: 3px 0;
}
.toggle input {
  appearance: none;
  width: 46px;
  height: 26px;
  background: #2a2a34;
  border: 1px solid #3a3a47;
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background .2s var(--ease), border-color .2s var(--ease);
  flex-shrink: 0;
  margin-top: 1px;
}
.toggle input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #8b8b9c;
  border-radius: 50%;
  transition: transform .2s var(--ease), background .2s var(--ease);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.toggle input:hover { border-color: #4a4a5a; }
.toggle input:checked {
  background: var(--purple);
  border-color: var(--purple);
}
.toggle input:checked::after {
  transform: translateX(20px);
  background: #fff;
}
.toggle input:focus-visible {
  box-shadow: 0 0 0 3px var(--purple-glow);
}
/* The label block beside the switch. */
.toggle > span { display: flex; flex-direction: column; gap: 2px; }
.toggle > span > span:first-child { font-size: 13.5px; font-weight: 550; color: var(--text); }
.toggle > span > span:last-child:not(:first-child) { font-size: 12px; color: var(--text-3); line-height: 1.45; }

/* Dense variant for toolbars. */
.toggle-sm input { width: 38px; height: 21px; border-radius: 11px; }
.toggle-sm input::after { width: 15px; height: 15px; }
.toggle-sm input:checked::after { transform: translateX(17px); }

/* ── Cards / panels ───────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.card-pad-sm { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.card-title { font-size: 15px; font-weight: 600; }

/* ── Badges / pills ───────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-purple { background: rgba(124, 58, 237, 0.15); color: #b794ff; border-color: rgba(124, 58, 237, 0.32); }
.badge-green  { background: rgba(63, 185, 80, 0.13); color: #56d364; border-color: rgba(63, 185, 80, 0.3); }
.badge-red    { background: rgba(248, 81, 73, 0.13); color: #ff8b84; border-color: rgba(248, 81, 73, 0.3); }
.badge-amber  { background: rgba(210, 153, 34, 0.13); color: #e3b341; border-color: rgba(210, 153, 34, 0.3); }
.badge-gray   { background: var(--surface-3); color: var(--text-2); border-color: var(--border-2); }
.badge-blue   { background: rgba(68, 147, 248, 0.13); color: #6cb6ff; border-color: rgba(68, 147, 248, 0.3); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ── Tables ───────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 11px 14px;
  background: var(--surface-2);
  color: var(--text-3); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .13s var(--ease); }
tbody tr:hover { background: rgba(255, 255, 255, 0.018); }

/* ── Toast ────────────────────────────────────────────────────────────── */

#toasts {
  position: fixed; bottom: 22px; right: 22px; z-index: 9000;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 250px; max-width: 400px;
  padding: 12px 15px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--purple);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: toastIn .3s var(--ease);
  pointer-events: auto;
}
.toast.ok    { border-left-color: var(--green); }
.toast.err   { border-left-color: var(--red); }
.toast.warn  { border-left-color: var(--amber); }
.toast.out   { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(24px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px) scale(.97); } }

/* ── Modal ────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(5, 5, 8, 0.78);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .2s var(--ease);
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn .28s var(--ease);
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 2; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-size: 16px; font-weight: 620; }
.modal-body { padding: 22px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.975); } to { opacity: 1; transform: none; } }

/* ── Code blocks ──────────────────────────────────────────────────────── */

.code {
  position: relative;
  background: #08080b;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 15px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  color: #d6d6e0;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}
.code-wrap { position: relative; }
.code-wrap .code { padding-right: 46px; }
.code-copy { position: absolute; top: 9px; right: 9px; }

/* ── Empty / loading states ───────────────────────────────────────────── */

.empty { padding: 52px 24px; text-align: center; color: var(--text-3); }
.empty svg { margin: 0 auto 14px; opacity: .35; }
.empty h4 { color: var(--text-2); margin-bottom: 6px; font-size: 15px; font-weight: 600; }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border-2);
  border-top-color: var(--purple-bright); border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
.spinner-lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ── Divider ──────────────────────────────────────────────────────────── */

.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.divider-text { display: flex; align-items: center; gap: 14px; color: var(--text-3); font-size: 12px; margin: 20px 0; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Scroll-reveal animation ──────────────────────────────────────────── */

.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .container { padding: 0 18px; }
  .card { padding: 18px; }
  .modal-body, .modal-head, .modal-foot { padding-left: 18px; padding-right: 18px; }
}
