/* SafeIntra — painel da central
   Branco de base, preto para texto, laranja para ação, vermelho só para alerta, cinzas para estrutura.
   Tipografia DIN (Bahnschrift) nos títulos e números, como placa de sinalização técnica. */

:root {
  --papel: #FFFFFF;
  --nevoa: #F4F4F3;
  --linha: #E1E1DF;
  --linha-forte: #C9C9C6;
  --cinza: #6A6A67;
  --cinza-claro: #9C9C98;
  --preto: #000000;
  --texto: #1F1F1E;
  --laranja: #F26A1B;
  --laranja-forte: #D9560A;
  --laranja-texto: #B3470A;
  --laranja-fundo: #FFF1E8;
  --vermelho: #CF2A1F;
  --vermelho-fundo: #FDECEA;
  --verde: #1F8A4C;

  --din: "Bahnschrift", "DIN Alternate", "DIN 2014", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --corpo: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --r-campo: 4px;
  --r-botao: 4px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--texto);
  font: 15px/1.5 var(--corpo);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--laranja); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--din); color: var(--preto); margin: 0; font-weight: 600; letter-spacing: -0.005em; }
h1 { font-size: 2rem; line-height: 1.1; font-stretch: 90%; }
h2 { font-size: 1.25rem; line-height: 1.2; }
h3 { font-size: 1rem; line-height: 1.3; }
p { margin: 0 0 0.75rem; max-width: 68ch; }
.muted { color: var(--cinza); }
.num { font-family: var(--din); font-variant-numeric: tabular-nums; }

/* ---------- Marca ---------- */
.wordmark {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--din); font-weight: 700; font-size: 1.35rem; color: var(--preto);
  text-decoration: none; letter-spacing: -0.01em; font-stretch: 85%;
}
.wordmark .porta {
  width: 18px; height: 18px; background: var(--laranja); position: relative; flex: none;
}
.wordmark .porta::after {
  content: ""; position: absolute; left: 5px; right: 5px; bottom: 0; height: 6px; background: var(--papel);
}
.wordmark small { font-weight: 400; color: var(--cinza); font-size: 0.8rem; font-stretch: 100%; margin-left: 2px; }

/* ---------- Estrutura do painel ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.rail {
  border-right: 1px solid var(--linha); padding: 22px 0 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; background: var(--papel);
}
.rail .wordmark { margin: 0 22px 30px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block; padding: 9px 22px; text-decoration: none; color: var(--cinza);
  font-family: var(--din); font-size: 1rem; border-left: 4px solid transparent;
}
.nav a:hover { color: var(--preto); background: var(--nevoa); }
.nav a[aria-current="page"] { color: var(--preto); border-left-color: var(--laranja); font-weight: 600; }
.rail-foot { margin-top: auto; padding: 16px 22px 0; border-top: 1px solid var(--linha); font-size: 0.85rem; }
.rail-foot .quem { font-weight: 600; color: var(--preto); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-foot .email { color: var(--cinza); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 10px; }
.rail-foot .acoes { display: flex; gap: 14px; }

.main { padding: 34px 44px 60px; min-width: 0; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head .sub { color: var(--cinza); margin-top: 6px; }
.crumb { display: inline-block; margin-bottom: 8px; color: var(--cinza); text-decoration: none; font-size: 0.9rem; }
.crumb:hover { color: var(--preto); text-decoration: underline; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r-botao); border: 1px solid transparent;
  background: var(--laranja); color: var(--preto); font-family: var(--din); font-weight: 600; font-size: 0.98rem;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--laranja-forte); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.sec { background: var(--papel); border-color: var(--linha-forte); color: var(--preto); }
.btn.sec:hover { border-color: var(--preto); background: var(--papel); }
.btn.perigo { background: var(--papel); border-color: var(--vermelho); color: var(--vermelho); }
.btn.perigo:hover { background: var(--vermelho); color: var(--papel); }
.btn.preto { background: var(--preto); color: var(--papel); }
.btn.preto:hover { background: #2b2b2a; }
.link { background: none; border: 0; padding: 0; color: var(--cinza); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.link:hover { color: var(--preto); }
.link.perigo { color: var(--vermelho); }

/* ---------- Faixa de portas (status dos gateways) ---------- */
.patch {
  border: 1px solid var(--linha-forte); border-radius: 6px; padding: 18px 20px 16px; margin-bottom: 30px;
  background: linear-gradient(var(--papel), var(--papel)) padding-box;
}
.patch-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.patch-head h2 { font-size: 1.05rem; }
.ports { display: flex; flex-wrap: wrap; gap: 8px; }
.port {
  width: 34px; height: 34px; border: 2px solid var(--linha-forte); border-radius: 3px; position: relative;
  display: grid; place-items: end center; text-decoration: none; background: var(--papel);
}
.port::after { content: ""; width: 14px; height: 6px; background: var(--linha-forte); margin-bottom: 4px; }
.port[data-estado="no_ar"] { border-color: var(--laranja); background: var(--laranja); }
.port[data-estado="no_ar"]::after { background: var(--papel); }
.port[data-estado="fora"] { border-color: var(--vermelho); background: var(--vermelho-fundo); }
.port[data-estado="fora"]::after { background: var(--vermelho); }
.port[data-estado="suspenso"] { border-color: var(--preto); background: repeating-linear-gradient(135deg, var(--preto) 0 3px, var(--papel) 3px 7px); }
.port[data-estado="suspenso"]::after { background: var(--preto); }
.port:hover { outline: 2px solid var(--preto); outline-offset: 2px; }
.port .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--preto); color: var(--papel); font-size: 0.8rem; padding: 4px 8px; border-radius: 3px; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 5;
}
.port:hover .tip, .port:focus-visible .tip { opacity: 1; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.85rem; color: var(--cinza); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border: 2px solid var(--linha-forte); border-radius: 2px; display: inline-block; }
.legend i.no_ar { background: var(--laranja); border-color: var(--laranja); }
.legend i.fora { background: var(--vermelho-fundo); border-color: var(--vermelho); }
.legend i.suspenso { border-color: var(--preto); background: repeating-linear-gradient(135deg, var(--preto) 0 2px, var(--papel) 2px 4px); }
.patch-empty { color: var(--cinza); padding: 6px 0 2px; }

