:root {
  color-scheme: dark;
  --bg: #0e1320;
  --bar: #0a0e19;
  --panel: #171d2d;
  --panel-2: #1f2740;
  --field: #0f1524;
  --line: #2a3350;
  --fg: #e7ebf5;
  --muted: #8d98b2;
  --accent: #5b9bff;
  --accent-soft: rgba(91, 155, 255, .16);
  --bad: #ff7a7a;
  --ok: #55d6a0;
  --warn: #f2b45a;
  --track: #28324d;
  /* aliases usados por dashboard.css */
  --card: var(--panel);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 28px; font-weight: 600; margin: 0 0 18px; }
h2 { font-size: 17px; margin: 0 0 12px; }
code { background: var(--field); padding: 1px 6px; border-radius: 5px; }
.muted { color: var(--muted); }
.inline { display: inline; }
mark { background: rgba(242, 180, 90, .28); color: #ffd99a; padding: 0 3px; border-radius: 3px; }
.sev-high { color: var(--bad); font-weight: 600; }
.sev-medium { color: var(--warn); font-weight: 600; }
.sev-low { color: var(--ok); font-weight: 600; }

/* ---- estrutura: barra superior + menu lateral + conteúdo ---- */
body.app { display: grid; grid-template-columns: 104px minmax(0, 1fr); grid-template-rows: 60px 1fr; grid-template-areas: "top top" "side main"; min-height: 100vh; }
.topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: var(--bar); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 700; font-size: 20px; letter-spacing: .2px; }
.brand .logo { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-right form { margin: 0; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-connected i { background: var(--ok); }
.status-reconnecting i { background: var(--warn); }
.status-invalid_session i { background: var(--bad); }

.sidebar { grid-area: side; background: var(--bar); border-right: 1px solid var(--line); position: sticky; top: 60px; height: calc(100vh - 60px); }
.sidebar nav { display: flex; flex-direction: column; }
.nav-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 6px 14px; color: var(--muted); text-decoration: none; font-size: 12px; text-align: center; }
.nav-item:hover { color: var(--fg); background: rgba(255, 255, 255, .03); }
.nav-item.active { color: var(--fg); background: var(--panel-2); }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.nav-item.active .icon { color: var(--accent); }

main.content { grid-area: main; padding: 28px 36px 48px; min-width: 0; }
body.auth { display: grid; place-items: center; min-height: 100vh; }
body.auth main.content { grid-area: auto; width: min(420px, 92vw); padding: 0; }
body.auth label { display: grid; gap: 6px; }
body.auth input { width: 100%; }
body.auth button { width: 100%; margin-top: 6px; }

/* ---- cartões e formulários ---- */
section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; margin-bottom: 20px; }
label { display: block; margin: 8px 0; color: var(--fg); }
input, select, button, textarea { font: inherit; color: var(--fg); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox], input[type=radio] { padding: 0; accent-color: var(--accent); }
button { background: var(--accent); border-color: var(--accent); color: #07101f; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.plain { background: transparent; color: var(--fg); border-color: var(--line); font-weight: 500; }
button.plain:hover { background: rgba(255, 255, 255, .05); filter: none; }
fieldset { border: 0; padding: 0; margin: 0; }
fieldset[disabled] { opacity: .45; }
dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; }
dialog::backdrop { background: rgba(4, 7, 14, .65); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }

.banner { padding: 11px 16px; border-radius: 10px; border: 1px solid transparent; }
.banner.ok { background: rgba(85, 214, 160, .12); color: var(--ok); border-color: rgba(85, 214, 160, .3); }
.banner.error { background: rgba(255, 122, 122, .12); color: var(--bad); border-color: rgba(255, 122, 122, .3); }
.info-banner { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 20px; margin-bottom: 18px; color: var(--fg); }
.info-banner svg { color: var(--muted); flex: none; }
.info-banner span { flex: 1; }
.info-banner .close { background: transparent; border: 0; color: var(--muted); padding: 2px 8px; font-size: 16px; font-weight: 400; }
.info-banner[hidden] { display: none; }

/* ---- telas estreitas: o menu vira uma faixa no topo ---- */
@media (max-width: 800px) {
  body.app { grid-template-columns: 1fr; grid-template-rows: 60px auto 1fr; grid-template-areas: "top" "side" "main"; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .nav-item { flex: 1 0 84px; padding: 10px 6px; }
  .nav-item.active::before { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 3px; }
  main.content { padding: 18px 16px 40px; }
  .status { display: none; }
}

.acct { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; background: var(--panel-2); }
.acct header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 6px; }
.acct details { margin-top: 10px; }
.acct form.row, details > form.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 8px 0; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip-ok { background: rgba(85, 214, 160, .15); color: var(--ok); }
.chip-bad { background: rgba(255, 122, 122, .15); color: var(--bad); }
.fine { font-size: 12px; }
button.danger { color: var(--bad); border-color: rgba(255, 122, 122, .4); }
summary { cursor: pointer; color: var(--accent); }

body.app.restricted { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
.who { color: var(--fg); text-decoration: none; font-weight: 600; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 8px; }
.codes { list-style: none; display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 32px; padding: 0; }
.codes code { font-size: 16px; letter-spacing: 1px; }

/* Cores das ontologias */
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; border: 1px solid rgba(255, 255, 255, .25); }
fieldset.colors { border: 0; padding: 0; margin: 10px 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
fieldset.colors legend { padding: 0; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch .dot { width: 24px; height: 24px; }
.swatch input:checked + .dot { outline: 2px solid var(--fg); outline-offset: 2px; }
.swatch input:focus-visible + .dot { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch.auto input { position: static; opacity: 1; width: auto; height: auto; }
