/* Gerenciador — mesma identidade do portfólio: fundo void, painéis frios, verde/azul da marca.
   Modo "operar": o degradê da marca aparece só na ação principal e na marca; o resto é contido. */
:root {
  --void: #08090c;
  --panel: #12151d;
  --panel-2: #191d27;
  --line: #262b38;
  --line-soft: #1d212c;
  --ink: #e4e8fb;
  --ink-soft: #9aa0b8;
  --ink-faint: #80879f; /* ≥ 4.5:1 sobre --panel-2 */
  --green: #00ff8f;
  --blue: #00a1ff;
  --brand-gradient: linear-gradient(135deg, var(--green), var(--blue));
  /* séries de gráfico validadas (CVD + contraste) contra --panel */
  --series-1: #3a95e6;
  --series-2: #16a86e;
  --danger: #ff6b7d;
  --warning: #ffc266;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-float: 0 12px 28px -10px rgba(0, 0, 0, .75);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font-body: "Inter", system-ui, sans-serif;
  --font-display: "Sora", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
  accent-color: var(--series-2);
  scrollbar-color: var(--line) transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--void);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--blue);
}
a { color: inherit; text-underline-offset: 3px; }
::selection { background: var(--blue); color: var(--void); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.icon { flex-shrink: 0; }
/* texto só para leitor de tela; o pai precisa ser posicionado (ver .btn, .table-wrap) para não vazar do scroll */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-faint); }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 22px 14px; border-right: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 0 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand-gradient); flex-shrink: 0; }
.brand strong { font: 700 14px var(--font-display); display: block; }
.brand small { font-size: 11px; font-weight: 500; color: var(--ink-faint); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-soft); text-decoration: none; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--panel-2); color: var(--ink); }
.nav a[aria-current="page"] .icon { color: var(--blue); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--ink-faint); padding: 0 8px; }
.sidebar-foot form { margin: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 32px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--void) 90%, transparent); backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; font: 700 20px/1.2 var(--font-display); letter-spacing: -.01em; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 28px 32px 64px; display: flex; flex-direction: column; gap: 24px; max-width: 1280px; width: 100%; }
.lead { margin: 0; color: var(--ink-soft); max-width: 70ch; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; min-width: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; min-width: 0; scrollbar-width: none;
         mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .nav a span { white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .topbar { position: static; padding: 14px 16px; flex-wrap: wrap; }
  .content { padding: 20px 16px 48px; }
}

/* ---------- botões: um desenho, três pesos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: 500 13px/1.3 var(--font-body);
  text-decoration: none; cursor: pointer; white-space: nowrap; position: relative;
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn:active { background: var(--panel-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; border-color: var(--line); color: var(--ink-soft); background: var(--panel); }
.btn-primary { border: 0; color: var(--void); font-weight: 600; background: var(--brand-gradient); }
.btn-primary:hover { color: var(--void); filter: brightness(1.08); }
.btn-primary:disabled { background: var(--panel-2); color: var(--ink-faint); filter: none; opacity: 1; border: 1px solid var(--line); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--panel-2); border-color: transparent; color: var(--ink); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 30px; padding: 5px 11px; font-size: 12.5px; }
.btn-icon { width: 32px; min-height: 32px; padding: 0; border-radius: 8px; }
.btn[aria-busy="true"] { cursor: progress; }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink-soft); font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--ink); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); text-decoration: none; font-size: 14px; min-height: 32px; }
.back-link:hover { color: var(--ink); }

/* toque e telas estreitas: alvo mínimo de 44px sem mudar o desenho no desktop */
@media (pointer: coarse), (max-width: 900px) {
  .btn, .btn-sm, .nav a, .segmented a, .back-link { min-height: 44px; }
  .btn-icon { width: 44px; min-height: 44px; }
}

/* ---------- status */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--ink-soft); white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
.pill.ok .dot { background: var(--green); }
.pill.info { border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); color: var(--ink); }
.pill.info .dot { background: var(--blue); }
.pill.warn { border-color: color-mix(in srgb, var(--warning) 45%, transparent); color: var(--warning); }
.pill.warn .dot { background: var(--warning); }
.pill.err { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.pill.err .dot { background: var(--danger); }
.pill.live .dot { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }

.alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
         padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 14px; }
