:root {
  --bg: #060914;
  --surface: rgba(255, 255, 255, .045);
  --surface-hi: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .09);
  --line-hi: rgba(255, 255, 255, .18);
  --text: #f1f4ff;
  --muted: #8d99bb;
  --brand-1: #6366f1; --brand-2: #8b5cf6; --brand-3: #22d3ee;
  --grad: linear-gradient(135deg, var(--brand-1), var(--brand-2) 55%, #d946ef);
  --grad-cool: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  --ok: #34d399; --danger: #fb7185; --warn: #fbbf24;
  --radius: 16px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .65);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--text); line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(52rem 34rem at 8% -8%, rgba(99, 102, 241, .32), transparent 60%),
    radial-gradient(44rem 30rem at 100% 0%, rgba(34, 211, 238, .16), transparent 60%),
    radial-gradient(40rem 30rem at 60% 110%, rgba(217, 70, 239, .14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 1.4rem; font-weight: 700; }
a { color: var(--brand-3); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 3rem 1rem; }
.sr-only { position: fixed; left: -9999px; top: 0; opacity: 0; }
::selection { background: rgba(139, 92, 246, .5); }

/* Logo mark */
.logo { position: relative; display: inline-block; width: 2.1rem; height: 2.1rem; border-radius: 11px; background: var(--grad); box-shadow: 0 6px 22px -4px rgba(139, 92, 246, .7); flex: none; }
.logo::before { content: ""; position: absolute; left: 50%; top: 18%; width: 42%; height: 34%; transform: translateX(-50%); border: 2.5px solid #fff; border-bottom: 0; border-radius: 99px 99px 0 0; }
.logo::after { content: ""; position: absolute; left: 50%; bottom: 17%; width: 54%; height: 38%; transform: translateX(-50%); background: #fff; border-radius: 4px; }

/* Controls */
input, select, textarea {
  width: 100%; padding: .7rem .85rem; background: rgba(5, 8, 20, .55); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; font: inherit; transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: #5f6b8e; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--brand-2); padding: 0; }
input[type=file] { padding: .55rem; }
input:hover, select:hover, textarea:hover { border-color: var(--line-hi); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(139, 92, 246, .22); background: rgba(5, 8, 20, .8); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--brand-3); outline-offset: 2px; }
textarea { resize: vertical; }
select option { background: #11162b; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .62rem 1.05rem;
  background: var(--surface-hi); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: rgba(255, 255, 255, .13); border-color: var(--line-hi); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: .34rem .72rem; font-size: .82rem; border-radius: 10px; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 8px 26px -8px rgba(139, 92, 246, .85); }
.btn.primary:hover { filter: brightness(1.1); box-shadow: 0 12px 32px -8px rgba(139, 92, 246, 1); }
.btn.danger { background: linear-gradient(135deg, #f43f5e, #fb7185); border-color: transparent; color: #fff; font-weight: 600; }
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover { background: rgba(251, 113, 133, .12); border-color: rgba(251, 113, 133, .4); }
.btn.block { width: 100%; margin-top: 1.2rem; padding: .8rem; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: .3rem .55rem; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-hi); color: var(--text); }
.input-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.input-row input { flex: 1 1 12rem; width: auto; }
.actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; flex-wrap: wrap; }
.check { display: flex; gap: .6rem; align-items: center; margin-top: .9rem; }

/* Fields */
.field { display: block; margin-top: .95rem; }
.field > span { display: block; font-size: .8rem; font-weight: 500; color: var(--muted); margin-bottom: .35rem; letter-spacing: .02em; }
.field small { display: block; color: var(--muted); margin-top: .3rem; }
.field .error { display: none; color: var(--danger); font-style: normal; font-size: .85rem; margin-top: .3rem; }
.field.invalid .error { display: block; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(251, 113, 133, .15); }
.req { color: var(--danger); }
.banner { padding: .7rem .95rem; border-radius: 12px; margin: .85rem 0; border: 1px solid; font-size: .92rem; }
.banner.error { background: rgba(251, 113, 133, .1); border-color: rgba(251, 113, 133, .35); color: #fecdd3; }
.banner.ok { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .35); color: #a7f3d0; }
fieldset.share-box { margin: 1.1rem 0 0; padding: .8rem .95rem .95rem; border: 1px dashed var(--line-hi); border-radius: 14px; background: rgba(34, 211, 238, .04); }
.share-box legend { padding: 0 .4rem; font-size: .8rem; font-weight: 600; color: var(--brand-3); }
.share-box small { color: var(--muted); }
.chip-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip-check { display: inline-flex; align-items: center; gap: .5rem; padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.chip-check:hover { border-color: var(--brand-3); }
.chip-check:has(input:checked) { border-color: var(--brand-3); background: rgba(34, 211, 238, .12); }

/* Surfaces */
.card, .table-wrap, .entry, .sidebar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.card { padding: 1.2rem 1.3rem; margin-top: 1.1rem; }

/* Auth */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(26rem, 100%); padding: 2rem 1.8rem; background: rgba(14, 18, 38, .7); border-color: var(--line-hi); }
.brand-lg { display: flex; align-items: center; gap: .8rem; margin-bottom: .6rem; }
.brand-lg .logo { width: 2.8rem; height: 2.8rem; border-radius: 14px; }
.brand-lg h1 { font-size: 1.7rem; font-weight: 800; background: var(--grad-cool); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Shell */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem; position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
  background: rgba(6, 9, 20, .72); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .65rem; font-size: 1.05rem; }
.brand strong { font-weight: 800; letter-spacing: -.01em; }
.tabs { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; padding: .25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; width: fit-content; flex: 0 1 auto; }
.tab { background: none; border: 0; color: var(--muted); padding: .42rem .95rem; border-radius: 10px; font: inherit; font-weight: 500; cursor: pointer; transition: color .15s, background .15s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px -6px rgba(139, 92, 246, .9); }
.user { display: flex; gap: .5rem; margin-left: auto; }
.content { max-width: 80rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page { max-width: 62rem; animation: rise .35s ease both; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.title { display: flex; align-items: baseline; gap: .8rem; }
.title h2 { font-size: 1.6rem; }

/* Vault */
.layout { display: grid; grid-template-columns: 17rem 1fr; gap: 1.5rem; align-items: start; }
.sidebar { padding: .7rem; position: sticky; top: 5rem; max-height: calc(100vh - 7rem); overflow: auto; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: .35rem .55rem .7rem; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.side-sep { height: 1px; background: var(--line); margin: .45rem .5rem; }
.cat { display: flex; align-items: center; gap: .65rem; width: 100%; background: none; border: 0; color: var(--text); padding: .55rem .65rem; border-radius: 12px; font: inherit; cursor: pointer; text-align: left; transition: background .15s, transform .12s; }
.cat:hover { background: var(--surface-hi); }
.cat.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 8px 22px -10px rgba(139, 92, 246, .95); }
.cat-icon { width: 1.9rem; height: 1.9rem; display: grid; place-items: center; background: rgba(255, 255, 255, .07); border-radius: 9px; font-size: .95rem; flex: none; }
.cat.active .cat-icon { background: rgba(255, 255, 255, .2); }
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: .78rem; padding: .05rem .5rem; border-radius: 99px; background: rgba(255, 255, 255, .08); color: var(--muted); }
.cat.active .count { background: rgba(255, 255, 255, .22); color: #fff; }
.main > input[type=search] { margin-bottom: 1.1rem; padding: .85rem 1rem; border-radius: 14px; }
.entries { display: grid; gap: .85rem; }
.cat-tools { display: flex; gap: .5rem; }

.entry { padding: 1rem 1.15rem; transition: transform .18s, border-color .18s, box-shadow .18s; animation: rise .3s ease both; }
.entry:hover { transform: translateY(-2px); border-color: var(--line-hi); box-shadow: 0 18px 50px -18px rgba(99, 102, 241, .5); }
.entry > header { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.ident { display: flex; gap: .85rem; align-items: center; min-width: 0; }
.ident-text { min-width: 0; }
.avatar {
  --hue: 240; width: 2.8rem; height: 2.8rem; border-radius: 14px; display: grid; place-items: center; flex: none;
  font-weight: 800; font-size: 1.15rem; color: #fff;
  background: linear-gradient(135deg, hsl(var(--hue) 80% 58%), hsl(calc(var(--hue) + 50) 85% 48%));
  box-shadow: 0 8px 20px -8px hsl(var(--hue) 90% 55% / .9), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.title-line { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.entry h3 { font-size: 1.08rem; font-weight: 650; }
.badge { background: var(--surface-hi); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .6rem; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.badge.share { color: #67e8f9; border-color: rgba(34, 211, 238, .4); background: rgba(34, 211, 238, .1); }
.badge.kid { color: #f0abfc; border-color: rgba(217, 70, 239, .4); background: rgba(217, 70, 239, .1); }
.site { display: block; font-size: .84rem; margin-top: .1rem; word-break: break-all; color: var(--muted); }
a.site { color: var(--brand-3); }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: flex-start; }
.entry dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .8rem 1.25rem; margin: .95rem 0 0; padding-top: .9rem; border-top: 1px solid var(--line); }
.entry dl > div { min-width: 0; }
.entry dt { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.entry dd { margin: .25rem 0 0; display: flex; align-items: center; gap: .55rem; min-height: 2rem; }
.entry .value, .entry .secret { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace; font-size: .92rem; }
.secret { letter-spacing: .12em; color: var(--muted); }
.secret.revealed { color: var(--ok); letter-spacing: 0; text-shadow: 0 0 18px rgba(52, 211, 153, .45); animation: pop .25s ease; }
.notes { margin-top: .85rem; padding: .7rem .9rem; background: rgba(5, 8, 20, .55); border: 1px solid var(--line); border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
.empty { text-align: center; padding: 4rem 1.5rem; color: var(--muted); border: 1px dashed var(--line-hi); border-radius: var(--radius); background: var(--surface); }
.empty strong { color: var(--text); font-size: 1.1rem; }

/* Tables */
.table-wrap { overflow-x: auto; margin: .9rem 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
th { color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }
tr:last-child td { border-bottom: 0; }
.role-pill { display: inline-block; padding: .1rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-hi); border: 1px solid var(--line); }
.role-pill.admin { color: #c4b5fd; border-color: rgba(139, 92, 246, .5); background: rgba(139, 92, 246, .14); }
.role-pill.child { color: #f0abfc; border-color: rgba(217, 70, 239, .45); background: rgba(217, 70, 239, .12); }
.role-pill.member { color: #67e8f9; border-color: rgba(34, 211, 238, .45); background: rgba(34, 211, 238, .1); }

/* Dialog + toasts */
.modal { background: rgba(14, 18, 38, .92); backdrop-filter: blur(20px); color: var(--text); border: 1px solid var(--line-hi); border-radius: 20px; padding: 0; width: min(28rem, calc(100vw - 2rem)); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8); animation: pop .22s ease; }
.modal.wide { width: min(37rem, calc(100vw - 2rem)); }
.modal::backdrop { background: rgba(3, 5, 14, .72); backdrop-filter: blur(4px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.3rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.15rem; }
.modal-body { padding: .6rem 1.3rem 1.3rem; max-height: 76vh; overflow: auto; }
.toasts { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 50; }
.toast { background: rgba(20, 26, 52, .95); border: 1px solid var(--line-hi); border-left: 4px solid var(--ok); padding: .7rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow); animation: rise .25s ease; }
.toast.error { border-left-color: var(--danger); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: 15rem; }
  .tabs { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tab { white-space: nowrap; }
  .content { padding: 1rem .85rem 4rem; }
}

/* Two-step verification */
.qr-wrap { display: grid; place-items: center; margin: 1rem 0; }
.qr { background: #fff; padding: .6rem; border-radius: 14px; box-shadow: 0 10px 30px -10px rgba(99, 102, 241, .6); }
.manual { margin: .25rem 0 .5rem; color: var(--muted); font-size: .9rem; }
.manual summary { cursor: pointer; }
.secret-key { display: block; margin-top: .5rem; padding: .6rem .8rem; background: rgba(5, 8, 20, .6); border: 1px solid var(--line); border-radius: 10px; color: var(--text); letter-spacing: .08em; overflow-wrap: anywhere; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.25rem; letter-spacing: .25em; text-align: center; }
.codes { list-style: none; margin: 1rem 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.codes li { padding: .55rem .75rem; text-align: center; background: rgba(5, 8, 20, .6); border: 1px solid var(--line); border-radius: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
.link-btn { display: block; margin: 1rem auto 0; background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.auth-card .card { margin: 0; }
