/* ===================== Coûts de revient — thème sombre & or ===================== */
:root {
  --bg: #0e0d0b;
  --bg-2: #15130f;
  --surface: #1b1915;
  --surface-2: #23201b;
  --surface-3: #2c2822;
  --line: #34302a;
  --line-2: #463f35;
  --text: #efe9dd;
  --text-2: #c8bfae;
  --muted: #968d7c;
  --gold: #c9a45c;
  --gold-2: #e0c07e;
  --gold-soft: rgba(201, 164, 92, .14);
  --ok: #7fb58a;
  --warn: #e0ad5a;
  --bad: #e07a6a;
  --ok-soft: rgba(127, 181, 138, .14);
  --warn-soft: rgba(224, 173, 90, .14);
  --bad-soft: rgba(224, 122, 106, .14);
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --serif: 'Cormorant Garamond', 'Cormorant', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --nav-w: 232px;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--sans); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
a { color: var(--gold-2); text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; margin: 0; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 25px; }
h3 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.gold { color: var(--gold-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.sep { height: 1px; background: var(--line); margin: 18px 0; }

/* ---------- Structure ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--nav-w); flex: 0 0 var(--nav-w); background: var(--bg-2);
  border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 22px 14px;
}
.brand { padding: 4px 10px 22px; }
.brand .mark { font-family: var(--serif); font-size: 24px; color: var(--gold-2); line-height: 1; }
.brand .sub { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-size: 14.5px; margin-bottom: 2px;
}
.nav a svg { width: 19px; height: 19px; flex: 0 0 19px; opacity: .85; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--gold-soft); color: var(--gold-2); }
.nav a .badge { margin-left: auto; }
.sidebar .foot { margin-top: auto; padding: 10px 12px; font-size: 12px; color: var(--muted); }
.main { flex: 1 1 auto; min-width: 0; padding: 28px 34px 80px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .kicker { font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.tabbar { display: none; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sync.dirty .dot { background: var(--warn); }
.sync.error .dot { background: var(--bad); }

/* ---------- Boutons & champs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  min-height: var(--tap); padding: 0 16px; border-radius: 11px; font: inherit; font-size: 14.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s; text-decoration: none;
}
.btn:hover { border-color: var(--gold); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: linear-gradient(180deg, #d8b46a, #b8924a); border-color: #c9a45c; color: #1a1408; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13.5px; border-radius: 9px; }
.btn.icon { width: var(--tap); padding: 0; }
.btn.sm.icon { width: 34px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

label.field { display: block; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 6px 2px; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 16px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
select.input { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.input.num { text-align: right; }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 46px; }
.input-suffix em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 13px; pointer-events: none; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.grid-form .span2 { grid-column: span 2; }
.grid-form .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; color: var(--text-2); min-height: 36px; }
.check input { width: 19px; height: 19px; accent-color: var(--gold); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; color: var(--muted); }
.search .input { padding-left: 40px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 13.5px; padding: 0 12px; min-height: 36px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--surface-3); color: var(--gold-2); }

/* ---------- Puces, badges ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { appearance: none; border: 1px solid var(--line-2); background: transparent; color: var(--text-2); border-radius: 999px; padding: 0 14px; min-height: 36px; font: inherit; font-size: 13.5px; cursor: pointer; }
.chip.on { border-color: var(--gold); color: var(--gold-2); background: var(--gold-soft); }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gold { background: var(--gold-soft); color: var(--gold-2); }

/* ---------- Cartes & panneaux ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h3 { font-size: 21px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.kpi .v { font-family: var(--serif); font-size: 31px; color: var(--text); margin-top: 4px; line-height: 1.1; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.hl { border-color: rgba(201, 164, 92, .45); background: linear-gradient(180deg, rgba(201, 164, 92, .10), var(--surface)); }
.kpi.hl .v { color: var(--gold-2); }
.alert { border-radius: var(--radius-s); padding: 12px 14px; display: flex; gap: 12px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.alert.warn { background: var(--warn-soft); border: 1px solid rgba(224, 173, 90, .35); color: #f1d29d; }
.alert.bad { background: var(--bad-soft); border: 1px solid rgba(224, 122, 106, .35); color: #f2b6ac; }
.alert.info { background: var(--gold-soft); border: 1px solid rgba(201, 164, 92, .3); color: var(--text-2); }
.alert .grow { min-width: 200px; }
.alert > svg { width: 20px; height: 20px; flex: 0 0 20px; }
.empty svg, .panel-head svg { width: 20px; height: 20px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 8px; }

/* ---------- Galerie ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1 1 260px; max-width: 420px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  cursor: pointer; transition: transform .18s, border-color .18s, box-shadow .18s; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); border-color: rgba(201, 164, 92, .5); box-shadow: var(--shadow); }
.card .ph { aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; overflow: hidden; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s; }
.card:hover .ph img { transform: scale(1.04); }
.card .ph .cat { position: absolute; left: 12px; top: 12px; background: rgba(14, 13, 11, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: var(--text-2); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; }
.card .edit { position: absolute; right: 10px; top: 10px; width: 38px; height: 38px; border-radius: 50%; background: rgba(14, 13, 11, .72); border: 1px solid rgba(255, 255, 255, .08); color: var(--text); display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.card .edit svg { width: 17px; height: 17px; }
.card .stale { position: absolute; left: 12px; bottom: 12px; }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card .name { font-family: var(--serif); font-size: 22px; line-height: 1.15; }
.card .figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: auto; }
.card .figs div:nth-child(3) { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.card .figs div { background: var(--bg-2); border-radius: 9px; padding: 7px 9px; }
.card .figs .l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.card .figs .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; white-space: nowrap; }
.placeholder { width: 100%; height: 100%; display: grid; place-items: center; background:
  radial-gradient(120% 90% at 30% 20%, rgba(201, 164, 92, .18), transparent 60%), linear-gradient(160deg, #25211b, #15130f); }
.placeholder span { font-family: var(--serif); font-size: 46px; color: rgba(224, 192, 126, .55); }
.fab { position: fixed; right: 22px; bottom: calc(22px + var(--safe-b)); z-index: 30; border-radius: 999px; min-height: 54px; padding: 0 22px; box-shadow: var(--shadow); }

/* ---------- Fiche technique ---------- */
.hero { display: grid; grid-template-columns: minmax(280px, 1.15fr) 1fr; gap: 24px; margin-bottom: 20px; }
.hero .photo { border-radius: 18px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--surface-2); border: 1px solid var(--line); position: relative; }
.hero .photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.hero .photo .actions { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.hero .photo .actions .btn { background: rgba(14, 13, 11, .78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.hero .info { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hero .title-input { font-family: var(--serif); font-size: 32px; background: transparent; border: 1px solid transparent; color: var(--text); width: 100%; padding: 2px 8px; margin-left: -9px; border-radius: 10px; }
.hero .title-input:focus { border-color: var(--line-2); outline: none; background: var(--bg-2); }
.costbox { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.costbox .kpi { padding: 13px 15px; }
.costbox .kpi .v { font-size: 27px; }
.breakdown { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.breakdown i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend b { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.lines { display: flex; flex-direction: column; gap: 8px; }
.lines-head, .line { display: grid; grid-template-columns: 26px minmax(170px, 2.2fr) 96px 104px 118px 132px 98px 92px; gap: 8px; align-items: center; }
.lines-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 10px 4px; }
.line { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.line:focus-within { border-color: var(--line-2); }
.line .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.line .ico svg { width: 15px; height: 15px; }
.line.sub .ico { background: var(--gold-soft); color: var(--gold-2); }
.line .pick { appearance: none; text-align: left; background: transparent; border: 1px solid transparent; color: var(--text); font: inherit; font-size: 15px; min-height: 40px; border-radius: 9px; padding: 0 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .pick:hover { border-color: var(--line-2); }
.line .pick small { display: block; font-size: 11.5px; color: var(--muted); }
.line .input { min-height: 40px; font-size: 15px; padding: 0 9px; }
.line select.input { padding-right: 24px; background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; }
.line .cost { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.line .cost small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.line .acts { display: flex; gap: 2px; justify-content: flex-end; }
.line .acts .btn { width: 30px; min-height: 30px; padding: 0; border-radius: 8px; }
.line .acts .btn svg { width: 15px; height: 15px; }
.line.extra { grid-template-columns: 26px 150px minmax(140px,1fr) 90px 80px 100px 132px 98px 40px; }
.line.extra.nolab { grid-template-columns: 26px 150px minmax(140px,1fr) 120px 132px 98px 40px; }
.line .more { grid-column: 2 / -1; display: none; gap: 14px; flex-wrap: wrap; align-items: center; padding: 6px 0 2px; }
.line.open .more { display: flex; }
.line .warn-line { grid-column: 2 / -1; font-size: 12.5px; color: var(--warn); }
.line .ml { display: none; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table .r, .table th.r { text-align: right; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; }
.table .sub-row td { color: var(--text-2); font-size: 13px; padding-top: 4px; padding-bottom: 4px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.twocol { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.sumlist { display: flex; flex-direction: column; }
.sumlist > div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.sumlist > div:last-child { border-bottom: 0; }
.sumlist .t { font-weight: 700; color: var(--gold-2); font-size: 16px; }

/* ---------- Fenêtres ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 4, 3, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s; }
.modal { background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; width: 100%; max-width: 640px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .18s; }
.modal.wide { max-width: 940px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.modal-body { padding: 4px 20px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { padding: 14px 20px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.picklist { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; max-height: 52vh; overflow-y: auto; }
.picklist button { appearance: none; text-align: left; border: 1px solid transparent; background: var(--bg-2); color: var(--text); font: inherit; padding: 10px 12px; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 48px; }
.picklist button:hover, .picklist button:focus { border-color: var(--gold); outline: none; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; animation: pop .2s; pointer-events: auto; max-width: 90vw; }
.toast.bad { border-color: var(--bad); }
.toast.ok { border-color: rgba(127, 181, 138, .6); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .94); z-index: 150; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }

/* recadrage */
.cropper { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: 12px; overflow: hidden; touch-action: none; cursor: grab; }
.cropper canvas { width: 100%; height: 100%; display: block; }
.cropper .grid { position: absolute; inset: 0; pointer-events: none; background:
  linear-gradient(to right, transparent 33.2%, rgba(255,255,255,.25) 33.3%, transparent 33.5%, transparent 66.5%, rgba(255,255,255,.25) 66.6%, transparent 66.8%),
  linear-gradient(to bottom, transparent 33.2%, rgba(255,255,255,.25) 33.3%, transparent 33.5%, transparent 66.5%, rgba(255,255,255,.25) 66.6%, transparent 66.8%); }
input[type=range] { width: 100%; accent-color: var(--gold); }

/* graphiques */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.bars .bar { display: grid; grid-template-columns: minmax(110px, 1.2fr) 3fr 80px; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13.5px; }
.bars .track { height: 12px; background: var(--surface-3); border-radius: 99px; overflow: hidden; position: relative; }
.bars .track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { appearance: none; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--text-2); font: inherit; padding: 10px 14px; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--gold-2); border-bottom-color: var(--gold); }

/* ---------- Authentification / démarrage ---------- */
.splash { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.splash .box { width: 100%; max-width: 420px; }
.splash .mark { font-family: var(--serif); font-size: 40px; color: var(--gold-2); text-align: center; }
.splash .sub { text-align: center; color: var(--muted); letter-spacing: .2em; font-size: 11.5px; text-transform: uppercase; margin: 6px 0 28px; }

/* ---------- Impression A4 ---------- */
#print-root { display: none; }

/* ---------- Tablette ---------- */
@media (max-width: 1180px) {
  .lines-head { display: none; }
  .line, .line.extra, .line.extra.nolab { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: auto; }
  .line .ico { display: none; }
  .line .pick { grid-column: 1 / -1; }
  .line.extra .f:nth-of-type(2) { grid-column: span 3; }
  .line .ml { display: block; font-size: 11px; color: var(--muted); margin: 0 0 3px 2px; }
  .line .f { min-width: 0; }
  .line .cost { grid-column: 1 / 3; text-align: left; }
  .line .acts { grid-column: 3 / -1; }
  .line .acts .btn { width: 40px; min-height: 40px; }
  .line .more, .line .warn-line { grid-column: 1 / -1; }
  .twocol { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .line, .line.extra, .line.extra.nolab { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line.extra .f:nth-of-type(2) { grid-column: 1 / -1; }
  .line .cost { grid-column: 1 / 2; }
  .line .acts { grid-column: 2 / 3; }
}
/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: calc(18px + var(--safe-t)) 16px calc(96px + var(--safe-b)); }
  h1 { font-size: 29px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(21, 19, 15, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
  }
  .tabbar a, .tabbar button { appearance: none; border: 0; background: transparent; font: inherit; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10.5px; padding: 5px 0; min-height: 50px; cursor: pointer; }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar .active { color: var(--gold-2); }
  .fab { bottom: calc(84px + var(--safe-b)); right: 16px; min-height: 52px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card .name { font-size: 18px; }
  .card .body { padding: 10px 11px 12px; gap: 8px; }
  .card .figs { grid-template-columns: 1fr; gap: 4px; }
  .card .figs div { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 8px; }
  .card .figs .l { font-size: 9.5px; letter-spacing: .04em; }
  .card .figs .v { font-size: 13.5px; }
  .card .figs .badge { font-size: 11px; padding: 1px 7px; }
  .card .edit { width: 34px; height: 34px; }
  .hero { grid-template-columns: 1fr; gap: 16px; }
  .hero .title-input { font-size: 27px; }
  .panel { padding: 15px; border-radius: 13px; }
  .dash-grid { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form .span2 { grid-column: 1 / -1; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 94vh; }
  .modal.wide { max-width: none; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .page-head { margin-bottom: 16px; }
  .hide-m { display: none !important; }
  .bars .bar { grid-template-columns: 100px 1fr 70px; }
}
@media (max-width: 380px) { .gallery { grid-template-columns: 1fr 1fr; } .grid-form { grid-template-columns: 1fr; } }
@media (min-width: 861px) { .show-m { display: none !important; } }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; color: #111 !important; }
  .app, .toasts, .overlay, .fab, .tabbar { display: none !important; }
  #print-root { display: block !important; }
}
#print-root { font-family: var(--sans); color: #111; background: #fff; }
.pr { width: 100%; font-size: 10.5pt; line-height: 1.35; }
.pr h1 { font-family: var(--serif); font-size: 24pt; color: #111; margin: 0; }
.pr .head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #b8924a; padding-bottom: 6px; margin-bottom: 10px; }
.pr .estab { font-size: 8.5pt; letter-spacing: .18em; text-transform: uppercase; color: #8a6d33; }
.pr .top { display: grid; grid-template-columns: 78mm 1fr; gap: 8mm; margin-bottom: 8px; }
.pr .top img { width: 78mm; height: 58.5mm; object-fit: cover; border-radius: 3mm; }
.pr .top .noimg { width: 78mm; height: 58.5mm; border: 1px solid #ddd; border-radius: 3mm; }
.pr table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.pr th { text-align: left; font-weight: 600; font-size: 8pt; text-transform: uppercase; letter-spacing: .05em; color: #555; border-bottom: 1px solid #999; padding: 4px 5px; }
.pr td { border-bottom: 1px solid #e3e3e3; padding: 4px 5px; vertical-align: top; }
.pr .r { text-align: right; white-space: nowrap; }
.pr tfoot td { font-weight: 700; border-top: 1px solid #999; border-bottom: 0; }
.pr .box { border: 1px solid #ccc; border-radius: 2mm; padding: 3mm 4mm; }
.pr .kv { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px dotted #ccc; }
.pr .kv:last-child { border-bottom: 0; }
.pr .kv.t { font-weight: 700; font-size: 11.5pt; }
.pr h2 { font-family: var(--serif); font-size: 14pt; margin: 10px 0 4px; color: #111; }
.pr .sub td { color: #555; font-size: 8.5pt; padding-top: 1px; }
.pr .foot { margin-top: 10px; font-size: 8pt; color: #777; display: flex; justify-content: space-between; }
.pr .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; }
.pr tr, .pr .box { break-inside: avoid; }
