/* ============================================================
   Workflox — base design system
   ============================================================ */

:root {
  --bg: #f7f2f3;
  --bg-2: #efe6e8;
  --surface: #fffdfd;
  --surface-2: #fbf6f7;
  --surface-3: #f5ecee;
  --ink: #29161a;
  --ink-2: #4a3035;
  --muted: #8b7277;
  --muted-2: #a68f93;
  --line: #ece1e3;
  --line-2: #e2d3d6;
  --primary: #7d1f2e;
  --primary-2: #a63d52;
  --primary-ink: #651624;
  --primary-soft: #faedf0;
  --green: #10b981;
  --green-soft: #e9faf3;
  --red: #ef4444;
  --red-soft: #fef0f0;
  --amber: #f59e0b;
  --amber-soft: #fff7e6;
  --pink: #ec4899;
  --pink-soft: #fdf0f7;
  --sky: #0ea5e9;
  --sky-soft: #e9f7ff;
  --teal: #14b8a6;
  --shadow-xs: 0 1px 2px rgba(58, 20, 28, .05);
  --shadow-sm: 0 1px 2px rgba(58, 20, 28, .04), 0 6px 16px -10px rgba(58, 20, 28, .12);
  --shadow-md: 0 2px 4px rgba(58, 20, 28, .04), 0 16px 36px -18px rgba(58, 20, 28, .2);
  --shadow-lg: 0 24px 70px -24px rgba(58, 20, 28, .32);
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --sidebar: 268px;
  --topbar: 76px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -.02em; }
::selection { background: rgba(125, 31, 46, .22); }

.ic { width: 18px; height: 18px; flex: none; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }

