:root {
  --ink: #172033;
  --muted: #687386;
  --line: #dfe4ea;
  --soft: #f4f6f8;
  --paper: #ffffff;
  --brand: #1d244b;
  --accent: #fad21b;
  --green: #147d64;
  --red: #b4233a;
  --blue: #2563a9;
  --shadow: 0 10px 30px rgba(23, 32, 51, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef2f5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: var(--accent);
  font-weight: 900;
}

.brand-title {
  margin: 0;
  color: var(--brand);
  font-size: 1.32rem;
  line-height: 1.1;
}

.brand-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: .92rem;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #3d4757;
  font-size: .87rem;
  font-weight: 700;
}

.field-label {
  margin-bottom: 8px;
  color: #3d4757;
  font-size: .87rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 169, .12);
}

.stack {
  display: grid;
  gap: 14px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  background: var(--brand);
  color: #fff;
}

.topbar-inner {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 24px;
}

.topbar .brand-lockup {
  margin: 0;
}

.topbar .brand-mark {
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: var(--brand);
}

.topbar .brand-title {
  color: #fff;
  font-size: 1.05rem;
}

.topbar .brand-subtitle {
  color: rgba(255, 255, 255, .68);
}

.nav {
  display: flex;
  align-items: stretch;
  gap: 4px;
  align-self: stretch;
}

