/* Cofre — estilos. Tema claro e escuro por variáveis. Sem dependências externas. */

:root {
  --bg: #F5F5F2; --surface: #FFFFFF; --surface-2: #EFEFEB; --seg: #E9E9E4;
  --line: #E2E2DE; --line-2: #D6D6D1;
  --ink: #16171A; --ink-2: #3F4146; --muted: #5E6066; --faint: #8E9095;
  --accent: #1D6B47; --accent-bg: #E3F1E9;
  --warn: #8A4B00; --warn-bg: #FBEFD9; --warn-dot: #C77700;
  --bad: #B3261E; --bad-bg: #FBE4E2;
  --inv-bg: #16171A; --inv-ink: #FFFFFF;
  --focus: #1D6B47;
  --shadow: 0 12px 32px rgba(22, 23, 26, .14);
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 12px; --r-lg: 14px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #111214; --surface: #1A1B1E; --surface-2: #232428; --seg: #232428;
  --line: #2A2B2F; --line-2: #3A3B40;
  --ink: #EDEDEA; --ink-2: #C9C9C4; --muted: #9EA0A6; --faint: #75777D;
  --accent: #4CC38A; --accent-bg: #16301F;
  --warn: #E5AA4A; --warn-bg: #3A2C12; --warn-dot: #E5AA4A;
  --bad: #F2847D; --bad-bg: #3B1D1B;
  --inv-bg: #EDEDEA; --inv-ink: #111214;
  --focus: #4CC38A;
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #111214; --surface: #1A1B1E; --surface-2: #232428; --seg: #232428;
    --line: #2A2B2F; --line-2: #3A3B40;
    --ink: #EDEDEA; --ink-2: #C9C9C4; --muted: #9EA0A6; --faint: #75777D;
    --accent: #4CC38A; --accent-bg: #16301F;
    --warn: #E5AA4A; --warn-bg: #3A2C12; --warn-dot: #E5AA4A;
    --bad: #F2847D; --bad-bg: #3B1D1B;
    --inv-bg: #EDEDEA; --inv-ink: #111214;
    --focus: #4CC38A;
    --shadow: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--ink); }
a:hover { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; font-weight: 600; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 18px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.lg { width: 22px; height: 22px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-2);
  background: transparent; color: var(--ink); font-weight: 500; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--inv-bg); color: var(--inv-ink); border-color: var(--inv-bg); font-weight: 600; }