/* ---------- Números ---------- */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--preto); margin-bottom: 34px; }
.figure { padding: 14px 18px 4px 0; }
.figure + .figure { padding-left: 18px; border-left: 1px solid var(--linha); }
.figure .v { font-family: var(--din); font-size: 2.4rem; line-height: 1; color: var(--preto); font-weight: 600; font-variant-numeric: tabular-nums; }
.figure .v.alerta { color: var(--vermelho); }
.figure .l { color: var(--cinza); margin-top: 6px; font-size: 0.9rem; }

.two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 40px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 12px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--cinza); font-size: 0.85rem; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--linha-forte); white-space: nowrap; }
td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--linha); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--nevoa); }
td .nome { font-weight: 600; color: var(--preto); text-decoration: none; }
td .nome:hover { text-decoration: underline; }
td .sec-line { color: var(--cinza); font-size: 0.85rem; }
.code { font-family: var(--din); letter-spacing: 0.04em; color: var(--preto); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Selos de estado ---------- */
.estado { display: inline-flex; align-items: center; gap: 7px; font-size: 0.88rem; white-space: nowrap; }
.estado::before { content: ""; width: 9px; height: 9px; border-radius: 1px; background: var(--linha-forte); }
.estado.no_ar::before, .estado.ativo::before { background: var(--laranja); }
.estado.fora::before { background: var(--vermelho); }
.estado.fora, .estado.suspenso, .estado.vencida { color: var(--vermelho); }
.estado.suspenso::before, .estado.vencida::before { background: var(--vermelho); }
.estado.inativo { color: var(--cinza); }

/* ---------- Atividade ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 10px 0; border-bottom: 1px solid var(--linha); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.feed .o-que { color: var(--preto); }
.feed .quem { color: var(--cinza); font-size: 0.85rem; grid-column: 1; }
.feed time { color: var(--cinza); font-size: 0.85rem; grid-row: 1; grid-column: 2; white-space: nowrap; }
.feed li.falha .o-que { color: var(--vermelho); }

/* ---------- Formulários ---------- */
.form { max-width: 760px; }
.fieldset { border: 0; padding: 0; margin: 0 0 30px; }
.fieldset legend { font-family: var(--din); font-weight: 600; font-size: 1.1rem; color: var(--preto); padding: 0; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; }
.f { display: flex; flex-direction: column; gap: 6px; grid-column: span 3; min-width: 0; }
.f.s2 { grid-column: span 2; } .f.s4 { grid-column: span 4; } .f.s6 { grid-column: span 6; }
.f label { font-size: 0.88rem; color: var(--texto); font-weight: 600; }
.f .hint { font-size: 0.82rem; color: var(--cinza); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], textarea, select {
  height: 40px; padding: 0 12px; border: 1px solid var(--linha-forte); border-radius: var(--r-campo); background: var(--papel); width: 100%;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: var(--cinza-claro); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--preto); box-shadow: 0 0 0 3px var(--laranja-fundo); }
