/* Inventaire de la maison — carnet d'architecte : papier, encre, terracotta. */

:root {
  --paper: #f6f1e7;
  --paper-2: #efe7d8;
  --card: #fffdf8;
  --ink: #1e2a2e;
  --ink-2: #55625f;
  --ink-3: #8a938f;
  --line: #ddd2bd;
  --line-2: #c9bba1;
  --accent: #c2571a;
  --accent-2: #a2460f;
  --accent-soft: #f6dfcc;
  --blue: #2d5d7b;
  --grid: rgba(45, 93, 123, .10);
  --grid-major: rgba(45, 93, 123, .22);
  --room: #e9dcc4;
  --furniture: #fbf6ec;
  --ok: #2f7a47;
  --warn: #9a6a00;
  --danger: #b3261e;
  --mark: #ffe08a;
  --shadow: 0 1px 2px rgba(30, 42, 46, .06), 0 6px 20px rgba(30, 42, 46, .06);
  --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: 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 {
    --paper: #14181a;
    --paper-2: #1b2023;
    --card: #1f2528;
    --ink: #ece6da;
    --ink-2: #b4b0a6;
    --ink-3: #807d76;
    --line: #2f383c;
    --line-2: #3f4a4f;
    --accent: #e27d43;
    --accent-2: #f0965f;
    --accent-soft: #3a2619;
    --blue: #8fb8d4;
    --grid: rgba(143, 184, 212, .07);
    --grid-major: rgba(143, 184, 212, .16);
    --furniture: #262d31;
    --ok: #6fc28a;
    --warn: #e0b04a;
    --danger: #f2837b;
    --mark: #6b5418;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
}
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--card); padding: 8px 12px; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.brand svg { width: 28px; height: 28px; color: var(--accent); }
.search {
  flex: 1; max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 0 14px; height: 44px; box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.search input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; height: 100%; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.hint { font: 12px var(--mono); color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; }
.topnav a { display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink-2); padding: 8px; border-radius: 8px; }
.topnav a:hover { background: var(--paper-2); }
.topnav svg { width: 22px; height: 22px; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .brand span, .hint, #nav-user { display: none; }
  .search { order: 3; flex-basis: 100%; height: 42px; }
  .topnav { margin-left: auto; }
}

