/* ── Golden-ratio spacing scale ──────────────────────────────
   φ = 1.618  →  5 · 8 · 13 · 21 · 34 · 55px
   border-radius: 5 · 8 · 13 · 21
   font-scale:    0.75rem · 0.875rem · 1rem · 1.25rem · 1.618rem
   ──────────────────────────────────────────────────────────── */

:root {
  --bg: #f8fafd;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #f0f5ff;
  --panel-ink: #1e293b;
  --sidebar: linear-gradient(180deg, #eef3fb 0%, #e8eef8 100%);
  --sidebar-ink: #334155;
  --accent: #60a5fa;
  --accent-soft: #e0edff;
  --accent-deep: #3b82f6;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.28);
  --muted: #94a3b8;
  --danger: #ef4444;
  --shadow: 0 13px 34px rgba(148, 163, 184, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.875rem;
  color: var(--panel-ink);
  background:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.05), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(147, 197, 253, 0.04), transparent 26rem),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

/* ── Shell & Sidebar ─────────────────────────────────────── */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  padding: 21px 13px;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 13px;
  font-size: 0.875rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 13px;
  background: rgba(96, 165, 250, 0.10);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.875rem;
}

.brand small {
  font-size: 0.75rem;
  color: var(--muted);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-deep) 0%, var(--accent) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
}

.sidebar-nav,
.sidebar-section,
.content,
.stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sidebar-link,
.table-pill {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 8px;
  transition: 180ms ease;
}

.sidebar-link:hover,
.table-pill:hover,
.table-pill.is-active,
.sidebar-link.is-active {
  background: rgba(96, 165, 250, 0.14);
}

.table-pill small,
.muted {
  color: var(--muted);
}

.sidebar .muted,
.sidebar .table-pill small {
  color: var(--muted);
}

.sidebar-heading,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.688rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
}

.sidebar .sidebar-heading {
  color: var(--muted);
  padding: 8px 0 0;
}

/* ── Content Area ────────────────────────────────────────── */

.content {
  padding: 21px;
  gap: 21px;
}

/* ── Shared card base ────────────────────────────────────── */

.hero-card,
.section-card,
.stat-card,
.table-card,
.modal-card,
.drawer,
.grid-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(13px);
}

.hero-card,
.section-card,
.grid-panel,
.drawer,
.modal-card {
  border-radius: 21px;
}

/* ── Hero ────────────────────────────────────────────────── */

.hero-card {
  padding: 21px;
  display: flex;
  justify-content: space-between;
  gap: 21px;
  align-items: center;
}

.hero-card h1 {
  margin: 0;
  font-size: 1.618rem;
  line-height: 1.25;
}

/* ── Table hero (compact single row) ─────────────────────── */

.table-hero {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-hero .eyebrow {
  margin: 0;
}

.table-hero h1 {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1;
}

.table-hero .hero-copy {
  margin: 0;
  font-size: 0.813rem;
}

.table-hero .hero-actions {
  margin-left: auto;
}

.table-card h3,
.section-card h2,
.drawer-head h2 {
  margin: 0;
  font-size: 1.125rem;
}

.hero-copy,
.table-card p,
.empty-state p,
pre,
code {
  color: var(--muted);
  margin: 5px 0 0;
}

/* ── Flex row helpers ────────────────────────────────────── */

.hero-actions,
.toolbar-group,
.form-actions,
.drawer-row,
.modal-head,
.section-head,
.grid-meta,
.pager {
  display: flex;
  gap: 8px;
  align-items: center;
}

.table-card-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Stats grid ──────────────────────────────────────────── */

.stats-grid,
.table-card-grid {
  display: grid;
  gap: 13px;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.table-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.stat-card {
  padding: 13px;
  border-radius: 13px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 5px;
}

.stat-card strong {
  font-size: 1.25rem;
}

/* ── Section card ────────────────────────────────────────── */

.section-card {
  padding: 21px;
}

.section-head {
  margin-bottom: 13px;
}

/* ── Table card ──────────────────────────────────────────── */

.table-card {
  border-radius: 13px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.table-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.table-card h3 {
  font-size: 1rem;
}

.table-card p {
  font-size: 0.75rem;
  margin: 3px 0 0;
}

.table-badge {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  height: fit-content;
  font-weight: 500;
  font-size: 0.75rem;
  white-space: nowrap;
}

.table-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin: 0;
}

.table-meta div {
  padding: 8px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
}

.table-meta dt {
  color: var(--muted);
  font-size: 0.688rem;
}

.table-meta dd {
  margin: 3px 0 0;
  font-weight: 700;
  font-size: 0.875rem;
}

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

.button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: 180ms ease;
  font-size: 0.813rem;
  white-space: nowrap;
}

.button {
  padding: 6px 13px;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent-deep) 0%, var(--accent) 100%);
  color: #fff;
  font-weight: 600;
}

