/* KeyDirect. Light theme, large type, high contrast. */
:root {
  --brand: #0f5132;
  --brand-2: #14734a;
  --brand-3: #198754;
  --brand-soft: #e3f1e8;
  --ink: #16211b;
  --ink-2: #4a5650;
  --muted: #6b766f;
  --bg: #f3f5f3;
  --surface: #ffffff;
  --line: #dfe5e0;
  --line-2: #c9d2cb;
  --red: #b42318;
  --red-soft: #fde8e6;
  --amber: #b54708;
  --amber-soft: #fff1dc;
  --focus: #2563eb;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(16,33,27,.06), 0 6px 24px rgba(16,33,27,.06);
  --side-w: 260px;
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.75rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 1.6rem 0 .6rem; }
p { margin: .35rem 0 .9rem; }
.muted { color: var(--muted); }
.fine { font-size: .92rem; color: var(--muted); }
.lead { font-size: 1.12rem; color: var(--ink-2); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 1.02rem; word-break: break-all; }
.admin-authenticator-qr { display: block; max-width: 100%; height: auto; margin: 1rem auto; }
[hidden] { display: none !important; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--brand-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--side-w); flex: none; background: linear-gradient(180deg, #0f5132 0%, #0b3d26 100%); color: #e8f1ec; display: flex; flex-direction: column; padding: 1.1rem .9rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .7rem; padding: .3rem .6rem 1.2rem; font-size: 1.15rem; color: #fff; }
.brand-name b { font-weight: 800; }
.brand-mark { display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .7rem; background: #fff; color: var(--brand); }
.brand-mark svg { width: 1.3rem; height: 1.3rem; }
.brand-mark.big { width: 2.8rem; height: 2.8rem; }
.side-nav { display: flex; flex-direction: column; gap: .25rem; }
.side-link { display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left; background: transparent; border: none; color: #d6e6dc; font: inherit; font-size: 1.02rem; font-weight: 600; padding: .7rem .8rem; border-radius: var(--radius-s); cursor: pointer; position: relative; }
.side-link:hover { background: rgba(255,255,255,.09); color: #fff; }
.side-link.active { background: rgba(255,255,255,.16); color: #fff; }
.side-link svg { width: 1.3rem; height: 1.3rem; }
.nav-badge { margin-left: auto; background: #f59e0b; color: #1a1200; font-size: .8rem; font-weight: 800; min-width: 1.5rem; height: 1.5rem; border-radius: 1rem; display: inline-grid; place-items: center; padding: 0 .4rem; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: .7rem; padding: .8rem .6rem .5rem; border-top: 1px solid rgba(255,255,255,.14); }
.side-avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; }
.side-name { font-weight: 700; color: #fff; line-height: 1.2; }
.side-role { font-size: .85rem; color: #b9d1c2; }
.side-actions { display: flex; gap: .4rem; padding: .3rem .4rem 0; }
.side-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); color: #fff; font: inherit; font-size: .9rem; font-weight: 600; padding: .5rem .4rem; border-radius: var(--radius-s); cursor: pointer; white-space: nowrap; }
.side-btn:hover { background: rgba(255,255,255,.2); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- top bar and content ---------- */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; padding: 1.6rem 2rem 1rem; flex-wrap: wrap; }
.topbar p { margin: .1rem 0 0; }
.topbar-actions { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 999px; padding: .45rem .9rem; min-width: 16rem; color: var(--muted); }
.search:focus-within { border-color: var(--brand-3); box-shadow: 0 0 0 3px rgba(25,135,84,.18); }
.search input { border: none; outline: none; font: inherit; font-size: 1.02rem; background: transparent; flex: 1; color: var(--ink); min-width: 0; }
.content { padding: 0 2rem 2rem; }
.content.narrow { max-width: 820px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-size: 1rem; font-weight: 600; padding: .55rem 1rem; border-radius: var(--radius-s); border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: #f6f8f6; border-color: #b3bfb6; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: var(--brand); border-color: var(--brand); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef2ef; }
.btn.danger { color: var(--red); border-color: #f0c2bd; }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { font-size: .9rem; padding: .3rem .65rem; }
.btn.lg { font-size: 1.08rem; padding: .7rem 1.25rem; }
.btn.xl { font-size: 1.2rem; padding: .9rem 1.5rem; }
.btn.block { width: 100%; }
.btn.icon-only { padding: .5rem; }
.btn.icon-only svg { width: 1.25rem; height: 1.25rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.push { margin-left: auto; }

/* ---------- entry screens ---------- */
.screen { flex: 1; display: grid; place-items: center; padding: 2rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.2rem 2.4rem; }
.panel.narrow { width: min(560px, 100%); text-align: center; }
.panel h1 { margin-bottom: .4rem; }
.panel-icon { width: 4rem; height: 4rem; border-radius: 50%; background: var(--brand-soft); color: var(--brand-2); display: grid; place-items: center; margin: 0 auto 1rem; }
.panel-icon svg { width: 2rem; height: 2rem; }
.panel-icon.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(25,135,84,.35); } 50% { box-shadow: 0 0 0 14px rgba(25,135,84,0); } }
.kv { display: flex; justify-content: space-between; gap: 1rem; background: var(--bg); border-radius: var(--radius-s); padding: .7rem 1rem; margin: 1rem 0; }
.spinner { width: 2.4rem; height: 2.4rem; border: 4px solid var(--line); border-top-color: var(--brand-3); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero { flex: 1; display: grid; grid-template-columns: 1.15fr 1fr; min-height: 100vh; }
.hero-panel { background: linear-gradient(160deg, #0f5132, #0b3d26 70%, #082d1c); color: #fff; padding: 4rem 3.5rem; display: flex; flex-direction: column; justify-content: center; }
.hero-brand { display: flex; align-items: center; gap: .8rem; font-size: 1.3rem; font-weight: 700; margin-bottom: 2.5rem; }
.hero-panel h1 { font-size: 2.4rem; line-height: 1.15; margin-bottom: .8rem; }
.hero-panel p { font-size: 1.15rem; color: #cfe3d6; }
.hero-points { list-style: none; padding: 0; margin: 2rem 0 0; display: flex; flex-direction: column; gap: .8rem; font-size: 1.05rem; }
.hero-points li { display: flex; gap: .7rem; align-items: center; }
.hero-points svg { color: #7bd3a3; }
.hero-card { display: flex; flex-direction: column; justify-content: center; padding: 3rem; max-width: 520px; width: 100%; margin: 0 auto; }
.hero-card h2 { margin: 0 0 .3rem; font-size: 1.8rem; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 1rem; text-align: left; }
.field { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .98rem; }
.field input, .field textarea, .field select, .inline-form input { font: inherit; font-size: 1.05rem; padding: .62rem .75rem; border: 1.5px solid var(--line-2); border-radius: var(--radius-s); background: #fff; color: var(--ink); width: 100%; font-weight: 400; }
.field input:focus, .field textarea:focus, .field select:focus, .inline-form input:focus { outline: none; border-color: var(--brand-3); box-shadow: 0 0 0 3px rgba(25,135,84,.18); }
.inline { display: flex; gap: .5rem; align-items: stretch; flex-wrap: wrap; }
.field input.masked { -webkit-text-security: disc; }
.inline input { flex: 1 1 10rem; min-width: 0; width: auto; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .4rem; }
.inline-form { display: flex; gap: .6rem; margin-bottom: 1rem; max-width: 640px; }

.own-pending { padding: 0 2rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.own-pending > .card > svg { width: 2rem; height: 2rem; color: var(--amber); }

/* ---------- vault split ---------- */
.split { flex: 1; display: grid; grid-template-columns: minmax(250px, 36%) 1fr; gap: 1.2rem; padding: 0 2rem 2rem; min-height: 0; }
.item-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 150px); padding: .4rem; }
.row { display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left; background: transparent; border: none; font: inherit; color: var(--ink); padding: .7rem .8rem; border-radius: var(--radius-s); cursor: pointer; }
.row:hover { background: #f1f5f2; }
.row.active { background: var(--brand-soft); }
.row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tag { font-size: .78rem; font-weight: 700; color: var(--brand-2); background: var(--brand-soft); padding: .1rem .45rem; border-radius: 1rem; }
.avatar { width: 2.6rem; height: 2.6rem; border-radius: .75rem; display: inline-grid; place-items: center; font-weight: 800; font-size: 1.15rem; color: #fff; flex: none; }
.avatar.lg { width: 3.4rem; height: 3.4rem; font-size: 1.5rem; border-radius: 1rem; }
.avatar.c0 { background: #0f5132; } .avatar.c1 { background: #1d4ed8; } .avatar.c2 { background: #7c2d12; } .avatar.c3 { background: #6d28d9; } .avatar.c4 { background: #0e7490; }
.avatar.c5 { background: #9f1239; } .avatar.c6 { background: #4d7c0f; } .avatar.c7 { background: #92400e; } .avatar.c8 { background: #1e3a8a; } .avatar.c9 { background: #065f46; }
.avatar.folder { background: var(--brand-soft); color: var(--brand-2); }
.avatar.folder svg { width: 1.6rem; height: 1.6rem; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 420px; overflow: auto; max-height: calc(100vh - 150px); }
.detail-inner { padding: 1.4rem 1.5rem; }
.detail-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.detail-title { flex: 1; min-width: 10rem; display: flex; flex-direction: column; }
.detail-title h2 { margin: 0; font-size: 1.5rem; }
.d-uri { font-size: .95rem; word-break: break-all; }
.detail-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.act-back { display: none; }
.fields { margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.f { background: var(--bg); border-radius: var(--radius-s); padding: .7rem 1rem; }
.f dt { font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.f dd { margin: .2rem 0 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.f dd > span:first-child { flex: 1; min-width: 8rem; }
.d-notes { white-space: pre-wrap; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; color: var(--muted); padding: 3rem 1rem; text-align: center; min-height: 320px; }
.empty svg { width: 3rem; height: 3rem; color: var(--line-2); }
.empty.small { min-height: 160px; padding: 1.5rem; }
.empty.small svg { color: var(--brand-3); }

/* ---------- cards, stats, tabs, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.cards { display: flex; flex-direction: column; gap: .8rem; }
.card-text { flex: 1; min-width: 12rem; }
.card-title { font-weight: 700; font-size: 1.1rem; }
.card-meta { font-size: .9rem; }
.card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card.pending { border-left: 5px solid #f59e0b; }
.callout { gap: .9rem; margin-bottom: 1rem; align-items: center; }
.callout svg { color: var(--brand-2); width: 1.6rem; height: 1.6rem; }
.steps { padding-left: 1.4rem; font-size: 1.05rem; }
.steps li { margin: .45rem 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1.4rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; display: flex; flex-direction: column; }
.stat-n { font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--brand); }
.stat-l { color: var(--muted); font-size: .92rem; font-weight: 600; }
.stat.warn .stat-n { color: var(--amber); }
.tabs { display: flex; gap: .2rem; border-bottom: 2px solid var(--line); margin-bottom: 1.2rem; flex-wrap: wrap; }
.tab { background: transparent; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; font: inherit; font-weight: 700; color: var(--muted); padding: .6rem .9rem; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand-2); border-bottom-color: var(--brand-2); }
.table-card { padding: 0; overflow: auto; display: block; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8faf8; }
.table tr:last-child td { border-bottom: none; }
.table td.mono { font-size: .88rem; color: var(--ink-2); }
.table td.actions { white-space: nowrap; }
.table td.actions .btn + .btn { margin-left: .4rem; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 1rem; font-size: .85rem; font-weight: 700; background: #eef2ef; color: var(--ink-2); }
.badge.ok { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.checks { display: flex; flex-direction: column; gap: .2rem; max-height: 55vh; overflow: auto; padding: .6rem; }
.checks label { display: flex; gap: .7rem; align-items: center; font-size: 1.02rem; padding: .45rem .6rem; border-radius: var(--radius-s); cursor: pointer; width: 100%; }
.checks label:hover { background: var(--bg); }
.checks input { width: 1.25rem; height: 1.25rem; accent-color: var(--brand-2); }

/* ---------- recovery kit ---------- */
.panel.kit { width: min(640px, 100%); text-align: center; }
.kit-code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 1.7rem; letter-spacing: .08em; font-weight: 700; background: var(--bg); border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 1.2rem; margin: 1rem 0; word-break: break-all; user-select: all; }
.check { display: flex; gap: .6rem; align-items: center; justify-content: center; font-weight: 600; margin: .6rem 0; }
.check input { width: 1.3rem; height: 1.3rem; accent-color: var(--brand-2); }
.row-actions { display: flex; gap: .8rem; align-items: center; margin-bottom: .8rem; flex-wrap: wrap; }
.warn-text { color: var(--amber); font-weight: 700; }
@media print {
  .sidebar, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  .screen { padding: 0; display: block; }
  .panel { box-shadow: none; border: none; }
  .panel-icon { display: none; }
}

/* ---------- toast ---------- */
.toast { position: fixed; right: 1.5rem; bottom: 1.5rem; background: #16211b; color: #fff; padding: .8rem 1.1rem; border-radius: var(--radius-s); font-size: 1rem; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: min(420px, 90vw); z-index: 20; display: flex; gap: .6rem; align-items: center; }
.toast.error { background: var(--red); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-panel { padding: 2.5rem 1.6rem; }
  .split { grid-template-columns: 1fr; }
  .split.showing-detail .item-list { display: none; }
  .split:not(.showing-detail) .detail { display: none; }
  .act-back { display: inline-flex; }
}
@media (max-width: 760px) {
  html { font-size: 16px; }
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .6rem .8rem; gap: .4rem; }
  .brand { padding: .2rem .4rem; }
  .side-nav { flex-direction: row; flex: 1; }
  .side-link span:not(.nav-badge) { display: none; }
  .side-link { padding: .55rem; }
  .side-user { display: none; }
  .side-actions { padding: 0; margin-left: auto; }
  .topbar, .content, .split { padding-left: 1rem; padding-right: 1rem; }
  .search { min-width: 0; flex: 1; }
  .detail-inner { padding: 1.1rem; }
}

/* Optional field label and helper text under an input */
.field .opt { font-weight: 400; color: var(--muted); }
.field .hint { display: block; margin-top: .35rem; font-size: .9rem; color: var(--muted); font-weight: 400; }
.d-totp { font-size: 1.35rem; letter-spacing: .08em; }
.d-totp-left { min-width: 2.6rem; text-align: center; font-variant-numeric: tabular-nums; }

/* Earlier passwords, Recently deleted, Bring in passwords */
.vault-tools { display: flex; gap: .4rem; flex-wrap: wrap; padding: 0 2rem .6rem; margin-top: -.4rem; }
.history { margin-top: 1.1rem; }
.d-history { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.hist-row { background: var(--bg); border-radius: var(--radius-s); padding: .6rem .8rem; }
.hist-val { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .25rem; }
.hist-val .mono { margin-right: auto; word-break: break-all; }
.list-rows { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.list-row { display: flex; align-items: center; gap: .8rem; background: var(--bg); border-radius: var(--radius-s); padding: .6rem .8rem; }
.list-row .card-text { flex: 1; min-width: 0; }
.list-row .card-title { font-weight: 700; overflow-wrap: anywhere; }
.import-drop { display: block; border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 1.4rem; text-align: center; cursor: pointer; margin: 1rem 0; }
.import-drop:hover { background: var(--brand-soft); border-color: var(--brand-2); }
.import-drop input { display: block; margin: .8rem auto 0; font: inherit; }
.warn-box { background: var(--amber-soft); color: #5c2a04; border-radius: var(--radius-s); padding: .8rem 1rem; margin: 1rem 0; }
.warn-box strong { color: var(--amber); }
.steps.small li { font-size: 1rem; }

/* Trusted network, approval code, admin vault */
.card-net { margin-top: .3rem; font-size: .95rem; }
.card-net.outside { color: var(--red); font-weight: 600; }
.code-check { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; font-size: .95rem; color: var(--muted); }
.code-check input { font: inherit; font-size: 1.05rem; width: 9.5rem; padding: .35rem .5rem; border: 1.5px solid var(--line-2); border-radius: var(--radius-s); letter-spacing: .05em; }
.code-check input.match { border-color: var(--brand-2); background: var(--brand-soft); }
.code-check input.nomatch { border-color: var(--red); }
.reason-box { background: var(--amber-soft); border-radius: var(--radius-s); padding: .7rem .8rem; margin: .4rem 0; display: flex; flex-direction: column; gap: .45rem; }
.reason-box input { font: inherit; padding: .45rem .6rem; border: 1.5px solid var(--line-2); border-radius: var(--radius-s); }
.reason-box .row-btns { display: flex; gap: .4rem; flex-wrap: wrap; }
.av-field { display: flex; flex-direction: column; gap: .15rem; }
.av-field .v { overflow-wrap: anywhere; }
.side-link.admin-only svg { opacity: .85; }
