/* Beluga: tokens (verde #03f96e + preto #060908, tema escuro e claro com contraste conferido em test/beluga.test.js) e os componentes comuns.
   Cada tela acrescenta o seu arquivo public/css/beluga-<tela>.css (entra sozinho na página). Nada de cor escrita fora das variáveis. */

:root {
	--bg: #060908;
	--surface: #0d1311;
	--raised: #131c18;
	--sunken: #080c0a;
	--line: #1f2d27;
	--line-strong: #2f4a3d;
	--text: #e8f1ec;
	--muted: #9bb0a5;
	--accent: #03f96e;
	--accent-ink: #03f96e;
	--on-accent: #04130a;
	--accent-soft: rgb(3 249 110 / 0.12);
	--accent-line: rgb(3 249 110 / 0.4);
	--danger: #ff7a7a;
	--danger-soft: rgb(255 122 122 / 0.13);
	--warn: #ffc247;
	--warn-soft: rgb(255 194 71 / 0.13);
	--info: #5cc8ff;
	--shadow: 0 18px 50px rgb(0 0 0 / 0.5);
	--radius: 14px;
	--radius-sm: 9px;
	--sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	--mono: ui-monospace, 'Cascadia Code', 'JetBrains Mono', 'SF Mono', Consolas, 'Liberation Mono', monospace;
	--bi-eye: #060908;
	color-scheme: dark;
}
:root[data-theme='light'] {
	--bg: #f3f8f5;
	--surface: #ffffff;
	--raised: #eef5f1;
	--sunken: #e8f0eb;
	--line: #d4e2da;
	--line-strong: #aac4b6;
	--text: #0b1511;
	--muted: #4a5f55;
	--accent: #03f96e;
	--accent-ink: #006b38;
	--on-accent: #04130a;
	--accent-soft: rgb(0 107 56 / 0.1);
	--accent-line: rgb(0 107 56 / 0.45);
	--danger: #b3202a;
	--danger-soft: rgb(179 32 42 / 0.1);
	--warn: #7d5200;
	--warn-soft: rgb(125 82 0 / 0.1);
	--info: #0a5f99;
	--shadow: 0 18px 40px rgb(15 40 28 / 0.16);
	--bi-eye: #ffffff;
	color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); min-height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
code, kbd, pre { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.bi { flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── barra de cima ───────── */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top__back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 13px; padding: 6px 8px; border-radius: 8px; }
.top__back:hover { color: var(--text); background: var(--raised); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; letter-spacing: 0.01em; }
.brand .bi { color: var(--accent-ink); }
.dbchip { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; max-width: 46vw; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; }
.dbchip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbchip small { color: var(--muted); white-space: nowrap; }
.dbchip[data-open='true'] { border-color: var(--accent-line); }
.dbchip:hover { background: var(--raised); }
.dbclose { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; }
.dbclose:hover { color: var(--danger); border-color: var(--danger); }
.tools { display: flex; align-items: center; gap: 4px; }
.tool { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px; gap: 6px; border: 0; background: transparent; color: var(--muted); border-radius: 10px; cursor: pointer; }
.tool:hover { color: var(--text); background: var(--raised); }
.tool[aria-pressed='false'] { opacity: 0.5; }
#tInstall { grid-auto-flow: column; color: var(--accent-ink); font-weight: 600; font-size: 13px; }

/* ───────── casca e navegação ───────── */
.shell { flex: 1; display: grid; grid-template-columns: 84px minmax(0, 1fr); min-height: 0; }
.nav { position: sticky; top: 59px; align-self: start; display: flex; flex-direction: column; gap: 4px; padding: 14px 8px; height: calc(100dvh - 59px); border-right: 1px solid var(--line); }
.nav__item { display: grid; justify-items: center; gap: 3px; padding: 10px 4px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 11.5px; cursor: pointer; }
.nav__item:hover { background: var(--raised); color: var(--text); }
.nav__item[aria-current='page'] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent-line); }
.stage { min-width: 0; padding: 24px clamp(14px, 3vw, 36px) 40px; }
.pane { max-width: 1320px; margin: 0 auto; }
.pane__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.pane__title { font-size: 24px; letter-spacing: -0.01em; }
.pane__lead { color: var(--muted); max-width: 62ch; margin-top: 4px; }
@media (max-width: 860px) {
	.shell { grid-template-columns: minmax(0, 1fr); }
	.nav { position: fixed; z-index: 30; inset: auto 0 0 0; top: auto; flex-direction: row; justify-content: space-around; height: auto; padding: 6px 6px max(6px, env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); overflow-x: auto; }
	.nav__item { flex: 1; min-width: 52px; font-size: 10.5px; }
	.stage { padding-bottom: 96px; }
	.top__back span, .dbchip small { display: none; }
}

