/* IDONCLOUD Proxy v2 — painel */
:root {
  --bg: #0b1220; --bg2: #0f1a2e; --card: #111d33; --line: #1e2d4a; --line2: #2a3d60;
  --text: #e6edf7; --muted: #8fa1bf; --blue: #2563eb; --blue2: #3b82f6;
  --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --info: #38bdf8;
  --r: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--blue2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: .9em; }
small { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 9; background: var(--blue); color: #fff; padding: 8px 12px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--blue2); outline-offset: 2px; }

/* estrutura */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--bg2) 219px, var(--line) 219px 220px, transparent 220px); }
.side { background: var(--bg2); padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; letter-spacing: .02em; margin: 0; }
.brand b { color: var(--blue2); }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--blue), #60a5fa); box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
.side nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side nav a, .nav-off { display: block; padding: 8px 12px; border-radius: 8px; color: var(--muted); }
.side nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.side nav a[aria-current] { background: rgba(37,99,235,.18); color: #fff; }
.nav-off { opacity: .55; cursor: default; }
.nav-off small { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; margin-left: 4px; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.me { display: flex; flex-direction: column; padding: 8px 12px; border-radius: 8px; color: var(--text); background: var(--card); }
.me:hover { text-decoration: none; border-color: var(--line2); }
.me[aria-current] { outline: 1px solid var(--blue); }
.ver { color: var(--muted); font-size: .75rem; margin: 0 12px; }
.main { padding: 28px 32px 60px; max-width: 1280px; width: 100%; min-width: 0; }
.main:focus { outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.page-narrow { max-width: 560px; }

/* cartões e grelhas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin: 0 0 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card.highlight { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.card.danger { border-color: rgba(239,68,68,.35); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card { margin: 0; }
.grid-2 { margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; }
.stat-n { font-size: 1.7rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: .85rem; }
.stat-off .stat-n { color: var(--muted); }
.empty { color: var(--muted); margin: 0; }

/* tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: rgba(255,255,255,.02); }
tbody tr:last-child td { border-bottom: 0; }
table.compact th, table.compact td { padding: 7px 10px; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.details { max-width: 420px; word-break: break-all; color: var(--muted); font-size: .8rem; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form, .actions-cell form { margin: 0; }

/* etiquetas */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; border: 1px solid transparent; vertical-align: middle; white-space: nowrap; }
.badge-ok { background: rgba(34,197,94,.12); color: #4ade80; border-color: rgba(34,197,94,.3); }
.badge-bad { background: rgba(239,68,68,.12); color: #f87171; border-color: rgba(239,68,68,.3); }
.badge-warn { background: rgba(245,158,11,.12); color: #fbbf24; border-color: rgba(245,158,11,.3); }
.badge-wait { background: rgba(56,189,248,.1); color: #7dd3fc; border-color: rgba(56,189,248,.3); }
.badge-off { background: rgba(143,161,191,.1); color: var(--muted); border-color: var(--line2); }
.badge-http { background: rgba(37,99,235,.15); color: #93c5fd; }
.badge-tcp { background: rgba(168,85,247,.15); color: #d8b4fe; }

/* avisos */
.flash { padding: 12px 14px; border-radius: 8px; margin: 0 0 16px; border: 1px solid; }
.flash-ok { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.35); }
.flash-error { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.4); }
.flash-warn { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.4); }
.flash-info { background: rgba(56,189,248,.06); border-color: rgba(56,189,248,.3); color: #cfe9fb; }

/* formulários */
label { display: grid; gap: 6px; font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 9px 11px; width: 100%; }
textarea { font-family: var(--mono); font-size: .9rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue2); outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
input[aria-invalid], textarea[aria-invalid], select[aria-invalid] { border-color: var(--bad); }
.field-err { color: #fca5a5; margin: -4px 0 4px; font-size: .88rem; }
.stack { display: grid; gap: 14px; }
.form-narrow { max-width: 640px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row .grow { flex: 1 1 220px; }
.w-port { width: 120px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; margin: 6px 0; }
.check input { width: auto; margin-top: 4px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0 0; }
.inline-form input { width: auto; min-width: 180px; }
.inline-form label { min-width: 180px; }
.search { margin-bottom: 14px; }
.search input { min-width: 300px; }
fieldset { border: 0; margin: 0; padding: 0; }
fieldset.card { padding: 20px; display: grid; gap: 14px; }
fieldset.card > legend { float: left; width: 100%; font-weight: 650; font-size: 1.05rem; margin-bottom: 4px; padding: 0; }
fieldset.plain legend { font-weight: 500; margin-bottom: 4px; }
input.code { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .3em; text-align: center; max-width: 200px; }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line2); border-radius: var(--r); padding: 14px; font-weight: 400; cursor: pointer; }
.choice input { width: auto; margin-top: 4px; }
.choice:has(input:checked) { border-color: var(--blue); background: rgba(37,99,235,.08); }
.choice b { color: #fff; }

/* assistente de 3 passos */
.wizard-steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 14px; flex-wrap: wrap; }
.wizard-steps li { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); font-size: .9rem; }
.wizard-steps li[aria-current] { border-color: var(--blue); color: #fff; background: rgba(37,99,235,.15); }
.wizard-steps li.has-err { border-color: var(--bad); }
.wizard-nav { display: flex; justify-content: flex-end; gap: 8px; }
.js .wizard [data-step][hidden] { display: none; }
.wizard-nav button[type=button] { display: none; }
.js .wizard-nav button[type=button] { display: inline-flex; }
.js .wizard-nav { justify-content: flex-end; }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border-radius: 8px; padding: 9px 16px; border: 1px solid transparent; cursor: pointer; color: var(--text); background: none; line-height: 1.2; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { border-color: var(--line2); }
.btn-ghost:hover { border-color: var(--blue2); background: rgba(59,130,246,.08); }
.btn-danger { background: #b91c1c; color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-link { color: var(--muted); padding: 6px 0; font-weight: 400; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }

/* detalhes */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pre { white-space: pre-wrap; }
.wrap { word-break: break-all; }
.copy-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
code.secret { background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 8px 10px; font-size: .95rem; }
.steps-list { padding-left: 20px; margin: 0; display: grid; gap: 14px; }
details summary { cursor: pointer; color: var(--muted); font-size: .88rem; margin-top: 6px; }
.flow { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; counter-reset: f; }
.flow li { display: grid; gap: 2px; padding: 10px 14px 10px 44px; position: relative; border: 1px solid var(--line); border-radius: 8px; }
.flow li::before { counter-increment: f; content: counter(f); position: absolute; left: 12px; top: 10px; width: 22px; height: 22px; border-radius: 50%; background: rgba(37,99,235,.2); color: #93c5fd; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.flow li span { color: var(--muted); word-break: break-word; }
.pill-list { list-style: none; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.pill-list li { border: 1px solid var(--line2); border-radius: 999px; padding: 4px 12px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }

/* login */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: radial-gradient(circle at 50% 0, #13284f 0, var(--bg) 60%); }
.auth-box { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-box .brand { margin-bottom: 22px; }
.auth-box h1 { font-size: 1.3rem; margin-bottom: 14px; }


/* fase 3: ecrãs ao vivo e gráficos */
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-n small { font-size: .85rem; color: var(--muted); font-weight: 500; }
.stats-6 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.live-dot::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: middle; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.live-dot.live-off::before { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: .85rem; background: none; color: var(--muted); border: 0; padding: 5px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button.seg-on { background: rgba(37,99,235,.2); color: #fff; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-grid h3 { font-size: .9rem; color: var(--muted); font-weight: 500; margin: 0 0 6px; }
.chart { min-height: 200px; position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .cursor { stroke: var(--line2); stroke-width: 1; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
.chart-legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; }
h3 { font-size: .95rem; margin: 16px 0 8px; }


/* fase 4 */
.w-num { width: 120px; }
.w-num2 { flex: 0 1 180px; }
.w-mode { flex: 0 1 260px; }
.indent { margin: -6px 0 4px 30px; }
.small { font-size: .82rem; }
.pill-list li { display: inline-flex; align-items: center; gap: 6px; }
.pill-x { display: inline; margin: 0; }
.pill-x button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 2px; }
.pill-x button:hover { color: var(--bad); }
.wrap-form { align-items: flex-end; }
.w-num3 { flex: 0 1 300px; }

/* fase 5 */
.alerts-card { border-color: rgba(239,68,68,.35); }
.alert-list, .plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.protection-ok { border-color: rgba(34,197,94,.45); }
.protection-warn { border-color: rgba(245,158,11,.45); }
.protection-bad { border-color: rgba(239,68,68,.5); }
.verdict { margin: 0 0 12px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.ck-icon { flex: 0 0 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.ck-ok .ck-icon { background: rgba(34,197,94,.18); color: #4ade80; }
.ck-warn .ck-icon { background: rgba(245,158,11,.18); color: #fbbf24; }
.ck-bad .ck-icon { background: rgba(239,68,68,.18); color: #f87171; }
.ck-fix { color: #fcd34d; font-size: .9rem; }
.ck-accepted .ck-icon { background: rgba(148,163,184,.18); color: #94a3b8; }
.ck-action { margin-top: 6px; }

/* ---------------------------------------------------------------------------------------------
   Telemóvel: barra de topo + menu, navegação em baixo, tabelas em cartões
   --------------------------------------------------------------------------------------------- */
.mtop, .mtabs { display: none; }
.nav-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; margin-left: 6px; }

@media (max-width: 1100px) and (min-width: 761px) {
  .stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { font-size: 15px; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .shell { display: block; background: none; }
  .side { display: none; }
  .main { padding: 14px 14px 24px; }

  .mtop { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; height: 54px; padding: 0 14px;
          background: rgba(15,26,46,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
  .mtop .brand { font-size: .95rem; margin-right: auto; }
  .mtop .brand-mark { width: 20px; height: 20px; }
  .mtop-alert { display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--bad); color: #fff; font-weight: 700; font-size: .85rem; text-decoration: none; }
  .mmenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 8px 12px; border: 1px solid var(--line2); border-radius: 8px; font-weight: 600; user-select: none; }
  .mmenu summary::-webkit-details-marker { display: none; }
  .burger, .burger::before, .burger::after { display: block; width: 16px; height: 2px; background: var(--text); border-radius: 2px; position: relative; }
  .burger::before, .burger::after { content: ""; position: absolute; left: 0; }
  .burger::before { top: -5px; } .burger::after { top: 5px; }
  .mmenu[open] summary { border-color: var(--blue2); background: rgba(59,130,246,.12); }
  .mmenu-panel { position: absolute; left: 0; right: 0; top: 54px; background: var(--bg2); border-bottom: 1px solid var(--line); padding: 8px 14px 14px;
                 box-shadow: 0 12px 30px rgba(0,0,0,.45); max-height: calc(100vh - 54px); overflow-y: auto; }
  .mmenu-panel ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .mmenu-panel a { display: block; padding: 12px; border-radius: 8px; color: var(--text); background: var(--card); text-decoration: none; }
  .mmenu-panel a[aria-current] { background: rgba(37,99,235,.25); }
  .mmenu-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 10px; }
  .mmenu-foot a { background: none; padding: 8px 0; }

  .mtabs { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
           background: rgba(15,26,46,.97); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(6px); }
  .mtabs a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 8px; color: var(--muted); font-size: .72rem; text-decoration: none; }
  .mtabs a[aria-current] { color: #fff; }
  .mtabs a[aria-current] svg { stroke: var(--blue2); }
  .mtabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tab-dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1rem; }
  .page-head { margin-bottom: 14px; align-items: center; }
  .page-head .muted { font-size: .85rem; }
  .card { padding: 14px; margin-bottom: 14px; border-radius: 12px; }
  .grid-2, .choice-grid, .chart-grid { grid-template-columns: 1fr; gap: 14px; }
  .stats, .stats-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .stat { padding: 12px 14px; }
  .stat-n { font-size: 1.35rem; }
  .stat-l { font-size: .78rem; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .actions { width: 100%; }
  .inline-form, .wrap-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form label, .search input { min-width: 0; width: 100%; }
  .row { flex-direction: column; }
  .row > label, .w-port, .w-num, .w-num2, .w-num3, .w-mode { width: 100%; flex: 1 1 auto; }
  .wizard-steps { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .wizard-steps li { white-space: nowrap; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; font-size: .8rem; }
  .copy-row code.secret { width: 100%; }
  .chart { min-height: 160px; }
  .flow li { padding-left: 40px; }

  /* tabelas → cartões (o JavaScript põe o nome da coluna em cada célula) */
  .table-wrap { overflow: visible; }
  table.js-cards thead { display: none; }
  table.js-cards, table.js-cards tbody { display: block; width: 100%; }
  /* cada linha: título em cima, valores numa grelha de 2 colunas (rótulo pequeno por cima do valor) */
  table.js-cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
                      padding: 10px 12px; margin-bottom: 10px; background: rgba(255,255,255,.015); }
  table.js-cards tbody tr:hover { background: rgba(255,255,255,.015); }
  table.js-cards td { display: block; border: 0; padding: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  table.js-cards td.num { text-align: left; }
  table.js-cards td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 1px; }
  table.js-cards td:first-child { grid-column: 1 / -1; font-weight: 600; font-size: 1.02rem; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  table.js-cards td:first-child::before { content: none; }
  table.js-cards td.clip, table.js-cards td.details, table.js-cards td.mono.clip, table.js-cards td:last-child:nth-child(even) { grid-column: 1 / -1; }
  table.js-cards td:not([data-label])::before { content: none; }
  table.js-cards td:empty { display: none; }
  table.js-cards.cards-3 tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  table.js-cards.cards-3 td:last-child:nth-child(even) { grid-column: auto; }
  table.js-cards .clip { max-width: none; white-space: normal; word-break: break-all; }
  table.js-cards .actions-cell { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; padding-top: 4px; }
  table.js-cards .details { max-width: none; }
}
.danger-form { border-left: 3px solid rgba(239,68,68,.45); padding-left: 14px; }
.recovery-codes { font-size: 1.05rem; letter-spacing: .04em; line-height: 1.9; word-spacing: .3em; }
