:root {
  --brand: #1f5fbf;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
  --brand-ink: color-mix(in srgb, var(--brand) 80%, black);
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --line: #e3e7ef;
  --line-strong: #cfd6e3;
  --text: #182032;
  --muted: #5f6b80;
  --faint: #8a94a8;
  --danger: #c4320a;
  --danger-soft: #fdeeea;
  --ok: #0f7a47;
  --ok-soft: #e6f6ee;
  --warn: #a35a00;
  --warn-soft: #fff4e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-soft: color-mix(in srgb, var(--brand) 22%, #141a26);
    --brand-ink: color-mix(in srgb, var(--brand) 55%, white);
    --bg: #0f141d;
    --surface: #171e2b;
    --surface-2: #1c2433;
    --line: #273042;
    --line-strong: #344057;
    --text: #e6eaf2;
    --muted: #a3adc0;
    --faint: #7d889c;
    --danger: #ff8a65;
    --danger-soft: #3a1e17;
    --ok: #4cd39a;
    --ok-soft: #13301f;
    --warn: #f5b454;
    --warn-soft: #362812;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 10px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.stack > * + * { margin-top: 14px; }
.spacer { flex: 1; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- icônes ---------- */
.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 22px; height: 22px; }

/* ---------- boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav a:focus-visible, .list-row:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 1px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 42px; font-size: 15px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: #e0a100; }

/* ---------- formulaires ---------- */
.field { display: block; }
.field > .lbl { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); outline: none; }
textarea.input { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.input.mono { font-family: var(--mono); letter-spacing: .02em; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.input-group:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.input-group .input { border: 0; box-shadow: none !important; background: transparent; }
.input-group .icon-btn { height: 36px; border-radius: 0; }
.input-group .icon-btn:last-child { border-radius: 0 8px 8px 0; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 4px 0; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.strength { height: 5px; border-radius: 3px; background: var(--line); margin-top: 7px; overflow: hidden; }
.strength > i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.strength-label { font-size: 12px; margin-top: 4px; color: var(--muted); }
.s0 > i { width: 8%; background: #d92d20; } .s1 > i { width: 28%; background: #e8590c; } .s2 > i { width: 52%; background: #d4a106; }
.s3 > i { width: 78%; background: #4c9a2a; } .s4 > i { width: 100%; background: #0f7a47; }
input[type=range] { width: 100%; accent-color: var(--brand); }

/* ---------- authentification ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--brand) 16%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 30px 30px 26px; }
.auth-card.wide { max-width: 520px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.brand-mark .ic { width: 21px; height: 21px; stroke-width: 2; }
.brand-name { font-weight: 750; font-size: 18px; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 20px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.notice { border-radius: 9px; padding: 11px 13px; font-size: 13.5px; line-height: 1.45; display: flex; gap: 10px; align-items: flex-start; }
.notice .ic { margin-top: 1px; }
.notice.info { background: var(--brand-soft); color: var(--brand-ink); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice > div > b:first-child { display: block; margin-bottom: 2px; }
.err-text { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- structure ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side .brand { padding: 16px 16px 0; margin-bottom: 12px; }
.side .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
.side .brand-name { font-size: 16px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 8px 6px; display: flex; align-items: center; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a .ic { color: var(--muted); }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.nav a.active .ic { color: var(--brand-ink); }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--faint); font-weight: 500; }
.nav a .pill { margin-left: auto; }
.side-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; align-items: center; gap: 6px; }
.me { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; padding: 4px 6px; color: inherit; text-decoration: none; border-radius: 8px; }
.me:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.page { flex: 1; overflow-y: auto; padding: 26px 32px 40px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.page .card { margin-bottom: 16px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.section-title { font-size: 15px; font-weight: 650; margin-bottom: 4px; }

/* ---------- coffre : liste + détail ---------- */
.vault { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; flex: 1; min-height: 0; }
.list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.list-head .title { font-weight: 700; font-size: 16px; }
.search { position: relative; margin-top: 10px; }
.search .ic { position: absolute; left: 10px; top: 10px; color: var(--faint); }
.search .input { padding-left: 34px; }
.list { flex: 1; overflow-y: auto; }
.list-row { display: flex; align-items: center; gap: 11px; padding: 10px 14px 10px 11px; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; background: none;
  border-left: 3px solid transparent; width: 100%; text-align: left; color: inherit; text-decoration: none; font: inherit; }
.list-row:hover { background: var(--surface-2); }
.list-row.active { background: var(--brand-soft); border-left-color: var(--brand); }
.list-row .t1 { font-weight: 600; }
.list-row .t2 { color: var(--muted); font-size: 12.5px; }
.tile { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; font-size: 14px; }
.tile .ic { width: 18px; height: 18px; stroke-width: 2; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.empty .ic { width: 40px; height: 40px; color: var(--faint); stroke-width: 1.4; margin-bottom: 10px; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 15px; }
.detail-pane { overflow-y: auto; min-height: 0; }
.detail { max-width: 760px; padding: 24px 30px 40px; }
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.detail-head .tile { width: 46px; height: 46px; border-radius: 12px; font-size: 19px; }
.detail-head h1 { font-size: 21px; word-break: break-word; }
.fields { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.fields + .fields { margin-top: 14px; }
.fld { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); min-height: 58px; }
.fld:last-child { border-bottom: 0; }
.fld .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.fld .v { word-break: break-all; margin-top: 1px; }
.fld .v.pw { font-family: var(--mono); font-size: 14.5px; letter-spacing: .03em; }
.fld .v.notes { white-space: pre-wrap; word-break: break-word; }
.totp { font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: .12em; color: var(--brand-ink); }
.ring { width: 22px; height: 22px; flex: none; }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--brand); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1s linear; }
.meta { color: var(--faint); font-size: 12.5px; margin-top: 16px; line-height: 1.7; }
.uri-row { display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; margin-bottom: 8px; }
.cf-row { display: grid; grid-template-columns: 180px 1fr auto auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.history-item { font-family: var(--mono); font-size: 13px; }

/* ---------- pastilles, tableaux ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill .ic { width: 13px; height: 13px; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.stat.bad .n { color: var(--danger); }
.stat.good .n { color: var(--ok); }
.seat-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; width: 90px; }
.seat-bar > i { display: block; height: 100%; background: var(--brand); }
.seat-bar.full > i { background: var(--warn); }

/* ---------- générateur ---------- */
.gen-out { font-family: var(--mono); font-size: 22px; letter-spacing: .04em; word-break: break-all; padding: 18px 20px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius); min-height: 70px; display: flex; align-items: center; }
.gen-out .d { color: #2563eb; } .gen-out .s { color: #c2410c; }
@media (prefers-color-scheme: dark) { .gen-out .d { color: #7aa7ff; } .gen-out .s { color: #ffa36e; } }

/* ---------- modales et notifications ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; animation: pop .14s; }
.modal.wide { max-width: 720px; }
.modal-head { padding: 18px 22px 0; display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0; } }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; }
.toast { background: #182032; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 9px;
  font-weight: 500; animation: pop .15s; max-width: 92vw; }
.toast.err { background: #b42318; }
.toast .ic { width: 17px; height: 17px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.banner.info { background: var(--brand-soft); color: var(--brand-ink); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.copybox { display: flex; gap: 8px; }
.copybox .input { font-family: var(--mono); font-size: 12.5px; }
.code-block { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; word-break: break-all; white-space: pre-wrap; }
.fingerprint { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border-radius: 7px; padding: 8px 10px; letter-spacing: .03em; }
.recovery-code { font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: .08em; text-align: center; padding: 16px; border: 2px dashed var(--line-strong); border-radius: 10px; }
.qr { display: block; margin: 0 auto; image-rendering: pixelated; width: 180px; height: 180px; border-radius: 8px; background: #fff; padding: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.access-list { border: 1px solid var(--line); border-radius: 9px; max-height: 300px; overflow-y: auto; }
.access-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.access-row:last-child { border-bottom: 0; }
.access-row select.input { width: 150px; height: 32px; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .shell.menu-open .side { transform: none; }
  .shell.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .topbar .brand-name { font-size: 16px; }
  .vault { grid-template-columns: 1fr; }
  .vault.has-detail .list-pane { display: none; }
  .vault:not(.has-detail) .detail-pane { display: none; }
  .page { padding: 18px 16px 30px; }
  .detail { padding: 16px 16px 30px; }
  .detail-head { flex-wrap: wrap; }
  .detail-head > .grow { flex: 1 1 60%; }
  .detail-actions { width: 100%; justify-content: flex-end; }
  .form-grid { grid-template-columns: 1fr; }
  .uri-row { grid-template-columns: 1fr auto; }
  .uri-row select { grid-column: 1; }
  .cf-row { grid-template-columns: 1fr auto auto; }
  .cf-row .input:first-child { grid-column: 1 / -1; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 901px) { .only-mobile { display: none !important; } }