.alert p { margin: 0; }
.alert.ok { border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }
.alert.warn { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); }
.alert.err { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); color: var(--danger); }

/* ---------- blocos */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font: 600 15px/1.35 var(--font-body); }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--ink-faint); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.segmented a { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; text-decoration: none; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.segmented a:hover { color: var(--ink); }
.segmented a[aria-current="true"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- gráficos */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-label { fill: var(--ink-faint); font: 11px var(--font-mono); font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--ink-faint); stroke-width: 1; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  font-size: 12px; box-shadow: var(--shadow-float); transform: translate(-50%, calc(-100% - 12px));
}
.tooltip strong { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.tooltip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.swatch { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.bars { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.bar-row .bar-label { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-value { font: 500 12px var(--font-mono); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.bar-track { display: block; grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.bar-fill.alt { background: var(--series-2); }
.empty { padding: 28px 12px; text-align: center; color: var(--ink-faint); font-size: 13px; margin: 0; }

details.table-view { margin-top: 12px; }
details.table-view summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); }

/* ---------- tabelas e listas */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-faint); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-family: var(--font-mono); font-size: 13px; }
/* linha inteira clicável, mas o alvo real é o link (teclado e leitor de tela) */
tr.row-link { position: relative; }
tr.row-link a.row-target::after { content: ""; position: absolute; inset: 0; }
tr.row-link:hover td, tr.row-link:focus-within td { background: var(--panel-2); }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--ink-faint); }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); color: var(--ink-soft); white-space: nowrap; }

/* ---------- jornada da sessão */
.journey { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.journey li { position: relative; }
.journey li::before { content: ""; position: absolute; left: -23px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); }
.journey li.click::before { background: var(--blue); border-color: var(--blue); }
.journey li.conv::before { background: var(--green); border-color: var(--green); }
.journey time { font: 500 12px var(--font-mono); color: var(--ink-faint); }
.journey p { margin: 2px 0 0; }
.journey .target { font: 12px var(--font-mono); color: var(--ink-faint); word-break: break-all; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--ink-faint); }
.facts dd { margin: 0; word-break: break-word; }

