/* kpx — paleta de ivnbrv.dev (negro #151515 + teal #28afb8), minimalista, mobile-first.
   Teléfono: lista y detalle son pantallas separadas. ≥760px: lista a la izquierda, detalle a la derecha. */
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/poppins-latin-600-normal.woff2") format("woff2");
}

:root {
  --bg: #151515; --surface: #1c1c1c; --raised: #252525; --line: #313131;
  --ink: #f1f1f1; --muted: #a1a1a1; --faint: #6e6e6e;
  --accent: #28afb8; --accent-hover: #4cbec6; --accent-ink: #151515; --accent-text: #4cbec6;
  --accent-soft: rgba(40, 175, 184, .14);
  --digit: #4cbec6; --symbol: #f0b26b; --danger: #ff7a70; --danger-soft: rgba(255, 122, 112, .12);
  --f-head: "Poppins", system-ui, sans-serif;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Cantarell, sans-serif;
  --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --r: 12px; --bar: 56px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff; --surface: #f6f7f7; --raised: #eef0f0; --line: #e3e6e6;
    --ink: #151515; --muted: #6e6e6e; --faint: #a1a1a1;
    --accent-text: #1b7f86; --accent-soft: rgba(40, 175, 184, .12);
    --digit: #1b7f86; --symbol: #a8590f; --danger: #c0352b; --danger-soft: rgba(192, 53, 43, .08);
    color-scheme: light;
  }
}

* { box-sizing: border-box }
[hidden] { display: none !important } /* si no, los elementos con display propio ignoran el atributo hidden */
html, body { height: 100% }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
::selection { background: var(--accent-soft) }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }
.mono { font-family: var(--f-mono); font-size: 14px }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }

/* ---------- controles ---------- */
.input {
  width: 100%; min-height: 46px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint) }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft) }
textarea.input { resize: vertical; min-height: 96px }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 10px 18px; border: 1px solid var(--line); border-radius: 10px; background: transparent;
  font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--raised) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover) }
.btn.danger { color: var(--danger); border-color: transparent }
.btn.danger:hover { background: var(--danger-soft) }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--bg) }
.btn:disabled { opacity: .5; cursor: default }
.icon {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); position: relative;
}
.icon:hover { background: var(--raised); color: var(--ink) }
.icon.sm { width: 36px; height: 36px; border-radius: 8px }
.link { border: 0; background: none; padding: 6px 2px; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line) }
.link:hover { color: var(--ink); text-decoration-color: currentColor }
.err { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px }
.fine { margin: 0; color: var(--faint); font-size: 13px; text-align: center; text-wrap: balance }

/* ---------- desbloqueo ---------- */
.lock {
  min-height: 100%; display: grid; place-items: center;
  padding: calc(32px + var(--safe-t)) calc(20px + var(--safe-r)) calc(32px + var(--safe-b)) calc(20px + var(--safe-l));
}
.lock-in { width: 100%; max-width: 380px; display: grid; justify-items: center; gap: 6px }
.mark { width: 56px; height: 56px; margin-bottom: 10px }
.m-bg { fill: var(--accent) }
.m-body { fill: var(--accent-ink) }
.m-shackle { fill: none; stroke: var(--accent-ink); stroke-width: 3.2; stroke-linecap: round }
.brand { margin: 0; font: 600 32px/1 var(--f-head); letter-spacing: -.02em }
.tagline { margin: 0 0 22px; color: var(--muted) }
.lock-form { width: 100%; display: grid; gap: 12px }
.file {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; text-align: left;
  border: 1px dashed var(--line); border-radius: var(--r); background: var(--surface); color: var(--muted);
  transition: border-color .15s, background .15s;
}
.file:hover, .file.over { border-color: var(--accent); background: var(--accent-soft) }
.file.ready { border-style: solid; color: var(--accent-text) }
.file-txt { display: grid; min-width: 0 }
.file-txt strong { color: var(--ink); font-weight: 600; overflow-wrap: anywhere }
.file-txt small { font-size: 13px }
.field-pw { position: relative }
.field-pw .input { padding-right: 52px; font-family: var(--f-mono) }
.field-pw .icon { position: absolute; right: 1px; top: 1px; height: 44px }
.keyfile summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 0; list-style-position: inside }
.keyfile[open] summary { margin-bottom: 8px }
.keyfile .input { min-height: 0; padding: 8px }
.pending { display: grid; gap: 10px; padding: 14px; border-radius: var(--r); background: var(--accent-soft) }
.pending p { margin: 0; font-size: 14px }
.lock-links { display: flex; gap: 18px; margin: 18px 0 6px }

