/* ============================================================
   LA PIERRE NOBLE — DESIGN SYSTEM v2
   ============================================================ */

:root {
  /* Fond */
  --bg:              #f0ebe0;
  --bg-deep:         #e5ddd0;
  --surface:         rgba(255, 253, 248, 0.96);
  --surface-strong:  rgba(255, 255, 252, 0.99);
  --glass:           rgba(255, 252, 246, 0.72);

  /* Texte */
  --ink:             #16110a;
  --ink-mid:         #4a4036;
  --ink-soft:        #7a6e5e;
  --ink-faint:       #b0a494;

  /* Brand */
  --gold:            #c4903a;
  --gold-deep:       #8a6020;
  --gold-soft:       #e8d4a4;
  --gold-glow:       rgba(196, 144, 58, 0.18);
  --stone:           #9e8e78;
  --olive:           #546048;

  /* Sémantique */
  --red:             #8f3020;
  --green:           #3e5a34;

  /* Structure */
  --line:            rgba(20, 14, 6, 0.10);
  --line-strong:     rgba(20, 14, 6, 0.18);
  --shadow-sm:       0 4px 16px rgba(16, 10, 2, 0.08);
  --shadow:          0 12px 40px rgba(16, 10, 2, 0.10);
  --shadow-lg:       0 24px 64px rgba(16, 10, 2, 0.14);
  --radius:          18px;
  --radius-sm:       10px;
  --radius-xs:       6px;

  /* Topbar */
  --topbar-bg:       #110e08;
  --topbar-text:     #f5f0e6;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: clamp(13px, 1.05vw, 15px);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", system-ui, sans-serif;
  background:
    radial-gradient(ellipse at 0% 0%,   rgba(196, 144, 58, 0.09) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 0%,  rgba(84,  96, 72, 0.07) 0%, transparent 42%),
    linear-gradient(180deg, #f8f3e8 0%, var(--bg) 60%, #e8e0d4 100%);
  background-attachment: fixed;
}

/* ---- Aura décorative ---- */
.page-aura {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
.page-aura-devis {
  background:
    radial-gradient(ellipse at 8% 22%, rgba(196, 144, 58, 0.07), transparent 32%),
    radial-gradient(ellipse at 92% 16%, rgba(84,  96, 72, 0.06), transparent 26%);
}
.page-aura-opti {
  background:
    radial-gradient(ellipse at 8% 18%,  rgba(84,  96, 72, 0.08), transparent 30%),
    radial-gradient(ellipse at 90% 16%, rgba(196, 144, 58, 0.07), transparent 28%);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.shell {
  width: min(98vw, 1800px);
  margin: 0 auto;
}

.layout {
  display: grid;
  gap: 12px;
  padding: 16px 0 28px;
}
.layout-devis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.layout-opti  { grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr); }

.hero-panel,
.items-panel,
.measures-panel,
.result-panel,
.docs-panel,
.catalog-panel,
.atelier-panel { grid-column: 1 / -1; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar-wrapper {
  background: var(--topbar-bg);
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.22);
  position: relative;
}

.topbar-wrapper::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(196, 144, 58, 0.55) 20%,
    rgba(196, 144, 58, 0.75) 50%,
    rgba(196, 144, 58, 0.55) 80%,
    transparent 100%
  );
}

header.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 0 13px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-logo {
  height: 44px;
  width: auto;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  opacity: 0.90;
  transition: opacity 200ms ease;
}
.topbar-logo:hover { opacity: 1; }

.topbar-title .eyebrow {
  color: var(--gold);
  margin-bottom: 2px;
  font-size: 0.70rem;
}

.topbar-title h1 {
  color: var(--topbar-text);
  font-size: clamp(1.3rem, 2.2vw, 1.85rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

/* ---- Eyebrow global ---- */
.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
}

/* ---- Headings ---- */
h1, h2, h3 {
  margin: 0;
  font-family: Georgia, "Palatino Linotype", serif;
  font-weight: 600;
  letter-spacing: -0.025em;
}
h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1; }
h2 { font-size: clamp(1.1rem, 1.8vw, 1.5rem); line-height: 1.1; }
p  { margin: 0; line-height: 1.55; }
.lede { margin-top: 8px; color: var(--ink-soft); }