/* ---------- Mise en page ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 80px; outline: none; }
.view.narrow { max-width: 860px; margin: 0 auto; }
.loading { text-align: center; color: var(--ink-2); padding: 80px 0; }
h1, h2 { font-family: var(--serif); letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3.6vw, 2.2rem); margin: 0; line-height: 1.15; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 small { font: 500 .85rem var(--sans); color: var(--ink-2); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
h2.sub { font-size: 1.25rem; margin: 30px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.h-icon { font-size: .9em; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 14px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notes { white-space: pre-wrap; background: var(--card); border-left: 3px solid var(--line-2); padding: 10px 14px; border-radius: 6px; color: var(--ink-2); }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .9rem; color: var(--ink-2); margin-bottom: 8px; }
.crumbs a { text-decoration: none; padding: 2px 4px; border-radius: 4px; }
.crumbs a:hover { background: var(--paper-2); color: var(--ink); }
.crumbs .sep { color: var(--ink-3); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.icon { width: 42px; padding: 0; font-size: 1.3rem; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); cursor: pointer; font-size: 1.1rem; line-height: 1; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--paper-2); }
.linklike { background: none; border: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; padding: 8px 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 250px;
  background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.menu-list button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.menu-list button:hover { background: var(--paper-2); }
.menu-list button.danger { color: var(--danger); }

/* ---------- Statistiques, onglets, puces ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.stat-value { font: 700 1.5rem var(--serif); }
.stat-label { font-size: .85rem; color: var(--ink-2); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-2); text-decoration: none; white-space: nowrap; background: var(--card); cursor: pointer; font-weight: 500; }
.tab.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tab.add { border-style: dashed; color: var(--ink-2); background: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); text-decoration: none; font-size: .9rem; background: var(--card); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Plan ---------- */
.plan-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); position: relative; }
.plan { display: block; width: 100%; height: auto; max-height: 68vh; user-select: none; -webkit-user-select: none; }
.plan.editing { touch-action: none; }
.plan-bounds { stroke: var(--line-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.grid-minor { fill: none; stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.grid-major { fill: none; stroke: var(--grid-major); stroke-width: 1; vector-effect: non-scaling-stroke; }
.scale path { stroke: var(--ink-2); stroke-width: 1.5; vector-effect: non-scaling-stroke; fill: none; }
.scale text { fill: var(--ink-2); font-family: var(--mono); }
.plan-shape { cursor: pointer; outline: none; }
.shape-rect { fill: var(--furniture); stroke: var(--ink); stroke-width: 2; vector-effect: non-scaling-stroke; transition: filter .15s; }
.plan-shape:hover .shape-rect, .plan-shape:focus-visible .shape-rect { filter: brightness(.95); stroke: var(--accent); stroke-width: 3; }
.shape-label { fill: var(--ink); font-family: var(--sans); font-weight: 700; pointer-events: none; }
.shape-sub { fill: var(--ink-2); font-family: var(--sans); pointer-events: none; }
.plan-shape.filled .shape-label { fill: #1e2a2e; }
.plan-shape.filled .shape-sub { fill: #55625f; }
@media (prefers-color-scheme: dark) {
  .shape-rect { stroke: var(--ink-2); }
}
.shape-dims { fill: var(--blue); font-family: var(--mono); display: none; pointer-events: none; }
.handle { fill: var(--accent); display: none; cursor: nwse-resize; }
.plan.editing .plan-shape { cursor: move; }
.plan.editing .handle, .plan.editing .shape-dims { display: block; }
.plan.editing .shape-rect { stroke-dasharray: 6 4; }
.plan-shape.dragging .shape-rect { stroke: var(--accent); filter: drop-shadow(0 4px 8px rgba(0,0,0,.2)); }
.plan-shape.hl .shape-rect { stroke: var(--accent); stroke-width: 4; animation: pulse 1.2s ease-in-out 3; }
@keyframes pulse { 50% { stroke-width: 9; } }
.plan-hint { position: absolute; inset: auto 0 40% 0; text-align: center; color: var(--ink-2); margin: 0; padding: 0 20px; pointer-events: none; }

/* ---------- Cartes et listes ---------- */
.grid.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; box-shadow: var(--shadow);
  transition: transform .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.card.hl { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card-title { font-weight: 700; font-size: 1.05rem; }
.card-meta { font-size: .85rem; color: var(--ink-2); }
.card-icon { font-size: 1.6rem; line-height: 1; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,.15); }
.swatch.big { width: 26px; height: 26px; border-radius: 7px; }
.room-card .swatch { margin-bottom: 4px; }
.box-card { padding-left: 22px; overflow: hidden; }
.box-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 7px; }
.code {
  font: 700 .82rem var(--mono); letter-spacing: .03em; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 7px; align-self: flex-start;
}
.code.big { font-size: 1.1rem; border-width: 2px; border-left-width: 8px; padding: 2px 10px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; min-height: 56px; }
a.row:hover { background: var(--paper-2); }
.row.static { justify-content: space-between; }
.row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { font-size: .87rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.row-sub.path { color: var(--blue); }
.list:not(.items) .row { flex-wrap: wrap; }
.list:not(.items) .row > .row-main { flex: 1; }
.qty { font: 600 .9rem var(--mono); color: var(--ink-2); }
.item-row { display: flex; align-items: center; padding-right: 12px; }
.item-row .row { flex: 1; min-width: 0; }
.item-row.hl { background: var(--accent-soft); }
.qty-ctl { display: flex; align-items: center; gap: 6px; }
.qty-val { min-width: 2.4ch; text-align: center; font: 700 1rem var(--mono); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; background: var(--paper-2); }
.kind { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 5px; background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line); }
.k-item { color: var(--accent); }
.k-container { color: var(--blue); }
.k-ok { color: var(--ok); }
.k-warn { color: var(--warn); }

.empty-block { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--ink-2); }
.empty-block .empty-title { font-weight: 700; color: var(--ink); margin: 0 0 4px; }
.empty-block p { margin: 0 0 8px; }
.empty { text-align: center; padding: 70px 16px; }
.empty h1 { justify-content: center; margin-bottom: 12px; }

.quick-add { display: flex; gap: 8px; margin-bottom: 10px; }
.quick-add input[type=text] { flex: 1; min-width: 0; }
.quick-add .qty-input { width: 82px; }
.quick-add input, .form input, .form select, .form textarea {
  height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card); width: 100%;
}
.form textarea { height: auto; padding: 10px 12px; resize: vertical; }
.quick-add input:focus, .form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Caisse / objet ---------- */
.box-info { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.hero-photo { width: 100%; max-width: 320px; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper-2); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 20px; margin: 0; flex: 1; min-width: 240px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.facts dd { margin: 0; font-weight: 600; }
.where { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.where-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.where-path { font-size: 1.02rem; }
.where-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.item-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .item-layout { grid-template-columns: 1fr; } }
.photo-box { display: flex; flex-direction: column; gap: 8px; }
.photo-box .hero-photo { max-width: none; }
.photo-empty { aspect-ratio: 4/3; border: 1.5px dashed var(--line-2); border-radius: var(--radius); display: grid; place-items: center; color: var(--ink-3); }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* ---------- Formulaires ---------- */
.form { display: flex; flex-wrap: wrap; gap: 12px; }
.form > * { flex-basis: 100%; }
.form .field { display: flex; flex-direction: column; gap: 5px; }
.form .field.half { flex: 1 1 calc(50% - 6px); flex-basis: calc(50% - 6px); }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label { font-size: .9rem; font-weight: 600; }
.help { color: var(--ink-2); font-size: .82rem; }
.form-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); padding: 8px 12px; border-radius: 8px; margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.actions.spread { justify-content: space-between; }
.confirm-text { margin-top: 0; }

/* ---------- Dialogues ---------- */
dialog {
  border: 1px solid var(--line-2); border-radius: 16px; padding: 0; background: var(--card); color: var(--ink);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog.wide { width: min(760px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20, 24, 26, .45); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-body { padding: 16px 18px 18px; }
.steps { padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.qr-2fa { width: 200px; max-width: 70%; margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qr-2fa svg { display: block; width: 100%; height: auto; }
.secret { display: block; font: 600 .95rem var(--mono); background: var(--paper-2); padding: 8px 10px; border-radius: 8px; word-break: break-all; margin-top: 6px; user-select: all; }
.codes { font: 600 1.05rem/1.8 var(--mono); background: var(--paper-2); padding: 12px 16px; border-radius: 10px; columns: 2; text-align: center; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; animation: tin .2s ease-out; transition: opacity .4s, transform .4s; }
.toast.err { background: var(--danger); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Connexion ---------- */
.auth-wrap { min-height: 80vh; display: grid; place-items: center; align-content: center; gap: 22px; padding: 20px 0; }
.auth-brand { text-align: center; max-width: 420px; }
.auth-brand h1 { justify-content: center; font-size: 2rem; }
.auth-brand p { color: var(--ink-2); margin: 6px 0 0; }
.auth-logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 2.2rem; box-shadow: var(--shadow); }
.auth-card { width: min(420px, calc(100vw - 32px)); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.auth-card h2 { margin: 0 0 4px; font-size: 1.3rem; }

/* ---------- Réglages ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 8px; font-size: 1.15rem; }
.panel p { margin: 0 0 10px; }
.panel .list { margin-bottom: 10px; }
.list.compact .row { min-height: 0; }
.ok-text { color: var(--ok); font-weight: 600; }
.table-wrap { overflow-x: auto; }
table.audit { width: 100%; border-collapse: collapse; font-size: .85rem; }
.audit th, .audit td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.audit td:nth-child(4) { white-space: normal; }
.audit tr.warn td { color: var(--warn); }

/* ---------- Étiquettes ---------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.label-card { display: flex; gap: 12px; align-items: center; background: #fff; color: #111; border: 1.5px solid #111; border-radius: 10px; padding: 10px; break-inside: avoid; }
.label-qr { width: 110px; flex: none; }
.label-qr svg { display: block; width: 100%; height: auto; }
.label-text { min-width: 0; }
.label-code { font: 800 1.6rem var(--mono); letter-spacing: .02em; }
.label-name { font: 700 1.1rem var(--sans); line-height: 1.2; margin: 2px 0 4px; }
.label-path { font-size: .8rem; color: #444; }

@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  .topbar, .no-print, #toasts, dialog { display: none !important; }
  main { padding: 0; max-width: none; }
  .labels { grid-template-columns: repeat(2, 1fr); gap: 6mm; }
  .label-card { border-radius: 3mm; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
