:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #121826;
  --muted: #5b6475;
  --faint: #8a93a6;
  --line: #e4e7f0;
  --brand: #5b4bff;
  --brand-2: #8f5cff;
  --brand-soft: #eeebff;
  --ok: #12a46f;
  --ok-soft: #e3f6ee;
  --warn: #c98a0b;
  --warn-soft: #fbf1db;
  --danger: #d9443a;
  --danger-soft: #fce8e6;
  --side: #0e1220;
  --nav-bg: #ffffff;
  --nav-2: #f1f3f9;
  --nav-text: #3b4254;
  --nav-muted: #8a93a6;
  --nav-strong: #121826;
  --nav-line: #e4e7f0;
  --nav-active: #eeebff;
  --nav-active-text: #4a3bf0;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 4px 16px rgb(16 24 40 / 0.06);
  --radius: 14px;
  color-scheme: light;
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e17;
    --surface: #131828;
    --surface-2: #1a2034;
    --text: #e8ebf3;
    --muted: #a3abbd;
    --faint: #737c91;
    --line: #252c42;
    --brand: #8577ff;
    --brand-2: #a98bff;
    --brand-soft: #231f45;
    --ok: #3ccf95;
    --ok-soft: #12302a;
    --warn: #f0b443;
    --warn-soft: #33290f;
    --danger: #ff7a70;
    --danger-soft: #3a1c1c;
    --side: #080b13;
    --nav-bg: #080b13;
    --nav-2: #121729;
    --nav-text: #c9cfdf;
    --nav-muted: #7d869c;
    --nav-strong: #ffffff;
    --nav-line: #121729;
    --nav-active: #121729;
    --nav-active-text: #ffffff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}
/* Escuro escolhido no painel (vale mesmo com o sistema no claro). */
@media screen {
  :root[data-theme="dark"] {
    --bg: #0b0e17;
    --surface: #131828;
    --surface-2: #1a2034;
    --text: #e8ebf3;
    --muted: #a3abbd;
    --faint: #737c91;
    --line: #252c42;
    --brand: #8577ff;
    --brand-2: #a98bff;
    --brand-soft: #231f45;
    --ok: #3ccf95;
    --ok-soft: #12302a;
    --warn: #f0b443;
    --warn-soft: #33290f;
    --danger: #ff7a70;
    --danger-soft: #3a1c1c;
    --side: #080b13;
    --nav-bg: #080b13;
    --nav-2: #121729;
    --nav-text: #c9cfdf;
    --nav-muted: #7d869c;
    --nav-strong: #ffffff;
    --nav-line: #121729;
    --nav-active: #121729;
    --nav-active-text: #ffffff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.015em; }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--nav-bg); color: var(--nav-text); border-right: 1px solid var(--nav-line); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; height: 100dvh; }
.content { min-width: 0; }
.page { max-width: 1120px; margin: 0 auto; padding: 32px 32px 80px; }

.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: var(--nav-strong); }
.logo:hover { text-decoration: none; }
.logo-mark { color: #fff; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 4px 14px rgb(91 75 255 / 0.45); }
.logo-name { font-weight: 700; font-size: 15px; line-height: 1.15; }
.logo-by { font-size: 11.5px; color: var(--nav-muted); font-weight: 500; }

/* Em tela baixa a lista de opções rola por dentro; aparência e usuário ficam sempre à vista embaixo. */
.nav { display: grid; gap: 2px; align-content: start; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -6px; padding: 0 6px 8px; scrollbar-width: thin; scrollbar-color: var(--nav-2) transparent; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--nav-2); border-radius: 99px; }
@media (min-width: 861px) and (max-height: 860px) {
  .side .logo { padding-bottom: 10px; }
  .side .nav-label { padding: 8px 10px 3px; }
  .side .nav a { padding: 6px 10px; }
}
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--nav-muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--nav-text); font-weight: 500; }
.nav a:hover { background: var(--nav-2); text-decoration: none; color: var(--nav-strong); }
.nav a.active { background: var(--nav-active); color: var(--nav-active-text); box-shadow: inset 2px 0 0 var(--brand-2); }