/* ───────── botões e campos ───────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.1s; }
.btn:hover { background: var(--raised); border-color: var(--accent-line); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); border-color: var(--accent); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; font-weight: 500; }
.btn--ghost:hover { background: var(--raised); border-color: var(--line); }
.btn--sm { min-height: 30px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn--icon { min-height: 34px; width: 34px; padding: 0; }
.linklike { border: 0; background: none; padding: 0; color: inherit; font: inherit; font-weight: 700; cursor: pointer; text-align: left; }
.linklike:hover { color: var(--accent-ink); text-decoration: underline; }

.input, .select, textarea.input { width: 100%; min-height: 38px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--sunken); color: var(--text); }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent-ink); outline: 2px solid var(--accent-soft); }
.input--num { width: 9em; font-family: var(--mono); }
.input::placeholder { color: var(--muted); opacity: 0.8; }
.input-group { display: flex; align-items: center; gap: 6px; }
.input-group .input { flex: 1; }
.field { display: grid; gap: 6px; }
.field__label { font-weight: 600; font-size: 13px; }
.field__hint { color: var(--muted); font-size: 12.5px; }
.field__error, .pform__risk { color: var(--danger); font-size: 13px; }
.pform__risk { background: var(--danger-soft); padding: 6px 10px; border-radius: 8px; }
.stack { display: grid; gap: 14px; }
.stack--lg { gap: 20px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { flex: none; width: 40px; height: 22px; margin-top: 2px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background 0.15s; }
.switch__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform 0.15s; }
.switch input:checked + .switch__track { background: var(--accent-ink); }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: 0.5; }
.switch__text { display: grid; gap: 2px; }
.switch__text small { color: var(--muted); font-size: 12.5px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); color: var(--text); font-size: 12px; white-space: nowrap; }
.chip--accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); font-weight: 600; }
.chip--quiet { color: var(--muted); background: transparent; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.note { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--raised); border: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
.note .bi { margin-top: 2px; color: var(--accent-ink); }
.note--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--text); }
.note--warn .bi { color: var(--warn); }
.errbox { display: flex; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent); }
.errbox .bi { color: var(--danger); margin-top: 2px; }
.errbox__detail { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; color: var(--muted); }
details.more > summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; font-size: 13px; padding: 4px 0; }
details.more--box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px; background: var(--surface); }
details.more--box > summary { color: var(--text); }

.kbd-row { display: inline-flex; gap: 4px; }
kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--raised); font-size: 12px; }
.shortcuts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.shortcuts li { display: flex; align-items: center; gap: 12px; }

/* ───────── cartões, estados vazios, esqueleto ───────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 56px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.empty__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); }
.empty__title { font-size: 18px; }
.empty__text { color: var(--muted); max-width: 52ch; }
.skeleton { display: grid; gap: 12px; padding: 6px 0; }
.skeleton i { display: block; height: 16px; border-radius: 8px; background: linear-gradient(90deg, var(--raised) 25%, var(--line) 50%, var(--raised) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ───────── biblioteca ───────── */
.dblist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 14px; }
.dbcard { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color 0.15s, transform 0.15s; }
.dbcard:hover { border-color: var(--accent-line); }
.dbcard--open { border-color: var(--accent-ink); box-shadow: inset 3px 0 0 var(--accent-ink); }
.dbcard__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); }
.dbcard__name { font-size: 16px; overflow-wrap: anywhere; }
.dbcard__chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.dbcard__meta { color: var(--muted); font-size: 12.5px; }
.dbcard__actions { display: flex; align-items: center; gap: 6px; }
@media (max-width: 560px) { .dbcard { grid-template-columns: auto minmax(0, 1fr); } .dbcard__actions { grid-column: 1 / -1; justify-content: flex-end; } }
.storage { margin-top: 22px; display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.storage__text { display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.storage__text strong { color: var(--text); }
.meter { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent-ink); border-radius: 999px; }
.dropzone { position: fixed; inset: 70px 12px 12px 12px; z-index: 40; display: grid; place-content: center; justify-items: center; gap: 6px; border: 2px dashed var(--accent-ink); border-radius: 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); color: var(--accent-ink); text-align: center; pointer-events: none; }
.menu { position: relative; }
.menu > summary { list-style: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; color: var(--muted); }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover, .menu[open] > summary { background: var(--raised); color: var(--text); }
.menu__list { position: absolute; z-index: 20; right: 0; top: 38px; display: grid; gap: 2px; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); }
.menu__list .btn { justify-content: flex-start; width: 100%; }

