/* ============================================================
   CONSOLE v2 · folha de estilos — tokens do DESIGN-A1.md
   (extraídos do CSS real do console Action1; identidade A1)
   ============================================================ */
@font-face {
  font-family: 'RooftopBook';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/vendor/fonts/rooftop-book.woff2') format('woff2');
}
@font-face {
  font-family: 'RooftopMedium';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/vendor/fonts/rooftop-medium.woff2') format('woff2');
}

:root {
  /* marca (hsl 220 96% 32% = #0337A0) */
  --brand: #0337A0;
  --brand-hover: hsl(220 76% 47%);
  --brand-active: hsl(220 76% 42%);
  --brand-light-bg: #A9CDF1;      /* fundo da tela de login */
  --brand-tint: #EDF2FC;          /* fundo de seleção/ativo suave */
  /* neutros */
  --text: #090A0B;
  --text-muted: #8A8A8A;
  --text-soft: #4A4A4C;
  --white: #FFFFFF;
  --surface: #F7F7F7;
  --border: #D4D4D4;
  --border-soft: #E7E7E7;
  /* semáforo */
  --ok: #07BC0C;
  --ok-tint: #EAF8EA;
  --warn: #F1C40F;
  --warn-tint: #FDF6DE;
  --danger: #E74C3C;
  --danger-hover: hsl(0 75% 46%);
  --danger-tint: #FBEAE8;
  --off: #9CA3AF;
  /* forma */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 20px;
  /* tipografia (escala A1: lg16 md14 sm12) */
  --font: 'RooftopBook', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-accent: 'RooftopMedium', var(--font);
  --t-lg: 16px; --t-md: 14px; --t-sm: 12px; --t-xs: 11px;
  --t-title: 24px; --t-h: 20px;
  /* controles */
  --ctl-h: 40px;      /* controle padrão interno (login usa 48) */
  --ctl-h-lg: 48px;
  /* layout */
  --sidebar-w: 236px;
  --topbar-h: 56px;
  --tr: 160ms cubic-bezier(0, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--t-md);
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
::selection { background: var(--brand-tint); }

/* ---------- botões (idioma A1: raio 6px, altura generosa) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--ctl-h); padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: transparent; color: var(--text);
  font-size: var(--t-md); font-weight: 500; font-family: var(--font-accent);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background var(--tr), border-color var(--tr), color var(--tr), box-shadow var(--tr);
}
.btn:hover { background: rgba(0,0,0,.04); }
.btn:active { background: rgba(0,0,0,.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:active { background: var(--brand-active); }
.btn-outline { border-color: var(--brand); color: var(--brand); background: #fff; }
.btn-outline:hover { background: var(--brand-tint); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: #fff; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 10px; font-size: var(--t-sm); gap: 6px; }
.btn-lg { height: var(--ctl-h-lg); font-size: var(--t-lg); }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r-sm); border: none; background: transparent;
  cursor: pointer; color: var(--text-soft); transition: background var(--tr);
}
.icon-btn:hover { background: rgba(0,0,0,.06); }
.btn svg { flex: 0 0 auto; }

/* ---------- inputs (borda #D4D4D4, raio 6px) ---------- */
.input, select.input, textarea.input {
  width: 100%; height: var(--ctl-h); padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: #fff; color: var(--text);
  font-family: var(--font); font-size: var(--t-md);
  outline: none; transition: border-color var(--tr), box-shadow var(--tr);
}
.input::placeholder { color: var(--text-muted); }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(3,55,160,.12); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A8A8A' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: var(--t-sm); font-weight: 500; color: var(--text-soft); margin-bottom: 6px; font-family: var(--font-accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- cartões ---------- */
.card {
  background: #fff; border: 1px solid var(--border-soft); border-radius: var(--r-lg);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { margin: 0 0 4px; font-size: var(--t-h); font-weight: 600; letter-spacing: -.01em; }
.card-sub { margin: 0 0 16px; color: var(--text-muted); font-size: var(--t-sm); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .card-title { margin: 0; }
.card-head .grow { flex: 1; }

/* ---------- layout shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto; background: #fff;
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 16px; border-bottom: 1px solid var(--border-soft);
}
.sidebar .logo b { font-family: var(--font-accent); font-size: 17px; letter-spacing: .01em; color: var(--text); }
.sidebar .logo .mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px; flex: 0 0 auto;
}
.nav { flex: 1; overflow-y: auto; padding: 12px 12px; }
.nav-section { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 14px 12px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin-bottom: 2px; border-radius: var(--r-sm);
  color: var(--text-soft); font-size: var(--t-md); font-weight: 500;
  transition: background var(--tr), color var(--tr);
}
.nav a:hover { background: var(--surface); text-decoration: none; }
.nav a.active { background: var(--brand-tint); color: var(--brand); font-family: var(--font-accent); }
.nav a svg { flex: 0 0 auto; opacity: .85; }
.sidebar-foot { border-top: 1px solid var(--border-soft); padding: 12px 14px; }
.userchip { display: flex; align-items: center; gap: 10px; }
.userchip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-tint); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: 0 0 auto;
}
.userchip .who { min-width: 0; flex: 1; }
.userchip .who b { display: block; font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip .who span { font-size: var(--t-xs); color: var(--text-muted); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: 0 0 auto; background: #fff; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.topbar .crumb { color: var(--text-muted); font-size: var(--t-sm); }
.env-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--warn-tint); color: #7a5b00; border: 1px solid #ecd98f;
  font-size: var(--t-xs); font-weight: 700; letter-spacing: .04em;
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.env-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #d9a400; }
.content { padding: 24px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------- badges/chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: var(--t-xs); font-weight: 600; white-space: nowrap;
}
.chip-ok { background: var(--ok-tint); color: #067a0a; }
.chip-off { background: #F0F1F3; color: #5B6472; }
.chip-warn { background: var(--warn-tint); color: #7a5b00; }
.chip-danger { background: var(--danger-tint); color: #b03024; }
.chip-info { background: var(--brand-tint); color: var(--brand); }
.chip-neutral { background: #F0F1F3; color: #4A4A4C; }
.dot-st { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot-online { background: var(--ok); box-shadow: 0 0 0 3px rgba(7,188,12,.15); }
.dot-offline { background: var(--off); }
.dot-warn { background: var(--warn); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .94em; }
.dim { color: var(--text-muted); }
.small { font-size: var(--t-sm); }

/* ---------- tabelas (densas, estilo console pro) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--r-lg); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 10px 14px; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border-soft);
  background: #FBFBFB; white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--tr); }
.tbl tbody tr:hover { background: #FAFBFD; }
.tbl td.actions { text-align: right; white-space: nowrap; }
.tbl td.actions .btn { margin-left: 6px; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* ---------- stats dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--border-soft); border-radius: var(--r-lg); padding: 16px 18px; }
.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { color: var(--text-muted); font-size: var(--t-sm); margin-top: 4px; }
.stat .ic { float: right; margin-top: 2px; color: var(--brand); opacity: .8; }

/* ---------- feed monoespaçado (canal/egress) ---------- */
.feed {
  background: #10151c; color: #c8d3e0; border-radius: var(--r-md); padding: 14px 16px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.7;
  max-height: 420px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}
.feed .ln-ok { color: #7de38a; }
.feed .ln-id { color: #8ab8ff; }
.feed .ln-k { color: #ffd479; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(9,10,11,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px;
  overflow-y: auto;
}
.modal {
  background: #fff; border-radius: var(--r-lg); width: 520px; max-width: 100%;
  padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: pop 140ms ease-out;
}
@keyframes pop { from { transform: translateY(6px) scale(.995); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 6px; font-size: var(--t-h); font-weight: 600; }
.modal .sub { color: var(--text-muted); font-size: var(--t-sm); margin: 0 0 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.badge-nome { background: var(--brand-tint); color: var(--brand); border-radius: var(--r-sm); padding: 8px 12px; font-size: var(--t-sm); margin-top: 8px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast {
  background: #10151c; color: #fff; border-radius: var(--r-md); padding: 12px 16px;
  font-size: var(--t-sm); box-shadow: 0 8px 28px rgba(0,0,0,.3); display: flex; gap: 10px; align-items: flex-start;
  animation: slidein 160ms ease-out;
}
@keyframes slidein { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--brand); }
.toast b { display: block; margin-bottom: 2px; font-size: var(--t-md); }

/* ---------- login (layout A1: azul-claro + cartão central) ---------- */
.login-page {
  min-height: 100vh; background: var(--brand-light-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px;
}
.login-logo { font-family: var(--font-accent); font-size: 34px; color: var(--brand); margin-bottom: 28px; letter-spacing: -.01em; }
.login-card { width: 430px; max-width: 100%; background: #fff; border-radius: var(--r-lg); padding: 28px 28px 24px; box-shadow: 0 10px 40px rgba(3,55,160,.10); }
.login-card h1 { margin: 0 0 20px; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.login-card .input { height: var(--ctl-h-lg); font-size: var(--t-lg); }
.login-card .forgot { text-align: right; margin: -6px 0 14px; font-size: var(--t-sm); }
.pw-toggle { position: relative; }
.pw-toggle .input { padding-right: 62px; }
.pw-toggle .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.login-demo {
  margin-top: 16px; background: #F4F7FD; border: 1px dashed #b9c8e8; border-radius: var(--r-md);
  font-size: var(--t-xs); color: #41506e; padding: 10px 12px; line-height: 1.6;
}
.login-foot { margin-top: 22px; color: #3c4c66; font-size: var(--t-xs); display: flex; gap: 8px; align-items: center; }

/* ---------- player (stage escura, estilo player A1) ---------- */
.player-page { height: 100vh; display: flex; flex-direction: column; background: #0B0D12; color: #E9ECF1; }
.player-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: #12151D; border-bottom: 1px solid #242A36; flex-wrap: wrap;
}
.player-head b { font-size: var(--t-md); }
.player-cid {
  font-family: ui-monospace, Menlo, monospace; font-size: var(--t-sm); color: #9FE0A0;
  background: #0D2018; border: 1px solid #1D3B2C; padding: 4px 10px; border-radius: 7px;
}
.player-st { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font-size: var(--t-sm); color: #97A0B2; }
.player-led { width: 9px; height: 9px; border-radius: 50%; background: #515A6B; flex: 0 0 auto; }
.player-led.on { background: #2ECC71; box-shadow: 0 0 0 4px rgba(46,204,113,.14); }
.player-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; min-height: 0; }
.player-framebox { aspect-ratio: 16/9; width: min(100%, calc((100vh - 170px) * 16 / 9)); background: #000; border-radius: 10px; overflow: hidden; box-shadow: 0 12px 48px rgba(0,0,0,.55); cursor: crosshair; position: relative; }
.player-framebox canvas, .player-framebox img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.player-foot {
  height: 34px; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  color: #6B7486; font-size: var(--t-xs); border-top: 1px solid #242A36; background: #0E1118; white-space: nowrap; overflow: hidden;
}
.player-foot .hint { margin-left: auto; opacity: .85; }
.gd-root { position: absolute; inset: 0; }

/* ---------- misc ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kv { display: grid; grid-template-columns: 190px 1fr; row-gap: 9px; column-gap: 12px; font-size: var(--t-md); }
.kv dt { color: var(--text-muted); font-size: var(--t-sm); padding-top: 1px; }
.kv dd { margin: 0; word-break: break-word; }
.banner {
  display: flex; align-items: center; gap: 10px; border-radius: var(--r-md);
  padding: 12px 16px; font-size: var(--t-sm); margin-bottom: 16px; flex-wrap: wrap;
}
.banner-warn { background: var(--warn-tint); border: 1px solid #ecd98f; color: #6b4f00; }
.banner-info { background: var(--brand-tint); border: 1px solid #c4d3f0; color: #1d3d7a; }
.banner .grow { flex: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 18px; }
.tabs button {
  all: unset; cursor: pointer; padding: 10px 14px; font-size: var(--t-md); font-weight: 500; color: var(--text-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--tr), border-color var(--tr);
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-family: var(--font-accent); }
.checkrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border-soft); border-radius: var(--r-sm); margin-bottom: 8px; cursor: pointer; }
.checkrow input { width: 16px; height: 16px; accent-color: var(--brand); }
.mono-line { display: flex; align-items: center; gap: 8px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(3,55,160,.25); border-top-color: var(--brand);
  border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- responsivo (laptop 1280 e menores) ---------- */
@media (max-width: 1100px) {
  :root { --sidebar-w: 200px; }
  .content { padding: 18px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 150px 1fr; }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; }
  .sidebar .logo { border-bottom: none; border-right: 1px solid var(--border-soft); padding: 12px 14px; }
  .nav { display: flex; overflow-x: auto; padding: 8px; flex: 1; }
  .nav-section { display: none; }
  .nav a { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .grid-2, .grid-3, .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
}

/* ===== TEMA ESCURO (default) — paleta escura A1; light = original ===== */
html[data-theme="dark"] :root {
  --brand: #4C8DFF;
  --brand-hover: hsl(218 99% 60%);
  --brand-active: hsl(220 96% 54%);
  --brand-light-bg: #0B0F17;      /* fundo da tela de login */
  --brand-tint: #172A4C;
  --text: #E8EAED;
  --text-muted: #8B93A3;
  --text-soft: #B7BFCC;
  --surface: #0E1116;
  --border: #2A3140;
  --border-soft: #202634;
  --ok-tint: rgba(7,188,12,.14);
  --warn-tint: rgba(241,196,15,.13);
  --danger-tint: rgba(231,76,60,.15);
}
html[data-theme="dark"] body { background: #0E1116; }
html[data-theme="dark"] .card, html[data-theme="dark"] .stat,
html[data-theme="dark"] .table-wrap, html[data-theme="dark"] .modal,
html[data-theme="dark"] .login-card, html[data-theme="dark"] .input { background: #151A22; }
html[data-theme="dark"] .input { color: var(--text); border-color: var(--border-soft); }
html[data-theme="dark"] .input:focus { box-shadow: 0 0 0 3px rgba(76,141,255,.18); }
html[data-theme="dark"] .sidebar { background: #12151D; }
html[data-theme="dark"] .topbar { background: #12151D; border-bottom-color: #242A36; }
html[data-theme="dark"] .btn:hover { background: rgba(255,255,255,.07); }
html[data-theme="dark"] .btn:active { background: rgba(255,255,255,.1); }
html[data-theme="dark"] .icon-btn:hover { background: rgba(255,255,255,.08); }
html[data-theme="dark"] .btn-outline { background: transparent; }
html[data-theme="dark"] .btn-danger { background: transparent; }
html[data-theme="dark"] .chip-off, html[data-theme="dark"] .chip-neutral { background: #232936; color: #A5ADBB; }
html[data-theme="dark"] .chip-warn { color: #E5C15A; border-color: rgba(241,196,15,.45); }
html[data-theme="dark"] .banner-warn { color: #E5C15A; border-color: rgba(241,196,15,.45); }
html[data-theme="dark"] .banner-info { border-color: #2E4A7A; color: #BCD2F7; }
html[data-theme="dark"] .tbl thead th { background: #171D27; }
html[data-theme="dark"] ::selection { background: rgba(76,141,255,.35); }
