/* ==========================================================================
   Chez Nat et Seb — Générateur de factures
   App chrome: light, minimal, Google/shadcn-inspired.
   Invoice sheet: brand fonts (Anton / Caveat / Work Sans) matching the site.
   ========================================================================== */

:root{
  --app-bg: #f4f5f7;
  --app-surface: #ffffff;
  --app-surface-2: #fbfbfc;
  --app-border: #e5e7eb;
  --app-border-strong: #d7dade;
  --text-primary: #17181a;
  --text-secondary: #5f6368;
  --text-tertiary: #94989e;

  --accent: #ff5a1f;
  --accent-hover: #e64d15;
  --accent-active: #cc4310;
  --accent-soft: #fff2eb;
  --accent-soft-border: #ffd6bd;

  --danger: #d93025;
  --danger-hover: #b7271e;
  --danger-soft: #fdeceb;

  --success: #1e8e3e;
  --success-soft: #e6f4ea;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-xs: 0 1px 2px rgba(16,24,32,.05);
  --shadow-sm: 0 1px 3px rgba(16,24,32,.08), 0 1px 2px rgba(16,24,32,.04);
  --shadow-md: 0 4px 14px rgba(16,24,32,.10), 0 1px 3px rgba(16,24,32,.06);
  --shadow-lg: 0 16px 40px rgba(16,24,32,.18), 0 4px 10px rgba(16,24,32,.08);

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Anton', sans-serif;
  --font-script: 'Caveat', cursive;
  --font-doc: 'Work Sans', sans-serif;

  --ease: cubic-bezier(.22,.7,.32,1);
  --app-bar-h: 64px;
}

*, *::before, *::after{ box-sizing: border-box; }
[hidden]{ display: none !important; }
html{ -webkit-text-size-adjust: 100%; }
body{
  margin:0;
  background: var(--app-bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
img{ max-width:100%; display:block; }
button{ font-family: inherit; }
input, select, textarea{ font-family: inherit; }
::selection{ background: var(--accent); color:#fff; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.001ms !important; transition-duration:.001ms !important; }
}

/* ---------- App bar ---------- */
.app-bar{
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--app-bar-h);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 24px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--app-border);
}
.app-bar-brand{
  display:flex;
  align-items:center;
  gap:12px;
}
.app-bar-brand img{
  width:36px; height:36px;
  border-radius:50%;
  object-fit:cover;
  box-shadow: 0 0 0 1px var(--app-border);
}
.app-bar-titles{ display:flex; flex-direction:column; line-height:1.15; }
.app-bar-title{
  font-size:0.68rem;
  font-weight:700;
  letter-spacing:1.2px;
  text-transform:uppercase;
  color:var(--text-tertiary);
}
.app-bar-sub{
  font-family: var(--font-display);
  font-weight:400;
  font-size:1.15rem;
  letter-spacing:.3px;
  color:var(--text-primary);
}
.app-bar-sub .amp{ color:var(--accent); }
.app-bar-status{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:0.78rem;
  color:var(--text-tertiary);
  font-weight:500;
  transition: opacity .2s ease;
}
.save-dot{
  width:7px; height:7px;
  border-radius:50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
  flex-shrink:0;
}
.app-bar-status.saving .save-dot{ background: var(--text-tertiary); box-shadow:0 0 0 3px var(--app-border); }

/* ---------- Mobile tabs ---------- */
.mobile-tabs{
  display:none;
  position: sticky;
  top: var(--app-bar-h);
  z-index: 39;
  gap:6px;
  padding: 10px 16px;
  background: var(--app-bg);
  border-bottom: 1px solid var(--app-border);
}
.mobile-tab{
  flex:1;
  border:1px solid var(--app-border-strong);
  background:var(--app-surface);
  color:var(--text-secondary);
  font-weight:600;
  font-size:0.85rem;
  padding:9px 12px;
  border-radius:999px;
  cursor:pointer;
  transition: all .15s var(--ease);
}
.mobile-tab.active{
  background:var(--text-primary);
  border-color:var(--text-primary);
  color:#fff;
}

/* ---------- Layout ---------- */
.workspace{
  display:grid;
  grid-template-columns: minmax(380px, 1fr) minmax(420px, 600px);
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  align-items:start;
}
.editor-pane{
  display:flex;
  flex-direction:column;
  gap:16px;
  min-width:0;
}
.side-pane{
  position: sticky;
  top: calc(var(--app-bar-h) + 20px);
  display:flex;
  flex-direction:column;
  gap:14px;
  max-height: calc(100vh - var(--app-bar-h) - 40px);
  min-width:0;
}