/* ============================================================
   NAVIGATION
   ============================================================ */
.page-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.page-nav a,
button,
.button-link {
  transition:
    transform       140ms ease,
    background-color 140ms ease,
    border-color    140ms ease,
    box-shadow      140ms ease,
    color           140ms ease,
    filter          140ms ease;
}

.page-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border-radius: 999px;
  border: 1px solid rgba(196, 144, 58, 0.32);
  text-decoration: none;
  color: rgba(245, 240, 230, 0.65);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
  letter-spacing: 0.03em;
}

.page-nav a.is-active,
.page-nav a:hover {
  color: var(--topbar-bg);
  background: linear-gradient(135deg, var(--gold) 0%, #dba840 100%);
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(196, 144, 58, 0.38);
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: rise-in 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Lueur décorative en coin */
.panel::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -70px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 144, 58, 0.055), transparent 70%);
  pointer-events: none;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel:nth-child(2) { animation-delay:  50ms; }
.panel:nth-child(3) { animation-delay: 100ms; }
.panel:nth-child(4) { animation-delay: 150ms; }
.panel:nth-child(5) { animation-delay: 200ms; }
.panel:nth-child(6) { animation-delay: 250ms; }

.hero-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: stretch;
  background:
    linear-gradient(145deg,
      rgba(255, 254, 250, 0.98),
      rgba(248, 240, 226, 0.90)
    );
  border-color: rgba(196, 144, 58, 0.14);
}

.hero-copy p:last-child {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

/* ============================================================
   METRIC & SUMMARY CARDS
   ============================================================ */
.hero-metrics,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.metric-card,
.summary-card {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  transition: box-shadow 200ms ease, border-color 200ms ease;
}
.metric-card:hover,
.summary-card:hover {
  border-color: rgba(196, 144, 58, 0.20);
  box-shadow: var(--shadow-sm);
}

.metric-card span,
.summary-card span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: 500;
}

.metric-card strong,
.summary-card strong {
  font-size: 1.16rem;
  font-family: Georgia, serif;
  line-height: 1.1;
  color: var(--ink);
}

