/* Sphinx v5.0.0 — styles de base (repris de Famille ROY) + thème Sphinx (or et sable) */
:root { --bg:#f6f4f0; --card:#ffffff; --text:#1f1c17; --muted:#736b5e; --accent:#9a6a1b; --accent-soft:#f1e6d1; --danger:#c4473f; --border:#e6e1d8; --on-accent:#ffffff; --w: 1100px; color-scheme: light; }
@media (prefers-color-scheme: dark) { :root { --bg:#13110e; --card:#1c1915; --text:#ece7de; --muted:#9a9284; --accent:#e0b052; --accent-soft:#3a2f1c; --danger:#e57366; --border:#2e2a23; --on-accent:#1f1c17; color-scheme: dark; } }
@media (min-width: 1500px) { :root { --w: 1240px; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: calc(20px + env(safe-area-inset-top)) 20px 12px; max-width: var(--w); margin: 0 auto; }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
main { max-width: var(--w); margin: 0 auto; padding: 0 16px; }
.eyebrow { margin: 0 0 2px; font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.ghost { font: inherit; font-size: .85rem; color: var(--accent); background: none; border: 1px solid var(--accent); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.primary-btn { font: inherit; font-size: .9rem; font-weight: 600; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; }
.primary-btn:disabled { opacity: .6; }
.hint { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 16px; }
.hint.left { text-align: left; margin: 6px 0 0; }
.tabs { display: flex; gap: 8px; overflow-x: auto; margin: 2px 0 14px; padding-bottom: 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: flex; align-items: center; gap: 8px; font: inherit; cursor: pointer; padding: 8px 14px; border-radius: 999px; color: var(--text); background: var(--card); border: 1px solid var(--border); }
.tab small { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tab.on small { color: inherit; opacity: .85; }
dialog { width: min(92vw, 440px); border: 0; border-radius: 18px; padding: 18px; background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0 0 12px; }
.td-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.td-actions .primary-btn { padding: 10px 18px; }
.td-actions .danger { margin-right: auto; font: inherit; color: var(--danger); background: none; border: 1px solid var(--danger); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 50; }
.ver { text-align: center; color: var(--muted); font-size: .75rem; opacity: .8; margin: 20px 0 0; }
a { color: var(--accent); }

/* ---------- 2.0.0 : Sphinx (inventaire et mots de passe chiffrés) ---------- */
body.sphinx header { align-items: center; }
.sx-title { display: flex; align-items: center; gap: 10px; }
.sx-logo { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.sx-logo svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sx-i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.sx-pill { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .8rem; border-radius: 20px; padding: 5px 11px; border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; white-space: nowrap; }
.sx-pill .sx-i { width: 14px; height: 14px; }
.sx-pill.ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.sx-pill.warn { color: #b07a1c; border-color: color-mix(in srgb, #b07a1c 45%, transparent); }
.sx-lock { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 22px; max-width: 440px; margin: 20px auto; display: flex; flex-direction: column; gap: 10px; }
.sx-motto { margin: 0; font-style: italic; color: var(--muted); font-size: .9rem; }
.sx-msg { margin: 0 0 4px; }
.sx-lock input, .sx-bar input[type=search], #sx-dlg input, #sx-dlg select, #sx-dlg textarea, #sx-gdlg input[type=text] {
  width: 100%; box-sizing: border-box; font: inherit; color: var(--text); background: var(--field, var(--bg)); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; }
#sx-dlg textarea { resize: vertical; }
.sx-lock .primary-btn { width: 100%; }
.sx-lock .ghost { margin: 0; width: 100%; }
.sx-err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: .85rem; }
.sx-bar { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; }
.sx-bar input[type=search] { flex: 1; min-width: 0; }
.sx-bar .ghost { margin: 0; padding: 9px 12px; }
.sx-bar .primary-btn { white-space: nowrap; }
.sx-menu { position: relative; }
#sx-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 6px; min-width: 260px; box-shadow: 0 12px 32px rgba(0,0,0,.18); }
#sx-menu button { display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: none; border: 0; border-radius: 9px; padding: 9px 10px; cursor: pointer; }
#sx-menu button:hover { background: var(--accent-soft); }
#sx-tabs .tab { display: inline-flex; align-items: center; gap: 6px; }
#sx-tabs .tab .sx-i { width: 15px; height: 15px; }
.sx-h { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.sx-list { background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.sx-it { display: grid; grid-template-columns: 36px minmax(140px, 1.2fr) minmax(140px, 1.1fr) minmax(120px, 1fr) minmax(130px, 1fr) minmax(110px, 1.1fr) 32px;
  grid-template-areas: "ic nm url lg sc nt ed"; gap: 4px 12px; padding: 11px 14px; border-top: 1px solid var(--border); align-items: center; }
.sx-it:first-child { border-top: 0; }
.sx-ic { grid-area: ic; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); }
.sx-nm { grid-area: nm; min-width: 0; } .sx-nm b { display: block; } .sx-nm span { color: var(--muted); font-size: .82rem; }
.sx-url { grid-area: url; font-size: .86rem; white-space: pre-line; min-width: 0; overflow-wrap: anywhere; }
.sx-url a { color: var(--accent); text-decoration: none; } .sx-url a:hover { text-decoration: underline; }
.sx-fld { display: flex; align-items: center; gap: 2px; min-width: 0; grid-area: lg; }
.sx-fld.sec { grid-area: sc; }
.sx-fld small { display: none; }
.sx-fld code { font: .86rem ui-monospace, Menlo, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-fld.sec code { color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.sx-note { grid-area: nt; color: var(--muted); font-size: .82rem; white-space: pre-line; overflow-wrap: anywhere; }
.sx-ed { grid-area: ed; }
.sx-ib { border: 0; background: none; color: var(--muted); padding: 4px 6px; border-radius: 8px; cursor: pointer; line-height: 0; }
.sx-ib:hover { color: var(--accent); background: var(--accent-soft); }
.sx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sx-grid label { font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.sx-grid .f { grid-column: 1 / -1; }
.sx-genrow { display: flex; gap: 6px; } .sx-genrow input { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace !important; }
.sx-genrow .ghost { margin: 0; }
.sx-range { display: block; margin: 14px 0 6px; font-size: .9rem; } .sx-range input { width: 100%; }
.sx-check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: .95rem; }
.sx-danger { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.sx-danger summary { cursor: pointer; color: var(--danger); font-size: .9rem; }
#sx-dlg { width: min(94vw, 680px); }
#sx-dlg input[type=password] { width: 100%; box-sizing: border-box; font: inherit; color: var(--text); background: var(--field, var(--bg)); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; font-family: ui-monospace, Menlo, Consolas, monospace; }
@media (max-width: 860px) {
  .sx-it { grid-template-columns: 36px 1fr 32px; grid-template-areas: "ic nm ed" ". url ." ". lg ." ". sc ." ". nt ."; }
  .sx-fld small { display: inline; color: var(--muted); font-size: .72rem; margin-right: 6px; min-width: 4.5em; }
}
@media (max-width: 520px) { .sx-grid { grid-template-columns: 1fr; } body.sphinx header { flex-wrap: wrap; }
  .sx-bar { flex-wrap: wrap; } .sx-bar input[type=search] { flex: 1 1 100%; } .sx-bar .primary-btn { flex: 1; } }

/* 2.1.0 : plusieurs identifiants par fiche + fusion */
.sx-sub { grid-column: 3 / 6; display: grid; grid-template-columns: subgrid; gap: 12px; align-items: center; padding-top: 2px; }
.sx-sub .sx-fld { grid-area: auto; }
.sx-lab { color: var(--muted); font-size: .8rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-lab:not(:empty)::after { content: " ›"; opacity: .6; }
.sx-more { display: flex; flex-direction: column; gap: 6px; }
.sx-more-h { font-size: .78rem; color: var(--muted); }
.sx-line { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; align-items: center; }
.sx-line input { padding: 9px 10px !important; }
.sx-line .ms { font-family: ui-monospace, Menlo, Consolas, monospace; }
.sx-line.split { opacity: .55; } .sx-line.split::after { content: "→ deviendra une fiche à part"; grid-column: 1 / -1; font-size: .75rem; color: var(--accent); }
.sx-lacts { display: flex; } .sx-lacts .sx-ib { line-height: 1; font-size: .95rem; }
.sx-addline { align-self: flex-start; margin: 0; padding: 7px 12px; }
.sx-pickbar { display: flex; align-items: center; gap: 8px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 14px; padding: 8px 10px 8px 14px; margin: 8px 0; position: sticky; top: 8px; z-index: 15; }
.sx-pickbar span { flex: 1; font-weight: 600; } .sx-pickbar .ghost { margin: 0; }
.sx-list .sx-it { transition: background .15s; }
#sx-list.picking .sx-it { cursor: pointer; } #sx-list.picking .sx-ed, #sx-list.picking .sx-ib { pointer-events: none; opacity: .35; }
#sx-list.picking .sx-it.on { background: var(--accent-soft); } #sx-list.picking .sx-it.on .sx-ic { background: var(--accent); color: var(--on-accent); }
@media (max-width: 860px) {
  .sx-sub { grid-column: 2; display: flex; flex-wrap: wrap; gap: 2px 10px; border-top: 1px dashed var(--border); padding-top: 6px; margin-top: 2px; }
  .sx-lab { text-align: left; width: 100%; font-weight: 600; } .sx-lab:not(:empty)::after { content: ""; }
  .sx-line { grid-template-columns: 1fr 1fr; } .sx-line .ml { grid-column: 1 / -1; } .sx-lacts { grid-column: 1 / -1; justify-content: flex-end; }
}

/* 2.1.1 : identifiants homogènes */
.sx-lhead { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 2px; }
.sx-line.main .ml { font-weight: 600; }
.sx-line .ms { padding-right: 10px !important; }
.sx-lacts .sx-ib[hidden] { display: inline-block; visibility: hidden; }
.sx-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 128px; } .sx-lacts { justify-content: flex-end; }
@media (max-width: 860px) { .sx-lhead { display: none; } .sx-line { grid-template-columns: 1fr 1fr; } }


/* 5.1.1 : vrai tableau, colonnes et boutons alignés */
.sx-fld { display: grid; grid-template-columns: minmax(0, 1fr) 30px 30px; align-items: center; gap: 0; }
.sx-fld small { display: none; }
.sx-fld code { min-width: 0; }
.sx-fld .sx-ib { justify-self: center; }
.sx-sub { align-items: center; min-height: 34px; }
.sx-lab { text-align: left; color: var(--muted); font-size: .84rem; }
.sx-lab:not(:empty)::after { content: ""; }
@media (min-width: 861px) { .sx-it { grid-template-columns: 36px minmax(150px, 1fr) minmax(190px, 1.25fr) minmax(200px, 1.2fr) minmax(140px, .65fr) minmax(100px, .85fr) 32px; } }
.sx-it .sx-nm, .sx-it .sx-url { align-self: start; padding-top: 7px; }
.sx-it > .sx-fld, .sx-it .sx-note { align-self: start; padding-top: 4px; }
@media (max-width: 860px) {
  .sx-it .sx-nm, .sx-it .sx-url, .sx-it > .sx-fld, .sx-it .sx-note { padding-top: 0; }
  .sx-fld { grid-template-columns: 4.6em minmax(0, 1fr) auto auto; }
  .sx-fld > span:empty { display: none; }
  .sx-it > .sx-fld, .sx-sub { grid-column: 2 / 4; }
  .sx-sub .sx-fld { grid-column: auto; }
  .sx-fld small { display: block; color: var(--muted); font-size: .72rem; margin: 0; min-width: 0; }
  .sx-sub { display: grid; grid-template-columns: 1fr; gap: 2px; }
}

/* 5.2.0 : codes MFA (TOTP) */
@media (min-width: 861px) { .sx-sub { grid-column: 3 / 7; } }
.sx-otp { display: grid; grid-template-columns: 20px minmax(0, auto) 30px; align-items: center; gap: 6px; justify-content: start; min-width: 0; }
.sx-otp code { font: 600 .95rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; color: var(--accent); }
.sx-otp.soon code { color: var(--danger); }
.sx-ring { width: 18px; height: 18px; transform: rotate(-90deg); }
.sx-ring circle { fill: none; stroke-width: 3; stroke: var(--border); }
.sx-ring .fg { stroke: var(--accent); stroke-dasharray: 50.27; transition: stroke-dashoffset 1s linear; }
.sx-otp.soon .sx-ring .fg { stroke: var(--danger); }
.sx-line .sx-mfa { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; margin: -2px 0 4px; }
.sx-line .sx-mfa .mt { font-family: ui-monospace, Menlo, Consolas, monospace; }
.sx-mfa-st { font-size: .78rem; color: var(--accent); white-space: nowrap; } .sx-mfa-st.bad { color: var(--danger); }
.sx-line.has-mfa .sx-mfab { background: var(--accent-soft); }
.sx-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 156px; }
@media (max-width: 860px) {
  .sx-otp { grid-template-columns: 4.6em 20px minmax(0, 1fr) auto; }
  .sx-otp::before { content: "MFA"; color: var(--muted); font-size: .72rem; }
  .sx-mfa-st { white-space: normal; }
}

@media (min-width: 861px) { .sx-it.multi .sx-note { grid-area: auto; grid-column: 3 / 7; padding-top: 6px; } }
.sx-it .sx-ic { align-self: start; }
