:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5;
  --ink: #0f172a; --ink-2: #475569; --muted: #94a3b8;
  --line: #e2e8f0; --brand: #4f46e5; --brand-ink: #ffffff;
  --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --radius: 10px; --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.hint { color: var(--ink-2); font-size: 13px; margin: 4px 0 12px; }
.err { color: var(--danger); font-size: 13px; }
code, .mono { font-family: var(--mono); }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 16px; margin: 0; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 20px 0 8px; }
hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---- Botões ---- */
.btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; transition: .15s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; }

input { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink); }
input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
label { display: block; margin: 12px 0; font-size: 13px; color: var(--ink-2); }
label input { margin-top: 5px; }

/* ---- Gate ---- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #eef2ff, var(--bg)); }
.gate-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand h1 { font-size: 18px; } .brand p { margin: 2px 0 0; }

/* ---- Topbar ---- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 16px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand-sm { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab { border: none; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  color: var(--ink-2); font: inherit; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.topbar #logout { margin-left: auto; }

/* ---- Layouts ---- */
.view { flex: 1; overflow: hidden; }
.three-pane { display: grid; grid-template-columns: 260px 1fr 300px; height: calc(100vh - 52px); }
.single { padding: 20px; overflow: auto; height: calc(100vh - 52px); }
.pane { padding: 16px; overflow: auto; border-right: 1px solid var(--line); }
.pane-side { border-right: none; background: var(--surface); }
.pane.narrow { max-width: 460px; } .pane-detail { background: var(--surface-2); }
.pane-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.empty { color: var(--muted); display: grid; place-items: center; height: 60%; }

/* ---- Lista de projetos ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 2px;
  display: flex; flex-direction: column; gap: 2px; }
.list li:hover { background: var(--surface-2); }
.list li.active { background: #eef2ff; }
.list li .li-name { font-weight: 600; }
.list li .li-meta { font-size: 12px; color: var(--muted); }

/* ---- Editor KV ---- */
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 3px 4px 3px 0; }
.kv td.k input { font-family: var(--mono); }
.kv td.rm { width: 30px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

/* ---- Painel lateral ---- */
.copyrow { display: flex; gap: 4px; }
.copyrow input { font-family: var(--mono); font-size: 12px; }
.secret-out { margin-top: 10px; padding: 10px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; }

/* ---- Auditoria ---- */
.status-cards { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.status-card { padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 160px; }
.status-card .label { font-size: 12px; color: var(--ink-2); }
.status-card .value { font-size: 15px; font-weight: 600; margin-top: 4px; }
.status-card.ok { border-color: #bbf7d0; background: #f0fdf4; }
.status-card.bad { border-color: #fecaca; background: #fef2f2; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #dcfce7; color: var(--ok); } .badge.bad { background: #fee2e2; color: var(--danger); }
.badge.warn { background: #fef3c7; color: var(--warn); }
table.audit { width: 100%; border-collapse: collapse; font-size: 13px; }
table.audit th, table.audit td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.audit th { color: var(--ink-2); font-weight: 600; }
table.audit td:nth-child(3) { font-family: var(--mono); font-size: 12px; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 50; }
.toast.err { background: var(--danger); }

@media (max-width: 860px) {
  .three-pane { grid-template-columns: 1fr; grid-auto-rows: min-content; height: auto; }
  .pane { border-right: none; border-bottom: 1px solid var(--line); }
}