.panel-sub {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.45;
  max-width: 560px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.toolbar,
.action-stack {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.action-stack { margin-top: 12px; }

.structure-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, auto);
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}
.structure-summary-main { min-width: 0; }
.summary-grid-inline    { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.structure-actions      { margin-top: 0; align-self: stretch; }

/* ============================================================
   BOUTONS
   ============================================================ */
button,
.button-link {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  font-size: 0.90rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #fff9f0;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  box-shadow: 0 4px 14px rgba(138, 96, 32, 0.22);
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(138, 96, 32, 0.30);
  filter: brightness(1.06);
}

button:active,
.button-link:active {
  transform: translateY(0);
  filter: brightness(0.96);
}

.ghost-button {
  color: var(--ink-mid);
  background: rgba(255, 252, 246, 0.75);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.ghost-button:hover {
  background: rgba(255, 252, 246, 0.96);
  box-shadow: var(--shadow-sm);
  filter: none;
}

.sand-button {
  color: var(--gold-deep);
  background: linear-gradient(135deg, #ead8b4 0%, #f5ecda 100%);
  box-shadow: none;
}
.sand-button:hover { box-shadow: var(--shadow-sm); filter: brightness(1.03); }

.danger-button {
  color: #fff5f0;
  background: linear-gradient(135deg, #b04d36 0%, var(--red) 100%);
  box-shadow: 0 4px 14px rgba(143, 48, 32, 0.22);
}

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label,
.catalog-form label {
  display: grid;
  gap: 7px;
  font-size: 0.90rem;
}

.form-grid label span,
.catalog-form label span {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 600;
}

.span-2 { grid-column: span 2; }

.context-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px 14px;
  align-items: flex-end;
  overflow-x: auto;
}
.context-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.84rem;
  color: var(--ink-soft);
  flex-shrink: 0;
  white-space: nowrap;
}
.context-field > span {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.context-field select,
.context-field input[type="number"] {
  width: auto !important;
  min-width: 0;
  padding: 7px 10px;
}
.context-number { width: 74px !important; }
.context-separator {
  width: 1px;
  height: 28px;
  background: var(--line-strong);
  align-self: flex-end;
  margin: 0 2px 8px;
  flex-shrink: 0;
}
.context-notes {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 16px;
}
.context-notes > span {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(20, 14, 6, 0.14);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196, 144, 58, 0.14);
}
textarea { resize: vertical; }

.toggle-field { align-content: end; }
.toggle-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  justify-self: start;
  accent-color: var(--gold);
}

/* ============================================================
   TABLEAUX
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.70);
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
}
.items-table { min-width: 760px; }
.cuts-table  { min-width: 760px; }

.grid-table thead {
  background: var(--ink);
  color: #f5f0e5;
}
.grid-table thead th {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: none;
}

.grid-table th,
.grid-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(20, 14, 6, 0.07);
  text-align: left;
  vertical-align: top;
}

.grid-table tbody tr {
  transition: background 120ms ease;
}
.grid-table tbody tr:hover    { background: rgba(196, 144, 58, 0.06); }
.grid-table tbody tr:last-child td { border-bottom: none; }

.level-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(196, 144, 58, 0.12);
  font-size: 0.82rem;
  white-space: nowrap;
}
.depth-marker {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.85;
}

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { padding: 5px 10px; font-size: 0.80rem; }

/* ============================================================
   STATUT / FEEDBACK
   ============================================================ */
.muted { color: var(--ink-soft); }

.status-panel {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.82);
  font-size: 0.90rem;
}
.status-panel.error {
  color: #fff3f0;
  background: linear-gradient(135deg, #b04d36 0%, #8f3020 100%);
  border-color: rgba(143, 48, 32, 0.38);
}
.status-panel.success {
  color: #f2fff0;
  background: linear-gradient(135deg, #4e7044 0%, #3a5430 100%);
  border-color: rgba(62, 90, 52, 0.42);
}

/* ============================================================
   CATALOGUE
   ============================================================ */
.catalog-panel .catalog-list { max-height: 320px; overflow-y: auto; }

.catalog-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(196, 144, 58, 0.20);
  background: rgba(252, 248, 240, 0.85);
}

.catalog-picker { flex: 2 1 200px; min-width: 160px; padding: 6px 10px; }
.catalog-inline-form input[type="text"],
.catalog-inline-form input[type="number"] {
  width: auto;
  flex: 1 1 90px;
  min-width: 70px;
  padding: 6px 10px;
}
.catalog-inline-form input[type="text"] { flex: 2 1 160px; }

.catalog-option-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  white-space: nowrap;
  color: var(--ink-soft);
}
.catalog-option-label input[type="checkbox"] { width: 15px; height: 15px; }
.catalog-form-actions { display: flex; gap: 6px; flex-shrink: 0; }

.catalog-compact-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.catalog-compact-table thead { background: rgba(20, 14, 6, 0.05); }
.catalog-compact-table th {
  padding: 7px 10px;
  text-align: left;
  font-size: 0.70rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.catalog-compact-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(20, 14, 6, 0.06);
  vertical-align: middle;
}
.catalog-compact-table tbody tr:last-child td { border-bottom: none; }
.catalog-compact-table tbody tr:hover { background: rgba(196, 144, 58, 0.05); }

.cat-num     { text-align: right; white-space: nowrap; }
.cat-actions { text-align: right; white-space: nowrap; }

/* ============================================================
   ATELIER — PRESTATIONS INTERNES
   ============================================================ */
.atelier-panel { border-left: 3px solid var(--gold); }

.atelier-presets { display: flex; flex-direction: column; gap: 6px; }