input[aria-invalid="true"] { border-color: var(--vermelho); }
.form-actions { display: flex; gap: 12px; align-items: center; padding-top: 18px; border-top: 1px solid var(--linha); }

.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] { width: 44px; height: 40px; padding: 2px; border: 1px solid var(--linha-forte); border-radius: var(--r-campo); background: var(--papel); cursor: pointer; flex: none; }
.color-row input[type="text"] { font-family: var(--din); text-transform: uppercase; }

/* ---------- Avisos ---------- */
.notice { border-left: 4px solid var(--preto); background: var(--nevoa); padding: 12px 16px; margin: 0 0 20px; border-radius: 0 4px 4px 0; }
.notice.erro { border-left-color: var(--vermelho); background: var(--vermelho-fundo); color: #7d1712; }
.notice.laranja { border-left-color: var(--laranja); background: var(--laranja-fundo); }
.notice p:last-child { margin-bottom: 0; }

.toast {
  position: fixed; right: 24px; bottom: 24px; background: var(--preto); color: var(--papel); padding: 12px 18px; border-radius: 4px;
  font-size: 0.95rem; z-index: 50; max-width: 420px; border-left: 4px solid var(--laranja);
}
.toast.erro { border-left-color: var(--vermelho); }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--linha-forte); margin-bottom: 28px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 10px 0; text-decoration: none; color: var(--cinza); font-family: var(--din); font-size: 1.02rem; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--preto); }
.tabs a[aria-current="page"] { color: var(--preto); border-bottom-color: var(--laranja); font-weight: 600; }

/* ---------- Ficha do provedor ---------- */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 2px solid var(--preto); margin-bottom: 30px; }
.fact { padding: 12px 18px 12px 0; }
.fact + .fact { padding-left: 18px; border-left: 1px solid var(--linha); }
.fact .l { font-size: 0.85rem; color: var(--cinza); }
.fact .v { font-family: var(--din); font-size: 1.25rem; color: var(--preto); margin-top: 2px; }