.button-secondary {
  background: rgba(148, 163, 184, 0.10);
  color: var(--panel-ink);
}

.button-danger {
  background: rgba(184, 58, 42, 0.10);
  color: var(--danger);
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button-primary:hover {
  box-shadow: 0 3px 13px rgba(96, 165, 250, 0.25);
}

/* ── Toolbar ─────────────────────────────────────────────── */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.toolbar-group {
  gap: 5px;
}

.toolbar input,
.toolbar select,
label input,
label textarea,
label select {
  width: 100%;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--panel-ink);
  font-size: 0.875rem;
}

.toolbar input::placeholder,
label input::placeholder,
label textarea::placeholder {
  color: var(--muted);
}

/* ── Table layout ────────────────────────────────────────── */

.table-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 13px;
}

.grid-panel {
  padding: 13px;
}

.grid-shell {
  min-height: 340px;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.grid-hint {
  padding-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Drawer ──────────────────────────────────────────────── */

.drawer {
  padding: 13px;
  position: sticky;
  top: 21px;
  height: calc(100vh - 42px);
  overflow: auto;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 13px;
}

.drawer-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Column studio ───────────────────────────────────────── */

.column-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 13px;
}

.column-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.column-card code,
pre code {
  font-family: "IBM Plex Mono", monospace;
  white-space: pre-wrap;
}

/* ── Grid helpers ────────────────────────────────────────── */

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-checks {
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
}

.form-checks label {
  flex-direction: row;
  align-items: center;
}

/* ── Modals ──────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(148, 163, 184, 0.25);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 21px;
  z-index: 30;
}

.modal.is-open {
  display: flex;
}

.modal-card {
  width: min(680px, 100%);
  padding: 21px;
}

.modal-card.wide {
  width: min(880px, 100%);
}

.modal-head {
  justify-content: space-between;
  margin-bottom: 13px;
}

.icon-button {
  padding: 5px 8px;
  background: rgba(26, 35, 51, 0.06);
  font-size: 0.813rem;
}

/* ── Empty state ─────────────────────────────────────────── */

.empty-state {
  padding: 34px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
}

.empty-state.compact {
  padding: 13px;
}

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

.toast-stack {
  position: fixed;
  right: 21px;
  bottom: 21px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
}

.toast {
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 0.813rem;
  color: #fff;
  background: rgba(51, 65, 85, 0.88);
}

.toast.error {
  background: rgba(184, 58, 42, 0.92);
}

/* ── Pre / code ──────────────────────────────────────────── */

.flat-list {
  margin: 0;
  padding-left: 21px;
}

pre {
  margin: 0;
  padding: 13px;
  border-radius: 13px;
  background: rgba(148, 163, 184, 0.07);
  overflow: auto;
  font-size: 0.813rem;
}

.docs-content {
  max-width: 880px;
}

/* ── Tabulator overrides ─────────────────────────────────── */

.tabulator {
  border: 0 !important;
  background: #fff;
  font-size: 0.813rem;
}

.tabulator .tabulator-header,
.tabulator .tabulator-row,
.tabulator .tabulator-footer {
  border-color: var(--line) !important;
}

.tabulator .tabulator-header,
.tabulator .tabulator-header .tabulator-col {
  background: var(--panel-strong) !important;
}

.tabulator .tabulator-row {
  background: #fff;
}

.tabulator .tabulator-row.tabulator-row-even {
  background: #f8fafd;
}

.tabulator .tabulator-row:hover {
  background: rgba(96, 165, 250, 0.08) !important;
}

.tabulator .tabulator-cell,
.tabulator .tabulator-col,
.tabulator .tabulator-col .tabulator-col-title {
  color: var(--panel-ink) !important;
}

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

.toggle-btn {
  font-size: 1rem;
  line-height: 1;
}

.sidebar {
  transition: margin-left 250ms ease, opacity 250ms ease;
}

.sidebar.is-hidden {
  margin-left: -240px;
  opacity: 0;
  pointer-events: none;
}

.shell.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

.drawer {
  transition: margin-right 250ms ease, opacity 250ms ease, width 250ms ease;
}

.drawer.is-hidden {
  width: 0;
  padding: 0;
  margin-right: -340px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  border: 0;
}

.table-layout.drawer-collapsed {
  grid-template-columns: 1fr;
}

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

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .table-layout {
    grid-template-columns: 1fr;
  }

  .drawer {
    position: static;
    height: auto;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 13px;
  }

  .hero-card,
  .toolbar,
  .modal-card,
  .section-card {
    padding: 13px;
  }

  .hero-card,
  .toolbar-group,
  .grid-two,
  .table-card-actions,
  .grid-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .table-meta {
    grid-template-columns: 1fr;
  }
}