.atelier-group {}

.atelier-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: rgba(196, 144, 58, 0.08);
  border: 1px solid rgba(196, 144, 58, 0.20);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
  transition: background 0.15s;
}
.atelier-group-header:hover { background: rgba(196, 144, 58, 0.15); }
.atelier-group-header .atelier-chevron {
  font-size: 0.75rem;
  color: var(--gold);
  transition: transform 0.2s;
}
.atelier-group.is-open .atelier-chevron { transform: rotate(90deg); }

.atelier-group-body {
  display: none;
  padding: 6px 0 4px 0;
  border: 1px solid rgba(196, 144, 58, 0.12);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: rgba(252, 248, 240, 0.6);
}
.atelier-group.is-open .atelier-group-body { display: block; }

.atelier-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  font-size: 0.84rem;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid rgba(20, 14, 6, 0.05);
  transition: background 0.12s;
}
.atelier-item:last-of-type { border-bottom: none; }
.atelier-item:hover { background: rgba(196, 144, 58, 0.07); }
.atelier-item-add {
  font-size: 0.78rem;
  color: var(--gold);
  opacity: 0;
  transition: opacity 0.12s;
  white-space: nowrap;
}
.atelier-item:hover .atelier-item-add { opacity: 1; }
.atelier-item.is-selected {
  background: rgba(196, 144, 58, 0.12);
  font-weight: 600;
}
.atelier-item.is-selected .atelier-item-add { opacity: 1; color: var(--gold-deep); }

.atelier-custom-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 6px;
  border-top: 1px dashed rgba(196, 144, 58, 0.20);
  margin-top: 2px;
}
.atelier-custom-row input[type="text"] {
  flex: 1;
  padding: 5px 9px;
  font-size: 0.82rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.atelier-custom-row button {
  padding: 5px 11px;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.atelier-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(196, 144, 58, 0.20);
  background: rgba(252, 248, 240, 0.95);
}
.atelier-form input[type="text"],
.atelier-form input[type="number"] {
  flex: 1 1 80px;
  min-width: 65px;
  padding: 6px 10px;
  font-size: 0.83rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.atelier-form .af-desc { flex: 3 1 180px; min-width: 140px; }
.atelier-form .af-unit { flex: 1 1 70px; }
.atelier-form .af-qty  { flex: 1 1 60px; max-width: 90px; }
.atelier-form .af-price { flex: 1 1 80px; }
.atelier-form .af-discount { flex: 1 1 70px; }
.cat-actions button {
  padding: 4px 9px;
  font-size: 0.80rem;
  box-shadow: none;
  border-radius: 7px;
  margin-left: 4px;
}

.row-locked     { background: rgba(84, 96, 72, 0.04); }
.row-opti-child { background: rgba(20, 14, 6, 0.02); }
.row-opti-child td {
  padding: 3px 12px;
  border-bottom: 1px solid rgba(20, 14, 6, 0.05);
}
.opti-child-chip {
  padding: 3px 8px;
  font-size: 0.74rem;
  background: rgba(20, 14, 6, 0.06);
}
.opti-child-label {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.locked-field {
  display: inline-block;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: rgba(20, 14, 6, 0.05);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: inherit;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.cat-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  background: rgba(84, 96, 72, 0.16);
  color: var(--olive);
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   LISTES CATALOGUE & DOCUMENTS
   ============================================================ */
.catalog-list,
.slab-grid   { display: grid; gap: 10px; }
.document-list { overflow-x: auto; }

.catalog-entry,
.slab-card {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.60);
  transition: box-shadow 200ms ease, border-color 200ms ease;
}
.catalog-entry:hover,
.slab-card:hover {
  border-color: rgba(196, 144, 58, 0.22);
  box-shadow: var(--shadow-sm);
}
.catalog-entry strong,
.slab-card strong {
  display: block;
  margin-bottom: 6px;
  font-family: Georgia, serif;
  font-size: 1.02rem;
}

.doc-compact-table { width: 100%; min-width: 620px; }
.doc-number {
  font-family: Georgia, serif;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink);
}
.doc-muted { color: var(--ink-soft); font-size: 0.85rem; }
.doc-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.doc-action-link {
  color: var(--gold-deep);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  transition: color 140ms ease;
}
.doc-action-link:hover { color: var(--gold); }
.doc-actions .ghost-button { padding: 5px 12px; font-size: 0.80rem; }
.doc-load-more {
  display: block;
  width: 100%;
  margin-top: 10px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.catalog-meta,
.document-meta,
.slab-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}
.catalog-meta span,
.document-meta span,
.slab-meta span {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(196, 144, 58, 0.11);
  font-size: 0.80rem;
  color: var(--ink-soft);
}

.empty-state {
  padding: 24px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(20, 14, 6, 0.16);
  color: var(--ink-faint);
  text-align: center;
  font-size: 0.90rem;
}

.document-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
}
.document-links a {
  color: var(--gold-deep);
  text-decoration: none;
  font-weight: 600;
}
.document-links button { width: auto; }
.link-muted { color: var(--ink-soft); font-size: 0.90rem; }

/* ============================================================
   PANEL MESURES
   ============================================================ */
.measures-panel .panel-head {
  align-items: center;
}

.cuts-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--gold);
  color: #fff9f0;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  margin-left: 10px;
  line-height: 1;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cuts-count-badge:empty { display: none; }

