:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --line: #2c2c2a;
  --axis: #383835;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --accent: #ffe14d;
  --accent-ink: #17142b;
  --link: #86b6ef;
  --series-1: #3987e5;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--link); }
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, textarea { font: inherit; }
.loading { padding: 48px; color: var(--muted); }

/* estrutura */
#app { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 24px; max-width: 1480px; margin: 0 auto; padding: 16px; min-height: 100vh; }
.side { position: sticky; top: 16px; height: calc(100vh - 32px); display: flex; flex-direction: column; align-items: stretch; gap: 20px; padding: 18px 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.brand strong { font-size: 16px; line-height: 1.2; }
.brand span { display: none; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a, .navbtn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 2px; border: 0; border-radius: 12px; background: none; color: var(--ink-2); text-decoration: none; font: inherit; font-size: 11px; line-height: 1.2; text-align: center; cursor: pointer; }
.side .icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side nav a .count { position: absolute; top: 4px; right: 12px; }
.side nav a:hover, .navbtn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.side nav a.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.side nav a.on .icon { stroke: var(--accent); }
.navbtn:disabled { opacity: 0.5; cursor: default; }
.count { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--axis); color: var(--ink); font-size: 12px; font-weight: 600; text-align: center; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-foot .status { flex-direction: column; gap: 4px; font-size: 10.5px; line-height: 1.25; text-align: center; color: var(--muted); }
main { padding: 16px 8px 72px; width: 100%; }

/* texto */
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 26px; line-height: 1.2; }
.page-head p { color: var(--muted); margin-top: 4px; }
h2 { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.prose p + p { margin-top: 10px; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }

/* peças */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel > h2 { margin-bottom: 12px; }
.panel + .panel { margin-top: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--axis); background: var(--surface-2); color: var(--ink); cursor: pointer; text-decoration: none; font-size: 14px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }
.btn.small { padding: 3px 10px; font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea { width: 100%; min-height: 76px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--axis); background: var(--page); color: var(--ink); resize: vertical; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--axis); color: var(--ink); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--axis); color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.status i { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font-style: normal; font-size: 10px; font-weight: 800; color: #0d0d0d; background: var(--muted); flex: none; }
.status.good i { background: var(--good); color: #fff; }
.status.warning i { background: var(--warning); }
.status.serious i { background: var(--serious); }
.status.critical i { background: var(--critical); color: #fff; }

/* indicadores */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 600; line-height: 1.2; }
.tile .sub { color: var(--muted); font-size: 12px; }
.panel .tile { background: var(--surface-2); border-color: transparent; }

/* pendências */
.todo { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 14px; }
.todo .panel { max-height: 240px; overflow-y: auto; }
.todo .panel + .panel { margin-top: 0; }
.todo .panel.you { border-color: var(--accent); }
.todo li { padding: 8px 0; border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; padding-top: 0; }
.todo li a { color: var(--ink); font-weight: 600; text-decoration: none; }
.todo li a:hover { text-decoration: underline; }

/* início */
.wip { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; overflow: hidden; }
a.card:hover { border-color: var(--muted); }
.wcard { display: grid; grid-template-columns: 92px minmax(0, 1fr); }
.wcard .thumb { display: block; width: 92px; height: 100%; min-height: 136px; object-fit: cover; object-position: center 35%; background: #000; }
.wcard .thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; }
.card-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 14px; }
.card-body strong { line-height: 1.3; }
.meter { display: inline-flex; gap: 2px; vertical-align: middle; }
.meter i { width: 12px; height: 6px; border-radius: 2px; background: var(--axis); }
.meter i.on { background: var(--accent); }
.table-scroll { overflow-x: auto; }
.table-foot { margin-top: 12px; }
.nowrap { white-space: nowrap; }
.vtable td { vertical-align: middle; padding: 7px 14px 7px 0; }
.vtable th:last-child, .vtable td:last-child { padding-right: 0; }
.vtable tbody tr:hover { background: var(--surface-2); }
.vtable td.num { width: 44px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vtable .vlink { display: flex; align-items: center; gap: 12px; min-width: 240px; color: var(--ink); text-decoration: none; }
.vtable .vlink > span { display: flex; flex-direction: column; min-width: 0; }
.vtable .vlink:hover strong { text-decoration: underline; }
.vtable .vlink strong { line-height: 1.3; font-weight: 600; }
.vtable .mini { display: block; width: 34px; height: 46px; border-radius: 6px; object-fit: cover; object-position: center 35%; background: var(--surface-2); flex: none; }

/* página do vídeo */
.video-page { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 32px; align-items: start; }
.player { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.phone { position: relative; width: 300px; aspect-ratio: 9 / 16; border-radius: 26px; overflow: hidden; background: #000; box-shadow: 0 0 0 7px var(--surface-2), 0 20px 50px rgba(0, 0, 0, 0.6); }
.phone video { width: 100%; height: 100%; display: block; object-fit: cover; }
.phone .empty { display: grid; place-items: center; height: 100%; color: var(--muted); padding: 24px; text-align: center; }
.safe { position: absolute; inset: 0; pointer-events: none; }
.safe i { position: absolute; background: rgba(208, 59, 59, 0.3); border: 1px solid rgba(255, 255, 255, 0.6); }
.safe .top { left: 0; right: 0; top: 0; height: 11.5%; }
.safe .bottom { left: 0; right: 0; bottom: 0; height: 25%; }
.safe .right { right: 0; top: 45%; bottom: 25%; width: 11%; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--ink); }
.steps { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; }
.steps li { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.steps li i { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--axis); font-style: normal; font-size: 10px; font-weight: 800; }
.steps li.done { color: var(--ink-2); }
.steps li.done i { background: var(--axis); color: var(--ink); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now i { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.next { border-color: var(--accent); }
.capa-box { display: flex; gap: 16px; align-items: flex-start; }
.capa-box img { width: 120px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 8px; flex: none; }
.tabs { margin-top: 18px; }
.tablist { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: thin; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warning); color: var(--accent-ink); font-size: 11px; font-weight: 700; }
.tab-panel[hidden] { display: none; }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; }
dl.facts dt { color: var(--muted); }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }
.beat { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; }
.beat .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 2px; }
.beat .visual { color: var(--muted); font-size: 13px; margin-top: 4px; }
.timeline > li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.timeline > li:first-child { border-top: 0; padding-top: 0; }
.timeline .when { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.timeline .who { font-weight: 600; }
audio { width: 100%; height: 36px; margin-top: 6px; }
.copy-box { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }

/* gráficos */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1); opacity: 0.1; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .end { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .tip { position: absolute; top: 0; pointer-events: none; background: var(--surface-2); border: 1px solid var(--axis); border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
.chart .tip strong { display: block; font-size: 14px; }
.chart .tip span { color: var(--muted); }
details.table-view { margin-top: 10px; }
details.table-view summary { cursor: pointer; color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 12px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
thead th { border-top: 0; color: var(--muted); font-weight: 500; font-size: 13px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }

/* ideias e canal */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.grid-cards .panel + .panel { margin-top: 0; }
.ideia { display: flex; flex-direction: column; gap: 8px; }
.ideia details.mais summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.ideia details.mais[open] summary { margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; margin-bottom: 14px; }
.grid-2 .panel + .panel { margin-top: 0; }
.ideia blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--accent); color: var(--ink); }
.ideia .actions { margin-top: auto; padding-top: 6px; }
.section-title { margin: 26px 0 10px; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 12px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--axis); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); white-space: pre-wrap; font-size: 14px; }
.toast.error { border-color: var(--critical); }
.toast[hidden] { display: none; }

