:root {
  color-scheme: light;
  --bg: #f3f5f8; --card: #fff; --subtle: #f8f9fb; --fg: #1a1f2b; --text: #3a4252; --muted: #5f6878;
  --line: #e3e7ed; --line-strong: #cfd5de;
  --accent: #0a6cf0; --accent-hover: #0858c7; --accent-soft: #e9f2fe; --ring: rgba(10, 108, 240, .2);
  --danger: #c8291d; --danger-soft: #fdeceb; --danger-line: #f3c3be;
  --warn: #7a4a00; --warn-soft: #fff5de; --warn-line: #f0d595;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .35rem; letter-spacing: -.01em; }
h1:focus { outline: none; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--warn); }
.error { color: var(--danger); }
.mono { font-family: var(--mono); font-size: .88rem; word-break: break-all; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; padding: .6rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; }
.badge { font-size: .75rem; font-weight: 600; color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); padding: .1rem .6rem; border-radius: 999px; }
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.bar-actions button { margin: 0; }
.timer { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
main { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* controls */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-size: .9rem; font-weight: 600; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--card); color: var(--fg); cursor: pointer; text-decoration: none; margin: .25rem .4rem .25rem 0; transition: background .15s, border-color .15s; }
button:hover, .button:hover { background: var(--subtle); border-color: #b9c1cc; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); border-color: var(--danger-line); }
button.danger:hover { background: var(--danger-soft); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--subtle); border-color: var(--line); }
button.link { background: none; border: none; padding: .35rem .2rem; color: var(--accent); }
button.link:hover { background: none; text-decoration: underline; }
button.small { padding: .3rem .65rem; font-size: .82rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.block { display: flex; width: 100%; margin: 1rem 0 .25rem; }
.large { padding: .75rem 1.4rem; font-size: 1rem; }
:focus-visible { outline: 3px solid rgba(10, 108, 240, .45); outline-offset: 2px; }
label { display: block; margin: 1rem 0 .35rem; font-size: .85rem; font-weight: 600; color: var(--text); }
input, textarea, select { font: inherit; width: 100%; padding: .6rem .75rem; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--card); color: var(--fg); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
textarea { min-height: 7rem; resize: vertical; }
input[type=file] { padding: .45rem; background: var(--subtle); }
input[type=file]::file-selector-button { font: inherit; font-size: .85rem; font-weight: 600; margin-right: .75rem; padding: .35rem .8rem; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--card); color: var(--fg); cursor: pointer; }
label.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .9rem; font-weight: 500; color: var(--fg); }
label.check input { width: auto; margin-top: .25rem; accent-color: var(--accent); }
.callout { background: var(--subtle); border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; }
.input-row { display: flex; gap: .5rem; align-items: center; }
.input-row input { flex: 1; min-width: 0; }
.input-row button { margin: 0; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.actions button { margin: 0; }

/* surfaces */
section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin: 0 0 1rem; }
.notice { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem 1rem; border: 1px solid; border-radius: 10px; margin: 0 0 1rem; font-size: .9rem; }
.notice .icon { margin-top: .15rem; }
.notice.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.notice.error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.pill { display: inline-block; margin-left: .4rem; padding: 0 .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; color: #fff; font-weight: 700; flex-shrink: 0; }
.av-0 { background: #0a6cf0; } .av-1 { background: #7b4ddb; } .av-2 { background: #0b8062; }
.av-3 { background: #c25b1a; } .av-4 { background: #b3285a; } .av-5 { background: #237aa6; } .av-bad { background: var(--danger); }

/* signed-out screens */
.auth { display: flex; justify-content: center; padding-top: 2vh; }
.auth-card { width: 100%; max-width: 560px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 24px rgba(16, 24, 40, .08); padding: 2rem; }
.auth-icon, .hero-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.auth-icon { margin-bottom: 1rem; }
.auth-icon .icon, .hero-icon .icon { width: 24px; height: 24px; }
.lead { color: var(--muted); margin: 0 0 1rem; }
.group { margin-top: 1.5rem; }
.group > h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .5rem; }
.bullets { padding-left: 1.1rem; margin: 0 0 .5rem; color: var(--text); font-size: .92rem; }
.bullets li { margin: .4rem 0; }
.back { margin-top: .75rem; }
.back .icon { width: 16px; height: 16px; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 1.25rem 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.5rem; margin-bottom: 1.5rem; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .85rem; font-weight: 700; }
.steps h2 { margin: .15rem 0 .25rem; }

/* list rows and choice tiles */
.tile, .row-item { display: flex; align-items: center; gap: .85rem; width: 100%; margin: 0 0 .5rem; padding: .85rem 1rem; text-align: left; font-weight: normal; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.tile:hover, .row-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.tile-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--subtle); color: var(--accent); flex-shrink: 0; }
.tile:hover .tile-icon { background: var(--card); }
.tile > .icon:last-child { color: var(--muted); }
.row-action { display: inline-flex; align-items: center; gap: .2rem; color: var(--accent); font-size: .88rem; font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.grow > strong, .grow > .muted { display: block; }
.grow > .muted { font-size: .85rem; }
ul.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; gap: .85rem; align-items: center; }
.rows > .row { padding: .8rem 0; border-top: 1px solid var(--line); }
.rows > .row:first-child { border-top: none; }
.rows > .row button { margin: 0; }
.row-icon { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--subtle); color: var(--muted); flex-shrink: 0; }
.unread .row-icon { background: var(--accent-soft); color: var(--accent); }
.unread .row-icon::after { content: ''; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--card); }
.empty { padding: 1rem; border: 1px dashed var(--line-strong); border-radius: 10px; margin-top: 1.5rem; }