.add-measure-btn {
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 9px 20px;
}

/* Colonnes */
.cuts-table .col-ref     { width: 100px; }
.cuts-table .col-dim     { width: 120px; }
.cuts-table .col-qty     { width: 72px;  }
.cuts-table .col-pattern { width: 150px; }
.cuts-table .col-group   { width: 130px; }
.cuts-table .col-actions { width: 110px; text-align: right; }

/* Inputs dans la table mesures */
.cuts-table .input-ref,
.cuts-table .input-dim,
.cuts-table .input-qty,
.cuts-table .input-group,
.cuts-table .input-select {
  padding: 7px 9px;
  font-size: 0.88rem;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.92);
}

.cuts-table .input-dim,
.cuts-table .input-qty {
  text-align: right;
  font-family: "Courier New", monospace;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.cuts-table .input-ref  { font-weight: 600; color: var(--gold-deep); }
.cuts-table .input-group { color: var(--ink-soft); }

/* Boutons d'action dans les lignes */
.row-actions { gap: 4px; flex-wrap: nowrap; align-items: center; }

.move-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.80rem;
  color: var(--ink-soft);
  background: rgba(255, 252, 246, 0.80);
  box-shadow: none;
  transition: background 140ms ease, color 140ms ease;
  line-height: 1;
}
.move-btn:hover:not(:disabled) {
  background: rgba(255, 252, 246, 1);
  color: var(--ink);
  transform: none;
  filter: none;
}
.move-btn:disabled {
  opacity: 0.28;
  cursor: default;
  pointer-events: none;
}

.remove-btn {
  padding: 5px 9px;
  font-size: 0.86rem;
  border-radius: 6px;
  box-shadow: none;
  line-height: 1;
}
.remove-btn:hover { box-shadow: none; }

/* ============================================================
   VISUALISEUR TRANCHES
   ============================================================ */
.slab-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.slab-svg {
  width: 100%;
  height: auto;
  margin-top: 12px;
  border-radius: var(--radius-sm);
  background: rgba(248, 244, 238, 0.90);
  border: 1px solid var(--line);
}
.slab-svg text { font-family: "Trebuchet MS", system-ui, sans-serif; }

.inline-help { font-size: 0.82rem; color: var(--ink-soft); }

/* ============================================================
   LOADING STATE — Spinner sur bouton
   ============================================================ */
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

button.is-loading {
  pointer-events: none;
  opacity: 0.72;
  position: relative;
  padding-right: 38px;
}
button.is-loading::after {
  content: '';
  position: absolute;
  right: 13px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid rgba(255, 249, 240, 0.30);
  border-top-color: rgba(255, 249, 240, 0.88);
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
  flex-shrink: 0;
}
button.ghost-button.is-loading::after {
  border-color: rgba(20, 14, 6, 0.18);
  border-top-color: var(--ink-mid);
}

