:root {
  --bg: #0e1117; --panel: #161b26; --panel-2: #1d2432; --line: #2a3444;
  --text: #e6ecf5; --muted: #8b97a8; --accent: #f0b429; --accent-2: #ffd166;
  --ok: #2fbf71; --info: #4a90d9; --low: #6ba3d6; --med: #e8a33d; --high: #e8703a; --crit: #e2483d;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent-2); }
.hidden { display: none !important; }

/* topo */
header.top {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .3px; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--accent), #c98a10); color: #1a1205; font-size: 15px;
}
nav.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav.tabs button {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
nav.tabs button:hover { color: var(--text); background: var(--panel-2); }
nav.tabs button.active { color: #1a1205; background: var(--accent); font-weight: 600; }
.who { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }

main { padding: 22px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 26px 0 10px; color: var(--muted); font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

/* cartões */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.card .value { font-size: 30px; font-weight: 700; margin-top: 6px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.risk { background: var(--crit); }

/* tabelas */
table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* severidade */
.sev { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #10151d; }
.sev.critical { background: var(--crit); color: #fff; }
.sev.high { background: var(--high); }
.sev.medium { background: var(--med); }
.sev.low { background: var(--low); }
.sev.info { background: #56606f; color: #dfe6ef; }

/* formulários e botões */
input, select, textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 8px; font: inherit; width: 100%;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
button.primary {
  background: var(--accent); color: #1a1205; border: none; padding: 10px 16px;
  border-radius: 8px; font-weight: 600; cursor: pointer;
}
button.primary:hover { background: var(--accent-2); }
button.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
button.ghost:hover { border-color: var(--accent); }

/* login */
.login-wrap { display: grid; place-items: center; min-height: 82vh; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 30px; width: min(400px, 92vw); }
.login-box h1 { text-align: center; margin-bottom: 4px; }
.login-box .sub { text-align: center; }

/* avisos */
.banner { padding: 12px 15px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.banner.warn { background: #3a2a12; border: 1px solid #6b4d18; color: var(--accent-2); }
.banner.err { background: #3a1a18; border: 1px solid #6b2723; color: #ffb3ad; }
.banner.ok { background: #14301f; border: 1px solid #1f5c39; color: #9ae6bb; }

/* assistente */
.chat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.msgs { max-height: 45vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { padding: 10px 13px; border-radius: 10px; max-width: 82%; white-space: pre-wrap; font-size: 14px; }
.msg.user { background: var(--panel-2); align-self: flex-end; }
.msg.bot { background: #1a2331; border: 1px solid var(--line); align-self: flex-start; }
.chat-row { display: flex; gap: 8px; }
.muted { color: var(--muted); }
.report { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; white-space: pre-wrap; font-size: 14px; line-height: 1.6; }

/* ============================================================
   LAYOUT MÓVEL — usado no telemóvel e dentro da app nativa.
   O mesmo código serve os dois; muda a apresentação, não a lógica.
   ============================================================ */
:root { --safe-top: env(safe-area-inset-top, 0px); --safe-bot: env(safe-area-inset-bottom, 0px); }

body.mobile header.top {
  padding: calc(10px + var(--safe-top)) 16px 10px;
  gap: 10px;
}
body.mobile nav.tabs { display: none; }           /* passa para a barra de baixo */
body.mobile .who { margin-left: auto; font-size: 12px; }
body.mobile main { padding: 15px 15px calc(78px + var(--safe-bot)); }
body.mobile h1 { font-size: 19px; }
body.mobile .sub { font-size: 13px; }

/* barra de navegação inferior (só móvel) */
.tabbar { display: none; }
body.mobile .tabbar {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 7px 4px calc(9px + var(--safe-bot));
}
.tabbar button {
  flex: 1; background: transparent; border: 0; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 10.5px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 3px 0;
}
.tabbar button i { font-style: normal; font-size: 18px; line-height: 1; }
.tabbar button.active { color: var(--accent); }

/* cartões em vez de tabelas */
body.mobile .table-wrap table { display: none; }
.mcards { display: none; }
body.mobile .mcards { display: block; }
.mcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 9px;
}
.mcard .mtop { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.mcard .mtop b { font-size: 13.5px; }
.mcard .msub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.mcard .mrow { font-size: 12.5px; margin-top: 7px; }

/* score grande no painel */
.bigscore { display: none; }
body.mobile .bigscore { display: block; text-align: center; padding: 14px 0 6px; }
body.mobile .bigscore .n { font-size: 50px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
body.mobile .bigscore .st { margin-top: 8px; font-size: 15px; }
body.mobile .cards { display: none; }             /* substituído pelo score + severidades */
.sevrow { display: none; }
body.mobile .sevrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 14px 0; }
body.mobile .sevrow div {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 4px; text-align: center;
}
body.mobile .sevrow b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
body.mobile .sevrow small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }

body.mobile .chat .msgs { max-height: none; }
body.mobile .msg { max-width: 92%; }
body.mobile .login-box { width: min(420px, 94vw); padding: 26px 22px; }
