:root {
  --bg: #0f1420;
  --surface: #1a2233;
  --surface-2: #232e45;
  --border: #2e3a55;
  --text: #e8ecf4;
  --muted: #8b97ad;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --danger: #e5534b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--danger); font-size: 0.9rem; margin: 0.5rem 0 0; }
.spacer { flex: 1; }

/* ── telas ─────────────────────────────── */
.center-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.auth-card p { font-size: 0.9rem; line-height: 1.5; }

/* ── formulários ───────────────────────── */
label { display: block; margin: 1rem 0 0; font-size: 0.85rem; color: var(--muted); }
label.inline { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; }

input[type="text"], input[type="password"], input[type="search"],
input[type="number"], textarea {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="number"] { width: 4.5rem; }
textarea { resize: vertical; }

.row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.3rem; }
.row.end { margin-top: 1.5rem; }
.row input { margin-top: 0; flex: 1; }

/* ── botões ────────────────────────────── */
.btn {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.wide { width: 100%; margin-top: 1.5rem; }
.btn.icon { padding: 0.45rem 0.6rem; font-size: 1rem; line-height: 1; }

/* ── topbar ────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-weight: 700; white-space: nowrap; }
.topbar input[type="search"] { flex: 1; margin-top: 0; min-width: 0; }

.menu {
  position: absolute;
  top: 100%;
  right: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.menu button {
  display: block;
  width: 100%;
  padding: 0.7rem 1.1rem;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
}
.menu button:hover { background: var(--surface); }

/* ── lista de entradas ─────────────────── */
.entry-list { max-width: 720px; margin: 1rem auto; padding: 0 1rem; }

.entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.entry-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-user { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-actions { display: flex; gap: 0.35rem; }

#empty-msg { margin-top: 3rem; }

/* ── modais ────────────────────────────── */
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem 2rem;
  width: 100%;
  max-width: 460px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0; font-size: 1.2rem; }

.gen-options {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  flex-wrap: wrap;
}

/* ── toast ─────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--accent);
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

/* ── mobile ────────────────────────────── */
@media (max-width: 540px) {
  .topbar { flex-wrap: wrap; }
  .topbar input[type="search"] { order: 3; flex-basis: 100%; }
  dialog { max-width: calc(100vw - 2rem); padding: 1.25rem; }
  .card { padding: 1.5rem; }
}

/* ── editor de texto único (ccofre) ────── */
.editor-wrap {
  max-width: 860px;
  margin: 1rem auto;
  padding: 0 1rem 1rem;
  display: flex;
  height: calc(100vh - 80px);
}
#vault-text {
  flex: 1;
  width: 100%;
  resize: none;
  padding: 1rem 1.2rem;
  font-size: 1rem;
  line-height: 1.6;
  border-radius: var(--radius);
}
.save-status { font-size: 0.85rem; white-space: nowrap; }
.save-status.warn { color: #e8b84f; }