/* ============================================================
   HAMBURGER — Navigation mobile
   ============================================================ */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-xs);
  box-shadow: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 140ms ease;
}
.nav-hamburger:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: none;
  filter: none;
  box-shadow: none;
}
.nav-hamburger.is-open {
  border-color: rgba(196, 144, 58, 0.45);
}
.nav-hamburger span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--topbar-text);
  transition: transform 220ms ease, opacity 200ms ease, width 200ms ease;
  transform-origin: center;
}
.nav-hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1020px) {
  .layout-opti,
  .catalog-layout     { grid-template-columns: 1fr; }
  .structure-summary  { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .layout-devis { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .shell { width: 96vw; }
  .topbar-logo { height: 34px; }
  .topbar-title h1 { font-size: 1.3rem; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .panel { padding: 14px; border-radius: 16px; }

  /* Touch targets */
  button, .button-link, .page-nav a {
    min-height: 44px;
  }
  input, select, textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS auto-zoom */
  }
  .move-btn, .remove-btn { min-height: 38px; }

  /* Hamburger visible, nav collapsed */
  .nav-hamburger { display: flex; }
  .topbar-wrapper { position: relative; }

  .page-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    flex-direction: column;
    gap: 5px;
    padding: 10px 14px 14px;
    background: var(--topbar-bg);
    border-top: 1px solid rgba(196, 144, 58, 0.28);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
  }
  .page-nav.nav-open {
    display: flex;
  }
  .page-nav a,
  .page-nav .user-badge {
    width: 100%;
    border-radius: var(--radius-sm);
    justify-content: flex-start;
    padding: 11px 16px;
  }
  .page-nav .user-badge {
    border-radius: var(--radius-sm);
  }
  .toolbar, .action-stack { flex-direction: column; }
  .row-actions { flex-wrap: wrap; }
}

@media (max-width: 520px) {
  button, .button-link { width: 100%; justify-content: center; }
  .hero-panel { grid-template-columns: 1fr; }
  .topbar-left { gap: 10px; }
  .topbar-logo { height: 28px; }

  /* Context row scrollable sur mobile */
  .context-row { gap: 6px 10px; }
  .context-field { flex-shrink: 0; }

  /* Panel head empilé */
  .panel-head { flex-direction: column; align-items: flex-start; }

  /* Smaller row action buttons */
  .row-actions button { font-size: 0.82rem; }
}

/* ============================================================
   AUTHENTICATION — Login / Setup pages
   ============================================================ */

.page-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(196, 144, 58, 0.11), transparent 45%),
    radial-gradient(ellipse at 80% 70%, rgba(84, 96, 72, 0.08), transparent 40%),
    linear-gradient(180deg, #f8f3e8 0%, var(--bg) 60%, #e8e0d4 100%);
  background-attachment: fixed;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.auth-logo {
  height: 110px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  align-self: center;
}

.auth-card h1 {
  text-align: center;
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}

.auth-card .eyebrow {
  text-align: center;
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
  margin: 0;
}

.auth-subtitle {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-mid);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.auth-form input {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.auth-submit {
  margin-top: 6px;
  width: 100%;
  padding: 11px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.auth-submit:hover {
  background: var(--gold-deep);
  box-shadow: 0 4px 16px rgba(196, 144, 58, 0.35);
}

.auth-error {
  background: rgba(143, 48, 32, 0.09);
  border: 1px solid rgba(143, 48, 32, 0.25);
  color: var(--red);
  border-radius: var(--radius-xs);
  padding: 9px 13px;
  font-size: 0.82rem;
  font-weight: 500;
}

/* ============================================================
   USER BADGE (topbar)
   ============================================================ */

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  color: var(--topbar-text);
  font-size: 0.8rem;
  text-decoration: none;
  transition: background 0.15s;
}

.user-badge:hover {
  background: rgba(255, 255, 255, 0.14);
}

.user-badge-name {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.temp-pwd-display {
  background: var(--bg-deep);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.8;
}

.temp-pwd-display code {
  font-family: monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-deep);
  background: rgba(196, 144, 58, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  user-select: all;
}

/* ============================================================
   ROLE BADGES
   ============================================================ */

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.6;
}

.role-badge.role-admin {
  background: rgba(196, 144, 58, 0.15);
  color: var(--gold-deep);
  border: 1px solid rgba(196, 144, 58, 0.35);
}

.role-badge.role-sous-admin {
  background: rgba(84, 96, 72, 0.13);
  color: var(--olive);
  border: 1px solid rgba(84, 96, 72, 0.28);
}

.role-badge.role-cuisiniste {
  background: rgba(158, 142, 120, 0.13);
  color: var(--stone);
  border: 1px solid rgba(158, 142, 120, 0.28);
}

/* ============================================================
   DOCUMENT STATUS BADGES
   ============================================================ */

.doc-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.6;
  white-space: nowrap;
}

.doc-status-badge.status-generated {
  background: rgba(62, 90, 52, 0.10);
  color: var(--green);
  border: 1px solid rgba(62, 90, 52, 0.25);
}

.doc-status-badge.status-pending {
  background: rgba(196, 144, 58, 0.12);
  color: var(--gold-deep);
  border: 1px solid rgba(196, 144, 58, 0.30);
}

.doc-status-badge.status-validated {
  background: rgba(62, 90, 52, 0.18);
  color: var(--green);
  border: 1px solid rgba(62, 90, 52, 0.35);
}

/* ============================================================
   CREATOR BADGE (documents récents)
   ============================================================ */

.creator-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* ============================================================
   PENDING VALIDATION PANEL
   ============================================================ */

.pending-panel {
  border: 1.5px solid rgba(196, 144, 58, 0.30);
  background: linear-gradient(135deg, rgba(196, 144, 58, 0.04) 0%, transparent 60%);
}

.pending-panel .panel-title {
  color: var(--gold-deep);
}

.pending-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--gold);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  margin-left: 6px;
}