.nav-item,
.nav-trigger {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 14px;
  color: rgba(255, 255, 255, .84);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.nav-item:hover,
.nav-trigger:hover,
.nav-item.active,
.nav-trigger.active {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.nav-group {
  position: relative;
}

.nav-menu {
  position: absolute;
  top: 100%;
  left: 0;
  display: none;
  min-width: 260px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.nav-group:hover .nav-menu,
.nav-group:focus-within .nav-menu {
  display: grid;
}

.nav-menu a {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}

.nav-menu a:hover {
  background: var(--soft);
}

.nav-menu small {
  color: var(--muted);
}

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, .72);
  font-size: .9rem;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 44px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dashboard-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 24px;
  border: 1px solid rgba(29, 36, 75, .18);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
}

.dashboard-hero .eyebrow {
  color: var(--accent);
}

.dashboard-hero h1 {
  color: #fff;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.dashboard-hero p {
  max-width: 680px;
  margin: 8px 0 0;
  color: rgba(255, 255, 255, .72);
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.button.hero-button {
  border-color: rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.button.hero-button:hover {
  background: rgba(255, 255, 255, .16);
}

.button.hero-button.accent {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--brand);
}

.eyebrow {
  color: var(--blue);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  color: var(--brand);
  font-size: clamp(1.55rem, 2.6vw, 2.2rem);
}

h2 {
  color: var(--brand);
  font-size: 1.1rem;
}

.muted {
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.toolbar input,
.toolbar select {
  min-height: 40px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 11px;
  outline: none;
}

.toolbar.compact {
  flex-wrap: nowrap;
  gap: 6px;
}

.toolbar.compact .button {
  min-height: 34px;
  padding: 6px 9px;
  font-size: .82rem;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.button:hover {
  background: var(--soft);
}

.button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.button.primary:hover {
  background: #111735;
}

.button.danger {
  border-color: rgba(180, 35, 58, .22);
  color: var(--red);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-metrics {
  margin-bottom: 16px;
}

.metric,
.panel,
.module-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.metric-value {
  margin-top: 6px;
  color: var(--brand);
  font-size: 1.65rem;
  font-weight: 850;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  margin-top: 16px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.category-stack {
  display: grid;
  gap: 18px;
}

.category-block {
  display: grid;
  gap: 10px;
}

.category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--brand);
  font-size: .82rem;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.category-head small {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
}

.module-tile {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  padding: 14px;
  color: inherit;
  text-decoration: none;
}

.module-tile:hover {
  border-color: #bcc7d4;
}

.dashboard-tile {
  position: relative;
  min-height: 96px;
  grid-template-columns: 54px minmax(0, 1fr) 28px;
  align-items: center;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.dashboard-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(23, 32, 51, .12);
}

.dashboard-tile h3 {
  font-size: 1.08rem;
}

.tile-arrow {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand);
  font-weight: 900;
}

.module-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.module-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.module-initials {
  background: var(--brand);
  color: var(--accent);
  font-weight: 900;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

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

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.module-tab {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.module-tab:hover {
  background: var(--soft);
}

.module-tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.switches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.months-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.admin-apps-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.choice input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 800;
}

.status-pill.ok {
  background: #e7f5ef;
  color: var(--green);
}

.status-pill.warn {
  background: #fff7d6;
  color: #7a5b00;
}

.status-pill.info {
  background: #e8f1fb;
  color: var(--blue);
}

.status-pill.off {
  background: #eef2f5;
  color: var(--muted);
}

.key-values {
  display: grid;
  gap: 10px;
}

.key-values div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.key-values div:last-child {
  border-bottom: 0;
}

.key-values strong {
  color: #3d4757;
}

.key-values span {
  color: var(--brand);
  font-weight: 800;
  text-align: right;
}

.link-box {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
}

.link-box code {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  overflow-wrap: anywhere;
}

.dashboard-side {
  display: grid;
  align-content: start;
  gap: 14px;
}

.side-stat {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
}

.side-stat span {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 750;
}

.side-stat strong {
  color: var(--brand);
  font-size: 1.55rem;
  line-height: 1.1;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-item div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.activity-item span {
  color: var(--muted);
  font-size: .86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item em {
  color: var(--brand);
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}

.dashboard-empty {
  display: grid;
  gap: 10px;
  padding: 22px;
  border: 1px dashed #cfd7e0;
  border-radius: 8px;
  background: #f7f9fb;
  text-align: left;
}

.dashboard-empty strong {
  color: var(--brand);
}

.dashboard-empty span {
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f7f9fb;
  color: #4b5565;
  font-size: .78rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}

td.wrap {
  min-width: 220px;
  white-space: normal;
}

.notice {
  display: none;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff7d6;
  color: #6d5200;
}

.notice.show {
  display: block;
}

.notice.error {
  background: #fde8ec;
  color: var(--red);
}

.notice.success {
  background: #e7f5ef;
  color: var(--green);
}

.empty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .topbar-inner,
  .page-head,
  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
    min-height: 46px;
  }

  .metrics,
  .layout,
  .dashboard-layout,
  .module-grid,
  .form-grid,
  .months-grid {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .hero-actions .button {
    flex: 1;
  }

  .form-grid .wide {
    grid-column: auto;
  }
}

/* Nimbus : modale d'edition, carnet d'adresses, bareme */
.modal {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(23, 32, 51, .45);
}

.row-actions,
.position-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.position-controls input {
  width: 58px;
  text-align: center;
}

.button.icon-button {
  min-width: 36px;
  padding-left: 0;
  padding-right: 0;
}

.button:disabled {
  opacity: .4;
  cursor: default;
}

.layout.single {
  grid-template-columns: 1fr;
}

.history-filters {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.history-filters #searchTrips {
  flex: 1;
  min-width: 200px;
}

tr.totals-row td {
  border-top: 2px solid var(--line);
  background: var(--soft);
}

.recap {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.recap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.recap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.recap-title {
  margin-bottom: 8px;
  color: var(--brand);
  font-weight: 800;
}

.recap-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.recap-values .metric {
  box-shadow: none;
  background: var(--soft);
}

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

/* Chiffrage */
textarea {
  width: 100%;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: var(--soft);
}

.leasing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

tr.row-selected td {
  background: rgba(250, 210, 27, .18);
  font-weight: 700;
}

.chiffrage-editor > .panel,
.chiffrage-editor > .notice,
.chiffrage-editor #chiffrageSections > .panel {
  margin-top: 16px;
}

.version-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.version-bar .notice {
  grid-column: 1 / -1;
}

.section-title {
  min-width: 260px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--brand);
  font-size: 1.1rem;
  font-weight: 800;
  background: transparent;
}

.section-title:hover:not(:disabled),
.section-title:focus {
  border-color: #cfd7e0;
  background: #fff;
  outline: none;
}

.chiffrage-table td {
  padding: 6px;
  vertical-align: middle;
}

.chiffrage-table input,
.chiffrage-table select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  padding: 5px 7px;
}

.chiffrage-table input:disabled,
.chiffrage-table select:disabled,
.chiffrage-table textarea:disabled,
.version-bar input:disabled {
  background: var(--soft);
  color: var(--ink);
}

.chiffrage-table .col-designation { min-width: 230px; }
.chiffrage-table .col-num { width: 80px; }
.chiffrage-table .col-unit { width: 90px; }
.chiffrage-table .col-money { width: 110px; }

.chiffrage-table td.computed {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chiffrage-table td.computed.negative {
  color: var(--red);
  font-weight: 700;
}

.chiffrage-table tr.line-main td {
  border-bottom: 0;
}

.chiffrage-table tr.line-detail td {
  padding-top: 0;
}

.chiffrage-table tr.line-detail input {
  width: calc(100% - 60px);
}

.section-actions,
.add-section {
  margin-top: 12px;
}

.add-section input {
  flex: 1;
  max-width: 360px;
}

.chiffrage-editor .layout {
  margin-top: 16px;
}

.recap-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.recap-line.strong strong {
  color: var(--brand);
  font-size: 1.1rem;
}

.dirty-flag {
  color: var(--red);
  font-size: .85rem;
  font-weight: 700;
}

@media (max-width: 860px) {
  .leasing-grid,
  .version-bar {
    grid-template-columns: 1fr;
  }
}

.layout > *,
.dashboard-layout > * {
  min-width: 0;
}

.chiffrage-table [data-k="fournisseur"] { min-width: 120px; }
.chiffrage-table [data-k="quantite"] { min-width: 72px; }
.chiffrage-table [data-k="unite"] { min-width: 84px; }
.chiffrage-table [data-k="coutAchat"],
.chiffrage-table [data-k="prixVente"] { min-width: 100px; }
.chiffrage-table select[data-k="tva"] { min-width: 86px; }

.chiffrage-create {
  flex-wrap: wrap;
}

.chiffrage-create input {
  flex: 1;
  min-width: 200px;
}

.line-detail-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.line-detail-tools select {
  width: auto;
  min-width: 150px;
}

.chiffrage-table tr.line-detail .line-detail-tools input {
  flex: 1;
  width: auto;
}

.chiffrage-table select[data-k="unite"] { min-width: 96px; }

.button.accent {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--brand);
}

.chiffrage-table [data-k="reference"] { min-width: 96px; }

.export-table td {
  vertical-align: middle;
}

.export-actions {
  margin-top: 14px;
  justify-content: flex-end;
}

/* Lignes de chiffrage en cartes : partie devis, description, puis partie chiffrage. */
.ch-lines {
  display: grid;
  gap: 10px;
}

.ch-line {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.ch-row.ch-cost {
  padding: 8px;
  border-radius: 6px;
  background: var(--soft);
}

.ch-tag {
  align-self: center;
  min-width: 74px;
  color: var(--brand);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ch-tag.internal {
  color: var(--muted);
}

.ch-field {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.ch-field label,
.ch-field .ch-label {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}

.ch-field input,
.ch-field select,
.ch-field textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 6px 8px;
}

.ch-field input:disabled,
.ch-field select:disabled,
.ch-field textarea:disabled {
  background: var(--soft);
}

.ch-ref { flex: 0 1 120px; }
.ch-designation { flex: 1 1 240px; }
.ch-qty { flex: 0 0 76px; }
.ch-unit { flex: 0 0 110px; }
.ch-money { flex: 0 0 110px; }
.ch-tva { flex: 0 0 86px; }
.ch-type { flex: 0 0 132px; }
.ch-supplier { flex: 0 1 180px; }
.ch-link { flex: 1 1 220px; }

.ch-description {
  padding-left: 82px;
}

.ch-link-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ch-computed {
  flex: 0 0 auto;
  min-width: 104px;
  text-align: right;
}

.ch-value {
  display: block;
  padding: 8px 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.ch-value.negative {
  color: var(--red);
}

.ch-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.ch-subtotal {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--soft);
}

.ch-subtotal > strong {
  margin-right: auto;
}

.ch-subtotal span {
  color: var(--muted);
}

.ch-subtotal span strong {
  margin-left: 6px;
  color: var(--brand);
}

@media (max-width: 760px) {
  .ch-description {
    padding-left: 0;
  }

  .ch-tag {
    flex-basis: 100%;
  }
}

.ch-supplier { flex: 0 1 150px; }
.ch-link { flex: 1 1 120px; }
.ch-cost .ch-actions .button { min-height: 34px; padding-top: 6px; padding-bottom: 6px; }

/* Chiffrage multi-articles : une rangee par article achete, puis le pied de ligne. */
.ch-costs {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 6px;
  background: var(--soft);
}

.ch-costs .ch-row.ch-cost {
  padding: 0;
  background: transparent;
}

.ch-article { flex: 1 1 180px; }
.ch-cost .ch-supplier { flex: 0 1 150px; }
.ch-cost .ch-link { flex: 1 1 140px; }

.ch-cost .cost-delete {
  min-height: 36px;
}

.ch-cost-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed #cfd7e0;
}

.ch-cost-footer .cost-add {
  margin-left: 82px;
  min-height: 34px;
  padding: 6px 12px;
}

.ch-cost-footer .ch-actions .button {
  min-height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
}

@media (max-width: 760px) {
  .ch-cost-footer .cost-add {
    margin-left: 0;
  }
}

/* Le style .button (display: inline-flex) ne doit pas annuler l attribut hidden. */
[hidden] {
  display: none !important;
}

/* Pied de ligne : revient, marge et taux bien separes. */
.ch-cost-footer {
  align-items: center;
}

.ch-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ch-stats .ch-computed {
  min-width: 112px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  text-align: left;
}

.ch-stats .ch-value {
  padding: 1px 0 0;
  white-space: nowrap;
}

/* En-tete figee, filtres et recapitulatif */
.chiffrage-header {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.chiffrage-header input:disabled,
.chiffrage-header select:disabled,
.chiffrage-header textarea:disabled {
  background: var(--soft);
  color: var(--ink);
}

.status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

#leasingPanel {
  margin-top: 12px;
}

#leasingPanel .toolbar {
  margin-bottom: 12px;
}

.recap-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.recap-strip .recap-line {
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.recap-strip .recap-line span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.version-bar {
  grid-template-columns: minmax(220px, 1fr) auto;
}

/* En-tete du devis : client + titre sur une ligne, puis la version. */
.chiffrage-head-main {
  flex: 1;
  width: 100%;
  min-width: 0;
}

.chiffrage-head > .toolbar {
  flex: 0 1 auto;
  justify-content: flex-end;
}

.chiffrage-title {
  overflow: hidden;
  white-space: nowrap;
}

.chiffrage-title.wrapped {
  white-space: normal;
}

.chiffrage-title-object {
  font-weight: 500;
}

.version-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.version-line label {
  color: #3d4757;
  font-size: .87rem;
  font-weight: 700;
}

.version-line select {
  max-width: 100%;
  min-height: 36px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 6px 10px;
  font-weight: 700;
}

.chiffrage-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.export-option {
  margin-top: 12px;
}

.export-variant {
  margin: 8px 0 0;
}

/* Les boutons passent sous le titre quand la largeur manque. */
.chiffrage-head {
  flex-wrap: wrap;
}

.chiffrage-head-main {
  flex: 1 1 400px;
  width: auto;
}

.signature-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.signature-panel p {
  margin: 0;
}

.signature-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.signature-history {
  flex: 1 1 100%;
}

.signature-history summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 700;
}

.signature-history .table-wrap {
  margin-top: 10px;
}

.signature-history p {
  margin-top: 8px;
}

/* Indicateur d'enregistrement automatique */
.save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
}

.save-status[data-status="saving"]::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: save-spin .7s linear infinite;
}

.save-status[data-status="saved"] {
  color: var(--green);
}

.save-status[data-status="saved"]::before {
  content: "✓";
}

.save-status[data-status="error"] {
  color: var(--red);
}

@keyframes save-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .save-status[data-status="saving"]::before {
    animation-duration: 2s;
  }
}

.attachments-panel #pennylaneDate {
  min-height: 36px;
  border: 1px solid #cfd7e0;
  border-radius: 6px;
  padding: 4px 8px;
}

.signature-variants {
  display: grid;
  gap: 6px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.version-bar {
  grid-template-columns: minmax(220px, 1fr) 160px 160px auto;
}

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

.signature-variants-summary {
  flex: 1 1 100%;
}

.signature-variants-summary p {
  margin: 0 0 8px;
}

.signature-variant-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.signature-variant-row .choice[hidden] {
  display: none;
}

.annex-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.annex-name {
  flex: 1 1 220px;
  overflow-wrap: anywhere;
}

.modal-preview {
  width: min(1000px, calc(100vw - 32px));
  height: calc(100vh - 48px);
  max-height: none;
}

.modal-preview[open] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-preview p {
  margin: 0;
}

#previewFrame {
  flex: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.signature-variant-row .choice {
  min-height: 0;
  border: 0;
  padding: 0;
  background: none;
}

.modal-preview .panel-head {
  margin: 0;
}

.client-masque-bar {
  align-items: center;
}

.login-microsoft {
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.login-separator {
  text-align: center;
}