/* YID approval */
.approval, .panel { margin-top: 1.25rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--subtle); }
.approval { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
.approval h2, .panel h2 { margin-bottom: .25rem; }
.match { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin: .75rem 0; padding: .6rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.match-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.code { font: 700 1.7rem/1.2 var(--mono); letter-spacing: .12em; }
.approval-qr { text-align: center; }
.qr { display: block; width: min(100%, 280px); margin: .5rem auto 0; padding: .6rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.status-line { display: flex; align-items: center; gap: .6rem; margin: .75rem 0; font-size: .9rem; font-weight: 500; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.checklist { list-style: none; margin: .25rem 0; padding: 0; font-size: .9rem; }

/* locked vault */
.page { max-width: 880px; margin: 0 auto; }
.hero { padding: 1.5rem; }
.hero-head { display: flex; align-items: center; gap: 1rem; }
.hero-icon { width: 52px; height: 52px; border-radius: 14px; }
.hero h1 { margin: 0; }
.hero-head .muted { margin: .15rem 0 0; font-size: .9rem; }
.hero .notice { margin: 1rem 0 0; }
.tabs { display: flex; gap: .25rem; margin: 1.5rem 0 1rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { margin: 0; padding: .65rem .85rem; border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); white-space: nowrap; }
.tab:hover { background: none; border-color: transparent; color: var(--fg); }
.tab[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.danger-zone { border-color: var(--danger-line); }
.danger-zone h2 { color: var(--danger); }

/* unlocked vault */
.vault { display: grid; grid-template-columns: 340px 1fr; min-height: 70vh; margin-bottom: 1rem; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.list-pane { display: flex; flex-direction: column; min-width: 0; background: var(--subtle); border-right: 1px solid var(--line); }
.list-head { padding: 1rem 1rem .5rem; }
.list-head h1 { font-size: 1.2rem; }
.list-head .row { flex-wrap: wrap; gap: .4rem; }
.list-head button { margin: 0; }
.search-wrap { position: relative; margin: .25rem 1rem .75rem; }
.search-wrap .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-wrap input { padding-left: 2.2rem; }
ul.items { flex: 1; list-style: none; margin: 0; padding: 0 .5rem .75rem; overflow-y: auto; }
.item { display: flex; align-items: center; gap: .75rem; width: 100%; margin: 0 0 2px; padding: .6rem; text-align: left; font-weight: normal; border: 1px solid transparent; border-radius: 9px; background: none; }
.item:hover { background: var(--card); border-color: var(--line); }
.item.selected, .item.selected:hover { background: var(--accent-soft); border-color: transparent; }
.item .grow > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item strong { font-weight: 600; }
.empty-list { padding: 1.5rem 1rem; text-align: center; }
.detail-pane { min-width: 0; padding: 1.5rem 2rem; }
.detail-pane:empty { display: grid; place-items: center; color: var(--muted); }
.detail-pane:empty::before { content: 'Select an item, or add a new one.'; }
.detail-head { display: flex; align-items: center; gap: 1rem; max-width: 640px; padding-bottom: 1rem; margin-bottom: .25rem; border-bottom: 1px solid var(--line); }
.detail-head .avatar { width: 52px; height: 52px; border-radius: 14px; font-size: 1.4rem; }
.detail-head h2 { margin: 0; font-size: 1.25rem; }
.fields { max-width: 640px; }
.input-group { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card); }
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.input-group input, .input-group input:focus { flex: 1; min-width: 0; border: none; box-shadow: none; font-family: var(--mono); }
.input-group button { margin: 0 .25rem 0 0; }
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; max-width: 640px; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.detail-actions button { margin: 0; }

@media (max-width: 760px) {
  main { padding: 1rem 1rem 2rem; }
  .bar { padding: .5rem 1rem; }
  .auth-card { padding: 1.25rem; border-radius: 14px; }
  .hero-head { flex-wrap: wrap; }
  .hero-head > .grow { flex: 1 1 60%; }
  .hero-head > button { flex-basis: 100%; margin: 0; }
  .vault { grid-template-columns: 1fr; min-height: 0; }
  .list-pane { border-right: none; }
  .vault.has-detail .list-pane, .vault:not(.has-detail) .detail-pane { display: none; }
  .detail-pane { padding: 1rem; }
  .input-group { flex-wrap: wrap; }
  .input-group input { flex-basis: 100%; }
  .input-group button { margin: 0 .25rem .35rem; }
}
