/* PAINEL MASTER — estilos. Mobile-first: o que está fora de @media é o celular. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-text);
  font: 400 15px/1.45 var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--color-primary); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estrutura ---------- */
.shell { min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--color-primary-hover); color: var(--color-white);
}
.brand { display: flex; align-items: center; gap: 10px; font: 600 20px var(--font-brand); letter-spacing: .06em; }
.brand img { width: 30px; height: 30px; }
.selo {
  font: 700 11px var(--font-ui); letter-spacing: .08em;
  background: var(--color-invite); color: var(--color-alert-ink);
  padding: 3px 8px; border-radius: 6px;
}
.menu-btn {
  margin-left: auto; width: var(--tap); height: var(--tap);
  background: transparent; border: 0; color: inherit; border-radius: 8px; cursor: pointer;
}
.menu-btn svg { width: 24px; height: 24px; }

.sidebar {
  position: fixed; inset: 0 0 0 auto; z-index: 40; width: min(86vw, 320px);
  background: var(--color-primary-hover); color: var(--color-white);
  display: flex; flex-direction: column; gap: 4px;
  padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
  transform: translateX(100%); transition: transform .2s ease; overflow-y: auto;
}
.sidebar .brand { padding: 4px 8px 16px; }
.nav-open .sidebar { transform: none; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgb(31 35 40 / .5); display: none; }
.nav-open .scrim { display: block; }

.nav a {
  display: flex; align-items: center; min-height: var(--tap);
  padding: 8px 12px; border-radius: 8px; color: inherit; text-decoration: none;
}
.nav a[aria-current="page"] { background: rgb(255 255 255 / .14); font-weight: 600; }
.nav a:hover { background: rgb(255 255 255 / .08); }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; font-size: 13px; opacity: .9; }
.sidebar-foot button {
  margin-top: 8px; background: transparent; color: inherit; cursor: pointer;
  border: 1px solid rgb(255 255 255 / .4); border-radius: 8px; min-height: 36px; padding: 0 12px;
}

main { padding: 16px; padding-bottom: calc(32px + env(safe-area-inset-bottom)); max-width: 1280px; }

/* ---------- Tipografia de página ---------- */
.eyebrow { font: 600 12px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-muted); }
.page-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
h1 { font: 700 28px/1.15 var(--font-brand); }
.lead { color: var(--color-text-muted); margin-top: 4px; }
.crumbs { font-size: 14px; color: var(--color-text-muted); margin-bottom: 8px; }

/* ---------- Componentes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--color-border-strong); background: var(--color-surface);
  color: var(--color-text); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--color-surface-sunken); }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-white); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.card-pad { padding: 16px; }
.card h2 { font: 700 18px var(--font-brand); }
.card .sub { color: var(--color-text-muted); font-size: 14px; margin-top: 2px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px; }
.kpi .t { font-size: 13px; color: var(--color-text-muted); font-weight: 500; }
.kpi .n { font: 700 28px/1.2 var(--font-brand); margin: 2px 0; }
.kpi .d { font-size: 13px; color: var(--color-text-muted); }

.pill { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill-ativo { background: var(--color-success-soft); color: var(--color-success-text); }
.pill-implantacao { background: var(--color-invite-soft); color: var(--color-invite-text); }
.pill-demonstracao, .pill-encerrado { background: var(--color-neutral-soft); color: var(--color-neutral-text); }
.pill-suspenso { background: var(--color-alert-soft); color: var(--color-alert-text); }
.pill-padrao { background: var(--color-neutral-soft); color: var(--color-neutral-text); }
.pill-excecao { background: var(--color-invite-soft); color: var(--color-invite-text); border: 1px solid var(--color-invite); }
.pill-escopo-padrao { background: var(--color-primary-soft); color: var(--color-primary-hover); }
.pill-escopo-ambiente { background: var(--color-invite-soft); color: var(--color-invite-text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--color-primary-soft); color: var(--color-primary-hover); }
.chip-off { background: transparent; color: var(--color-neutral-text); border: 1px dashed var(--color-border-strong); text-decoration: line-through; }
.tipo { font-size: 12px; font-weight: 600; color: var(--color-text-muted); }

.txt-excecao { color: var(--color-invite-text); font-weight: 600; }
.muted { color: var(--color-text-muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.input {
  min-height: var(--tap); padding: 0 12px; width: 100%;
  background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: 8px;
}

/* ---------- Tabela que vira cartões no celular ---------- */
.tbl-head { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-bottom: 1px solid var(--color-border); }
.tbl-foot { padding: 12px 16px; font-size: 13px; color: var(--color-text-muted); border-top: 1px solid var(--color-border); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl thead { display: none; }
.tbl tr { display: block; padding: 14px 16px; border-bottom: 1px solid var(--color-surface-sunken); }
.tbl tr:last-child { border-bottom: 0; }
.tbl td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; }
.tbl td::before { content: attr(data-label); font-size: 12px; color: var(--color-text-muted); font-weight: 600; flex: none; }
.tbl td.cell-main { display: block; padding-bottom: 8px; }
.tbl td.cell-main::before, .tbl td.cell-acoes::before { display: none; }
.tbl td.cell-acoes { display: flex; gap: 8px; padding-top: 10px; }
.tbl td.cell-acoes .btn { flex: 1; }
.nome { font-weight: 700; }
.nome-sub { font-size: 13px; color: var(--color-text-muted); }

