/* VideoFlow — painel. Direção: sala de edição/broadcast. Grafite quente,
   luz "tally" âmbar como acento, números em mono. */
:root {
  --bg: #12100e;
  --bg-2: #1a1714;
  --panel: #201c18;
  --panel-2: #29241f;
  --line: #3a332b;
  --line-2: #4a4137;
  --ink: #f3ece2;
  --ink-2: #b9ad9d;
  --ink-3: #85796a;
  --tally: #ffb020;
  --tally-ink: #1a1306;
  --rec: #ff4d3d;
  --ok: #5fd08a;
  --radius: 12px;
  --display: "Bricolage Grotesque", ui-sans-serif, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255,176,32,.07), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 1px, transparent 1px 3px),
    var(--bg);
  color: var(--ink); font: 400 14.5px/1.45 var(--display); -webkit-font-smoothing: antialiased;
}
a { color: var(--tally); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; background: rgba(18,16,14,.6); backdrop-filter: blur(6px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; padding: 4px 6px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--tally); display: grid; place-items: center; box-shadow: 0 0 22px rgba(255,176,32,.35); }
.brand-mark svg { width: 13px; fill: var(--tally-ink); margin-left: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font: 500 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .14em; color: var(--ink-3); padding: 10px 8px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--panel); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 2px 0 0 var(--tally); }
.side-foot { margin-top: auto; font: 11px/1.4 var(--mono); color: var(--ink-3); padding: 0 8px; }
.side-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.side-foot .dot.off { background: var(--ink-3); }

.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head h1 { font-size: clamp(26px, 3.2vw, 38px); line-height: 1; margin: 0; font-weight: 800; letter-spacing: -.03em; }
.head .crumb { font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .14em; color: var(--ink-3); margin-bottom: 8px; }
.head .crumb a { color: var(--ink-3); text-decoration: none; }
.head .crumb a:hover { color: var(--tally); }
.head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* componentes */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--panel); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--tally); color: var(--tally-ink); border-color: var(--tally); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--tally); }
.btn-danger { color: var(--rec); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .seg button:focus-visible { outline: 2px solid var(--tally); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.card { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid-proj { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.proj { padding: 18px; display: flex; flex-direction: column; gap: 14px; text-decoration: none; color: var(--ink); transition: transform .18s, border-color .18s; animation: rise .4s both; }
.proj:hover { transform: translateY(-2px); border-color: var(--line-2); }
.proj h3 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.proj .stats { display: flex; gap: 18px; font: 12px var(--mono); color: var(--ink-2); }
.proj .stats b { color: var(--ink); font-size: 18px; display: block; font-weight: 500; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--ink-2); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--tally); }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font: 500 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--line); }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tr:hover td { background: rgba(255,255,255,.015); }
.t .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.thumb { width: 38px; aspect-ratio: 9/16; border-radius: 6px; background: #000 center/cover; border: 1px solid var(--line); flex: none; position: relative; overflow: hidden; }
.thumb.h { aspect-ratio: 16/9; width: 64px; }
.vid-cell { display: flex; gap: 12px; align-items: center; }
.vid-cell a { color: var(--ink); font-weight: 700; text-decoration: none; }
.vid-cell a:hover { color: var(--tally); }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 500 11px/1 var(--mono); padding: 5px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); }
.chip.tally { color: var(--tally); border-color: rgba(255,176,32,.4); }
.chip.ok { color: var(--ok); border-color: rgba(95,208,138,.35); }

.empty { padding: 48px 20px; text-align: center; color: var(--ink-2); }
.empty h3 { color: var(--ink); margin: 0 0 6px; font-size: 20px; }

