:root {
  --ink: #1a2b2c;
  --muted: #5c6f71;
  --brand: #0e8b92;
  --brand-dark: #0a6a70;
  --brand-hover: #0c757b;
  --brand-soft: #edf8f8;
  --brand-glow: rgba(14, 139, 146, 0.22);
  --accent: #f47920;
  --accent-soft: #fff1e6;
  --field: #f4f8f8;
  --line: #d5e4e5;
  --surface: #ffffff;
  --ok: #2f9e5b;
  --warn: #f47920;
  --danger: #e24b3b;
  --info: #4ca9a8;
  --sidebar: #0f2e32;
  --sidebar-2: #0a2226;
  --sidebar-hover: #164247;
  --sidebar-border: #1e4c52;
  --sidebar-text: #e8f2f3;
  --sidebar-muted: #8fadb1;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 46, 50, 0.05);
  --shadow: 0 10px 30px rgba(15, 46, 50, 0.08);
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sidebar-w: 268px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(14, 139, 146, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(244, 121, 32, 0.08), transparent 45%),
    linear-gradient(180deg, #eef6f6 0%, var(--field) 42%, #eaf3f3 100%);
  color: var(--ink);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus {
  left: 8px;
  background: #fff;
  padding: 8px 12px;
  z-index: 40;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* ——— Sidebar ——— */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 20, 22, 0.48);
  backdrop-filter: blur(4px);
  z-index: 28;
}
.sidebar {
  background:
    linear-gradient(180deg, rgba(43, 184, 191, 0.08), transparent 28%),
    linear-gradient(165deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  position: relative;
  border-right: 1px solid var(--sidebar-border);
  z-index: 30;
}
.brand-block {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex: none;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, #2bb8bf 0%, var(--brand) 55%, #0a6a70 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  flex: none;
  box-shadow: 0 8px 20px rgba(14, 139, 146, 0.35);
}
.brand { font-size: 15px; font-weight: 800; letter-spacing: -0.03em; }
.brand-sub { color: var(--sidebar-muted); font-size: 11px; margin-top: 2px; font-weight: 500; }
.sidebar-search {
  padding: 12px 12px 4px;
  flex: none;
}
.sidebar-search__box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 10px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.sidebar-search__box:focus-within {
  border-color: rgba(43, 184, 191, 0.55);
  background: rgba(255, 255, 255, 0.08);
}
.sidebar-search__box svg {
  width: 16px;
  height: 16px;
  color: var(--sidebar-muted);
  flex: none;
}
.sidebar-search__input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  color: #fff !important;
  padding: 0 !important;
  max-width: none !important;
  font-size: 13px !important;
  box-shadow: none !important;
  outline: none !important;
}
.sidebar-search__input::placeholder { color: var(--sidebar-muted); }
.sidebar-search__kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--sidebar-muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 2px 5px;
  flex: none;
}

.nav-group {
  margin: 14px 14px 6px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  font-weight: 700;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 4px 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.sidebar nav a {
  color: rgba(232, 242, 243, 0.88);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
  position: relative;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.sidebar nav a.is-active {
  background: linear-gradient(90deg, rgba(14, 139, 146, 0.28), rgba(14, 139, 146, 0.12));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(43, 184, 191, 0.22);
}
.sidebar nav a.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: #2bb8bf;
}
.nav-ico {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  opacity: 0.9;
  flex: none;
}
.nav-ico svg { width: 18px; height: 18px; }

.sidebar-status {
  margin: 0 12px 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
}
.sidebar-status strong {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.sidebar-status span {
  font-size: 11px;
  color: var(--sidebar-muted);
}
.mode-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(244, 121, 32, 0.25);
}
.mode-dot.is-live {
  background: #3ecf7a;
  box-shadow: 0 0 0 3px rgba(62, 207, 122, 0.25);
}

.sidebar-foot {
  border-top: 1px solid var(--sidebar-border);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
}
.user-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.sidebar-foot form { margin: 0; }
.sidebar-foot .btn-ghost {
  width: auto;
  color: var(--sidebar-muted);
  border: 0;
  padding: 6px 8px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
}
.sidebar-foot .btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, #1e4c52, #0e8b92);
  color: #d7e8ff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex: none;
}
.who { font-size: 13px; font-weight: 700; color: #fff; }
.who-role { font-size: 11px; color: var(--sidebar-muted); font-weight: 500; }

.icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.icon-btn svg { width: 20px; height: 20px; }
.sidebar-close {
  display: none !important;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}

/* ——— Workspace ——— */
.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
.topbar {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(213, 228, 229, 0.9);
  padding: 0 28px;
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crumb { color: var(--muted); font-size: 13px; font-weight: 500; }
.crumb-sep { margin: 0 8px; color: #b7c8c9; }
.crumb strong { color: var(--ink); font-weight: 700; }
.topbar-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.env, .mode-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
}
.env {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border: 1px solid rgba(14, 139, 146, 0.18);
}
.mode-pill {
  color: #8a4b10;
  background: var(--accent-soft);
  border: 1px solid rgba(244, 121, 32, 0.22);
}
.mode-pill.is-live {
  color: #0d5c45;
  background: #e8f7f0;
  border-color: rgba(47, 158, 91, 0.25);
}

main {
  padding: 28px 32px 64px;
  min-width: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  animation: rise 0.45s var(--ease) both;
  scrollbar-gutter: stable;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.page-head .lede { max-width: 52ch; }

.guide-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 20px;
}
.guide-flow article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow-sm);
}
.guide-flow h2 { margin: 8px 0 6px; font-size: 15px; }
.guide-flow p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.guide-step {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}
.guide-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 0 0 14px;
  box-shadow: var(--shadow-sm);
}
.guide-card h2 { margin: 0 0 12px; }
.guide-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}
.guide-list li { margin: 0 0 8px; }
.guide-list li:last-child { margin-bottom: 0; }
.guide-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.guide-grid .guide-card { margin: 0; }
.guide-card code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--brand-soft);
  padding: 1px 6px;
  border-radius: 6px;
}