.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--nav-line); }
.me-name { color: var(--nav-strong); font-weight: 600; font-size: 13px; }
.me-role { color: var(--nav-muted); font-size: 11.5px; }
.me form { margin-left: auto; }
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin-top: 10px; padding: 3px; border-radius: 10px; background: var(--nav-2); }
.theme-switch button { display: flex; align-items: center; justify-content: center; gap: 5px; border: 0; background: transparent; color: var(--nav-muted); font: inherit; font-size: 11.5px; font-weight: 600; padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.theme-switch button:hover { color: var(--nav-strong); }
.theme-switch button.on { background: var(--nav-bg); color: var(--nav-strong); box-shadow: 0 1px 3px rgb(0 0 0 / 0.18); }
.theme-switch + .me { margin-top: 10px; }
.theme-switch button:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.icon-btn { background: transparent; border: 0; color: var(--nav-muted); padding: 6px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--nav-2); color: var(--nav-strong); }

/* ---------- cabeçalho de página ---------- */
.crumbs { font-size: 13px; color: var(--faint); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.head h1 { font-size: 26px; margin: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head p { margin: 6px 0 0; color: var(--muted); }

/* ---------- blocos ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card, .grid-2 > .card { margin-top: 0; }
.card-title { font-size: 15px; font-weight: 650; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--muted); margin: 0 0 16px; font-size: 13.5px; }
.section { margin-top: 36px; }
.section-title { font-size: 17px; font-weight: 650; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
/* Gráfico largo + lista ao lado; no celular, um embaixo do outro. */
.grid-2.grid-wide { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 860px) { .grid-2.grid-wide { grid-template-columns: minmax(0, 1fr); } }

.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 12.5px; }

/* ---------- tabela ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); font-weight: 600; padding: 12px 16px; background: var(--surface-2); }
td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.row-link:hover td { background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 12px; }
.who strong { display: block; }
.who small { color: var(--faint); }

/* ---------- elementos ---------- */
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.plain::before { display: none; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; text-align: right; }

/* ---------- formulários ---------- */
form.fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 180px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color 0.12s, box-shadow 0.12s; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 10px 16px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; box-shadow: 0 2px 8px rgb(91 75 255 / 0.3); }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

details.drawer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
details.drawer > summary { list-style: none; cursor: pointer; padding: 14px 20px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--brand); }
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer[open] > summary { border-bottom: 1px solid var(--line); }
details.drawer > div { padding: 20px; }