/* ---------- editor */
.editor, #editor { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 500; color: var(--ink); }
.field .help { font-size: 12.5px; color: var(--ink-faint); }
.field .counter { font: 12px var(--font-mono); color: var(--ink-faint); align-self: flex-end; }
.field .counter.over { color: var(--danger); }
input[type="text"], input[type="password"], input[type="file"], textarea, select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--void); color: var(--ink); font: 14px/1.5 var(--font-body);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent); }
input[type="file"]::file-selector-button { margin-right: 10px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font: 500 12.5px var(--font-body); cursor: pointer; }
textarea { resize: vertical; min-height: 84px; }
textarea.code { font: 12.5px/1.55 var(--font-mono); white-space: pre; overflow-x: auto; min-height: 150px; tab-size: 2; }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; min-height: 32px; }
.toggle input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; margin: 0; transition: background .15s var(--ease); flex-shrink: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); transition: transform .15s var(--ease); }
.toggle input:checked { background: var(--series-2); }
.toggle input:checked::after { transform: translateX(16px); }
.toggle input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.repeater { display: flex; flex-direction: column; gap: 8px; }
.repeater-item { border: 1px solid var(--line); border-radius: 12px; background: var(--void); }
.repeater-head { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 12px; }
.repeater-head button.title { flex: 1; min-width: 0; min-height: 36px; display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--ink); font: 500 14px var(--font-body); text-align: left; cursor: pointer; padding: 4px 0; }
.repeater-head .index { font: 500 12px var(--font-mono); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.repeater-head .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repeater-head .chev { color: var(--ink-faint); transition: transform .15s var(--ease); }
.repeater-item.open .chev { transform: rotate(90deg); }
.repeater-body { display: none; padding: 14px 14px 16px; flex-direction: column; gap: 14px; border-top: 1px solid var(--line-soft); }
.repeater-item.open > .repeater-body { display: flex; }
.repeater-item .repeater-item { background: var(--panel); }

.save-bar {
  position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px 10px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); box-shadow: var(--shadow-float);
}
.save-bar .state { font-size: 13px; color: var(--ink-soft); }
.save-bar .state.dirty { color: var(--warning); }
@media (max-width: 560px) { .save-bar { border-radius: 16px; } }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: min(380px, calc(100vw - 40px));
  padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2);
  font-size: 14px; box-shadow: var(--shadow-float); animation: toast-in .2s var(--ease);
}
.toast.ok { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }
.toast.err { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  /* sem deslocamento; mudanças de estado continuam visíveis (cor/opacidade instantâneas) */
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
pre.log { max-height: 280px; overflow: auto; background: var(--void); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: 12px/1.5 var(--font-mono); color: var(--ink-soft); white-space: pre-wrap; margin: 10px 0 0; }

.image-field { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.image-field .preview { width: 96px; height: 96px; border-radius: 12px; border: 1px solid var(--line); background: var(--void) center/cover no-repeat; flex-shrink: 0; display: grid; place-items: center; color: var(--ink-faint); font-size: 12px; text-align: center; }
.image-field .meta { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.image-field .path { font: 12px var(--font-mono); color: var(--ink-faint); word-break: break-all; }

dialog.picker { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow-float); }
dialog.picker::backdrop { background: rgba(4, 5, 8, .72); }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.picker-head h2 { margin: 0; font: 600 16px var(--font-body); }
.picker-body { padding: 16px 20px 20px; overflow: auto; max-height: calc(100vh - 170px); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.picker-grid button { padding: 0; border: 2px solid transparent; border-radius: 12px; background: none; cursor: pointer; overflow: hidden; aspect-ratio: 1; }
.picker-grid button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-grid button:hover, .picker-grid button:focus-visible { border-color: var(--blue); outline: none; }
.picker-grid button[aria-pressed="true"] { border-color: var(--green); }
.upload-label { position: relative; overflow: hidden; }
.upload-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-label:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(600px 400px at 50% 20%, color-mix(in srgb, var(--blue) 10%, transparent), transparent); }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login h1 { margin: 0; font: 700 24px/1.2 var(--font-display); }
.login p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.login code { font-family: var(--font-mono); font-size: 12px; background: var(--void); padding: 2px 6px; border-radius: 6px; }

/* =====================================================================
   Espaço de trabalho do editor de conteúdo
   Formulário em grupos (título à esquerda, campos em grid de 12 colunas)
   + prévia ao vivo fixa à direita. O menu vira trilho de ícones nesta tela.
   ===================================================================== */
:root { --topbar-h: 65px; --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px; }

/* trilho de ícones */
.shell.rail { grid-template-columns: 68px minmax(0, 1fr); }
.shell.rail .sidebar { padding: 18px 10px; align-items: center; }
.shell.rail .brand { padding: 0; }
.shell.rail .brand > span:last-child, .shell.rail .who, .shell.rail .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.shell.rail .nav a { justify-content: center; width: 44px; min-height: 44px; padding: 0; }
.shell.rail .sidebar-foot { align-items: center; padding: 0; }
.shell.rail .site-link { width: 40px; padding: 0; }
.link-btn.logout { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-height: 32px; }

.content-wide { max-width: none; padding-top: 16px; gap: 16px; }
.workspace { container: surface / inline-size; display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }

/* abas de seção */
.section-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.section-tabs a { position: relative; display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; min-height: 34px; padding: 6px 14px; border-radius: 9px; color: var(--ink-soft); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease); }
.section-tabs a:hover { color: var(--ink); background: var(--panel-2); }
.section-tabs a[aria-current="page"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.tab-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }

.context-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.context-desc { margin: 0; color: var(--ink-soft); font-size: 14px; }
.draft-note { display: inline-flex; align-items: center; gap: var(--space-2); }
.draft-note[hidden] { display: none; }
.draft-note form { margin: 0; }

/* formulário + prévia */
.ws-body { display: grid; grid-template-columns: minmax(0, 1fr) var(--pv-width, 440px); gap: var(--space-5); align-items: start; }
.ws-body.preview-off { grid-template-columns: minmax(0, 1fr); }
.ws-body.preview-off .ws-preview { display: none; }
.ws-form { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.cv-card .alert { margin-bottom: var(--space-3); }

.surface { container: surface / inline-size; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 24px; }

/* grupo: título à esquerda, campos à direita; coleções usam a largura toda */
.group-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--space-5); padding: var(--space-5) 0; border-top: 1px solid var(--line-soft); }
.group-row:first-child { border-top: 0; }
.group-row.wide { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.group-label { position: sticky; top: calc(var(--topbar-h) + 16px); align-self: start; display: flex; flex-direction: column; gap: 4px; }
.group-row.wide .group-label { position: static; flex-direction: row; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.group-label h2 { margin: 0; font: 600 14px/1.35 var(--font-body); color: var(--ink); }
.group-label p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-faint); }
.group-label .count { font-size: 12.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.fgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }
.fgrid > .f { grid-column: span 12; }
.fgrid > .s-2 { grid-column: span 2; } .fgrid > .s-3 { grid-column: span 3; } .fgrid > .s-4 { grid-column: span 4; }
.fgrid > .s-5 { grid-column: span 5; } .fgrid > .s-6 { grid-column: span 6; } .fgrid > .s-7 { grid-column: span 7; }
.fgrid > .s-8 { grid-column: span 8; } .fgrid > .s-10 { grid-column: span 10; }
.f.t-bool { align-self: end; min-height: 42px; display: flex; align-items: center; }