/* scrollbar */
* { scrollbar-width: thin; scrollbar-color: #d6c3c7 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #d8c4c8; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #c5a9af; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================ shell */
.app { display: flex; min-height: 100vh; }
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.view {
  flex: 1;
  overflow: auto;
  position: relative;
  scroll-behavior: smooth;
}
.view-fill { overflow: hidden; }

/* ============================================================ sidebar */
.sidebar {
  width: var(--sidebar);
  flex: none;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  position: relative;
  z-index: 50;
}
.sidebar-top { flex: none; }
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 7px 20px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(140deg, #a63d52 0%, #7d1f2e 52%, #c46577 100%);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px -8px rgba(125, 31, 46, .8), inset 0 1px 0 rgba(255,255,255,.28);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-type { display: flex; flex-direction: column; line-height: 1.08; }
.brand-type strong { font-family: var(--font-display); font-size: 17px; font-weight: 800; letter-spacing: -.03em; }
.brand-type span { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); margin-top: 2px; }

.workspace {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: #fbf6f7;
  border: 1px solid var(--line);
  border-radius: 13px;
  text-align: left;
  transition: border-color .2s, background .2s;
}
.workspace:hover { background: #f3f5fc; border-color: var(--line-2); }
.workspace-logo {
  width: 31px; height: 31px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  font-weight: 800; font-size: 13px;
  font-family: var(--font-display);
  box-shadow: inset 0 0 0 1px rgba(146, 64, 14, .08);
}
.workspace-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.workspace-meta strong { font-size: 12.5px; font-weight: 700; }
.workspace-meta span { font-size: 10.5px; color: var(--muted); }
.workspace-chevron { color: var(--muted-2); }
.workspace-chevron svg { width: 14px; height: 14px; }

.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0 8px;
  margin: 0 -6px;
}
.side-nav::-webkit-scrollbar { width: 0; }
.nav-group + .nav-group { margin-top: 22px; }
.nav-label {
  padding: 0 14px 8px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted-2);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 11px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 550;
  position: relative;
  transition: background .18s, color .18s;
}
.nav-item + .nav-item { margin-top: 2px; }
.nav-icon {
  width: 29px; height: 29px; flex: none;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--nav-tint, #f5ecee);
  color: var(--nav-color, var(--muted));
  transition: transform .18s var(--ease);
}
.nav-icon svg { width: 16px; height: 16px; }
.nav-item:hover { background: #fbf4f5; color: var(--ink); }
.nav-item:hover .nav-icon { transform: scale(1.06); }
.nav-item.active {
  background: linear-gradient(90deg, #faedf0, #f9e9ed);
  color: var(--primary-ink);
  font-weight: 650;
}
.nav-item.active .nav-icon { background: #fff; color: var(--primary); box-shadow: 0 2px 6px rgba(125, 31, 46, .14); }
.nav-count {
  margin-left: auto;
  background: #f1e6e8;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .nav-count { background: #fff; color: var(--primary); }
.nav-live { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.14); }

.sidebar-bottom { flex: none; padding-top: 10px; }
.usage-card {
  border-radius: 14px;
  padding: 13px;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(166, 61, 82, .14), transparent 55%),
    linear-gradient(145deg, #fdf8f9, #f8eef0);
  border: 1px solid #ead6da;
}
.usage-top { display: flex; gap: 9px; align-items: center; }
.usage-icon { width: 28px; height: 28px; border-radius: 8px; background: #fff; color: var(--primary); display: grid; place-items: center; box-shadow: var(--shadow-xs); }
.usage-icon svg { width: 15px; height: 15px; }
.usage-top strong { display: block; font-size: 11.5px; font-weight: 650; }
.usage-top small { display: block; font-size: 10px; color: var(--muted); margin-top: 1px; }
.usage-track { height: 5px; border-radius: 99px; background: #ebdadd; margin: 11px 0 8px; overflow: hidden; }
.usage-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7d1f2e, #b14a5d); }
.usage-link { background: none; border: 0; padding: 0; display: flex; align-items: center; gap: 4px; color: var(--primary-ink); font-size: 10.5px; font-weight: 700; }
.usage-link svg { width: 12px; height: 12px; }
.side-user { display: flex; align-items: center; gap: 9px; padding: 14px 4px 0; margin-top: 12px; border-top: 1px solid var(--line); }
.side-user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-user-meta strong { font-size: 12px; font-weight: 650; }
.side-user-meta span { font-size: 10px; color: var(--muted); }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800;
  letter-spacing: .02em;
  flex: none;
  position: relative;
}
.avatar-photo { background: linear-gradient(135deg, #fee2c8, #f8c39c); color: #8c4a1c; box-shadow: inset 0 0 0 1px rgba(140, 74, 28, .08); }
.status-dot { position: absolute; right: -1px; bottom: 0px; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }

/* ============================================================ topbar */
.topbar {
  height: var(--topbar);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .84);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  position: relative;
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 15px; min-width: 0; }
.topbar-left .menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); margin-bottom: 2px; }
.crumbs strong { color: var(--ink-2); font-weight: 600; }
.crumbs span:nth-child(2) { color: #c6ccdc; }
.page-heading h1 { font-size: 20px; font-weight: 700; line-height: 1.15; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 9px; }
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  min-width: 244px;
  padding: 0 11px;
  background: #fbf5f6;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  transition: border-color .2s, background .2s;
}
.search-trigger:hover { border-color: #d9def0; background: #fff; }
.search-trigger svg { width: 15px; height: 15px; }
.search-trigger span:nth-child(2) { flex: 1; }
.search-trigger kbd {
  font-family: var(--font-body);
  font-size: 10px;
  color: var(--muted-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  box-shadow: 0 1px 0 #eceef6;
}
.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  position: relative;
  transition: border-color .18s, background .18s, transform .18s;
}
.icon-btn:hover { background: #fbf6f7; border-color: var(--line-2); }
.icon-btn:active { transform: scale(.96); }
.icon-btn.tiny { width: 30px; height: 30px; border-radius: 8px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.tiny:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.soft { background: var(--surface-2); border-color: transparent; }
.icon-btn.has-dot::after { content: ""; position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; }
.topbar-divider { width: 1px; height: 26px; background: var(--line); margin: 0 5px; }
.topbar-user { display: flex; align-items: center; gap: 9px; border: 0; background: none; padding: 2px 0; text-align: left; border-radius: 10px; }
.topbar-user .avatar { width: 34px; height: 34px; }
.topbar-user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-user-meta strong { font-size: 11.5px; font-weight: 650; }
.topbar-user-meta span { font-size: 10px; color: var(--muted); }
.topbar-user-chevron { color: var(--muted-2); margin-left: 2px; }
.topbar-user-chevron svg { width: 13px; height: 13px; }

/* ============================================================ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .18s, background .18s, border-color .18s;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  background: linear-gradient(135deg, #7d1f2e 0%, #9b3145 100%);
  color: #fff;
  box-shadow: 0 7px 16px -8px rgba(125, 31, 46, .8), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { box-shadow: 0 10px 22px -8px rgba(125, 31, 46, .85); filter: saturate(1.05); }
.btn-ghost { background: #fff; border-color: var(--line-2); color: var(--ink-2); box-shadow: var(--shadow-xs); }
.btn-ghost:hover { background: #fdf8f9; border-color: #d8c2c7; }
.btn-soft { background: var(--primary-soft); color: var(--primary-ink); }
.btn-soft:hover { background: #f3dde2; }
.btn-danger { background: #ef4444; color: #fff; box-shadow: 0 8px 16px -10px rgba(239, 68, 68, .8); }
.btn-danger:hover { background: #dc2626; }
.btn-white { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 11.5px; border-radius: 8px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 13.5px; border-radius: 12px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary-ink); font-size: 12px; font-weight: 650; display: inline-flex; align-items: center; gap: 4px; }
.link-btn svg { width: 13px; height: 13px; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ============================================================ form controls */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 13px; }
.field > label, .field-label {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.field > label .optional { font-size: 10px; font-weight: 500; color: var(--muted-2); }
.field-hint { font-size: 10.5px; color: var(--muted); line-height: 1.45; }
.field-info {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 9px 10px;
  border: 1px solid #f1e6e8;
  border-radius: 8px;
  background: #fbf6f7;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
}
.field-info > svg { width: 13px; height: 13px; flex: none; margin-top: 1px; color: var(--primary); }
.field-info strong { color: var(--ink-2); font-weight: 600; }
.field-info code { font-family: var(--font-mono); font-size: 9.5px; background: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; }
.field-info.amber { background: #fffbf0; border-color: #fdf0d5; }
.field-info.amber > svg { color: #d97706; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row .field + .field { margin-top: 0; }
.input, .select, textarea.input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: 9px;
  padding: 0 11px;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.input::placeholder { color: var(--muted-2); }
.input:hover, .select:hover { border-color: #cbd2e6; }
.input:focus, .select:focus, textarea.input:focus {
  border-color: rgba(125, 31, 46, .55);
  box-shadow: 0 0 0 3.5px rgba(125, 31, 46, .12);
}
.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d86a2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
textarea.input { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 42px; }
.input-suffix .suffix { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 10px; font-weight: 600; color: var(--muted-2); }
input[type="time"], input[type="date"] { font-family: var(--font-body); }
input[type="color"] { appearance: none; width: 100%; height: 38px; padding: 3px; border: 1px solid var(--line-2); border-radius: 9px; background: #fff; cursor: pointer; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 2px 0; cursor: pointer; }
.switch-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.switch-copy strong { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.switch-copy small { font-size: 10.5px; color: var(--muted); line-height: 1.45; }
.switch { flex: none; position: relative; width: 36px; height: 21px; display: inline-block; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 2; }
.switch-track { position: absolute; inset: 0; border-radius: 99px; background: #ddc9cd; transition: background .2s; }
.switch-thumb { position: absolute; width: 15px; height: 15px; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(58,20,28,.25); transition: transform .22s var(--ease); }
.switch input:checked + .switch-track { background: linear-gradient(135deg, #7d1f2e, #9b3145); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(15px); }
.switch.sm { width: 31px; height: 18px; }
.switch.sm .switch-thumb { width: 12px; height: 12px; }
.switch.sm input:checked + .switch-track .switch-thumb { transform: translateX(13px); }

.checkbox { width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid #cdd4e5; appearance: none; background: #fff; display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.checkbox:checked { background: var(--primary); border-color: var(--primary); }
.checkbox:checked::after { content: ""; width: 8px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translateY(-1px); }

/* ============================================================ badges / chips */
.status {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: 6px;
  font-size: 10.5px; font-weight: 650;
  white-space: nowrap;
}
.status svg { width: 11px; height: 11px; }
.status-success, .status-active { background: #e9faf3; color: #059669; }
.status-failed, .status-error { background: #fef0f0; color: #dc2626; }
.status-running { background: var(--sky-soft); color: #0284c7; }
.status-paused, .status-stopped, .status-skipped { background: #f5ecee; color: #667085; }
.status-draft { background: #fff7e6; color: #b45309; }
.status-running svg { animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: 99px;
  background: var(--surface-3); color: var(--muted);
  font-size: 10px; font-weight: 600;
  white-space: nowrap;
}
.pill svg { width: 11px; height: 11px; }
.pill-green { background: var(--green-soft); color: #059669; }
.pill-indigo { background: var(--primary-soft); color: var(--primary-ink); }
.pill-amber { background: var(--amber-soft); color: #b45309; }
.pill-rose { background: #fff1f2; color: #e11d48; }
.pill-sky { background: var(--sky-soft); color: #0284c7; }
.pill-pink { background: var(--pink-soft); color: #be185d; }
.pill-lock { background: #f9e9ed; color: #8b2336; }
.pill-violet { background: #f9e9ed; color: #8b2336; }
.pill-slate { background: #f1f5f9; color: #475569; }
.type-badge {
  display: inline-flex; align-items: center;
  height: 19px; padding: 0 7px;
  border-radius: 5px;
  color: var(--c);
  background: var(--surface-3);
  font-size: 9px; font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.kbd { font-family: var(--font-body); font-size: 10px; color: var(--muted-2); background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.code-inline { font-family: var(--font-mono); font-size: 10.5px; background: #f4f6fb; border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; color: #475569; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ============================================================ cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 0; }
.card-head h3 { font-size: 14px; font-weight: 700; }
.card-head p { font-size: 11px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 18px 20px; }
.card-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-flush { overflow: hidden; }

/* page scaffolding */
.page { padding: 26px 28px 40px; max-width: 1560px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.025em; }
.page-head p { font-size: 12.5px; color: var(--muted); margin-top: 4px; max-width: 620px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 9.5px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; color: var(--primary-ink); margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.eyebrow svg { width: 12px; height: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h3 { font-size: 14px; font-weight: 700; }
.section-head p { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* segmented + tabs */
.segmented { display: inline-flex; background: #f3f5fa; border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { height: 28px; padding: 0 10px; border: 0; background: transparent; border-radius: 7px; font-size: 10.5px; font-weight: 600; color: var(--muted); }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(58,20,28,.12); }
.tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  height: 38px; padding: 0 14px; border: 0; background: none;
  font-size: 12px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
}
.tabs button svg { width: 14px; height: 14px; }
.tabs button:hover { color: var(--ink-2); }
.tabs button.active { color: var(--primary-ink); border-bottom-color: var(--primary); }

/* ============================================================ tables */
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted-2);
  font-weight: 700; text-align: left; padding: 10px 16px;
  background: #fbf6f7; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th:first-child { padding-left: 20px; }
.data-table th:last-child { padding-right: 20px; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid #f2e7e9; font-size: 12px; color: var(--ink-2); vertical-align: middle; }
.data-table td:first-child { padding-left: 20px; }
.data-table td:last-child { padding-right: 20px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: #fdf9fa; }
.data-table .row-click { cursor: pointer; }
.table-strong { font-weight: 650; color: var(--ink); }
.table-sub { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.table-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.cell-user { display: flex; align-items: center; gap: 8px; }
.mini-avatar { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 9px; font-weight: 800; background: #f3f0ff; color: #732032; flex: none; }

/* ============================================================ modal + drawer + toast */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(58, 20, 28, .42);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity .2s;
}
.modal-overlay.in { opacity: 1; }
.modal-overlay.out { opacity: 0; }
.modal {
  width: 100%; max-width: 560px;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  transform: translateY(12px) scale(.985);
  opacity: .7;
  transition: transform .26s var(--ease), opacity .2s;
  overflow: hidden;
}
.modal-overlay.in .modal { transform: none; opacity: 1; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 0; }
.modal-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; color: var(--c); }
.modal-icon svg { width: 19px; height: 19px; }
.modal-title-wrap { flex: 1; min-width: 0; }
.modal-title-wrap h2 { font-size: 17px; font-weight: 700; }
.modal-title-wrap p { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.modal-close { margin-top: -2px; }
.modal-body { padding: 18px 22px; overflow: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fdf8f9; }
.confirm-copy { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(58, 20, 28, .34);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .22s;
  z-index: 80;
}
.drawer-overlay.in { opacity: 1; }
.drawer-overlay.out { opacity: 0; }
.drawer {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(560px, 94vw);
  background: #fff;
  box-shadow: -18px 0 60px rgba(58, 20, 28, .18);
  display: flex; flex-direction: column;
  transform: translateX(28px);
  opacity: .6;
  transition: transform .3s var(--ease), opacity .22s;
}
.drawer-wide { width: min(700px, 96vw); }
.drawer-overlay.in .drawer { transform: none; opacity: 1; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer-head-main { display: flex; gap: 12px; flex: 1; min-width: 0; }
.drawer-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--c); flex: none; }
.drawer-icon svg { width: 20px; height: 20px; }
.drawer-kicker { font-size: 9px; text-transform: uppercase; letter-spacing: .13em; color: var(--muted-2); font-weight: 700; margin-bottom: 2px; }
.drawer-head h2 { font-size: 17px; font-weight: 700; }
.drawer-head p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.drawer-body { flex: 1; overflow: auto; padding: 20px 22px; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fdf8f9; }

.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 500; display: flex; flex-direction: column; gap: 9px; align-items: flex-end; pointer-events: none; }
body:has(.drawer-overlay) .toast-root { bottom: 86px; }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 300px; max-width: 390px;
  padding: 12px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow-md);
  transform: translateY(14px) scale(.97);
  opacity: 0;
  transition: transform .28s var(--ease), opacity .2s;
  position: relative;
  overflow: hidden;
}
.toast.in { transform: none; opacity: 1; }
.toast.out { transform: translateY(8px); opacity: 0; }
.toast-icon { width: 27px; height: 27px; flex: none; border-radius: 8px; display: grid; place-items: center; background: var(--green-soft); color: #059669; }
.toast-icon svg { width: 15px; height: 15px; }
.toast-error .toast-icon { background: #fef0f0; color: #dc2626; }
.toast-warn .toast-icon { background: var(--amber-soft); color: #b45309; }
.toast-info .toast-icon { background: var(--primary-soft); color: var(--primary); }
.toast-copy { flex: 1; min-width: 0; padding-top: 1px; }
.toast-copy strong { display: block; font-size: 11.5px; font-weight: 650; }
.toast-copy span { display: block; color: var(--muted); font-size: 10.5px; line-height: 1.45; margin-top: 1px; }
.toast-close { border: 0; background: none; color: var(--muted-2); padding: 2px; border-radius: 4px; }
.toast-close svg { width: 13px; height: 13px; }
.toast-life { position: absolute; bottom: 0; left: 0; height: 2px; width: 100%; background: linear-gradient(90deg, #7d1f2e, #b14a5d); transform-origin: left; animation: toastlife 4.2s linear forwards; opacity: .5; }
@keyframes toastlife { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ============================================================ misc */
.empty-state { text-align: center; padding: 52px 24px; }
.empty-icon { width: 54px; height: 54px; border-radius: 16px; display: inline-grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 12px; }
.empty-icon svg { width: 24px; height: 24px; }
.empty-state h3 { font-size: 15px; font-weight: 700; }
.empty-state p { font-size: 11.5px; color: var(--muted); margin: 4px auto 14px; max-width: 330px; line-height: 1.55; }
.sparkline { width: 104px; height: 34px; overflow: visible; }
.area-chart { width: 100%; height: 245px; }
.chart-axis { font-size: 10px; fill: #a68f93; font-family: var(--font-body); }
.donut { position: relative; display: grid; place-items: center; }
.donut svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.donut span { font-size: 11px; font-weight: 750; color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.grow { flex: 1; }

/* menu popover */
.menu-pop {
  position: absolute;
  min-width: 172px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 5px;
  z-index: 70;
  animation: popIn .16s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-pop button {
  width: 100%; display: flex; align-items: center; gap: 8px;
  border: 0; background: none; border-radius: 7px;
  padding: 7px 9px; font-size: 11.5px; color: var(--ink-2); text-align: left;
}
.menu-pop button svg { width: 14px; height: 14px; color: var(--muted); }
.menu-pop button:hover { background: var(--surface-3); }
.menu-pop button.danger { color: #dc2626; }
.menu-pop button.danger svg { color: #dc2626; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 3px; }

/* command palette */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(58, 20, 28, .42);
  backdrop-filter: blur(5px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 22px 22px;
  opacity: 0; transition: opacity .18s;
}
.cmdk-overlay.in { opacity: 1; }
.cmdk {
  width: min(620px, 100%);
  background: #fff;
  border-radius: 17px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(12px) scale(.99);
  transition: transform .24s var(--ease);
}
.cmdk-overlay.in .cmdk { transform: none; }
.cmdk-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cmdk-search svg { color: var(--muted); width: 18px; height: 18px; }
.cmdk-search input { flex: 1; border: 0; outline: none; font-size: 14px; background: none; }
.cmdk-search input::placeholder { color: var(--muted-2); }
.cmdk-list { padding: 8px; max-height: 55vh; overflow: auto; }
.cmdk-group { font-size: 9px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--muted-2); padding: 8px 9px 5px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 9px; cursor: pointer; }
.cmdk-item.active, .cmdk-item:hover { background: #f5f6fd; }
.cmdk-item-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--c, var(--primary)); background: var(--t, var(--primary-soft)); }
.cmdk-item-icon svg { width: 15px; height: 15px; }
.cmdk-item-copy { flex: 1; min-width: 0; }
.cmdk-item-copy strong { display: block; font-size: 12px; font-weight: 600; }
.cmdk-item-copy span { display: block; font-size: 10px; color: var(--muted); }
.cmdk-item kbd { font-size: 9px; }
.cmdk-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 12px; }
.cmdk-foot { border-top: 1px solid var(--line); padding: 9px 14px; display: flex; gap: 14px; font-size: 9.5px; color: var(--muted-2); background: #fdf8f9; }
.cmdk-foot span { display: flex; align-items: center; gap: 4px; }

/* responsive */
@media (max-width: 1280px) {
  .page { padding: 24px 22px 36px; }
  .topbar { padding: 0 22px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 1100px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-104%);
    transition: transform .3s var(--ease);
    box-shadow: 18px 0 50px rgba(58,20,28,.18);
  }
  .sidebar.open { transform: none; }
  .topbar-left .menu-btn { display: inline-grid; }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 45;
    background: rgba(20,25,45,.4);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .builder-layout { grid-template-columns: 200px minmax(0, 1fr) 310px !important; }
  .form-studio { grid-template-columns: 200px minmax(0, 1fr) 310px !important; }
}
@media (max-width: 860px) {
  :root { --topbar: 66px; }
  .search-trigger { min-width: 38px; width: 38px; padding: 0; justify-content: center; }
  .search-trigger span:not(:first-child), .search-trigger kbd { display: none; }
  .topbar-user-meta, .topbar-user-chevron { display: none; }
  .topbar { padding: 0 14px; }
  .topbar-left { gap: 10px; }
  .page-heading h1 { font-size: 17px; }
  .crumbs { display: none; }
  .page { padding: 18px 14px 30px; }
  .topbar-divider { display: none; }
  .stat-grid { grid-template-columns: 1fr !important; }
}