/* ---------- Marca + prévia do app ---------- */
.brand-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start; }
.logo-drop { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px dashed var(--linha-forte); border-radius: 6px; }
.logo-drop .thumb { width: 72px; height: 72px; border: 1px solid var(--linha); border-radius: 4px; display: grid; place-items: center; background: var(--nevoa); overflow: hidden; flex: none; }
.logo-drop .thumb img { max-width: 100%; max-height: 100%; }
.logo-drop .acoes { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.phone {
  width: 280px; height: 572px; border: 10px solid var(--preto); border-radius: 38px; overflow: hidden; position: sticky; top: 30px;
  background: var(--app-claro, #fff); display: flex; flex-direction: column;
}
.phone .notch { height: 26px; display: flex; justify-content: center; align-items: flex-end; }
.phone .notch::before { content: ""; width: 86px; height: 20px; background: var(--preto); border-radius: 0 0 12px 12px; margin-top: -6px; align-self: flex-start; }
.phone .app { flex: 1; display: flex; flex-direction: column; padding: 26px 22px 22px; color: var(--app-escuro, #000); }
.phone .app-logo { height: 54px; display: flex; align-items: center; margin-bottom: 18px; }
.phone .app-logo img { max-height: 54px; max-width: 150px; }
.phone .app-logo .ph { width: 54px; height: 54px; border-radius: 12px; background: var(--app-principal, #F26A1B); }
.phone .app-name { font-family: var(--din); font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.phone .app-sub { font-size: 0.82rem; opacity: 0.7; margin-top: 4px; }
.phone .app-status { margin: 34px auto 0; width: 150px; height: 150px; border-radius: 50%; border: 10px solid var(--app-principal, #F26A1B); display: grid; place-items: center; text-align: center; }
.phone .app-status b { font-family: var(--din); font-size: 1.05rem; display: block; }
.phone .app-status span { font-size: 0.75rem; opacity: 0.7; }
.phone .app-btn { margin-top: auto; height: 46px; border-radius: 10px; background: var(--app-principal, #F26A1B); color: var(--app-claro, #fff); display: grid; place-items: center; font-family: var(--din); font-weight: 700; font-size: 1rem; }
.phone .app-foot { text-align: center; font-size: 0.72rem; opacity: 0.55; margin-top: 12px; }
.contrast-warn { margin-top: 12px; font-size: 0.85rem; color: var(--vermelho); max-width: 280px; }

/* ---------- Instalação ---------- */
.secret-box { border: 2px solid var(--preto); border-radius: 6px; padding: 16px 18px; margin: 14px 0 18px; }
.secret-box .val { font-family: var(--din); font-size: 1.2rem; color: var(--preto); word-break: break-all; letter-spacing: 0.02em; user-select: all; }
.secret-box .meta { color: var(--cinza); font-size: 0.85rem; margin-top: 6px; }
pre.cmd { background: var(--preto); color: #fff; padding: 14px 16px; border-radius: 6px; overflow-x: auto; font-size: 0.85rem; margin: 10px 0 20px; }
.steps { margin: 0 0 20px; padding-left: 1.2rem; }
.steps li { margin-bottom: 6px; }

/* ---------- Diálogo ---------- */
dialog { border: 0; border-radius: 8px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dlg { padding: 24px 26px 22px; }
.dlg h2 { margin-bottom: 10px; }
.dlg .form-actions { border-top: 0; padding-top: 10px; justify-content: flex-end; }

/* ---------- Entrada ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.auth-side { background: var(--preto); color: var(--papel); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side .wordmark { color: var(--papel); font-size: 1.6rem; }
.auth-side .wordmark .porta::after { background: var(--preto); }
.auth-side .big { font-family: var(--din); font-size: clamp(2.2rem, 4vw, 3.4rem); line-height: 1.02; font-weight: 600; font-stretch: 85%; max-width: 13ch; }
.auth-side .rack { display: flex; gap: 8px; flex-wrap: wrap; max-width: 420px; }
.auth-side .rack i { width: 26px; height: 26px; border: 2px solid #3a3a39; border-radius: 3px; display: grid; place-items: end center; }
.auth-side .rack i::after { content: ""; width: 10px; height: 5px; background: #3a3a39; margin-bottom: 3px; }
.auth-side .rack i.on { border-color: var(--laranja); background: var(--laranja); }
.auth-side .rack i.on::after { background: var(--preto); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 32px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { font-size: 1.8rem; margin-bottom: 6px; }
.auth-box .sub { color: var(--cinza); margin-bottom: 26px; }
.auth-box .f { margin-bottom: 16px; }
.auth-box .btn { width: 100%; height: 44px; margin-top: 6px; }
.otp { font-family: var(--din); font-size: 1.6rem !important; letter-spacing: 0.35em; text-align: center; height: 54px !important; }
.key-grid { font-family: var(--din); font-size: 1.15rem; color: var(--preto); letter-spacing: 0.06em; word-spacing: 0.35em; line-height: 1.6; user-select: all; }

.empty { padding: 40px 0; border-top: 1px solid var(--linha); }
.empty h2 { margin-bottom: 8px; }
.empty .btn { margin-top: 12px; }

.loading { color: var(--cinza); padding: 30px 0; }
#root > .loading { padding: 40px; }
.spacer { height: 18px; }
.form > input[type="search"] { max-width: 420px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1080px) {
  .two { grid-template-columns: 1fr; }
  .brand-layout { grid-template-columns: 1fr; }
  .phone { position: static; margin: 0 auto; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 14px 16px; gap: 10px; }
  .rail .wordmark { margin: 0 auto 0 0; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 8px 12px; white-space: nowrap; }
  .nav a[aria-current="page"] { border-bottom-color: var(--laranja); }
  .rail-foot { margin: 0; border: 0; padding: 0; }
  .rail-foot .quem, .rail-foot .email { display: none; }
  .main { padding: 24px 16px 48px; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { padding-left: 0; border-left: 0; }
  .facts { grid-template-columns: 1fr; }
  .fact + .fact { padding-left: 0; border-left: 0; border-top: 1px solid var(--linha); }
  .grid { grid-template-columns: 1fr; }
  .f, .f.s2, .f.s4, .f.s6 { grid-column: auto; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; gap: 24px; }
  .auth-side .big { font-size: 2rem; }
  .auth-side .rack { display: none; }
  .auth-main { padding: 32px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
