/* =========================================================================
   Videochamada 1:1 — Fundação de frontend (preview reutilizável)
   Design system + telas do contrato. Sem CDNs; assets vêm de node_modules.
   ========================================================================= */
:root {
  --bg: #0b0f14;
  --bg-2: #0f141c;
  --surface: #141b25;
  --surface-2: #1a2330;
  --surface-3: #212c3b;
  --line: #26313f;
  --line-2: #334154;
  --text: #eaf0f7;
  --muted: #93a3b8;
  --faint: #808fa4;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --accent-ink: #062622;
  --info: #60a5fa;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --danger-strong: #ef4444;
  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --radius-full: 999px;
  --shadow: 0 12px 34px rgba(0, 0, 0, .38);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .28);
  --ring: 0 0 0 3px rgba(45, 212, 191, .35);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  background:
    radial-gradient(900px 500px at 90% -10%, rgba(45, 212, 191, .07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num { font-variant-numeric: tabular-nums; }

/* ------- Layout helpers ------- */
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.grow { flex: 1 1 auto; min-width: 0; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.wrapflex { flex-wrap: wrap; }

/* ------- Top bar (única faixa fixa, <= 64px) ------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: 56px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(11, 15, 20, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 9px; font-weight: 650; }
.topbar .brand svg { color: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar .tb-link { color: var(--muted); font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.topbar .tb-link:hover, .topbar .tb-link[aria-current="page"] { color: var(--text); background: var(--surface-2); text-decoration: none; }

/* ------- Buttons ------- */
.btn {
  --btn-bg: var(--surface-2); --btn-fg: var(--text); --btn-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px;
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-bd); border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .05s ease, opacity .15s ease;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; pointer-events: none; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-bd: transparent; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { --btn-bg: var(--danger-strong); --btn-fg: #fff; --btn-bd: transparent; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { --btn-bg: transparent; --btn-bd: var(--line-2); }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 16px; border-radius: var(--radius); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 52px; height: 52px; min-height: 52px; padding: 0; border-radius: var(--radius-full);
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text);
}
.btn-icon:hover { background: var(--surface-3); }
.btn-icon.off { background: #3a2026; border-color: #5b2a33; color: #ffb4b4; }
.btn-icon.danger { background: var(--danger-strong); border-color: transparent; color: #fff; }
.btn-icon svg { width: 22px; height: 22px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------- Forms / link box ------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.input, .select, .link-box {
  width: 100%; min-height: 42px; padding: 10px 12px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px;
}
.link-box { display: flex; align-items: center; gap: 8px; padding-right: 6px; }
.link-box input {
  flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px;
}
.link-box input:focus { outline: none; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 14px top 19px, right 9px top 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

/* ------- Panels / cards ------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-pad { padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 15px; }
.panel-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 18px; }

/* ------- Badges / pills ------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; border: 1px solid var(--line-2); color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.badge.ok { color: #7ff0c1; border-color: #1c5c46; background: #0d2b22; }
.badge.warn { color: #fcd34d; border-color: #5c4a17; background: #2c2410; }
.badge.danger { color: #ffb4b4; border-color: #5b2a33; background: #2c1519; }
.badge.info { color: #bcd6ff; border-color: #2a4172; background: #131f36; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ------- Media status indicators ------- */
.media-status { display: flex; gap: 10px; flex-wrap: wrap; }
.media-chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-2);
  font-size: 13px; font-weight: 600;
}
.media-chip svg { width: 17px; height: 17px; }
.media-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.media-chip.on { border-color: #1c5c46; background: #0d2b22; color: #aef4d4; }
.media-chip.on .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.media-chip.off { border-color: #5b2a33; background: #2c1519; color: #ffc9c9; }
.media-chip.off .dot { background: var(--danger); }
.media-chip.pending { color: var(--muted); }

/* ------- Call stage ------- */
/* Mobile-first: o palco é a área dominante da conversa. Em telas largas usa
   proporção cinematográfica; em telas estreitas acompanha a altura útil da
   viewport para que os controles nunca saiam do alcance do polegar. */
.call-stage { position: relative; width: 100%; background: #05080c; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 16 / 10; }
.call-stage.mobile { aspect-ratio: 9 / 16; max-width: 380px; margin: 0 auto; }
.video-surface { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(600px 300px at 50% 0%, #16202c, #05080c); }
.video-remote { position: absolute; inset: 0; }
.video-remote .avatar-big { width: 104px; height: 104px; }
.video-local {
  position: absolute; right: 12px; bottom: 104px; width: 30%; max-width: 190px; min-width: 108px;
  aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line-2); background: #0d141c; box-shadow: var(--shadow); z-index: 5;
}
.video-local video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05080c; }
.video-local video { display: none; }
.video-local.has-stream video { display: block; }
.video-local.has-stream .photo { display: none; }
.video-local.has-stream.cam-off video { display: none; }
.video-local.has-stream.cam-off .photo { display: grid; }
.video-local video.mirror { transform: scaleX(-1); }
.selfview video.mirror { transform: scaleX(-1); }
.video-remote video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05080c; display: none; }
.video-remote .photo { position: absolute; inset: 0; }
.video-remote.has-stream video { display: block; }
.video-remote.has-stream .photo { display: none; }
.video-remote.has-stream.peer-cam-off video { display: none; }
.video-remote.has-stream.peer-cam-off .photo { display: grid; }
.remote-name {
  position: absolute; left: 12px; bottom: 12px; z-index: 3;
  font-size: 12px; color: #cddaea; background: rgba(5, 8, 12, .6);
  border: 1px solid var(--line-2); padding: 5px 10px; border-radius: var(--radius-full);
  backdrop-filter: blur(6px);
}
.peer-mic-muted {
  position: absolute; right: 12px; bottom: 12px; z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #ffc9c9;
  background: rgba(44, 21, 25, .82); border: 1px solid #5b2a33;
  padding: 5px 10px; border-radius: var(--radius-full); backdrop-filter: blur(6px);
}
.call-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(5, 8, 12, .94), transparent);
}
.call-topline { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.call-topline .pill { background: rgba(5, 8, 12, .62); border: 1px solid var(--line-2); border-radius: var(--radius-full); padding: 6px 12px; font-size: 12.5px; font-weight: 600; backdrop-filter: blur(6px); }

/* Avatar / placeholders */
.avatar {
  border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(160deg, #243447, #16202c);
  color: #9fb3c8; font-weight: 700; border: 1px solid var(--line-2);
  width: 46px; height: 46px; font-size: 16px; flex: none;
}
.avatar-big { width: 84px; height: 84px; font-size: 30px; }
.photo {
  width: 100%; height: 100%;
  background:
    radial-gradient(120% 90% at 30% 20%, #3b5168, #1b2836 70%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 2px, transparent 2px 6px);
  display: grid; place-items: center;
}
.photo .label { text-align: center; font-size: 12px; color: #cddaea; background: rgba(5,8,12,.5); padding: 4px 10px; border-radius: var(--radius-full); }

/* ------- Overlays de estado ------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 28px;
  background: rgba(8, 12, 17, .82); backdrop-filter: blur(3px);
}
.overlay h2 { font-size: 20px; }
.overlay p { color: var(--muted); max-width: 360px; }

/* ------- Spinner ------- */
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
.wait-dots span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.wait-dots span:nth-child(2) { animation-delay: .15s; }
.wait-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ------- State pages (T3/T4/T5/T6) ------- */
.state-page { min-height: 100vh; display: flex; flex-direction: column; }
.state-main { flex: 1; display: grid; place-items: center; padding: 40px 20px; }
.state-card { width: 100%; max-width: 460px; text-align: center; padding: 34px 28px; }
.state-icon { width: 64px; height: 64px; border-radius: var(--radius); display: grid; place-items: center; margin: 0 auto 16px; background: var(--surface-2); border: 1px solid var(--line-2); }
.state-icon svg { width: 30px; height: 30px; }
.state-icon.warn { color: var(--warn); border-color: #5c4a17; background: #2c2410; }
.state-icon.danger { color: var(--danger); border-color: #5b2a33; background: #2c1519; }
.state-icon.info { color: var(--info); border-color: #2a4172; background: #131f36; }
.state-card h1 { font-size: 22px; margin-bottom: 10px; }
.state-card p { color: var(--muted); margin-bottom: 22px; }
.rec-list { text-align: left; margin: 18px auto 22px; max-width: 320px; display: grid; gap: 8px; }
.rec-list .row { gap: 10px; color: var(--muted); font-size: 13.5px; }
.rec-list .mark { color: var(--ok); font-weight: 800; }

/* ------- Home (T1) ------- */
.home { min-height: 100vh; display: flex; flex-direction: column; }
.home-main { flex: 1; display: grid; place-items: center; text-align: center; padding: 48px 20px; }
.home-inner { max-width: 520px; }
.home-logo { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; margin: 0 auto 22px; background: var(--surface); border: 1px solid var(--line-2); color: var(--accent); box-shadow: var(--shadow); }
.home-logo svg { width: 38px; height: 38px; }
.home h1 { font-size: clamp(30px, 6vw, 44px); letter-spacing: -.02em; }
.home .lead { color: var(--muted); font-size: clamp(15px, 3.4vw, 17px); margin: 14px auto 28px; max-width: 420px; }
.home-meta { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-top: 34px; color: var(--faint); font-size: 12.5px; }
.home-meta .row { gap: 7px; }
.home-meta svg { width: 15px; height: 15px; color: var(--muted); }
.foot { padding: 18px 20px; text-align: center; color: var(--faint); font-size: 12px; border-top: 1px solid var(--line); }

/* ------- Preparation (T2.1) ------- */
.prep { display: grid; grid-template-columns: 1.05fr .95fr; gap: 22px; align-items: start; padding: 26px 0 40px; }
.prep-copy { display: flex; flex-direction: column; gap: 18px; }
.prep h1 { font-size: clamp(24px, 4vw, 30px); }
.preview-panel { position: relative; }
.preview-frame { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line-2); background: #05080c; }
.preview-frame .selfview { position: absolute; inset: 0; }
.preview-frame .selfview .photo { height: 100%; }
.preview-note { position: absolute; left: 10px; bottom: 10px; font-size: 11.5px; color: #cddaea; background: rgba(5,8,12,.55); padding: 4px 9px; border-radius: var(--radius-full); }
.preview-permission { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: rgba(8,12,17,.9); gap: 10px; padding: 20px; }
.preview-permission .spinner { margin: 0 auto 10px; }
.preview-panel .media-status { margin-top: 14px; }

/* ------- Dashboard / painel ------- */
.page-head { padding: 26px 0 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 5px; }
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px; margin-bottom: 18px; }
.filterbar .field { min-width: 150px; }
.filterbar .field.grow-f { flex: 1 1 200px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-title h2 { font-size: 17px; }
.section-title .sub { color: var(--faint); font-size: 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kpi { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi .k { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 28px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; margin-top: 5px; color: var(--muted); }
.kpi .d.up { color: #7ff0c1; } .kpi .d.down { color: #ffb4b4; }
.chart-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.chart-wrap { height: 300px; width: 100%; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; background: var(--surface-2); position: sticky; top: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 6px; }
.pagination .pages button { min-width: 34px; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline .step { display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
.timeline .marker { display: flex; flex-direction: column; align-items: center; }
.timeline .marker .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--line-2); margin-top: 4px; }
.timeline .step.done .marker .dot { background: var(--accent); }
.timeline .marker::after { content: ""; width: 2px; flex: 1; background: var(--line); }
.timeline .step:last-child .marker::after { display: none; }
.timeline .step .body { padding-bottom: 14px; }
.timeline .step .body b { font-size: 13.5px; }
.timeline .step .body span { display: block; color: var(--faint); font-size: 12px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.report-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.report-totals .t { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.report-totals .t .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.report-totals .t .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--accent); }

/* ------- Preview navigation (página /preview) ------- */
.pv-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 20px; }
.pv-tabs a { padding: 7px 12px; border-radius: var(--radius-full); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.pv-tabs a:hover, .pv-tabs a[aria-current] { color: var(--text); border-color: var(--accent); text-decoration: none; }
.pv-frame { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 14px; background: var(--bg-2); }
.pv-label { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.note-banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: #12202a; border: 1px solid #1f4a52; color: #bfeee6; font-size: 13px; margin: 16px 0; }
.note-banner svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.privacy-note { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line-2); }
.privacy-note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--accent); }
.media-error-item + .media-error-item { margin-top: 8px; padding-top: 8px; border-top: 1px solid #5b2a33; }
.media-error-item b { font-weight: 650; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text); padding: 10px 16px; border-radius: var(--radius-full); box-shadow: var(--shadow); font-size: 13.5px; z-index: 80; opacity: 0; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ------- Responsive ------- */
/* Mobile-first: a base (acima) já é de uma coluna; o layout largo só se
   expande a partir daqui. */
.prep { grid-template-columns: 1fr; }
.chart-grid { grid-template-columns: 1fr; }
.split { grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .prep { grid-template-columns: 1.05fr .95fr; }
  .chart-grid { grid-template-columns: 1.4fr 1fr; }
  .split { grid-template-columns: 1fr 1fr; }
  .call-stage.solo { max-width: 980px; margin: 0 auto; }
}
/* Palco da chamada em telas estreitas: limitado pela altura da viewport, de
   modo que vídeo remoto, miniatura local e controles caibam sem rolagem. */
@media (max-width: 860px) {
  .call-stage { aspect-ratio: auto; height: min(calc(100vh - 200px), 640px); height: min(calc(100dvh - 200px), 640px); min-height: 340px; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 14px; }
  .call-stage { height: min(calc(100vh - 236px), 560px); height: min(calc(100dvh - 236px), 560px); border-radius: var(--radius); }
  .video-local { width: 30%; min-width: 100px; bottom: 100px; right: 10px; }
  .call-controls { gap: 10px; padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .btn-icon { width: 50px; height: 50px; min-height: 50px; }
  .filterbar .field { min-width: 130px; }
  .kpi .v { font-size: 24px; }
}

/* =========================================================================
   BOSIA DESIGN FOUNDATION — camada de refino (produto Videochamada 1:1)
   Reaproveita os componentes do design system (bosia-*) e aplica escala de
   8px, escala tipográfica, foco visível, estados e responsividade.
   Somente aparência: nenhuma lógica, rota, dado ou contrato foi alterado.
   ========================================================================= */
:root {
  /* escala de espaçamento (múltiplos de 8 · 4 para detalhes) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  /* escala tipográfica */
  --fs-1: 12px; --fs-2: 13.5px; --fs-3: 16px; --fs-4: 20px; --fs-5: 26px; --fs-6: 34px;
  /* movimento e profundidade */
  --motion: 160ms cubic-bezier(.2, .8, .2, 1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .32);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  --focus: 0 0 0 3px rgba(45, 212, 191, .42);
  /* ponte para os tokens do design system BOSIA */
  --bosia-bg: var(--bg); --bosia-bg-2: var(--bg-2); --bosia-panel: var(--surface);
  --bosia-border: var(--line); --bosia-border-2: var(--line-2); --bosia-text: var(--text);
  --bosia-muted: var(--muted); --bosia-accent: var(--accent); --bosia-ok: var(--ok);
  --bosia-fail: var(--danger); --bosia-warn: var(--warn); --bosia-radius: var(--radius);
}

/* Foco visível consistente em todo elemento interativo (teclado). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm);
}

/* ---------- hierarquia e ritmo vertical (8px) ---------- */
body { font-size: 15px; line-height: 1.55; }
h1, h2, h3, h4 { letter-spacing: -.015em; }
.wrap { max-width: 1160px; padding: 0 var(--sp-5); }
.page-head { padding: var(--sp-6) 0 var(--sp-4); }
.page-head h1 { font-size: var(--fs-5); }
.page-head .sub { font-size: var(--fs-2); margin-top: var(--sp-2); }
.section-title { margin: var(--sp-6) 0 var(--sp-4); }
.section-title h2 { font-size: var(--fs-4); }
.panel-pad { padding: var(--sp-5); }
.panel-head { padding: var(--sp-4) var(--sp-5); }
.state-card { padding: 40px var(--sp-6); }
.state-card h1 { font-size: var(--fs-4); margin-bottom: var(--sp-4); }
.state-card p { margin-bottom: var(--sp-5); }
.overlay h2 { font-size: var(--fs-4); }
.report-totals .t { padding: var(--sp-4); }
.kpi { padding: var(--sp-5); transition: border-color var(--motion), transform var(--motion); }
.kpi:hover { border-color: var(--accent); transform: translateY(-1px); }
.filterbar { padding: var(--sp-4); gap: var(--sp-3); }

/* ---------- botões: alvos de toque >= 32px e estados ---------- */
.btn { min-height: 44px; transition: background var(--motion), border-color var(--motion), transform .06s ease, opacity var(--motion); }
.btn-sm { min-height: 36px; padding: 0 14px; }
.btn-icon { width: 56px; height: 56px; min-height: 56px; }
.btn[disabled], .btn.is-busy { opacity: .55; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy svg { opacity: 0; }
.btn.is-busy::after {
  content: ""; position: absolute; top: 50%; left: 50%; margin: -9px 0 0 -9px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite;
}
.btn { position: relative; }
.btn-primary.is-busy::after, .btn-danger.is-busy::after { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }
.btn.is-copied { background: #0d2b22; border-color: #1c5c46; color: #7ff0c1; }
.tb-link { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 12px; }
.pagination .pages button { min-width: 40px; min-height: 40px; }
.pv-tabs a { min-height: 40px; display: inline-flex; align-items: center; }

/* ---------- estados vazio / carregando (reutilizáveis) ---------- */
.empty { text-align: center; padding: var(--sp-7) var(--sp-5); color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty .ico { display: block; font-size: 28px; margin-bottom: var(--sp-2); opacity: .65; }
.skeleton { background: linear-gradient(90deg, #182238 25%, #22304a 37%, #182238 63%); background-size: 400% 100%; animation: bosia-shimmer 1.4s ease infinite; border-radius: 8px; height: 14px; }
@keyframes bosia-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- componentes BOSIA reaproveitados ---------- */
.bosia-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-5); box-shadow: var(--shadow-sm); }
.bosia-stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.bosia-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.bosia-row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.bosia-muted { color: var(--muted); }
.bosia-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.bosia-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: background var(--motion), border-color var(--motion), transform .06s ease;
}
.bosia-btn:hover { background: var(--surface-3); border-color: var(--accent); text-decoration: none; }
.bosia-btn:active { transform: translateY(1px); }
.bosia-btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.bosia-btn-primary:hover { background: var(--accent-strong); }
.bosia-btn-success { background: #1f9e4d; border-color: transparent; color: #04210f; }
.bosia-btn-danger { background: var(--danger-strong); border-color: transparent; color: #fff; }
.bosia-btn-ghost { background: transparent; border-color: var(--line-2); }
.bosia-btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.bosia-btn:disabled { opacity: .55; cursor: not-allowed; }
.bosia-btn.is-busy { position: relative; color: transparent !important; cursor: progress; pointer-events: none; }
.bosia-btn.is-busy::after {
  content: ""; position: absolute; top: 50%; left: 50%; margin: -9px 0 0 -9px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .8s linear infinite;
}

.bosia-input, .bosia-select { width: 100%; min-height: 44px; padding: 10px 12px; background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--radius-sm); font: inherit; font-size: 14px; }
.bosia-input:focus, .bosia-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45, 212, 191, .18); }
.bosia-field { display: flex; flex-direction: column; gap: 6px; }
.bosia-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.bosia-hint { font-size: 12px; color: var(--muted); }

.bosia-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; border: 1px solid var(--line-2); color: var(--muted); background: var(--surface-2); }
.bosia-badge.ok { color: #7ff0c1; border-color: #1c5c46; background: #0d2b22; }
.bosia-badge.fail { color: #ffb4b4; border-color: #5b2a33; background: #2c1519; }
.bosia-badge.warn { color: #fcd34d; border-color: #5c4a17; background: #2c2410; }
.bosia-badge.info { color: #bcd6ff; border-color: #2a4172; background: #131f36; }

.bosia-kpi { display: flex; flex-direction: column; gap: 4px; padding: var(--sp-5); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.bosia-kpi .kpi-value { font-size: var(--fs-6); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bosia-kpi .kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.bosia-tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); }
.bosia-tab { min-height: 44px; padding: 0 16px; border: none; background: transparent; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font: inherit; font-size: 13px; }
.bosia-tab:hover { color: var(--text); }
.bosia-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.bosia-alert { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--bg-2); font-size: var(--fs-2); }
.bosia-alert.info { border-color: rgba(96, 165, 250, .45); }
.bosia-alert.ok { border-color: rgba(52, 211, 153, .45); }
.bosia-alert.warn { border-color: rgba(251, 191, 36, .5); }
.bosia-alert.error { border-color: rgba(248, 113, 113, .5); }

.bosia-table { width: 100%; border-collapse: collapse; }
.bosia-table th, .bosia-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
.bosia-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.bosia-table tbody tr:hover { background: var(--surface-2); }

.bosia-empty { text-align: center; padding: var(--sp-7) var(--sp-5); color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.bosia-skeleton { background: linear-gradient(90deg, #182238 25%, #22304a 37%, #182238 63%); background-size: 400% 100%; animation: bosia-shimmer 1.4s ease infinite; border-radius: 8px; height: 14px; }
.bosia-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.bosia-app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.bosia-sidebar { background: var(--bg-2); border-right: 1px solid var(--line); padding: var(--sp-4); }
.bosia-main { padding: var(--sp-5); max-width: 1200px; }

/* ---------- acessibilidade e não-overflow em telas estreitas ---------- */
.link-box { flex-wrap: wrap; row-gap: var(--sp-2); }
.link-box input { min-width: 0; text-overflow: ellipsis; }
.address, .mono, code { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .wrap { padding: 0 var(--sp-4); }
  .page-head { padding: var(--sp-5) 0 var(--sp-3); }
  .section-title { margin: var(--sp-5) 0 var(--sp-3); }
  .panel-pad, .panel-body { padding: var(--sp-4); }
  .panel-head { padding: var(--sp-3) var(--sp-4); }
  .state-card { padding: var(--sp-6) var(--sp-5); }
  .kpi, .bosia-kpi { padding: var(--sp-4); }
  .kpi .v { font-size: var(--fs-5); }
  .link-box .btn { flex: 1 1 auto; }
  .btn-row .btn { flex: 1 1 auto; justify-content: center; }
  .filterbar .field { min-width: 120px; }
}
@media (max-width: 820px) {
  .bosia-app { grid-template-columns: 1fr; }
  .bosia-sidebar { border-right: none; border-bottom: 1px solid var(--line); }
}
/* Barra superior sem overflow em telas estreitas (360px) */
.topbar .brand { min-width: 0; }
.topbar .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) {
  /* Com indicadores de fase + efemeridade + id, a barra passa a poder quebrar
     linha em vez de espremer os badges ou causar overflow. */
  .topbar { flex-wrap: wrap; height: auto; min-height: 56px; padding: 8px var(--sp-3); row-gap: 6px; }
}
@media (max-width: 480px) {
  .topbar { gap: var(--sp-2); padding: 8px var(--sp-3); }
  .topbar .brand span { display: none; }
  .bosia-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ---------- contenção de layout: nada estoura a largura do viewport ---------- */
.kpi-grid, .chart-grid, .split, .report-totals { min-width: 0; }
.chart-grid > *, .split > *, .kpi-grid > * { min-width: 0; }
.panel { min-width: 0; }
.chart-wrap { overflow: hidden; max-width: 100%; }
.chart-wrap canvas { max-width: 100% !important; }
.table-scroll { max-width: 100%; }
.tbl, .bosia-table { min-width: 0; }

/* =========================================================================
   Impressão / exportação em PDF (R1/R2/R3) — respeita os filtros ativos,
   remove o cromo interativo e evita cortar painéis e linhas entre páginas.
   ========================================================================= */
@media print {
  @page { margin: 14mm 12mm; }
  html, body { background: #fff !important; color: #111 !important; color-scheme: light; }
  .topbar, .note-banner, .filterbar, .btn-row, .pagination, .toast,
  .tb-link, [data-action], .sub, .section-title .tiny { display: none !important; }
  .wrap { max-width: none; padding: 0 !important; }
  .section-title { border-bottom: 1px solid #d5dbe3; padding-bottom: 4px; margin: 14px 0 8px; }
  .section-title h2, h1, h2, h3 { color: #111 !important; }
  .page-head .sub { display: block !important; color: #555 !important; }
  .panel, .kpi, .report-totals, .panel-pad { background: #fff !important; border-color: #d5dbe3 !important; color: #111 !important; box-shadow: none !important; color-adjust: exact; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chart-wrap { color-adjust: exact; -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; }
  .kpi .k, .kpi .d, .t .k, .faint, .muted { color: #555 !important; }
  .kpi .v, .t .v { color: #111 !important; }
  .tbl, .bosia-table { color: #111 !important; }
  .tbl th, .bosia-table th { background: #eef1f5 !important; color: #111 !important; }
  .tbl td, .bosia-table td, .tbl th, .bosia-table th { border-color: #d5dbe3 !important; }
  .panel, .kpi, .split, section { break-inside: avoid; }
  .chart-grid, .kpi-grid, .split { display: block !important; }
  .chart-grid > *, .kpi-grid > *, .split > * { margin-bottom: 12px; }
}