/* formulários */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field small { color: var(--ink-3); font-size: 12px; }
input[type="text"], input[type="url"], input[type="number"], input[type="password"], select, textarea {
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 11px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 70px; font-family: var(--mono); font-size: 12.5px; }
input[type="color"] { width: 42px; height: 34px; padding: 0; border: 1px solid var(--line-2); border-radius: 8px; background: none; cursor: pointer; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .field { flex: 1; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.switch input { appearance: none; width: 36px; height: 21px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.switch input:checked { background: var(--tally); }
.switch input:checked::after { transform: translateX(15px); background: var(--tally-ink); }
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type="text"] { font-family: var(--mono); }

/* editor */
.editor { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 18px; align-items: start; }
.panels { display: flex; flex-direction: column; gap: 8px; }
details.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; }
details.panel > summary { list-style: none; cursor: pointer; padding: 13px 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; margin-left: auto; font: 500 16px var(--mono); color: var(--ink-3); }
details.panel[open] > summary::after { content: "–"; }
details.panel > summary .ix { font: 500 10.5px var(--mono); color: var(--tally); }
details.panel .body { padding: 2px 16px 14px; border-top: 1px solid var(--line); }

.stage { position: sticky; top: 20px; padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.stage-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.monitor { display: flex; justify-content: center; align-items: center; min-width: 0; min-height: 560px; border-radius: 12px; padding: 20px;
  background: repeating-conic-gradient(#191613 0 25%, #1d1a16 0 50%) 0 0/22px 22px; border: 1px solid var(--line); }
.device { transition: width .35s cubic-bezier(.2,.8,.2,1); width: 100%; }
.device.mobile { width: 390px; max-width: 100%; border: 10px solid #0b0a09; border-radius: 34px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.device.desktop { width: 100%; border: 1px solid var(--line-2); border-radius: 10px; background: #f6f3ee; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.device .page { padding: 18px 16px 24px; color: #2a2520; font-family: system-ui, sans-serif; max-height: 720px; overflow: auto; }
.device.desktop .page { padding: 28px; }
.device .page .ph { height: 12px; border-radius: 6px; background: #e3ddd4; margin: 0 auto 8px; max-width: 520px; }
.device .page .ph.t { height: 22px; width: 70%; background: #d6cec2; margin-bottom: 16px; }
.device .slot { margin: 14px auto; }
.tally-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 10px var(--rec); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* modal */
dialog { border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 30px 90px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(8,7,6,.7); backdrop-filter: blur(3px); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.dlg-head h2 { margin: 0; font-size: 19px; }
.dlg-head button { margin-left: auto; }
.dlg-body { padding: 18px 20px; max-height: 70vh; overflow: auto; }
.dlg-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow: auto; font: 12.5px/1.55 var(--mono); color: #f1d9a8; white-space: pre-wrap; word-break: break-all; margin: 0 0 10px; }
.progress { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--tally); transition: width .2s; }

/* analytics */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .l { font: 500 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.kpi .v { font: 500 28px/1.1 var(--mono); margin-top: 10px; letter-spacing: -.02em; }
.kpi .s { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.chart { padding: 18px; margin-bottom: 16px; }
.chart h3 { margin: 0 0 4px; font-size: 16px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { font: 10.5px var(--mono); fill: var(--ink-3); }
.legend { font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

#toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
#toast .msg { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--tally); padding: 11px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: rise .25s both; max-width: 360px; }
#toast .msg.err { border-left-color: var(--rec); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(420px, 100%); padding: 28px; }
.login h1 { font-size: 34px; letter-spacing: -.03em; margin: 18px 0 6px; }
.notice { border: 1px dashed var(--line-2); border-radius: 10px; padding: 12px 14px; color: var(--ink-2); font-size: 13px; margin-bottom: 14px; }
.notice b { color: var(--ink); }

@media (max-width: 980px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .stage { position: static; }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label, .side-foot { display: none; }
  .main { padding: 20px 16px 48px; }
  .monitor { min-height: 0; padding: 10px; }
}

/* consumo estimado */
.meter { position: relative; height: 16px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line-2); margin: 26px 0 8px; }
.meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: 7px; background: var(--ok); transition: width .4s; }
.meter .fill.lvl-50 { background: var(--tally); }
.meter .fill.lvl-70 { background: #ff8a1f; }
.meter .fill.lvl-85, .meter .fill.lvl-limit { background: var(--rec); }
.meter .tick { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 1px dashed var(--ink-3); }
.meter .tick em { position: absolute; top: -18px; left: 0; transform: translateX(-50%); font: 500 10.5px var(--mono); font-style: normal; color: var(--ink-3); white-space: nowrap; }
.meter .tick.limit { border-left: 2px solid var(--rec); }
.meter .tick.limit em { color: var(--rec); top: auto; bottom: -18px; }
.usage-alert { color: #ffb4a8; font-size: 13px; margin: 18px 0 0; }
.usage-banner { display: block; margin: -8px 0 16px; padding: 10px 14px; border-radius: 10px; text-decoration: none; color: var(--ink); font-size: 13px;
  border: 1px solid rgba(255,176,32,.45); background: rgba(255,176,32,.08); }
.usage-banner.lvl-70 { border-color: rgba(255,138,31,.6); background: rgba(255,138,31,.1); }
.usage-banner.lvl-85, .usage-banner.lvl-limit { border-color: rgba(255,77,61,.6); background: rgba(255,77,61,.1); }