@media (max-width: 1000px) {
  #app { grid-template-columns: 1fr; gap: 12px; padding: 12px; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 14px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav a, .navbtn { min-width: 76px; }
  .side-foot { margin: 0; flex-direction: row; align-items: center; flex-wrap: wrap; }
  main { padding: 8px 4px 56px; }
  .video-page { grid-template-columns: 1fr; }
  .player { position: static; }
}

/* automação */
input, select { font: inherit; }
input[type="text"], input[type="password"], input[type="number"], input[type="time"], select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--axis); background: var(--page); color: var(--ink); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.field input[type="text"]:not(.hora-input), .field textarea { width: 100%; }
.num-input { width: 88px; }
.unsaved { position: sticky; top: 12px; z-index: 5; padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--warning); }
.resposta { max-width: 380px; white-space: pre-line; color: var(--ink-2); }
pre.log { max-height: 520px; overflow: auto; margin: 0; padding: 12px; border-radius: 8px; background: var(--page); color: var(--ink-2); font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.side nav a .count { font-size: 10px; }

/* login */
main.login { grid-column: 1 / -1; display: grid; place-items: center; min-height: 80vh; }
main.login form { width: min(340px, 100%); }
main.login input { width: 100%; }
main.login .erro { color: var(--critical); min-height: 1.2em; }
.field > label { display: flex; flex-direction: column; gap: 6px; }
.hora-input { width: 72px; text-align: center; }
.hora-input:invalid { border-color: var(--critical); }
.tiles + .panel { margin-top: 14px; }
.tabs { margin-top: 18px; }

/* Tela do navegador do estúdio (noVNC) */
.tela-navegador {
  width: 100%;
  aspect-ratio: 1366 / 900;
  border: 1px solid var(--line, #ccc);
  border-radius: 8px;
  background: #000;
}