/* ---------- Abas (rolam na horizontal no celular) ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--color-border); margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; display: flex; align-items: center; min-height: var(--tap); padding: 0 12px;
  color: var(--color-text-muted); text-decoration: none; border-bottom: 3px solid transparent; font-weight: 500;
}
.tabs a[aria-current="page"] { color: var(--color-primary-hover); border-bottom-color: var(--color-primary); font-weight: 700; }

.grid-2 { display: grid; gap: 16px; }

/* ---------- Interruptor ---------- */
.mod { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--color-border); }
.mod:first-of-type { border-top: 0; }
.mod b { display: block; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--color-neutral); border-radius: var(--radius-pill); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: var(--color-white); border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--color-primary); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ---------- Assistente (Criar ambiente) ---------- */
.h3 { font: 700 16px var(--font-brand); margin-bottom: 8px; }
.steps { list-style: none; margin: 0 -16px 16px; padding: 0 16px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.steps li { flex: none; }
.step {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface);
  color: var(--color-text-muted); text-decoration: none; font-weight: 500;
}
.step-n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--color-surface-sunken); font-size: 13px; font-weight: 700; }
.step.done { background: var(--color-success-soft); border-color: var(--color-success-border); color: var(--color-success-text); font-weight: 600; }
.step.done .step-n { background: var(--color-success); color: var(--color-white); }
.step.cur { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-white); font-weight: 700; }
.step.cur .step-n { background: var(--color-white); color: var(--color-primary); }

