:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f0f3f7; --border: #dde3ea;
  --text: #16202c; --muted: #5d6b7c; --accent: #0b5fd6; --accent-text: #ffffff; --accent-soft: #e4eefc;
  --ok: #17794a; --ok-soft: #dff4e8; --warn: #9a6200; --warn-soft: #fdf0d2; --bad: #b3261e; --bad-soft: #fbe3e1;
  --side: #101a28; --side-text: #b9c4d2; --side-active: #1d2c42;
  --radius: 8px; --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141c; --surface: #17202b; --surface-2: #1e2935; --border: #2b3847;
    --text: #e6ecf3; --muted: #94a3b5; --accent: #5b9dff; --accent-text: #0a1220; --accent-soft: #1b2f4d;
    --ok: #5fd39a; --ok-soft: #173a2a; --warn: #f0b955; --warn-soft: #40310f; --bad: #ff8a80; --bad-soft: #4a1f1c;
    --side: #0a1017; --side-active: #18243a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
h1 { font-size: 20px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 12px 16px; letter-spacing: .2px; }
.brand span { color: #6ea8ff; }
.side a { color: inherit; text-decoration: none; padding: 8px 12px; border-radius: 6px; display: block; }
.side a:hover { background: var(--side-active); color: #fff; }
.side a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #6ea8ff; }
.side .spacer { flex: 1; }
.side .who { padding: 10px 12px; font-size: 12.5px; border-top: 1px solid #223044; margin-top: 8px; overflow-wrap: anywhere; }
.main { padding: 24px 28px 60px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 2px 0 0; color: var(--muted); }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .side .brand { width: 100%; padding-bottom: 6px; }
  .side .spacer, .side .who { display: none; }
  .main { padding: 16px; }
}

/* blocos */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* tabela */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* botões e formulários */
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 6px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 6px; }
button.link.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea { font: inherit; width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; }
textarea { min-height: 64px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
label.field > small, .hint { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
label.check { display: flex; align-items: center; margin-bottom: 10px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; font-size: 13px; }
.checklist { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.rule-row { display: grid; grid-template-columns: 1.1fr .9fr 1.2fr 1fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.kv-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 6px; margin-bottom: 6px; }
@media (max-width: 640px) { .rule-row, .kv-row { grid-template-columns: 1fr; } }

/* etiquetas */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); margin: 1px 3px 1px 0; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(8, 14, 22, .55); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow: auto; z-index: 20; }
.modal { background: var(--surface); border-radius: 10px; width: 100%; max-width: 720px; border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.error { background: var(--bad-soft); color: var(--bad); padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }
.notice { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.secret { background: var(--surface-2); border: 1px dashed var(--border); padding: 10px 12px; border-radius: 6px; font-family: var(--mono); overflow-wrap: anywhere; margin-bottom: 10px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow: auto; font-family: var(--mono); font-size: 12.5px; max-height: 480px; margin: 0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 26px; }
.login h1 { margin-bottom: 4px; }

/* gráfico */
.chart { width: 100%; height: 180px; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar.err { fill: var(--bad); }
.chart text { fill: var(--muted); font-size: 10px; }
.chart line { stroke: var(--border); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.meter > div { height: 100%; background: var(--accent); }
.meter.hot > div { background: var(--bad); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 40; }
.toast { background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 380px; }
.toast.bad { background: var(--bad); color: #fff; }

.side .who .tag { background: #223044; border-color: #2f4058; color: #d5deea; }
.action-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.action-item:last-child { border-bottom: 0; padding-bottom: 0; }
.action-item:first-child { padding-top: 0; }
.action-item button { white-space: nowrap; min-width: 130px; }

.error { white-space: pre-wrap; overflow-wrap: anywhere; }
textarea.code { font-family: var(--mono); font-size: 12.5px; line-height: 1.45; white-space: pre; overflow: auto; min-height: 320px; tab-size: 4; }

.mfa-setup { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; margin: 4px 0 16px; }
.mfa-setup > div { flex: 1 1 220px; min-width: 0; }
.mfa-qr img { display: block; margin-top: 8px; background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--border); image-rendering: pixelated; }