/* ============================================================
   USER MANAGEMENT PAGE
   ============================================================ */

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.users-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-strong);
}

.users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.users-table tr:last-child td {
  border-bottom: none;
}

.users-table tr:hover td {
  background: var(--bg-deep);
}

/* ============================================================
   SUBMISSION MODAL (dialog natif)
   ============================================================ */

.submit-modal {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: var(--surface-strong);
  padding: 0;
  max-width: 520px;
  width: calc(100% - 32px);
}

.submit-modal::backdrop {
  background: rgba(16, 10, 2, 0.45);
  backdrop-filter: blur(2px);
}

.submit-modal-content {
  padding: 32px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.submit-modal-content h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.submit-modal-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.submit-modal-content label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-mid);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.submit-modal-content textarea,
.submit-modal-content select,
.submit-modal-content input[type="file"] {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

.submit-modal-content textarea:focus,
.submit-modal-content select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.submit-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ============================================================
   SUBMISSION INFO (panneau admin lors de l'inspection)
   ============================================================ */

.submission-info {
  background: rgba(196, 144, 58, 0.06);
  border: 1px solid rgba(196, 144, 58, 0.20);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.submission-info > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.submission-info strong {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.submission-message-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink);
  white-space: pre-wrap;
  line-height: 1.55;
}

.attachment-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attachment-list li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.attachment-link {
  font-size: 0.88rem;
  color: var(--gold-deep);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.attachment-link:hover {
  color: var(--gold);
}

/* ============================================================
   AUTH — Responsive
   ============================================================ */

@media (max-width: 480px) {
  .auth-card {
    padding: 28px 20px 24px;
  }
  .submit-modal-content {
    padding: 24px 16px 20px;
  }
  .submit-modal-actions {
    flex-direction: column;
  }
}