.wiz { display: grid; gap: 16px; }
.wiz-main { min-width: 0; }
.form { display: flex; flex-direction: column; gap: 16px; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.ajuda { font-size: 13px; color: var(--color-text-muted); }
.input-num { max-width: 120px; }

.opts, .opts-col { display: grid; gap: 12px; }
.opt {
  position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); cursor: pointer;
}
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.opt > span:last-child { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.opt .muted { font-size: 14px; }
.opt.sel { border: 2px solid var(--color-primary); padding: 13px; background: var(--color-surface); }
.opt:has(input:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.radio { flex: none; width: 22px; height: 22px; margin-top: 1px; border: 2px solid var(--color-border-strong); border-radius: 50%; background: var(--color-surface); }
.opt.sel .radio { border-color: var(--color-primary); background: radial-gradient(circle, var(--color-primary) 0 45%, var(--color-surface) 50%); }
.chip-soft { background: var(--color-surface-sunken); color: var(--color-text-subtle); font-weight: 600; }
.chips { margin-top: 6px; }

.resumo dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 12px 0; font-size: 14px; }
.resumo dt { color: var(--color-text-muted); }
.resumo dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.resumo .nota { font-size: 13px; color: var(--color-text-muted); }
.txt-pend { color: var(--color-invite-text); }

.wiz-acoes { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.wiz-acoes .btn-primary { flex: 1; }
.wiz-acoes .btn:not(.btn-primary) { flex: none; }
.wiz-main .erro { margin-top: 12px; min-height: 0; }
.wiz-main .erro:empty { display: none; }

/* ---------- Contextos do Radar ---------- */
.badge { display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 6px; border-radius: var(--radius-pill); background: var(--color-neutral-soft); color: var(--color-neutral-text); font-size: 12px; font-weight: 700; text-align: center; }
.tabs a[aria-current="page"] .badge { background: var(--color-primary-soft); color: var(--color-primary-hover); }
.grid-radar { display: grid; gap: 16px; }
.upload { background: var(--color-invite-soft); border: 1.5px dashed var(--color-invite); border-radius: var(--radius); padding: 16px; color: var(--color-invite-text); }
.upload h2 { font: 700 18px var(--font-brand); color: var(--color-invite-text); }
.upload p { margin-top: 4px; }
.nota-upload { font-size: 13px; margin-top: 12px !important; }
.btn-link { border-color: transparent; background: transparent; color: var(--color-primary); text-decoration: underline; }
.erro-box { background: var(--color-alert-soft); color: var(--color-alert-ink); border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.erro-box ul { margin: 0; padding-left: 18px; }
.erro-box p { margin-top: 6px; }
.lista-previa { margin: 6px 0 10px; padding-left: 18px; }
.chip-falta { background: var(--color-invite-soft); color: var(--color-invite-text); border: 1px dashed var(--color-invite); }
.input-sm { min-height: 36px; width: auto; margin-left: 8px; padding: 0 8px; font-size: 14px; }
.input-sm.sel-valor { background: var(--color-primary-soft); color: var(--color-primary-hover); border-color: transparent; font-weight: 700; }
.input-sm.sel-volume { background: var(--color-neutral-soft); color: var(--color-neutral-text); border-color: transparent; font-weight: 700; }
.txt-ok { color: var(--color-success-text); }
.txt-alert { color: var(--color-alert-text); }
details.novo { position: relative; }
details.novo summary { list-style: none; }
details.novo summary::-webkit-details-marker { display: none; }
.form-inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.form-inline .input { width: auto; flex: 1 1 160px; }

/* ---------- Avisos ---------- */
.aviso { padding: 12px 16px; border-radius: var(--radius); background: var(--color-invite-soft); color: var(--color-invite-text); border: 1px dashed var(--color-invite); margin-bottom: 16px; font-size: 14px; }
.vazio { padding: 32px 16px; text-align: center; color: var(--color-text-muted); }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--color-text); color: var(--color-white); padding: 12px 16px; border-radius: var(--radius);
}

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.login .brand { color: var(--color-text); }
.erro { color: var(--color-alert-text); font-size: 14px; font-weight: 600; }

/* ---------- Computador ---------- */
@media (min-width: 900px) {
  .topbar, .menu-btn, .scrim { display: none !important; }
  .sidebar { transform: none; inset: 0 auto 0 0; width: var(--sidebar-w); padding-top: 24px; }
  .shell { padding-left: var(--sidebar-w); }
  main { padding: 32px 40px 48px; }
  .page-head { flex-direction: row; justify-content: space-between; align-items: flex-start; }
  h1 { font-size: 34px; }
  .kpis { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .tabs { margin: 0 0 16px; padding: 0; }
  .steps { margin: 0 0 20px; padding: 0; }
  .steps li { flex: 1; }
  .step { width: 100%; }
  .wiz { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .grid-radar { grid-template-columns: 1fr 1fr; align-items: start; }
  .opts-3 { grid-template-columns: repeat(3, 1fr); }
  .wiz-acoes .btn-primary { flex: none; }
  .grid-2 { grid-template-columns: minmax(260px, 1fr) 2fr; align-items: start; }
  .tbl-head { flex-direction: row; justify-content: space-between; align-items: center; }
  .tbl-head .input { max-width: 300px; }
  .toast { left: auto; right: 24px; max-width: 360px; }
}

/* Tabela de verdade só onde cabe; abaixo disso cada linha vira um cartão */
@media (min-width: 1180px) {
  .tbl thead { display: table-header-group; }
  .tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--color-text-muted); padding: 12px 12px; border-bottom: 1px solid var(--color-border); }
  .tbl tr { display: table-row; padding: 0; }
  .tbl td { display: table-cell; padding: 14px 12px; vertical-align: middle; border-bottom: 1px solid var(--color-surface-sunken); }
  .tbl tr:last-child td { border-bottom: 0; }
  .tbl td::before { display: none; }
  .tbl td.cell-main { padding-bottom: 14px; }
  .tbl td.cell-acoes { display: table-cell; white-space: nowrap; text-align: right; }
  .tbl td.cell-acoes .btn { flex: none; margin-left: 6px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