/* ───────── formulário de PRAGMAs ───────── */
.pform { display: grid; gap: 14px; }
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; border: 0; padding: 0; margin: 0; }
.presets legend { font-weight: 600; font-size: 13px; margin-bottom: 8px; padding: 0; }
.preset { position: relative; cursor: pointer; }
.preset input { position: absolute; opacity: 0; }
.preset__body { display: grid; gap: 3px; height: 100%; padding: 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.preset__body small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.preset input:checked + .preset__body { border-color: var(--accent-ink); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-ink); }
.preset input:focus-visible + .preset__body { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.pgroup { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.pgroup > summary { display: grid; gap: 2px; padding: 12px 14px; cursor: pointer; }
.pgroup > summary span { color: var(--muted); font-size: 12.5px; }
.pgroup__body { display: grid; gap: 0; border-top: 1px solid var(--line); }
.pform__row { display: grid; gap: 7px; padding: 14px; border-bottom: 1px solid var(--line); }
.pform__row:last-child { border-bottom: 0; }
.pform__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.pform__label { font-weight: 600; }
.pform__help { color: var(--muted); font-size: 13.5px; }
.pform__note { font-size: 13px; padding: 6px 10px; border-left: 3px solid var(--accent-ink); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.pform__lock { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.pform__dev { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.pform__dev code { background: var(--sunken); padding: 1px 5px; border-radius: 5px; color: var(--text); }

/* ───────── diálogos e avisos ───────── */
.dlg { width: min(94vw, 560px); max-height: 92dvh; padding: 0; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); overflow: hidden; }
.dlg[open] { display: flex; flex-direction: column; animation: dlg-in 0.18s ease-out; }
.dlg--sm { width: min(94vw, 440px); }
.dlg--lg { width: min(96vw, 760px); }
.dlg--xl { width: min(96vw, 1040px); }
.dlg::backdrop { background: rgb(2 6 4 / 0.62); backdrop-filter: blur(3px); }
.dlg[data-busy] { cursor: progress; }
.dlg__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 6px; }
.dlg__head h2 { font-size: 19px; }
.dlg__lead { padding: 0 18px; color: var(--muted); }
.dlg__body { padding: 14px 18px; overflow: auto; min-height: 0; }
.dlg__foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); background: var(--sunken); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.toasts { position: fixed; z-index: 60; right: 14px; bottom: 14px; display: grid; gap: 8px; width: min(92vw, 380px); }
@media (max-width: 860px) { .toasts { bottom: 78px; } }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); animation: dlg-in 0.2s ease-out; }
.toast__text { flex: 1; font-size: 14px; }
.toast--ok .bi:first-child { color: var(--accent-ink); }
.toast--error { border-color: var(--danger); }
.toast--error .bi:first-child { color: var(--danger); }
.toast--warn .bi:first-child { color: var(--warn); }

/* ───────── tabela de dados (usada pelas telas) ───────── */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 36ch; overflow: hidden; text-overflow: ellipsis; }
.tbl th { position: sticky; top: 0; background: var(--raised); font-weight: 600; z-index: 1; }
.tbl tbody tr:hover { background: var(--accent-soft); }
.tbl .num { text-align: right; font-family: var(--mono); }
.tbl .null { color: var(--muted); font-style: italic; }
.mono { font-family: var(--mono); }

/* ───────── abertura (a versão completa vem de beluga-splash.css) ───────── */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); }
.splash__box { display: grid; gap: 14px; justify-items: center; width: min(86vw, 360px); text-align: center; }
.splash__title { font-size: 34px; letter-spacing: 0.02em; }
.splash__label { color: var(--muted); font-size: 13px; }
.splash__bar { width: 100%; height: 6px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.splash__bar i { display: block; width: 0; height: 100%; background: var(--accent); transition: width 0.25s ease; }

.foot { margin-top: auto; padding: 22px clamp(14px, 3vw, 36px) 90px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: grid; gap: 14px; }
.foot a { color: inherit; }

@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }
html[data-motion='reduced'] * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }

/* ───────── Ajustes: barra de seções ───────── */
.subnav { display: flex; gap: 4px; margin-bottom: 18px; padding: 4px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.subnav__item { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13.5px; white-space: nowrap; cursor: pointer; }
.subnav__item:hover { background: var(--raised); color: var(--text); }
.subnav__item[aria-current='page'] { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-line); }

/* barra de cima em tela estreita: o banco aberto desce para uma segunda linha (senão a página alarga e o menu de baixo fica clicável só em parte) */
@media (max-width: 560px) {
	.top { flex-wrap: wrap; gap: 8px 6px; }
	.tools { margin-left: auto; }
	.dbchip { order: 10; flex: 1 1 calc(100% - 44px); margin-left: 0; max-width: none; min-width: 0; }
	.dbclose { order: 11; }
}