/* campo destacado ao chegar pela prévia */
.f.flash > input, .f.flash > textarea, .f.flash > select, .f.flash .image-field { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 35%, transparent); border-color: var(--blue); }

/* tabela editável (coleções pequenas: métricas, destaques, certificações) */
.trep { display: flex; flex-direction: column; gap: 6px; }
.trep-head, .trep-row { display: grid; grid-template-columns: var(--cols); gap: 8px; align-items: center; }
.trep-head { padding: 0 2px; font-size: 12px; font-weight: 600; color: var(--ink-faint); }
.trep-row { padding: 6px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--void); }
.trep-row:hover, .trep-row:focus-within { border-color: var(--line); }
.trep-row input[type="text"], .trep-row select { padding: 7px 10px; font-size: 13.5px; }
.trep-idx { font: 500 12px var(--font-mono); color: var(--ink-faint); text-align: center; font-variant-numeric: tabular-nums; }
.trep-cell { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.trep-cell .cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.row-actions { display: flex; gap: 2px; }
.row-actions .btn-icon { width: 30px; min-height: 30px; }

/* lista + detalhe (coleções grandes: experiências, cases, projetos…) */
.md { display: grid; grid-template-columns: 240px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--void); min-height: 300px; }
.md-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--void); min-width: 0; }
.md-items { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; max-height: min(68vh, 640px); overflow-y: auto; }
.md-item { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 2px 8px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: var(--ink-soft); text-align: left; cursor: pointer; font: inherit; }
.md-item:hover { background: var(--panel); color: var(--ink); }
.md-item[aria-current="true"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.md-item .idx { grid-row: span 2; font: 500 12px/1.6 var(--font-mono); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.md-item .t { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-item .sub { font-size: 12px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-add { margin: auto 6px 6px; justify-content: flex-start; }
.md-detail { padding: 20px 22px 24px; background: var(--panel); min-width: 0; display: flex; flex-direction: column; gap: var(--space-5); }
.md-detail-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding-bottom: var(--space-4); border-bottom: 1px solid var(--line-soft); }
.md-detail-head h3 { margin: 0; font: 600 16px/1.3 var(--font-body); min-width: 0; overflow-wrap: anywhere; }
.md-detail-head .pos { font: 500 12px var(--font-mono); color: var(--ink-faint); margin-right: 8px; }
.subgroups { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-5) var(--space-5); }
.subgroup { grid-column: span 12; display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.subgroup.half { grid-column: span 6; }
.subgroup h4 { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.md-empty { display: grid; place-items: center; align-content: center; gap: var(--space-3); padding: var(--space-7) var(--space-5); text-align: center; color: var(--ink-faint); font-size: 14px; }

/* prévia ao vivo */
.ws-preview { position: sticky; top: calc(var(--topbar-h) + 16px); height: calc(100vh - var(--topbar-h) - 32px); min-height: 420px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.pv-toolbar { display: flex; align-items: center; gap: var(--space-2); padding: 8px 8px 8px 10px; border-bottom: 1px solid var(--line); }
.pv-toolbar .segmented a { padding: 4px 10px; font-size: 12.5px; }
.pv-status { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-status.live { color: var(--ink-soft); }
.pv-note { margin: 0; padding: 10px 14px; font-size: 13px; color: var(--ink-soft); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--warning) 6%, var(--panel)); }
.pv-stage { position: relative; flex: 1; overflow: hidden; background: var(--void); }
.pv-stage iframe { position: absolute; top: 0; left: 50%; width: var(--frame-w, 390px); height: calc(100% / var(--scale, 1)); border: 0; transform: translateX(-50%) scale(var(--scale, 1)); transform-origin: top center; background: var(--void); }
.pv-stage[data-device="mobile"] iframe { box-shadow: 0 0 0 1px var(--line); }
.pv-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; background: color-mix(in srgb, var(--void) 82%, transparent); color: var(--ink-soft); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
.pv-loading.on { opacity: 1; pointer-events: auto; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pv-close { display: none; }
.pv-hint { margin: 0; padding: 8px 12px; font-size: 12px; color: var(--ink-faint); border-top: 1px solid var(--line); }

/* larguras intermediárias: prévia vira gaveta sobre o conteúdo */
@media (max-width: 1180px) {
  .ws-body, .ws-body.preview-off { grid-template-columns: minmax(0, 1fr); }
  .ws-preview { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(440px, 100vw); height: auto; border-radius: 0; border-width: 0 0 0 1px; box-shadow: var(--shadow-float); transform: translateX(100%); transition: transform .2s var(--ease); display: flex !important; }
  .ws-body:not(.preview-off) .ws-preview { transform: none; }
  .pv-close { display: inline-flex; }
}

/* o formulário se adapta à própria largura, não à da janela */
@container surface (max-width: 760px) {
  .group-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .group-label { position: static; }
  .md { grid-template-columns: minmax(0, 1fr); }
  .md-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .md-items { flex-direction: row; overflow-x: auto; max-height: none; }
  .md-item { width: auto; min-width: 180px; max-width: 240px; }
  .md-add { margin: 0 6px 6px; }
}
@container surface (max-width: 560px) {
  .surface { padding: 4px 16px; }
  .fgrid > .f { grid-column: span 12; }
  .subgroup.half { grid-column: span 12; }
  .trep-head { display: none; }
  .trep-row { grid-template-columns: minmax(0, 1fr) auto; }
  .trep-row .trep-idx { display: none; }
  .trep-row .trep-cell { grid-column: 1; }
  .trep-row .row-actions { grid-column: 2; grid-row: 1 / span 4; align-self: start; flex-direction: column; }
  .trep-cell .cell-label { position: static; width: auto; height: auto; clip-path: none; font-size: 12px; color: var(--ink-faint); }
}
@media (max-width: 900px) {
  .shell.rail { grid-template-columns: minmax(0, 1fr); }
  .shell.rail .sidebar { padding: 10px 16px; }
}

/* =====================================================================
   Padrões compartilhados por todas as telas (mesmas regras do editor)
   ===================================================================== */
.group-body { min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.subgroup.third { grid-column: span 4; }
.align-end { align-self: end; }
.ellipsis { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-action { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.inline-action p { margin: 0; color: var(--ink-soft); font-size: 14px; max-width: 60ch; }
.add-user { padding-top: var(--space-4); border-top: 1px dashed var(--line); }

/* números do período: uma faixa só, divisórias finas em vez de cards aninhados */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0; border: 1px solid var(--line-soft); border-radius: 12px; overflow: hidden; }
.stats > div { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-right: 1px solid var(--line-soft); margin-right: -1px; border-bottom: 1px solid var(--line-soft); margin-bottom: -1px; }
.stats dt { font-size: 12.5px; color: var(--ink-soft); }
.stats dd { margin: 0; font: 600 24px/1.15 var(--font-body); letter-spacing: -.01em; }
.stats-compact > div { padding: 10px 12px; }
.stats-compact dd { font-size: 18px; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--danger); }

.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: var(--space-3); color: var(--ink-soft); font-size: 14px; max-width: 75ch; }
.steps strong { color: var(--ink); font-weight: 600; }
.steps code { font: 12px var(--font-mono); background: var(--void); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; word-break: break-all; }

/* lista + detalhe como página (visitas, histórico, publicações) */
.md-page { min-height: calc(100vh - var(--topbar-h) - 190px); }
.md-page .md-items { max-height: calc(100vh - var(--topbar-h) - 240px); }
.md-page .md-detail { overflow-wrap: anywhere; }
a.md-item { text-decoration: none; }
.md-item.no-idx { grid-template-columns: minmax(0, 1fr); }
.md-item .t { display: flex; align-items: center; gap: 6px; }
.md-item .tt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--ink-faint); }
.md-dot.ok { background: var(--green); }
.md-dot.warn { background: var(--warning); }
.md-dot.err { background: var(--danger); }
.md-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: auto 0 0; padding: 10px 14px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--ink-faint); }
.md-legend .md-dot:not(:first-child) { margin-left: 8px; }
.md-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px; border-top: 1px solid var(--line-soft); font-size: 12.5px; }
[data-md-detail][aria-busy="true"] { opacity: .55; transition: opacity .15s var(--ease); }
pre.log-tall { max-height: 60vh; }