.btn-primary:hover { color: var(--inv-ink); opacity: .9; }
.btn-danger { color: var(--bad); }
.btn-block { width: 100%; height: 52px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-ghost { border-color: transparent; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.link { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font-weight: 500; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); outline: none; font-size: 15px;
}
.field textarea { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); }
.input-wrap { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 4px 0 14px; min-height: 48px; }
.input-wrap:focus-within { border-color: var(--ink); }
.input-wrap input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; min-height: 46px; padding: 0; font-size: 15px; }
.input-wrap.strong { border-color: var(--ink); min-height: 56px; }
.input-wrap.strong input { font-family: var(--mono); font-size: 17px; letter-spacing: .06em; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ink); flex-shrink: 0; }
input[type="range"] { width: 100%; accent-color: var(--ink); }
.form { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.err { color: var(--bad); font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- Segmentado ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--seg); padding: 4px; border-radius: 12px; border: 0; margin: 0; }
.seg button, .seg label { height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[aria-pressed="true"], .seg label:has(input:checked) { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- Cartões e listas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card.pad { padding: 20px; }
.rows > * { border-bottom: 1px solid var(--line); }
.rows > *:last-child { border-bottom: 0; }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 12px 0 18px; }
.row-btn { text-decoration: none; width: 100%; background: transparent; border: 0; text-align: left; cursor: pointer; color: var(--ink); font-size: 15px; }
.row-btn:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .val { color: var(--muted); font-family: var(--mono); font-size: 14px; }
.section-label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.ok { color: var(--accent); background: var(--accent-bg); }
.dot { width: 8px; height: 8px; border-radius: 4px; display: inline-block; flex-shrink: 0; }
.dot.bad { background: var(--bad); } .dot.warn { background: var(--warn-dot); } .dot.mute { background: var(--faint); } .dot.ok { background: var(--accent); }
.avatar { width: 36px; height: 36px; border-radius: 9px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 15px; font-weight: 500; flex-shrink: 0; color: var(--ink); }
.avatar.lg { width: 56px; height: 56px; border-radius: 14px; font-size: 24px; background: var(--inv-bg); color: var(--inv-ink); }
.callout { border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.callout ol { margin: 4px 0 0; padding-left: 20px; }
.callout-bad { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }
.callout-warn { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }
.kv { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 10px 8px 10px 18px; min-height: 56px; }
.kv .k { font-size: 13px; color: var(--muted); }
.kv .v { font-size: 15px; overflow-wrap: anywhere; min-width: 0; }
.kv .v.secret { font-family: var(--mono); letter-spacing: .04em; }
.kv .acts { display: flex; }
.totp { font-family: var(--mono); font-size: 24px; font-weight: 500; letter-spacing: .08em; color: var(--accent); }
.ring { width: 32px; height: 32px; position: relative; display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: var(--surface-2); } .ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.meter { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.meter > div { height: 100%; border-radius: 2px; transition: width .2s; }
.pw-big { font-family: var(--mono); font-size: 22px; line-height: 1.45; word-break: break-all; min-height: 64px; }
.pw-big .d { color: var(--accent); } .pw-big .s { color: var(--warn); }
.ticks { display: grid; gap: 3px; }
.ticks > div { height: 12px; border-radius: 2px; background: var(--line-2); }
.ticks > div.on { background: var(--accent); }
.score { font-family: var(--mono); font-size: 72px; line-height: 1; font-weight: 500; letter-spacing: -0.04em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.stat .n { font-family: var(--mono); font-size: 30px; font-weight: 500; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--line-2); background: transparent; color: var(--ink); font-size: 13px; white-space: nowrap; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--inv-bg); color: var(--inv-ink); border-color: var(--inv-bg); font-weight: 500; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 6px; color: var(--muted); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- Estrutura ---------- */
#app { min-height: 100%; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.brand-mark { width: 20px; height: 20px; display: inline-block; background: currentColor; -webkit-mask: url("../icons/mark.svg") center / contain no-repeat; mask: url("../icons/mark.svg") center / contain no-repeat; }

.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.side { width: 240px; flex-shrink: 0; border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; }
.side .brand { padding: 0 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 12px; border-radius: 9px; text-decoration: none; font-size: 14px; color: var(--ink-2); gap: 10px; }
.nav a .lbl { display: flex; align-items: center; gap: 10px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--seg); color: var(--ink); font-weight: 600; }
.nav .cnt { font-family: var(--mono); font-size: 12px; color: var(--muted); font-weight: 400; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 12px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 32px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.search:focus-within { border-color: var(--ink); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 15px; }
.split { flex: 1; display: flex; min-height: 0; }
.list-col { width: 380px; flex-shrink: 0; border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.detail-col { flex: 1; min-width: 0; padding: 32px 40px; overflow-y: auto; }
.page { padding: 40px; max-width: 980px; width: 100%; display: flex; flex-direction: column; gap: 28px; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hstack { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.item-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.item-row:hover { background: var(--surface-2); color: var(--ink); }
.item-row[aria-current="true"] { background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.item-row .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.item-row .n { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .u { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 12px 10px; font-size: 12px; color: var(--muted); }

.detail-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.detail-head .t { flex: 1; min-width: 0; }
.detail-head h1 { font-size: 26px; overflow-wrap: anywhere; }
.meta3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 20px; }
.meta3 > div { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.meta3 .k { font-size: 12px; color: var(--muted); }

.bottom-nav { display: none; }
.fab { display: none; }
.mobile-only { display: none !important; }

/* ---------- Telas de acesso ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 28px 24px; }
.gate-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gate-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 0; }
.gate-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 26px; }
.gate-card h1 { font-size: 34px; }
.gate-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.recovery-key { font-family: var(--mono); font-size: 20px; letter-spacing: .06em; padding: 18px; border: 1px dashed var(--ink-2); border-radius: 12px; text-align: center; word-break: break-all; background: var(--surface); }

/* ---------- Diálogos e avisos ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 10, 12, .5); }
.dlg { padding: 24px; display: flex; flex-direction: column; gap: 18px; max-height: 85vh; overflow-y: auto; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--inv-bg); color: var(--inv-ink); border-radius: 12px; padding: 14px 16px; font-size: 13px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); animation: up .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.qr { background: #fff; padding: 12px; border-radius: 12px; display: inline-flex; align-self: center; }
.qr canvas, .qr img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }

/* ---------- Instalador ---------- */
body.install { min-height: 100vh; }
.install-wrap { max-width: 720px; margin: 0 auto; padding: 32px 24px 64px; display: flex; flex-direction: column; gap: 22px; }
.install-head { display: flex; justify-content: space-between; align-items: center; }
.install .card { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.install h2 { margin-top: 6px; }
.install .grid2 { gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.req { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.req li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.req li:last-child { border-bottom: 0; }
.req li > span:nth-child(2) { flex: 1; }
.req-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--accent); }
.req li.bad .req-dot { background: var(--bad); } .req li.warn .req-dot { background: var(--warn-dot); }
.req-state { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.install .seg label { font-size: 13px; }

/* ---------- Kit de emergência (impressão) ---------- */
.kit { max-width: 720px; margin: 0 auto; padding: 40px 24px; display: flex; flex-direction: column; gap: 22px; }
.kit-sheet { border: 1px solid var(--line-2); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 18px; background: var(--surface); }
.kit-line { border-bottom: 1px solid var(--ink-2); height: 34px; }
@media print {
  html, body { background: #fff !important; color: #000 !important; }
  .no-print, .side, .bottom-nav, .topbar, .toast-wrap { display: none !important; }
  .kit { padding: 0; } .kit-sheet { border-color: #000; }
  .shell { display: block; } .main { display: block; }
}

/* ---------- Celular ---------- */
@media (max-width: 899px) {
  .side { display: none; }
  .mobile-only { display: flex !important; }
  .desk-only { display: none !important; }
  .main { padding-bottom: 84px; }
  .topbar { padding: 16px 20px 12px; border-bottom: 0; }
  .split { display: block; }
  .list-col { width: auto; border-right: 0; padding: 0 12px 12px; overflow: visible; }
  .detail-col { padding: 16px 20px 32px; }
  .page { padding: 20px 20px 32px; gap: 22px; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 6px 10px 16px; }
  .kv .k { grid-column: 1; }
  .kv .v { grid-column: 1; }
  .kv .acts { grid-column: 2; grid-row: 1 / span 2; }
  .detail-col.split-hidden, .list-col.split-hidden { display: none; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--muted); text-decoration: none; font-size: 11px; }
  .bottom-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
  .fab {
    display: flex; position: fixed; right: 20px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 21;
    width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--inv-bg); color: var(--inv-ink);
    align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow);
  }
  h1 { font-size: 26px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; gap: 6px; }
  .stat .n { font-size: 24px; }
  .detail-head { gap: 12px; }
  .detail-head .t { flex: 1 1 180px; }
  .detail-head > .hstack { flex: 1 1 100%; }
  .btn.mobile-only { display: inline-flex !important; margin: 0 0 12px -10px; }
  .meta3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score { font-size: 64px; }
  .gate { padding: 24px 20px; }
  .gate-card h1 { font-size: 30px; }
  .toast-wrap { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