/* ---------- bóveda ---------- */
.vault { height: 100%; display: flex; flex-direction: column }
.bar {
  display: flex; align-items: center; gap: 2px; flex: none;
  min-height: calc(var(--bar) + var(--safe-t));
  padding: var(--safe-t) calc(6px + var(--safe-r)) 0 calc(6px + var(--safe-l));
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.bar-title { flex: 1; min-width: 0; padding: 0 8px; display: grid }
.bar-title h1 { margin: 0; font: 600 17px/1.25 var(--f-head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.bar-meta { color: var(--faint); font: 12px/1.3 var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.dirty { color: var(--symbol) }
#saveBtn.has-changes { color: var(--accent-text) }
#saveBtn.has-changes::after { content: ""; position: absolute; top: 10px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent) }
.menu-wrap { position: relative }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 230px; padding: 6px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
}
.menu button { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; text-align: left }
.menu button:hover { background: var(--raised) }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) }
.side { min-height: 0; display: flex; flex-direction: column }
.search { display: block; padding: 12px calc(14px + var(--safe-r)) 6px calc(14px + var(--safe-l)) }
.search input {
  width: 100%; min-height: 40px; padding: 8px 14px; border: 0; border-radius: 10px; background: var(--surface);
}
.search input:focus { outline: none; box-shadow: 0 0 0 2px var(--accent) }
.groups {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: none;
  padding: 6px calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
}
.groups::-webkit-scrollbar { display: none }
.chip {
  flex: none; display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; min-height: 32px;
  border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); font-size: 13px;
}
.chip:hover { color: var(--ink) }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg) }
.chip .n { font: 11px var(--f-mono); opacity: .7 }
.list { flex: 1; overflow-y: auto; padding-bottom: calc(16px + var(--safe-b)) }
.row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%;
  padding: 10px calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l)); border: 0; background: none; text-align: left;
}
.row:hover { background: var(--surface) }
.row[aria-selected="true"] { background: var(--accent-soft) }
.av {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--raised); color: var(--accent-text); font: 600 15px var(--f-head);
}
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.row .u { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.empty { padding: 48px 24px; color: var(--faint); text-align: center; text-wrap: balance }

.detail {
  min-height: 0; overflow-y: auto;
  padding: 20px calc(20px + var(--safe-r)) calc(32px + var(--safe-b)) calc(20px + var(--safe-l));
}
.dh { display: flex; gap: 14px; align-items: center; margin-bottom: 18px }
.dh .av { width: 48px; height: 48px; border-radius: 14px; font-size: 21px }
.dh h2 { margin: 0; font: 600 21px/1.2 var(--f-head); overflow-wrap: anywhere; text-wrap: balance }
.dh .g { color: var(--muted); font-size: 13px }
.fields { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden }
.f { display: flex; align-items: center; gap: 4px; padding: 10px 6px 10px 14px; min-height: 60px }
.f + .f { border-top: 1px solid var(--line) }
.f-main { flex: 1; min-width: 0; display: grid }
.f-label { color: var(--faint); font-size: 12px }
.f-val { overflow-wrap: anywhere }
.f-val a { color: var(--accent-text); text-decoration: none }
.f-val a:hover { text-decoration: underline }
.f-sub { color: var(--faint); font-size: 12px }
.none { color: var(--faint) }
.pw-val .d { color: var(--digit) } .pw-val .s { color: var(--symbol) }
.notes { margin-top: 16px; padding: 14px; border-radius: var(--r); background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px }
.meta { margin-top: 16px; color: var(--faint); font: 12px var(--f-mono) }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding: 12px 14px; border-radius: var(--r); background: var(--danger-soft) }
.confirm p { margin: 0; flex: 1 1 180px; font-size: 14px }

/* editor */
.edit { display: grid; gap: 14px; max-width: 560px }
.edit h2 { margin: 0 0 4px; font: 600 20px var(--f-head) }
.edit label { display: grid; gap: 6px; color: var(--muted); font-size: 13px }
.pwrow { display: flex; gap: 6px; align-items: center }
.pwrow .input { flex: 1; min-width: 0; font-family: var(--f-mono) }
.meter { height: 3px; border-radius: 2px; background: var(--raised); overflow: hidden }
.meter i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s }
.gen { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--faint); font-size: 13px }
.gen .input { width: 72px; min-height: 34px; padding: 4px 8px }

/* diálogo, avisos */
.dlg {
  width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--bg); color: var(--ink);
}
.dlg::backdrop { background: rgba(0, 0, 0, .6) }
.dlg form { display: grid; gap: 12px; padding: 22px }
.dlg h2 { margin: 0 0 4px; font: 600 18px var(--f-head) }
.dlg .fine { text-align: left }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px }
.check input { margin-top: 4px; accent-color: var(--accent) }
.check small { display: block; color: var(--faint); font-size: 12px }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30; bottom: calc(20px + var(--safe-b));
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.fallback {
  position: fixed; inset: auto 0 0 0; z-index: 31; display: grid; gap: 8px;
  padding: 14px calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l));
  border-top: 1px solid var(--line); background: var(--surface); font-size: 13px; color: var(--muted);
}
#fallbackClose { justify-self: start }

/* ---------- teléfono: lista y detalle como pantallas separadas ---------- */
.back { display: none }
@media (max-width: 759px) {
  .vault.open .side { display: none }
  .vault:not(.open) .detail { display: none }
  .vault.open .back { display: inline-grid }
}
/* ---------- tablet / escritorio ---------- */
@media (min-width: 760px) {
  .layout { grid-template-columns: 340px minmax(0, 1fr) }
  .side { border-right: 1px solid var(--line) }
  .groups { flex-wrap: wrap; overflow: visible }
  .detail { padding: 32px 40px }
  .detail > * { max-width: 640px }
}
@media (min-width: 1200px) { .layout { grid-template-columns: 380px minmax(0, 1fr) } }
@media (display-mode: standalone) { .lock-links #installBtn { display: none } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important } }