/* diff campo a campo */
.diff { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.diff-row { border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; background: var(--void); display: flex; flex-direction: column; gap: 10px; }
.diff-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.diff-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.diff-values > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.diff-values p { margin: 0; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 10px; border-radius: 8px; }
.diff-before p { background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--ink-soft); }
.diff-after p { background: color-mix(in srgb, var(--green) 7%, transparent); color: var(--ink); }
.diff-tag { font-size: 11.5px; font-weight: 600; color: var(--ink-faint); }
.diff-row.added .diff-before, .diff-row.removed .diff-after { opacity: .5; }

/* mídia: galeria + inspetor */
.gallery-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-5); align-items: start; }
.gallery-surface { padding: 16px; }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
.thumb { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 12px; text-decoration: none; border: 1px solid transparent; }
.thumb:hover { background: var(--panel-2); }
.thumb[aria-current="true"] { background: var(--panel-2); border-color: var(--blue); }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: var(--void); }
.thumb-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }
.thumb-name { flex: 1; min-width: 0; font: 12px var(--font-mono); color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inspector { position: sticky; top: calc(var(--topbar-h) + 16px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.inspector-figure { margin: 0; background: var(--void) repeating-conic-gradient(var(--panel) 0 25%, var(--void) 0 50%) 50% / 16px 16px; display: grid; place-items: center; max-height: 320px; }
.inspector-figure img { max-width: 100%; max-height: 320px; object-fit: contain; display: block; }
.inspector-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: var(--space-4); }
.inspector-title { margin: 0; font: 600 14px var(--font-mono); overflow-wrap: anywhere; }
.usage { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.usage li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

@container surface (max-width: 900px) {
  .gallery-layout { grid-template-columns: minmax(0, 1fr); }
  .inspector { position: static; }
  .subgroup.third { grid-column: span 6; }
}
@container surface (max-width: 560px) {
  .subgroup.third { grid-column: span 12; }
  .diff-values { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- divisor arrastável entre formulário e prévia */
.ws-body { grid-template-columns: minmax(0, 1fr) 14px var(--pv-width, 440px); column-gap: 6px; }
.ws-resizer {
  position: sticky; top: calc(var(--topbar-h) + 16px); height: calc(100vh - var(--topbar-h) - 32px);
  display: grid; place-items: center; cursor: col-resize; touch-action: none; border-radius: 8px;
}
.ws-resizer::before { content: ""; width: 1px; height: 100%; background: var(--line); transition: background .15s var(--ease); }
.ws-resizer .grip { position: absolute; width: 6px; height: 40px; border-radius: 999px; background: var(--line); transition: background .15s var(--ease), transform .15s var(--ease); }
.ws-resizer:hover::before, .ws-resizer:focus-visible::before, body.resizing .ws-resizer::before { background: var(--blue); }
.ws-resizer:hover .grip, .ws-resizer:focus-visible .grip, body.resizing .ws-resizer .grip { background: var(--blue); transform: scaleY(1.4); }
.ws-resizer:focus-visible { outline: none; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }
body.resizing .pv-stage iframe { pointer-events: none; } /* senão o iframe engole o arraste */
.ws-body.preview-off .ws-resizer { display: none; }
@media (max-width: 1180px) { .ws-resizer { display: none; } }
@media (max-width: 1180px) { .ws-body { grid-template-columns: minmax(0, 1fr); } }