.flash { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-weight: 550; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.erro { background: var(--danger-soft); color: var(--danger); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brand { background: radial-gradient(1200px 600px at 0% 0%, #2a2470 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #4a2a8a 0%, transparent 55%), var(--side); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-brand h2 { font-size: 34px; line-height: 1.15; margin: 0 0 14px; max-width: 460px; }
.auth-brand p { color: #b8bfd6; max-width: 440px; margin: 0; }
.auth-points { display: grid; gap: 12px; margin-top: 28px; color: #d7dcec; }
.auth-points div { display: flex; gap: 10px; align-items: center; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 26px; margin: 0 0 6px; }
.auth-card p { color: var(--muted); margin: 0 0 24px; }
.auth-foot { color: #7d869c; font-size: 12.5px; }

.menu-toggle { display: none; }

@media (max-width: 860px) {
  /* Celular e tablet em pé: barra fina no topo; o menu abre por cima da página pelo botão. */
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--nav-line); position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0; padding: 10px 16px; }
  .logo { padding: 0; order: 1; }
  .menu-toggle { display: grid; place-items: center; order: 2; margin-left: auto; width: 42px; height: 42px; border: 0; border-radius: 10px; background: var(--nav-2); color: var(--nav-strong); cursor: pointer; }
  .nav, .me { display: none; order: 3; flex-basis: 100%; }
  .side.open .nav { display: grid; gap: 2px; padding-top: 10px; max-height: calc(100dvh - 210px); overflow-y: auto; }
  .side.open .nav a { padding: 12px 10px; }
  .side.open .me { display: flex; margin-top: 8px; padding: 12px 8px 4px; }
  .theme-switch { display: none; order: 3; flex-basis: 100%; }
  .side.open .theme-switch { display: grid; margin-top: 8px; }
  .page { padding: 18px 14px 60px; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .bubble { max-width: 92%; }
}

/* ---------- comando para copiar ---------- */
.code { position: relative; min-width: 0; max-width: 100%; }
.code pre { margin: 0; background: var(--side); color: #d7dcec; border-radius: 12px; padding: 16px 96px 16px 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.7; overflow-x: auto; white-space: pre; }
.code .copy { position: absolute; top: 10px; right: 10px; padding: 6px 12px; font-size: 12.5px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

/* ---------- Voz ---------- */
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
audio { width: 100%; height: 38px; display: block; }
.text-preview { max-width: 460px; }
.text-preview div { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.text-preview audio { margin-top: 8px; }
.inline { display: inline; }
.check { display: inline-flex; flex-direction: row; gap: 8px; align-items: flex-start; color: var(--text); font-weight: 500; }
.check input { width: auto; margin-top: 3px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.hint { color: var(--faint); font-size: 12.5px; font-weight: 400; }
.recorder { display: grid; gap: 12px; padding: 16px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); }
.recorder-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.script { background: var(--surface); border-radius: 10px; padding: 12px 14px; margin: 0; font-size: 14px; line-height: 1.6; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); }
.meter span.loud { background: var(--danger); }
.timer { font-variant-numeric: tabular-nums; font-weight: 650; }
.key-once { display: grid; gap: 10px; margin-bottom: 20px; border-color: var(--warn); }
.key-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.result { display: grid; gap: 12px; margin-top: 16px; }
.endpoint { display: grid; gap: 8px; }
.endpoint + .endpoint { margin-top: 22px; }
.endpoint h3 { margin: 0; font-size: 14.5px; }
.endpoint p { margin: 0; color: var(--muted); }
.code pre { overflow-x: auto; }
[hidden] { display: none !important; }
.table-wrap td form { margin: 0; }
.speed-field { max-width: 96px; }
@media (max-width: 860px) { .text-preview { max-width: 240px; } }
.btn-center { justify-content: center; margin-top: 6px; }
.text-preview audio { min-width: 230px; }
.table-wrap table { min-width: 860px; }
.alert-space { margin-bottom: 16px; }
.warn-text { color: var(--warn); font-size: 12.5px; font-weight: 550; margin-top: 4px; }
textarea.short { min-height: 72px; }
.compare-source { display: grid; gap: 6px; margin-bottom: 18px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; }
.sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px 24px; }
.slider { gap: 4px; }
.slider-top { display: flex; justify-content: space-between; gap: 8px; }
.slider output { color: var(--text); font-variant-numeric: tabular-nums; }
.slider input[type="range"] { padding: 0; border: 0; background: transparent; accent-color: var(--brand); box-shadow: none; }
.tests { display: grid; gap: 12px; margin-top: 16px; }
.test { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.test-values { display: flex; flex-wrap: wrap; gap: 6px; }
.compare-table { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.compare-item { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.compare-item strong { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.alert > svg { flex: none; margin-top: 2px; }
.alert.warn > svg { color: var(--warn); }
.alert strong { display: block; }
.alert small { color: var(--muted); font-size: 13px; }
.test-head { display: flex; align-items: center; gap: 8px; }
.test.chosen { border-color: var(--brand); }
.head .actions { align-items: center; margin: 0; }