@media (max-width: 1100px) {
  .guide-flow, .guide-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .guide-flow, .guide-grid { grid-template-columns: 1fr; }
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 1.2rem + 1.1vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
}
h2 { font-size: 16px; font-weight: 750; letter-spacing: -0.02em; }
.kicker {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 750;
}
.muted { color: var(--muted); line-height: 1.5; }
.lede { margin: 8px 0 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.text-link {
  color: var(--brand-dark);
  font-weight: 700;
  text-decoration: none;
  transition: color 0.15s ease;
}
.text-link:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 22px;
}
.quick-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), border-color 0.18s ease, box-shadow 0.18s ease;
}
.quick-link:hover {
  transform: translateY(-1px);
  border-color: rgba(14, 139, 146, 0.35);
  box-shadow: var(--shadow);
}
.quick-link svg { width: 16px; height: 16px; color: var(--brand); }

.btn, button.btn {
  background: linear-gradient(180deg, #12959c 0%, var(--brand) 100%);
  color: #fff;
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(14, 139, 146, 0.28);
  transition: transform 0.15s var(--ease), filter 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(14, 139, 146, 0.32);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  border-radius: 10px;
  font-weight: 650;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 14px;
  margin: 22px 0;
}
.stats article {
  background: var(--surface);
  border: 1px solid rgba(213, 228, 229, 0.95);
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.stats article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand);
}
.stats article:nth-child(2)::before { background: var(--warn); }
.stats article:nth-child(3)::before { background: var(--info); }
.stats article:nth-child(4)::before { background: var(--danger); }
.stats article:nth-child(5)::before { background: var(--ok); }
.stats article:nth-child(6)::before { background: #c4a035; }
.stats article:nth-child(7)::before { background: #6b7c8a; }
.stats article:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stats strong {
  display: block;
  font-size: 30px;
  letter-spacing: -0.05em;
  font-weight: 800;
  margin-top: 2px;
}
.stats span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13px;
}
th {
  color: var(--muted);
  font-weight: 750;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.stack p, .filters p, form p { margin: 0 0 12px; }
label, form p label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 650;
}
input, select, textarea {
  font: inherit;
  width: 100%;
  max-width: 640px;
  padding: 11px 12px;
  border: 1px solid #d5e2e2;
  background: #fbfefe;
  color: var(--ink);
  border-radius: 12px;
  box-shadow: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}
input:hover, select:hover, textarea:hover {
  border-color: #b9cece;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px var(--brand-glow);
}
select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 3px),
    calc(100% - 11px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.flash {
  background: var(--brand-soft);
  color: #0a5a5f;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid rgba(14, 139, 146, 0.18);
  font-weight: 600;
}
.flash.error { background: #fde8e8; color: var(--danger); border-color: rgba(226, 75, 59, 0.2); }
.flash.success { background: #e8f7f0; color: #0d5c45; }
.pill {
  font-size: 11px;
  border: 1px solid var(--line);
  padding: 4px 9px;
  display: inline-block;
  border-radius: 999px;
  font-weight: 750;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }
pre {
  white-space: pre-wrap;
  font-size: 12px;
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 12px;
}

/* ——— Login ——— */
.login-body {
  display: grid;
  place-items: center;
  grid-template-columns: 1fr;
  height: auto;
  min-height: 100vh;
  max-height: none;
  overflow: auto;
  background:
    radial-gradient(900px 500px at 15% 20%, rgba(43, 184, 191, 0.28), transparent 55%),
    radial-gradient(700px 420px at 90% 80%, rgba(244, 121, 32, 0.18), transparent 50%),
    linear-gradient(145deg, #07191c 0%, #0f2e32 48%, #0a2226 100%);
  padding: 24px;
}
.login-split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  width: min(920px, 96vw);
  background: var(--surface);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  animation: rise 0.5s var(--ease) both;
}
.login-brand {
  background:
    linear-gradient(165deg, rgba(14, 139, 146, 0.35), transparent 50%),
    linear-gradient(180deg, #0f2e32, #0a2226);
  color: var(--sidebar-text);
  padding: 48px 40px;
  position: relative;
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -80px;
  bottom: -90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 121, 32, 0.28), transparent 65%);
  pointer-events: none;
}
.login-brand .brand-mark { margin-bottom: 28px; width: 48px; height: 48px; font-size: 13px; }
.login-brand .kicker { color: #7fd6db; }
.login-brand h1 { color: #fff; margin: 10px 0 14px; font-size: 2rem; }
.login-brand p { color: var(--sidebar-muted); margin: 0; line-height: 1.6; max-width: 34ch; position: relative; z-index: 1; }
.login-card { padding: 48px 40px; }
.login-card h2 { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.login-card .btn { width: 100%; margin-top: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ——— Studio / tables / forms (preserved semantics) ——— */
.page-studio { height: 100vh; overflow: hidden; }
.page-studio .sidebar { height: 100vh; }
.page-studio .workspace { min-height: 0; height: 100vh; overflow: hidden; }
.page-studio main {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  animation: none;
}
.studio { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.stat-pill {
  background: #f5f8fb;
  border: 1px solid var(--line);
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 650;
}
.stat-pill.warn { border-color: #f0d2a0; background: #fff8ec; }
.studio-board {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.15fr) minmax(0, 0.95fr);
  gap: 10px;
  min-height: 0;
  flex: 1;
}
.studio-col {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 10px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.studio-col header h2 { margin: 0 0 8px; font-size: 14px; }
.bridge-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.bridge-head h2 { margin: 0; }
.col-select { margin-bottom: 8px; }
.col-select select { max-width: none; font-size: 12px; padding: 6px 8px; }
.seg { display: flex; gap: 4px; flex-wrap: nowrap; margin-bottom: 8px; }
.seg button {
  background: #f5f8fb;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 5px 8px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  border-radius: 999px;
  font-weight: 700;
  flex: 1;
}
.seg button.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.studio-col header input[type="search"] { max-width: none; margin-bottom: 0; font-size: 12px; padding: 6px 8px; }
.chip-list, .link-list, #rules-pane { overflow: auto; min-height: 0; flex: 1; }
#composer-pane { overflow: hidden; min-height: 0; flex: 1; display: flex; flex-direction: column; }
.chip-group { margin-bottom: 10px; }
.chip-group h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-weight: 750;
}
.chip-group h3 span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.chip-group h3 span:last-child { flex: none; }
.row-wrap { margin: 0 0 5px; }
.row-wrap .flow-row,
.row-wrap .sage-row { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.row-details {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: #fff;
  padding: 0 8px;
  font-size: 11px;
  color: var(--muted);
}
.row-details summary {
  cursor: pointer;
  padding: 4px 0;
  font-weight: 700;
  color: var(--brand-dark);
  list-style: none;
}
.row-details summary::-webkit-details-marker { display: none; }
.row-details[open] { padding-bottom: 6px; }
.row-details .io-hint { margin: 4px 0; line-height: 1.35; }
.field-mini { margin: 0; padding: 0 0 0 14px; }
.field-mini li { margin: 2px 0; }
.field-mini code {
  font-family: var(--mono);
  font-size: 10px;
  background: #eef4f3;
  padding: 1px 4px;
  border-radius: 4px;
  margin-right: 4px;
}
.io-panel {
  margin-top: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
  font-size: 12px;
}
.io-panel summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-dark);
  list-style: none;
}
.io-panel summary::-webkit-details-marker { display: none; }
.io-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.io-cols h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.io-hint { margin: 0 0 6px; color: var(--muted); line-height: 1.35; font-size: 11px; }
.io-cols ul { margin: 0; padding: 0 0 0 14px; font-size: 11px; }
.io-cols li { margin: 2px 0; }
.io-cols code {
  font-family: var(--mono);
  font-size: 10px;
  background: #eef4f3;
  padding: 1px 4px;
  border-radius: 4px;
  margin-right: 4px;
}
.io-group {
  list-style: none;
  margin: 8px 0 2px -14px !important;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}
.flow-row, .sage-row {
  display: grid;
  width: 100%;
  margin: 0 0 5px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  cursor: grab;
  text-align: left;
  font: inherit;
  border-radius: 10px;
  gap: 8px;
  align-items: center;
}
.flow-row { grid-template-columns: 8px minmax(0, 1fr) auto; }
.sage-row { grid-template-columns: 1fr; gap: 1px; }
.flow-row:hover, .sage-row:hover, .flow-row.is-selected, .sage-row.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.flow-row.is-selected, .sage-row.is-selected { outline: 2px solid var(--brand); outline-offset: -2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.cov-missing .dot { background: var(--danger); }
.cov-default .dot { background: var(--warn); }
.flow-row-main { min-width: 0; }
.flow-row-main strong { font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-dest { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.cov-missing .flow-dest { color: var(--danger); }
.sage-row strong { font-size: 12px; font-family: var(--mono); }
.sage-row span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.variants { margin: 0 0 8px 8px; border-left: 1px solid var(--line); padding-left: 8px; }
.toggle-var { background: none; border: 0; color: var(--brand-dark); cursor: pointer; font: inherit; font-size: 12px; padding: 0 0 6px; font-weight: 700; }
.empty-col { color: var(--muted); font-size: 13px; padding: 16px 4px; }
.composer {
  border: 1px solid var(--line);
  padding: 10px;
  background: #f3faf9;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.composer-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.composer-actions .btn { flex: 1; }
.composer:focus { outline: 2px solid var(--brand); }
.composer-hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; line-height: 1.35; }
.map-label { display: block; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; font-weight: 700; }
.map-from {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.composer-flow { font-weight: 650; font-size: 13px; color: var(--muted); line-height: 1.3; }
.composer-flow.is-filled { color: var(--ink); }
.map-slots { display: flex; flex-direction: column; gap: 6px; }
.slot {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px dashed #b7cfc6;
  padding: 7px 10px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font: inherit;
  border-radius: 10px;
  width: 100%;
  min-height: 38px;
}
.slot-kicker { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.slot-value { font-size: 13px; font-weight: 700; font-family: var(--mono); }
.slot.over, .slot.is-needed { border-color: var(--brand); border-style: solid; color: var(--ink); }
.slot.filled { border-style: solid; color: var(--ink); background: var(--brand-soft); }
.link-card { border-bottom: 1px solid var(--line); padding: 10px 0; font-size: 13px; }
.link-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.link-arrow { color: var(--muted); }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  font-size: 13px;
  z-index: 40;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
body.is-dragging .flow-row,
body.is-dragging .sage-row { opacity: 0.7; }

.page-studio h1 { font-size: 22px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  margin: 12px 0 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.table-wrap table { margin: 0; }
thead th { background: #f3f8f8; position: sticky; top: 0; }
tbody tr:hover td { background: #f5fbfb; }
.empty { color: var(--muted); padding: 28px 12px; }
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
  margin: 18px 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.filters button { width: auto; max-width: 160px; }
form.stack {
  background: transparent;
  border: 0;
  padding: 0;
  max-width: 920px;
  margin: 16px 0 28px;
  border-radius: 0;
  box-shadow: none;
}
form.stack input, form.stack select, form.stack textarea { max-width: none; }
.helptext { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 4px 0 0; font-size: 12px; font-weight: 650; }
.form-actions { display: flex; gap: 14px; align-items: center; margin: 8px 0 20px; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-weight: 750; margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 8px; }
.check label { margin: 0; }
input[type="checkbox"] { width: auto; max-width: none; box-shadow: none; }
.inline-form { margin: 12px 0 20px; }

/* ——— Formulaires modernes (partagés) ——— */
.ui-page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.ui-page-head h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.ui-page-head .muted { margin: 0; max-width: 52ch; }
.ui-note { margin: -6px 0 16px; }
.ui-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 920px;
  margin: 0 0 28px;
}
.ui-form-compact { max-width: 760px; }
.ui-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px 18px;
  box-shadow: var(--shadow-sm);
}
.ui-card-h {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}
.ui-card-h h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.ui-card-h p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.ui-grid {
  display: grid;
  gap: 12px 14px;
}
.ui-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ui-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ui-span-2 { grid-column: span 2; }
.ui-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
  min-width: 0;
}
.ui-grid .ui-field { margin: 0; }
.ui-field > span {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.ui-field input,
.ui-field select,
.ui-field textarea {
  width: 100%;
  max-width: none;
  border: 0;
  background: #e8f4f8;
  box-shadow: none;
  border-radius: 10px;
  padding: 12px 14px;
}
.ui-field input:hover,
.ui-field select:hover,
.ui-field textarea:hover { background: #dff0f5; }
.ui-field input:focus,
.ui-field select:focus,
.ui-field textarea:focus {
  background: #d7eef3;
  box-shadow: 0 0 0 3px rgba(14, 139, 146, 0.22);
}
.ui-field > span {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 750;
  color: #142628;
}
.ui-field textarea {
  min-height: 120px;
  font-family: var(--mono);
  font-size: 12px;
}
.ui-switch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbfb;
  cursor: pointer;
  grid-column: 1 / -1;
}
.ui-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ui-switch-ui {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #c9d6d6;
  position: relative;
  flex: none;
  transition: background 0.2s var(--ease);
  margin-top: 2px;
}
.ui-switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s var(--ease);
}
.ui-switch input:checked + .ui-switch-ui { background: var(--brand); }
.ui-switch input:checked + .ui-switch-ui::after { transform: translateX(18px); }
.ui-switch-text { display: flex; flex-direction: column; gap: 2px; }
.ui-switch-text strong { font-size: 13px; color: var(--ink); }
.ui-switch-text small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.ui-form-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.ui-filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  margin: 0 0 18px;
  box-shadow: var(--shadow-sm);
}
.ui-filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.ui-filters-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.ui-filters-inline .ui-field {
  margin: 0;
  min-width: 220px;
}
.ui-filters-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.login-card .ui-field { margin-bottom: 14px; }
.login-card .ui-switch { margin-bottom: 14px; }
.login-remember { grid-column: auto; }
@media (max-width: 900px) {
  .ui-grid-2, .ui-grid-3, .ui-filters-grid { grid-template-columns: 1fr 1fr; }
  .ui-span-2 { grid-column: span 2; }
  .ui-page-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .ui-grid-2, .ui-grid-3, .ui-filters-grid { grid-template-columns: 1fr; }
  .ui-span-2 { grid-column: auto; }
}
.actions .btn-ghost { font-size: 12px; padding: 4px 8px; color: var(--ink); border-color: var(--line); }
.pill.status-PENDING, .pill.status-PROCESSING { color: #2a6f8f; border-color: #c5dbf0; background: #eef6fc; }
.pill.status-NEEDS_REVIEW, .pill.status-RETRYING { color: #8a4b10; border-color: #f0d2a0; background: #fff8ec; }
.pill.status-FAILED { color: var(--danger); border-color: #f3c2c2; background: #fdecec; }
.pill.status-PROCESSED, .pill.status-ACCEPTED, .pill.status-SKIPPED { color: #0d5c45; border-color: #bfe8d6; background: #e8f7f0; }
.pill.status-DRY_RUN, .pill.status-HELD { color: #6b5c2e; border-color: #e6d9a8; background: #fbf6e4; }
td.err { color: var(--muted); font-size: 12px; max-width: 280px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .login-split { grid-template-columns: 1fr; }
  .login-brand { min-height: 200px; }
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(var(--sidebar-w), 88vw);
    transform: translateX(-105%);
    transition: transform 0.28s var(--ease);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  }
  html.sidebar-open .sidebar { transform: none; }
  html.sidebar-open .sidebar-overlay { display: block; }
  .icon-btn { display: inline-grid; }
  .sidebar-close { display: inline-grid !important; }
  main { padding: 20px 16px 48px; }
  .topbar { padding: 0 14px; height: 58px; }
}

/* ——— Apps / connexions HMAC ——— */
.apps-howto { margin-bottom: 22px; }
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin: 8px 0 40px;
}
.app-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app-card.is-off { opacity: 0.72; }
.app-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.app-card__head h2 {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.app-card__code {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.app-meta {
  margin: 0;
  display: grid;
  gap: 10px;
}
.app-meta dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 2px;
}
.app-meta dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.app-meta code,
.env-block {
  font-family: var(--mono);
  font-size: 12px;
}
.app-meta code {
  background: #f3f8f8;
  border: 1px solid var(--line);
  padding: 3px 7px;
  border-radius: 6px;
  word-break: break-all;
}
.env-block {
  width: 100%;
  resize: vertical;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #0f1f1e;
  color: #d7efe8;
  line-height: 1.45;
}
.app-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.app-card__actions form { margin: 0; }
.btn-mini {
  font-size: 11px !important;
  padding: 2px 8px !important;
  min-height: 0;
}
.app-notes {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.tiny { font-size: 11px; }
.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;
}