/* ---------- Cards ---------- */
.card{
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow:hidden;
  animation: card-in .35s var(--ease) both;
}
@keyframes card-in{
  from{ opacity:0; transform:translateY(6px); }
  to{ opacity:1; transform:translateY(0); }
}
.card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 18px 20px 14px;
}
.card-head h2{
  margin:0;
  font-size:0.95rem;
  font-weight:700;
  letter-spacing:.1px;
  color:var(--text-primary);
}
.card-body{
  padding: 4px 20px 20px;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.card-body.no-pad{ padding: 0 0 16px; }
.count-pill{
  background: var(--app-bg);
  color: var(--text-secondary);
  font-size:0.72rem;
  font-weight:700;
  padding: 3px 9px;
  border-radius: 999px;
  border:1px solid var(--app-border);
}

/* ---------- Fields ---------- */
.field{ display:flex; flex-direction:column; gap:6px; }
.field-row{ display:flex; gap:14px; }
.field-row.two > .field{ flex:1; min-width:0; }
.field label{
  font-size:0.78rem;
  font-weight:600;
  color:var(--text-secondary);
}
.field label .req{ color:var(--accent); }
.field-hint{
  font-size:0.74rem;
  color:var(--text-tertiary);
  margin:2px 0 0;
}
input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="number"], select, textarea{
  width:100%;
  padding: 9px 12px;
  border:1px solid var(--app-border-strong);
  border-radius: var(--radius-sm);
  background: var(--app-surface);
  color: var(--text-primary);
  font-size:0.875rem;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea{ resize: vertical; min-height:44px; font-family:inherit; }
input::placeholder, textarea::placeholder{ color: var(--text-tertiary); }
input:hover, select:hover, textarea:hover{ border-color: var(--app-border-strong); }
input:focus, select:focus, textarea:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input.field-invalid, textarea.field-invalid{
  border-color: var(--danger);
  animation: shake .32s var(--ease);
}
@keyframes shake{
  0%,100%{ transform:translateX(0); }
  25%{ transform:translateX(-4px); }
  75%{ transform:translateX(4px); }
}
.field-error{
  color: var(--danger);
  font-size:0.78rem;
  font-weight:500;
  margin:2px 0 0;
}

.logo-row{ display:flex; align-items:center; gap:14px; flex-direction:row; }
.logo-thumb{
  width:52px; height:52px;
  border-radius:50%;
  object-fit:cover;
  box-shadow: 0 0 0 1px var(--app-border);
  flex-shrink:0;
}

.switch-inline{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size:0.8rem;
  font-weight:600;
  color: var(--text-secondary);
  cursor:pointer;
  user-select:none;
}
.switch-block{ margin-bottom:2px; }
.switch-inline input[type="checkbox"]{
  appearance:none;
  width:34px; height:20px;
  border-radius:999px;
  background: var(--app-border-strong);
  position:relative;
  cursor:pointer;
  transition: background .18s ease;
  flex-shrink:0;
}
.switch-inline input[type="checkbox"]::after{
  content:"";
  position:absolute;
  top:2px; left:2px;
  width:16px; height:16px;
  border-radius:50%;
  background:#fff;
  box-shadow: var(--shadow-xs);
  transition: transform .18s var(--ease);
}
.switch-inline input[type="checkbox"]:checked{ background: var(--accent); }
.switch-inline input[type="checkbox"]:checked::after{ transform: translateX(14px); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  height:40px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size:0.85rem;
  font-weight:600;
  cursor:pointer;
  white-space:nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease);
}
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.btn:disabled{ opacity:.5; cursor:not-allowed; transform:none; box-shadow:none; }
.btn-sm{ height:32px; padding:0 12px; font-size:0.78rem; }

.btn-primary{ background: var(--accent); color:#fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled){ background: var(--accent-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-primary:active:not(:disabled){ background: var(--accent-active); transform: translateY(0); }

.btn-outline{ background: var(--app-surface); border-color: var(--app-border-strong); color: var(--text-primary); }
.btn-outline:hover:not(:disabled){ border-color: var(--accent); color: var(--accent-hover); background: var(--accent-soft); }

.btn-ghost{ background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled){ background: var(--app-bg); color: var(--text-primary); }

.btn-danger{ background: var(--danger); color:#fff; }
.btn-danger:hover:not(:disabled){ background: var(--danger-hover); }

.btn-add-row{
  margin: 4px 20px 0;
  justify-content:flex-start;
  border: 1px dashed var(--app-border-strong);
  color: var(--text-secondary);
}
.btn-add-row:hover{ border-color: var(--accent); color: var(--accent-hover); background: var(--accent-soft); border-style:dashed; }

/* ---------- Items table (editor) ---------- */
.items-table{ display:flex; flex-direction:column; }
.items-head{
  display:grid;
  grid-template-columns: 1fr 92px 96px 76px 92px 28px;
  gap:8px;
  padding: 0 20px 8px;
  font-size:0.7rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.6px;
  color: var(--text-tertiary);
}
.items-body{ display:flex; flex-direction:column; }
.item-row{
  display:grid;
  grid-template-columns: 1fr 92px 96px 76px 92px 28px;
  gap:8px;
  align-items:center;
  padding: 10px 20px;
  border-top: 1px solid var(--app-border);
  animation: row-in .25s var(--ease) both;
}
@keyframes row-in{
  from{ opacity:0; transform: translateY(-4px); }
  to{ opacity:1; transform:translateY(0); }
}
.item-row.row-removing{
  animation: row-out .18s ease forwards;
}
@keyframes row-out{
  to{ opacity:0; transform: scale(.97); max-height:0; padding-top:0; padding-bottom:0; }
}
.item-cell.item-name{ display:flex; flex-direction:column; gap:4px; min-width:0; }
.input-inline{
  border:1px solid transparent;
  background: transparent;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  font-size:0.85rem;
  width:100%;
  transition: border-color .15s ease, background .15s ease;
}
.input-inline:hover{ background: var(--app-surface-2); }
.input-inline:focus{ outline:none; border-color: var(--accent); background:#fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.input-desc{ font-size:0.76rem; color: var(--text-tertiary); }
.item-qty{ display:flex; align-items:center; gap:2px; }
.item-qty input{
  width:34px;
  text-align:center;
  padding: 5px 2px;
  border:1px solid transparent;
  background:transparent;
  font-weight:600;
  -moz-appearance: textfield;
}
.item-qty input::-webkit-outer-spin-button, .item-qty input::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }
.item-qty input:focus{ outline:none; }
.stepper{
  width:22px; height:22px;
  border-radius:6px;
  border:1px solid var(--app-border-strong);
  background:var(--app-surface);
  color:var(--text-secondary);
  font-size:0.9rem;
  line-height:1;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  flex-shrink:0;
  transition: all .12s var(--ease);
}
.stepper:hover{ border-color:var(--accent); color:var(--accent-hover); background:var(--accent-soft); }
.stepper:active{ transform: scale(.9); }
.item-price input, .item-discount input{
  padding: 5px 7px;
  border:1px solid transparent;
  background:transparent;
  text-align:right;
  font-size:0.85rem;
}
.item-price input:hover, .item-discount input:hover{ background: var(--app-surface-2); }
.item-price input:focus, .item-discount input:focus{ outline:none; border-color:var(--accent); background:#fff; box-shadow:0 0 0 3px var(--accent-soft); }
.item-total{
  text-align:right;
  font-weight:700;
  font-size:0.88rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.icon-btn{
  width:26px; height:26px;
  border-radius:50%;
  border:none;
  background:transparent;
  color: var(--text-tertiary);
  font-size:1.05rem;
  line-height:1;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: all .12s var(--ease);
}
.icon-btn:hover{ background: var(--danger-soft); color: var(--danger); }
.item-row.row-flash{ animation: flash-bg .9s ease; }
@keyframes flash-bg{
  from{ background: var(--accent-soft); }
  to{ background: transparent; }
}
.card.card-invalid{
  animation: shake .32s var(--ease);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.items-empty{
  display:none;
  text-align:center;
  padding: 28px 20px 8px;
  color: var(--text-tertiary);
}
.items-empty p{ margin:0 0 4px; font-size:0.85rem; }
.items-empty .muted{ font-size:0.78rem; }
.items-table.is-empty .items-empty{ display:block; }
.items-table.is-empty .items-head{ display:none; }

/* ---------- Totals ---------- */
.totals-summary{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding-top:6px;
  border-top:1px solid var(--app-border);
}
.totals-line{
  display:flex;
  justify-content:space-between;
  font-size:0.85rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.totals-line.totals-final{
  margin-top:6px;
  padding-top:12px;
  border-top:1px dashed var(--app-border-strong);
  font-size:1.15rem;
  font-weight:800;
  color: var(--text-primary);
}

/* ---------- Catalog ---------- */
.catalog-panel{
  background: var(--app-surface);
  border:1px solid var(--app-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 16px 16px 14px;
  flex-shrink:0;
}
.catalog-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}
.catalog-head h2{ margin:0; font-size:0.95rem; font-weight:700; }
.catalog-tabs{
  display:flex;
  gap:6px;
  overflow-x:auto;
  padding-bottom:8px;
  margin-bottom:8px;
  border-bottom:1px solid var(--app-border);
  scrollbar-width:thin;
}
.catalog-tabs::-webkit-scrollbar{ height:4px; }
.catalog-tabs::-webkit-scrollbar-thumb{ background: var(--app-border-strong); border-radius:4px; }
.catalog-tab{
  flex-shrink:0;
  padding: 6px 12px;
  border-radius: 999px;
  border:1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size:0.78rem;
  font-weight:600;
  cursor:pointer;
  transition: all .15s var(--ease);
}
.catalog-tab:hover{ background: var(--app-bg); }
.catalog-tab.active{ background: var(--text-primary); color:#fff; }
.catalog-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:8px;
  max-height:190px;
  overflow-y:auto;
  padding-right:2px;
}
.catalog-grid::-webkit-scrollbar{ width:6px; }
.catalog-grid::-webkit-scrollbar-thumb{ background: var(--app-border-strong); border-radius:4px; }
.catalog-item{
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:2px;
  text-align:left;
  padding: 9px 12px;
  border:1px solid var(--app-border);
  border-radius: var(--radius-sm);
  background: var(--app-surface-2);
  cursor:pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease);
}
.catalog-item:hover{ border-color: var(--accent); background:#fff; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.catalog-item:active{ transform: translateY(0) scale(.98); }
.catalog-item.just-added{ animation: pop .32s var(--ease); border-color:var(--accent); }
@keyframes pop{
  0%{ transform:scale(1); }
  40%{ transform:scale(1.045); box-shadow: 0 0 0 3px var(--accent-soft); }
  100%{ transform:scale(1); }
}
.catalog-item .ci-name{ font-size:0.8rem; font-weight:600; color:var(--text-primary); line-height:1.25; }
.catalog-item .ci-price{ font-size:0.76rem; font-weight:700; color: var(--accent); }
.catalog-item .ci-remove{
  position:absolute;
  top:-6px; right:-6px;
  width:18px; height:18px;
  border-radius:50%;
  background: var(--app-surface);
  border:1px solid var(--app-border-strong);
  color: var(--text-tertiary);
  font-size:0.7rem;
  line-height:1;
  display:none;
  align-items:center;
  justify-content:center;
  cursor:pointer;
}
.catalog-item:hover .ci-remove{ display:flex; }
.catalog-item .ci-remove:hover{ background: var(--danger); border-color:var(--danger); color:#fff; }
.catalog-empty{
  grid-column: 1 / -1;
  text-align:center;
  color: var(--text-tertiary);
  font-size:0.8rem;
  padding: 18px 8px;
}

/* ---------- Preview panel ---------- */
.preview-panel{
  background: var(--app-surface);
  border:1px solid var(--app-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 14px 14px 0;
  display:flex;
  flex-direction:column;
  flex:1;
  min-height: 260px;
}
.preview-panel-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  padding: 2px 4px 12px;
}
.preview-panel-head h2{ margin:0; font-size:0.95rem; font-weight:700; }
.preview-panel-head .muted{ font-size:0.72rem; color:var(--text-tertiary); }
.preview-scroll{
  flex:1;
  overflow:auto;
  background: var(--app-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px;
  display:flex;
  justify-content:center;
}
.preview-scale{
  transform-origin: top center;
  transition: transform .15s ease;
  height:fit-content;
}

/* ---------- Side actions ---------- */
.side-actions{
  display:flex;
  gap:10px;
  flex-shrink:0;
}
.side-actions .btn-primary{ flex:1.4; }
.side-actions .btn-outline{ flex:1; }
.side-actions .btn-ghost{ flex:1; }

/* ==========================================================================
   Invoice sheet — the actual A4 document
   ========================================================================== */
.sheet{
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  color: #1c1c1c;
  font-family: var(--font-doc);
  font-size: 10.5px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 12px 32px rgba(20,20,20,.12);
  padding: 16mm 15mm 14mm;
  display:flex;
  flex-direction:column;
}
.sheet-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
}
.sheet-brand{ display:flex; align-items:center; gap:12px; }
.sheet-logo{
  width:52px; height:52px;
  border-radius:50%;
  object-fit:cover;
  flex-shrink:0;
}
.sheet-brand-text{ display:flex; flex-direction:column; }
.sheet-company-name{
  font-family: var(--font-display);
  font-weight:400;
  font-size:17px;
  letter-spacing:.3px;
  color:#141414;
}
.sheet-company-details{
  font-size:9px;
  color:#6a6a6a;
  line-height:1.5;
  margin-top:3px;
  white-space:pre-line;
}
.sheet-doc-meta{ text-align:right; flex-shrink:0; }
.sheet-doc-title{
  font-family: var(--font-display);
  font-weight:400;
  font-size:22px;
  letter-spacing:1.5px;
  color: var(--accent);
  margin-bottom:6px;
}
.sheet-doc-row{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  font-size:9.5px;
  color:#555;
  margin-top:2px;
}
.sheet-doc-row span{ color:#8a8a8a; }
.sheet-doc-row strong{ color:#1c1c1c; font-weight:700; min-width:70px; text-align:right; }

.sheet-divider{
  height:2px;
  background: linear-gradient(90deg, var(--accent), #ffd6bd 65%, transparent);
  margin: 14px 0 16px;
  flex-shrink:0;
}

.sheet-parties{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:20px;
  margin-bottom:18px;
}
.sheet-party-label{
  display:block;
  font-size:8.5px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:1px;
  color: var(--accent);
  margin-bottom:6px;
}
.sheet-party-block{
  font-size:10px;
  line-height:1.55;
  color:#2a2a2a;
  white-space:pre-line;
}
.sheet-party-block strong{ display:block; font-size:11px; margin-bottom:2px; }
.sheet-party-block-empty{ color:#b3b3b3; font-style:italic; }

.sheet-table{
  width:100%;
  border-collapse:collapse;
  margin-bottom: 4mm;
}
.sheet-table thead th{
  text-align:left;
  font-size:8.5px;
  text-transform:uppercase;
  letter-spacing:.6px;
  color:#8a8a8a;
  font-weight:700;
  padding: 0 6px 8px;
  border-bottom: 1.5px solid #1c1c1c;
}
.sheet-table thead th.ac{ text-align:center; }
.sheet-table thead th.ar{ text-align:right; }
.sheet-table tbody td{
  padding: 8px 6px;
  border-bottom: 1px solid #e6e6e6;
  font-size:10px;
  vertical-align:top;
}
.sheet-table tbody tr:last-child td{ border-bottom:1px solid #1c1c1c; }
.sheet-table td.ac{ text-align:center; }
.sheet-table td.ar{ text-align:right; font-variant-numeric: tabular-nums; }
.sheet-item-name{ font-weight:600; color:#141414; }
.sheet-item-desc{ font-size:8.8px; color:#8a8a8a; margin-top:2px; }
.sheet-empty-row td{ text-align:center; color:#b3b3b3; font-style:italic; padding:18px 6px; }

.sheet-bottom{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:24px;
  margin-top:2mm;
}
.sheet-conditions{ flex:1; font-size:9.5px; color:#555; line-height:1.6; min-width:0; }
.sheet-conditions > div:first-child{ font-weight:600; color:#333; }
.sheet-notes{ margin-top:8px; white-space:pre-line; }
.sheet-totals{
  width: 62mm;
  flex-shrink:0;
  display:flex;
  flex-direction:column;
  gap:5px;
}
.sheet-totals-row{
  display:flex;
  justify-content:space-between;
  font-size:9.8px;
  color:#555;
}
.sheet-totals-row.final{
  margin-top:4px;
  padding: 8px 10px;
  background: #141414;
  color:#fff;
  border-radius:4px;
  font-size:12px;
  font-weight:700;
}
.sheet-totals-row.final span:first-child{ font-weight:600; letter-spacing:.3px; }
.sheet-totals-row.final span:last-child{ color: var(--accent-2, #ff8a3d); }

.sheet-footer{
  margin-top:auto;
  padding-top: 10mm;
  font-size:8.3px;
  color:#9a9a9a;
  line-height:1.6;
  white-space:pre-line;
  border-top: 1px solid #eee;
  margin-top: 8mm;
  padding-top: 6mm;
}

/* ---------- Toast ---------- */
.toast{
  position:fixed;
  left:50%;
  bottom:28px;
  transform: translate(-50%, 20px);
  background: #17181a;
  color:#fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size:0.85rem;
  font-weight:600;
  box-shadow: var(--shadow-lg);
  opacity:0;
  pointer-events:none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
  z-index: 100;
  display:flex;
  align-items:center;
  gap:8px;
}
.toast.show{
  opacity:1;
  transform: translate(-50%, 0);
}
.toast.toast-success::before{ content:"✓"; color:#7ee08a; font-weight:800; }
.toast.toast-error{ background:#3a1414; }
.toast.toast-error::before{ content:"!"; color:#ff8a8a; font-weight:800; }

/* ---------- Modals ---------- */
.modal-overlay{
  position:fixed;
  inset:0;
  background: rgba(20,20,22,.45);
  backdrop-filter: blur(2px);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 200;
  padding:20px;
  animation: overlay-in .18s ease;
}
@keyframes overlay-in{ from{ opacity:0; } to{ opacity:1; } }
.modal{
  background:#fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  display:flex;
  flex-direction:column;
  gap:14px;
  animation: modal-in .22s var(--ease);
}
@keyframes modal-in{
  from{ opacity:0; transform: translateY(12px) scale(.98); }
  to{ opacity:1; transform:translateY(0) scale(1); }
}
.modal h3{ margin:0; font-size:1.05rem; font-weight:800; }
.modal p{ margin:0; color: var(--text-secondary); font-size:0.88rem; line-height:1.5; }
.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:6px;
}

/* ---------- PDF loading overlay ---------- */
.pdf-loading{
  position:fixed;
  inset:0;
  background: rgba(20,20,22,.35);
  z-index: 300;
  display:flex;
  align-items:center;
  justify-content:center;
}
.pdf-loading-box{
  background:#fff;
  padding: 20px 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display:flex;
  align-items:center;
  gap:12px;
  font-weight:600;
  font-size:0.9rem;
}
.spinner{
  width:18px; height:18px;
  border-radius:50%;
  border: 2.5px solid var(--accent-soft-border);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1180px){
  .workspace{ grid-template-columns: 1fr; }
  .side-pane{
    position:static;
    max-height:none;
  }
  .catalog-grid{ max-height:none; }
  .preview-scroll{ overflow:visible; }
}

@media (max-width: 960px){
  .app-bar-status span:last-child{ display:none; }
  .mobile-tabs{ display:flex; }
  .workspace{ padding: 16px 16px 40px; }
  .editor-pane, .side-pane{ display:none; }
  .editor-pane.panel-active, .side-pane.panel-active{ display:flex; }
  .side-pane.panel-active{ position:static; max-height:none; }
}

@media (max-width: 560px){
  .field-row.two{ flex-direction:column; gap:14px; }
  .items-head{ display:none; }
  .item-row{
    grid-template-columns: 1fr;
    gap:8px;
    padding: 14px 16px;
    position:relative;
  }
  .item-row .icon-btn{ position:absolute; top:10px; right:12px; }
  .item-cell.item-qty::before{ content:"Quantité"; }
  .item-cell.item-price::before{ content:"Prix unitaire"; }
  .item-cell.item-discount::before{ content:"Remise %"; }
  .item-cell.item-total::before{ content:"Total"; }
  .item-cell.item-qty, .item-cell.item-price, .item-cell.item-discount, .item-cell.item-total{
    display:flex;
    justify-content:space-between;
    align-items:center;
  }
  .item-cell.item-qty::before, .item-cell.item-price::before, .item-cell.item-discount::before, .item-cell.item-total::before{
    font-size:0.72rem;
    font-weight:600;
    color: var(--text-tertiary);
    text-transform:uppercase;
    letter-spacing:.4px;
  }
  .item-total{ text-align:right; }
  .catalog-grid{ grid-template-columns: 1fr 1fr; }
  .side-actions{ flex-wrap:wrap; }
  .side-actions .btn{ flex: 1 1 100%; }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print{
  body *{ visibility:hidden; }
  .sheet, .sheet *{ visibility:visible; }
  .preview-scroll, .preview-scale, .preview-panel{
    overflow:visible !important;
    position:static !important;
    height:auto !important;
    max-height:none !important;
  }
  .sheet{
    position:absolute;
    top:0; left:0;
    margin:0;
    box-shadow:none;
    width:210mm;
    min-height:297mm;
    transform:none !important;
  }
  @page{ size:A4; margin:0; }
}
