
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #202631;
  --muted: #89919e;
  --border: #e8ebef;
  --primary: #426b59;
  --primary-light: #e9f1ec;
  --orange: #d99a5b;
  --red: #c66c66;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 42px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-family: Manrope, sans-serif;
  font-size: 23px;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 12px;
  letter-spacing: 1.2px;
}

.brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.menu-label {
  margin: 0 0 12px 10px;
  color: #a0a7b1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

nav {
  display: grid;
  gap: 6px;
  margin-bottom: 32px;
}

.nav-link {
  border: 0;
  background: transparent;
  color: #6e7784;
  text-align: left;
  padding: 12px;
  border-radius: 9px;
  font-size: 13px;
}

.nav-link:hover {
  background: #f5f7f6;
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 700;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid var(--border);
  color: #727b87;
  font-size: 11px;
}

.sidebar-bottom small {
  display: block;
  margin-top: 8px;
  color: #a0a7b1;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  background: #5ba47a;
  border-radius: 50%;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 34px 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: #9ba2ac;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

h1 {
  margin: 0;
  font-family: Manrope, sans-serif;
  font-size: 28px;
  letter-spacing: -0.8px;
}

h2 {
  margin: 0;
  font-family: Manrope, sans-serif;
  font-size: 17px;
}

h3 {
  margin: 0;
  font-size: 14px;
}

.primary-btn {
  border: 0;
  border-radius: 9px;
  padding: 12px 17px;
  color: #fff;
  background: var(--primary);
  font-weight: 600;
}

.primary-btn:hover {
  background: #345644;
}

.secondary-btn {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 14px;
  background: #fff;
  color: var(--text);
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}

.card-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.stat-label {
  color: #7f8895;
  font-size: 12px;
}

.stat-value {
  margin-top: 12px;
  font-family: Manrope, sans-serif;
  font-size: 27px;
  font-weight: 800;
}

.stat-note {
  margin-top: 8px;
  color: #8d96a2;
  font-size: 11px;
}

.project-list {
  display: grid;
  gap: 12px;
}

.project-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.project-row:last-child {
  border-bottom: 0;
}

.project-name {
  font-weight: 700;
}

.project-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.project-price {
  font-weight: 700;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 20px;
  background: #f2f4f6;
  color: #737d89;
  font-size: 10px;
  font-weight: 700;
}

.tag.green {
  background: #eaf3ed;
  color: #4c8061;
}

.tag.orange {
  background: #fbf0e5;
  color: #b77a3f;
}

.tag.red {
  background: #f9eaea;
  color: #b96560;
}

.chart {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  height: 180px;
  padding-top: 15px;
}

.chart-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: end;
  gap: 9px;
  height: 100%;
}

.chart-bar {
  width: 100%;
  max-width: 34px;
  min-height: 5px;
  border-radius: 6px 6px 2px 2px;
  background: #dce8df;
}

.chart-bar.current {
  background: var(--primary);
}

.chart-label {
  color: #929aa5;
  font-size: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #747e8a;
  font-size: 12px;
  font-weight: 600;
}

.field input, .field select {
  width: 100%;
  border: 1px solid #e2e6eb;
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
  background: #fff;
}

.field input:focus, .field select:focus {
  border-color: #7c9b89;
  box-shadow: 0 0 0 3px #e9f1ec;
}

.full {
  grid-column: 1 / -1;
}

.line-items {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.line-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 110px 35px;
  gap: 10px;
  align-items: center;
}

.quote-workspace {
  display: grid;
  grid-template-columns: minmax(400px, 0.95fr) minmax(470px, 1.05fr);
  align-items: start;
  gap: 20px;
}

.quote-editor {
  min-width: 0;
}

.quote-editor-heading,
.quote-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.quote-editor-heading {
  margin-bottom: 22px;
}

.quote-editor-heading .eyebrow {
  margin-bottom: 4px;
}

.quote-number-badge {
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.quote-editor-section {
  padding: 18px 0;
  border-top: 1px solid var(--border);
}

.quote-editor-section > h3,
.quote-section-heading h3 {
  margin-bottom: 14px;
}

.quote-section-heading h3 {
  margin-bottom: 0;
}

.quote-line-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.quote-column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.quote-column-toggle input {
  margin: 0;
  accent-color: var(--primary);
}

.quote-editor .field textarea,
.quote-editor .field > input,
.quote-editor .field > select {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.quote-editor .field textarea {
  resize: vertical;
}

.quote-editor .quote-same-address {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.quote-editor .quote-same-address input {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

.quote-editor .field textarea:disabled {
  background: #f1f3f2;
  color: #7b827e;
  border-color: #e1e5e2;
  cursor: not-allowed;
  opacity: 1;
}

body.dark-mode .quote-editor .field textarea:disabled {
  background: #2b2e35;
  color: #aeb4bd;
  border-color: #3d424c;
}

.quote-travel-calculator .quote-travel-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.quote-travel-calculator details > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.quote-travel-calculator details > summary::-webkit-details-marker {
  display: none;
}

.quote-travel-calculator details > summary::before {
  content: "＋";
  display: inline-block;
  width: 14px;
  color: var(--muted);
  font-size: 13px;
}

.quote-travel-calculator details[open] > summary::before {
  content: "−";
}

.quote-travel-content {
  padding-top: 12px;
}

.quote-travel-calculator .quote-travel-total {
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.45;
}

.quote-travel-calculator button:disabled {
  cursor: default;
  opacity: 0.65;
}

.quote-line-labels,
.line-item {
  display: grid;
  grid-template-columns: 24px minmax(110px, 1.6fr) 52px 58px 76px 86px 32px;
  gap: 6px;
  align-items: center;
}

.quote-line-labels {
  margin-top: 16px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.line-item {
  grid-template-columns: 24px minmax(110px, 1.6fr) 52px 58px 76px 86px 32px;
  gap: 6px;
}

.quote-line-drag-handle {
  display: grid;
  place-items: center;
  width: 24px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  cursor: grab;
  touch-action: none;
}

.quote-line-drag-handle:active {
  cursor: grabbing;
}

.quote-line-drag-handle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.quote-line-dragging {
  opacity: 0.45;
}

.quote-line-drop-before {
  border-top: 2px solid var(--primary);
}

.quote-line-drop-after {
  border-bottom: 2px solid var(--primary);
}

.quote-line-item-group {
  display: grid;
  gap: 5px;
}

.quote-line-description {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  resize: vertical;
}

.line-item input, .line-item select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.line-item input {
  padding: 8px 5px;
  text-align: right;
}

.quote-line-unit {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
}

.quote-line-total {
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.quote-actions {
  display: grid;
  gap: 9px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.quote-docusign-hint {
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.quote-preview-dialog {
  width: min(1000px, calc(100vw - 32px));
  max-width: none;
  max-height: 94vh;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: #eef0ed;
  box-shadow: 0 18px 60px rgba(20, 28, 24, 0.28);
}

.quote-preview-dialog::backdrop {
  background: rgba(25, 32, 29, 0.62);
}

.quote-preview-dialog-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(32, 38, 49, 0.1);
}

.quote-preview-dialog-toolbar > span {
  color: #202631;
  font-size: 14px;
  font-weight: 700;
}

.quote-preview-dialog-toolbar > div {
  display: flex;
  gap: 8px;
}

.quote-preview-dialog-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  max-height: calc(94vh - 57px);
  overflow: auto;
  padding: 18px;
}

.quote-preview-dialog-sheet {
  display: flex;
  flex: 0 0 auto;
  width: min(210mm, 100%);
  aspect-ratio: 210 / 297;
  box-sizing: border-box;
  padding: 4.713%;
  background: #fff;
  box-shadow: 0 2px 16px rgba(32, 38, 49, 0.16);
}

.quote-preview-dialog-page .quote-preview-card {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 182 / 269;
  box-sizing: border-box;
  padding: 0 0 1.75%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.quote-preview-dialog-page > .quote-preview-dialog-sheet > .quote-preview-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
}

.quote-preview-dialog-page .quote-bottom-block {
  margin-top: auto;
}

.quote-preview-dialog-page .quote-preview-table,
.quote-preview-inline-pages .quote-preview-table {
  flex: 0 0 auto;
}

.quote-preview-dialog-page .quote-totals,
.quote-preview-dialog-page .quote-bottom-block,
.quote-preview-inline-pages .quote-totals,
.quote-preview-inline-pages .quote-bottom-block {
  flex-shrink: 0;
}

.quote-preview-dialog-page .quote-page-number {
  position: absolute;
  right: 0;
  bottom: 0;
  margin: 0;
}

.quote-preview-column {
  min-width: 0;
}

.quote-preview-source {
  display: none;
}

.quote-preview-inline-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.quote-preview-inline-pages .quote-preview-dialog-sheet {
  width: min(210mm, 100%);
  max-width: 100%;
}

.quote-preview-inline-pages .quote-preview-card {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 182 / 269;
  box-sizing: border-box;
  padding: 0 0 1.75%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.quote-preview-inline-pages .quote-bottom-block {
  margin-top: auto;
}

.quote-preview-inline-pages .quote-page-number {
  position: absolute;
  right: 0;
  bottom: 0;
  margin: 0;
}

.quote-preview-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 10px;
  color: var(--muted);
  font-size: 12px;
}

.quote-preview-toolbar span:first-child {
  color: var(--text);
  font-weight: 700;
}

.quote-preview-card {
  width: 100%;
  min-height: 0;
  aspect-ratio: 210 / 297;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 14mm;
  border: 1px solid #e2e7e3;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(32, 38, 49, 0.08);
  color: #202631;
  font-size: 11px;
}

.quote-page-number {
  align-self: flex-end;
  margin-top: 5px;
  color: #515c65;
  font-size: 8px;
}

.quote-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 5px;
  border-bottom: 2px solid #426b59;
}

.quote-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quote-brand-logo {
  display: block;
  width: 112px;
  height: 72px;
  object-fit: contain;
  object-position: left center;
}

.quote-preview-title {
  display: grid;
  gap: 3px;
}

.quote-preview-title {
  justify-items: end;
  color: #426b59;
  font-weight: 700;
  letter-spacing: 1px;
}

.quote-preview-title span {
  font-size: 19px;
}

.quote-preview-title strong {
  font-size: 11px;
  letter-spacing: 0;
}

.quote-preview-dates {
  display: grid;
  gap: 2px;
  margin-top: 3px;
  color: #78838b;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-align: right;
}

.quote-preview-title .quote-preview-dates > span {
  font-size: 11px;
}

.quote-preview-dates strong {
  color: #202631;
  font-size: inherit;
  font-weight: 600;
}

.quote-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  padding: 12px 0 11px;
}

.quote-parties section {
  display: grid;
  align-content: start;
  gap: 4px;
}

.quote-parties .quote-issuer-id {
  font-size: 9px;
  line-height: 1.25;
}

.quote-parties strong {
  font-size: 12px;
}

.quote-label {
  margin-bottom: 4px;
  color: #7d8790;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.quote-client-preview span:not(.quote-label):empty {
  display: none;
}

.quote-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 2px 0 18px;
  padding: 12px;
  border-radius: 7px;
  background: #f5f7f6;
}

.quote-meta div {
  display: grid;
  gap: 4px;
}

.quote-meta div span {
  color: #78838b;
  font-size: 9px;
}

.quote-meta div strong {
  font-size: 10px;
}

.quote-preview-description {
  margin: 0 0 7px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.quote-validity-note {
  margin: -10px 0 16px;
  color: #59645f;
  font-size: 9px;
}

.quote-client-preview #preview-client-address {
  white-space: pre-line;
}

.quote-preview-table {
  width: 100%;
  aspect-ratio: auto;
  border-collapse: collapse;
  table-layout: auto;
}

.quote-preview-table th:first-child,
.quote-preview-table td:first-child {
  text-align: left;
}

.quote-preview-table th {
  padding: 9px 7px;
  background: #f3f7f4;
  color: #42634f;
  font-size: 9px;
  text-align: left;
  white-space: normal;
}

.quote-preview-table td {
  padding: 10px 7px;
  border-bottom: 1px solid #e8ebef;
  font-size: 10px;
  overflow-wrap: anywhere;
}

.quote-preview-table td:first-child p {
  margin: 4px 0 0;
  color: #647078;
  font-size: 9px;
  white-space: pre-wrap;
}

.quote-preview-table th:nth-child(n+2),
.quote-preview-table td:nth-child(n+2) {
  text-align: right;
}

.quote-preview-table .quote-money {
  white-space: nowrap;
  overflow-wrap: normal;
}

.quote-hide-quantity-unit .quote-quantity-column,
.quote-hide-quantity-unit .quote-unit-column {
  display: none;
}

.quote-preview-no-lines {
  color: #89919e;
  text-align: center !important;
}

.quote-totals {
  display: grid;
  gap: 9px;
  max-width: 290px;
  margin: 16px 0 0 auto;
}

.quote-totals > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.quote-totals > div[hidden] {
  display: none;
}

.quote-totals strong {
  text-align: right;
}

.quote-vat-note {
  color: #59645f;
  font-size: 9px;
}

.quote-vat-note strong {
  max-width: 190px;
}

.quote-grand-total {
  margin-top: 3px;
  padding: 11px;
  border-radius: 7px;
  background: #e9f1ec;
  color: #315440;
  font-size: 12px;
}

.quote-deposit-row {
  font-size: 10px;
}

.quote-discount-row {
  color: #53665b;
  font-size: 10px;
}

.quote-terms-signature {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 16px;
  margin-top: 16px;
}

.quote-bottom-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.quote-terms {
  display: grid;
  align-content: start;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid #e8ebef;
}

.quote-terms p {
  margin: 0;
  color: #515c65;
  font-size: 9px;
  white-space: pre-wrap;
}

.quote-signature {
  display: flex;
  min-width: 0;
}

.quote-signature-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
  width: 100%;
  padding: 8px;
  border: 1px solid #e2e7e3;
  border-radius: 5px;
  color: #68737b;
  font-size: 9px;
}

.quote-signature-box strong {
  color: #202631;
  font-size: 10px;
}

.quote-signature-box span {
  margin-top: auto;
}

.quote-retention-clause {
  display: grid;
  gap: 3px;
  margin-top: 0;
  padding-top: 8px;
  border-top: 1px solid #e8ebef;
  color: #515c65;
  font-size: 7px;
  line-height: 1.35;
}

.quote-retention-clause > * {
  margin: 0;
  line-height: 1.35;
}

.quote-retention-clause strong {
  color: #202631;
  font-size: 7px;
}

.remove-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  color: #b76a65;
  background: #f9eeee;
}

.total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  border-radius: 12px;
  background: #f1f5f2;
  color: var(--primary);
  font-weight: 700;
}

.total-box strong {
  font-size: 24px;
  font-family: Manrope, sans-serif;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.services-table {
  min-width: 720px;
}

.services-category-row th {
  padding: 14px 12px 8px;
  background: #f3f7f4;
  color: #42634f;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}

.services-description-cell {
  min-width: 320px;
  max-width: 560px;
  vertical-align: top;
}

.services-description-cell p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.service-edit-trigger {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.service-edit-trigger:hover {
  text-decoration: underline;
}

.service-edit-trigger:focus-visible {
  border-radius: 3px;
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.services-edit-input {
  width: 100%;
  min-width: 85px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.service-save-status {
  display: block;
  margin-top: 4px;
  color: var(--primary);
  font-size: 10px;
}

.service-save-status[hidden] {
  display: none;
}

.service-modal {
  width: min(620px, calc(100% - 32px));
  max-width: 620px;
  max-height: min(90vh, 760px);
  padding: 26px;
  overflow: auto;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.22);
}

.service-modal::backdrop {
  background: rgba(25, 34, 29, 0.48);
}

.service-modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.service-modal-heading h2 {
  font-size: 20px;
}

.service-modal-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: #f3f5f4;
  color: #69736e;
  font-size: 22px;
}

.service-modal-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.service-modal-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.service-modal-field-full {
  grid-column: 1 / -1;
}

.service-modal-field input,
.service-modal-field textarea,
.service-modal-field select {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.service-modal-field textarea {
  resize: vertical;
}

.service-modal-field input:focus,
.service-modal-field textarea:focus,
.service-modal-field select:focus {
  border-color: #7c9b89;
  outline: none;
  box-shadow: 0 0 0 3px #e9f1ec;
}

.service-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

th {
  padding: 12px;
  background: #f7f8f9;
  color: #8a939e;
  font-size: 10px;
  letter-spacing: .7px;
  text-transform: uppercase;
}

td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}

.empty {
  padding: 35px;
  color: var(--muted);
  text-align: center;
}

.settings-note {
  padding: 14px;
  border-radius: 10px;
  background: #f4f6f5;
  color: #6f7c73;
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 1000px) {
  .sidebar {
    width: 210px;
  }

  .main {
    padding: 25px;
  }

  .page-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app {
    display: block;
  }

  .sidebar {
    width: 100%;
    padding: 15px;
  }

  .brand {
    margin-bottom: 20px;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 15px;
  }

  .sidebar-bottom {
    display: none;
  }

  .main {
    padding: 20px 15px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .line-item {
    grid-template-columns: 24px minmax(110px, 1fr) 52px 58px 76px 86px 32px;
  }
}

/* TABLEAU DE BORD */

.dashboard-page {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-header h1 {
    margin-bottom: 6px;
}

.dashboard-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    padding: 24px;
}

.dashboard-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.dashboard-section-heading h2 {
    margin: 0 0 6px;
}

.dashboard-section-heading p {
    margin: 0;
}

.dashboard-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.dashboard-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
}

.dashboard-form-grid input,
.dashboard-form-grid select,
.dashboard-form-grid textarea,
.dashboard-task-form input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid #d9dce3;
    border-radius: 8px;
    font: inherit;
    background: #fff;
}

.dashboard-form-full {
    grid-column: 1 / -1;
}

.dashboard-planning-list {
    margin-top: 28px;
}

.dashboard-planning-list h3 {
    text-transform: capitalize;
    margin-bottom: 16px;
}

.dashboard-planning-item {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 18px 0;
    border-bottom: 1px solid #eceef2;
}

.dashboard-planning-time {
    min-width: 75px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-planning-time span {
    color: #7b8190;
    font-size: 12px;
}

.dashboard-planning-details {
    flex: 1;
    min-width: 0;
}

.dashboard-planning-details h4 {
    margin: 7px 0;
}

.dashboard-planning-details p {
    margin: 5px 0;
    color: #6b7280;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.dashboard-event-type {
    display: inline-block;
    background: #f0edff;
    color: #6551a5;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 12px;
}

.dashboard-task-form {
    display: grid;
    grid-template-columns: 1fr 180px auto;
    gap: 10px;
    margin-bottom: 18px;
}

.dashboard-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dashboard-task-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: #f8f9fb;
    border-radius: 10px;
}

.dashboard-task-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-task-content span {
    font-size: 12px;
    color: #7b8190;
}

.dashboard-task-time {
    font-weight: 700;
    min-width: 55px;
}

.dashboard-task-source {
    font-size: 12px;
    color: #7b8190;
}

.dashboard-task-item.is-done {
    opacity: 0.6;
}

.dashboard-task-item.is-done strong {
    text-decoration: line-through;
}

.dashboard-task-item input[type="checkbox"] {
    width: 17px;
    height: 17px;
}

.dashboard-page .remove-btn {
    border: none;
    background: transparent;
    color: #b45353;
    cursor: pointer;
    font-size: 12px;
}

.dashboard-page .empty-state {
    color: #7b8190;
    padding: 18px 0;
}

@media (max-width: 700px) {
    .dashboard-card {
        padding: 16px;
    }

    .dashboard-form-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-form-full {
        grid-column: auto;
    }

    .dashboard-section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-task-form {
        grid-template-columns: 1fr;
    }

    .dashboard-planning-item {
        flex-wrap: wrap;
    }
}

/* =========================================================
   ARKELYS PILOT — CALENDRIER HEBDOMADAIRE
   ========================================================= */

.calendar-app {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  min-height: 720px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 5px 25px rgba(30, 45, 38, 0.03);
}

.calendar-sidebar {
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: #fcfdfc;
}

.calendar-create-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 28px;
  border: 1px solid #e5e8e5;
  border-radius: 10px;
  background: white;
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(20, 30, 25, 0.04);
}

.calendar-create-btn span {
  color: var(--primary);
  font-size: 20px;
}

.mini-calendar {
  margin-bottom: 30px;
}

.mini-calendar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}

.mini-calendar-heading strong {
  font-family: Manrope, sans-serif;
  font-size: 14px;
  text-transform: capitalize;
}

.mini-calendar-arrows {
  display: flex;
  gap: 4px;
}

.mini-calendar-arrows button,
.calendar-arrow {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: #606a75;
  font-size: 20px;
}

.mini-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.mini-calendar-weekdays {
  margin-bottom: 8px;
}

.mini-calendar-weekdays span {
  text-align: center;
  color: #929aa5;
  font-size: 11px;
  font-weight: 700;
}

.mini-day {
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #4f5965;
  font-size: 11px;
}

.mini-day:hover {
  background: #edf2ee;
}

.mini-day.outside-month {
  color: #c4c9cf;
}

.mini-day.is-today {
  border: 1px solid var(--primary);
  color: var(--primary);
  font-weight: 800;
}

.mini-day.is-selected {
  background: var(--primary);
  color: white;
}

.calendar-sidebar-note {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: #626d78;
  font-size: 12px;
}

.calendar-note-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--primary);
}

.calendar-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.calendar-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.calendar-toolbar h2 {
  margin-left: 8px;
  font-size: 16px;
  text-transform: capitalize;
}

.calendar-today-btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: #59636f;
  font-size: 12px;
  font-weight: 700;
}

.calendar-view-label {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.calendar-scroll {
  flex: 1;
  overflow: auto;
}

.week-calendar {
  min-width: 700px;
}

.week-header {
  display: grid;
  grid-template-columns: 58px repeat(7, minmax(0, 1fr));
  position: sticky;
  top: 0;
  z-index: 3;
  background: white;
  border-bottom: 1px solid var(--border);
}

.week-time-header {
  border-right: 1px solid var(--border);
}

.week-day-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 4px;
  border: 0;
  border-right: 1px solid #f0f1f3;
  background: white;
  color: #78828e;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
}

.week-day-heading strong {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  color: #303944;
  font-size: 15px;
}

.week-day-heading.is-today strong {
  background: var(--primary);
  color: white;
}

.week-grid {
  display: grid;
  grid-template-columns: 58px repeat(7, minmax(0, 1fr));
}

.week-time-column {
  background: #fff;
  border-right: 1px solid var(--border);
}

.week-time-label {
  height: 64px;
  padding: 0 8px;
  position: relative;
  top: -8px;
  color: #929aa5;
  text-align: right;
  font-size: 10px;
}

.week-day-column {
  position: relative;
  min-width: 0;
  border-right: 1px solid #edf0f2;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 63px,
    #edf0f2 63px,
    #edf0f2 64px
  );
}

.week-hour-cell {
  display: block;
  width: 100%;
  height: 64px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
}

.week-hour-cell:hover {
  background: rgba(66, 107, 89, 0.06);
}

.calendar-event {
  position: absolute;
  left: 3px;
  right: 3px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  overflow: hidden;
  padding: 7px;
  border: 0;
  border-left: 3px solid #426b59;
  border-radius: 6px;
  background: #e9f1ec;
  color: #345644;
  text-align: left;
  font-size: 10px;
  cursor: pointer;
}

.calendar-event strong {
  font-size: 11px;
  line-height: 1.35;
}

.calendar-event span,
.calendar-event small {
  font-size: 10px;
  opacity: 0.85;
}

.event-prospection {
  border-left-color: #d99a5b;
  background: #fbf0e5;
  color: #9a642e;
}

.event-meeting,
.event-video,
.event-call {
  border-left-color: #8c7ab7;
  background: #f0edfa;
  color: #6551a5;
}

.event-admin {
  border-left-color: #7194bc;
  background: #eaf1f8;
  color: #496c94;
}

.event-collaboration {
  border-left-color: #bf858c;
  background: #f8ecee;
  color: #985b64;
}

/* Fenêtre d'ajout / modification */

.calendar-modal-overlay[hidden] {
  display: none;
}

.calendar-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(25, 34, 29, 0.42);
}

.calendar-modal {
  width: min(680px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.16);
}

.calendar-modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.calendar-modal-heading h2 {
  font-size: 20px;
}

.calendar-modal-heading button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: #f3f5f4;
  color: #69736e;
  font-size: 22px;
}

.calendar-modal-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.calendar-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #68727d;
  font-size: 12px;
  font-weight: 700;
}

.calendar-field.full {
  grid-column: 1 / -1;
}

.calendar-field input,
.calendar-field select,
.calendar-field textarea {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  outline: none;
  background: white;
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.calendar-field input:focus,
.calendar-field select:focus,
.calendar-field textarea:focus {
  border-color: #7c9b89;
  box-shadow: 0 0 0 3px #e9f1ec;
}

.calendar-modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
}

.calendar-modal-actions-right {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.calendar-delete-btn {
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: #faeeee;
  color: #b45e5e;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .calendar-app {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .calendar-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 750px) {
  .calendar-app {
    grid-template-columns: 1fr;
  }

  .calendar-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .mini-calendar {
    max-width: 300px;
  }

  .calendar-toolbar {
    padding: 16px;
  }

  .calendar-modal-fields {
    grid-template-columns: 1fr;
  }

  .calendar-field.full {
    grid-column: auto;
  }

  .calendar-modal {
    padding: 18px;
  }
}


/* =========================================================
   CORRECTIONS DU CALENDRIER ARKELYS PILOT
   ========================================================= */

/* Planning 24 heures : 24 lignes de 64 px */
.week-time-column,
.week-day-column {
  height: calc(24 * 64px);
}

.week-grid {
  align-items: start;
}

.week-time-label {
  height: 64px;
  box-sizing: border-box;
}

.week-hour-cell {
  height: 64px;
  box-sizing: border-box;
}

/* Les week-ends sont grisés mais restent interactifs */
.week-day-column.is-weekend {
  background: #f1f2f2;
}

.week-day-column.is-weekend .week-hour-cell {
  background: transparent;
}

.week-day-column.is-weekend .week-hour-cell:hover {
  background: rgba(120, 140, 130, 0.15);
}

.week-day-heading.is-weekend {
  background: #f1f2f2;
}

/* Événements : couleur réglable depuis le formulaire */
.calendar-event {
  position: absolute;
  left: 3px;
  right: 3px;
  z-index: 3;
  overflow: hidden;
  display: block;
  text-align: left;
  padding: 4px 6px;
  border: none;
  border-left: 4px solid var(--event-color, #8da99b);
  border-radius: 5px;
  background: color-mix(in srgb, var(--event-color, #8da99b) 22%, white);
  color: #26332d;
  cursor: pointer;
  min-height: 32px;
}

.calendar-event strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.calendar-event span {
  display: block;
  font-size: 10px;
  margin-top: 3px;
  white-space: nowrap;
}

.calendar-event:hover {
  z-index: 10;
  filter: brightness(0.97);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

/* Le calendrier peut défiler sur toute la journée */
.calendar-scroll {
  overflow: auto;
  max-height: calc(100vh - 190px);
}

.week-calendar {
  min-width: 780px;
}

/* En-tête : numéro de semaine et dates */
.calendar-toolbar-left h2 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

/* Retirer la mention "Vue semaine" si elle subsiste */
.calendar-view-label {
  display: none !important;
}

/* Couleur sélectionnée dans le formulaire */
.calendar-field input[type="color"] {
  width: 100%;
  min-height: 42px;
  padding: 4px;
  cursor: pointer;
}

/* Modal : détails de l'événement */
.calendar-modal {
  max-height: 90vh;
  overflow-y: auto;
}

.calendar-modal-fields {
  gap: 14px;
}

.calendar-modal textarea {
  resize: vertical;
}

/* Sur écran étroit, garder le défilement horizontal */
@media (max-width: 700px) {
  .calendar-scroll {
    max-height: 70vh;
  }

  .calendar-toolbar-left {
    flex-wrap: wrap;
  }

  .calendar-toolbar-left h2 {
    white-space: normal;
  }
}

/* =========================================================
   CALENDRIER — HAUTEUR ADAPTATIVE ET PLAGES GRISÉES
   ========================================================= */

.week-time-column,
.week-day-column {
  height: calc(14 * var(--hour-height, 40px));
}

.week-time-label {
  height: var(--hour-height, 40px);
}

.week-hour-cell {
  height: var(--hour-height, 40px);
}

/* Traits horizontaux adaptés à la hauteur réelle d'une heure */
.week-day-column {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--hour-height, 40px) - 1px),
    #edf0f2 calc(var(--hour-height, 40px) - 1px),
    #edf0f2 var(--hour-height, 40px)
  );
}

/* Griser 00 h à 07 h, ainsi que 20 h à 23 h.
   Les boutons restent cliquables pour ajouter des événements. */
.week-hour-cell[data-add-time="00:00"],
.week-hour-cell[data-add-time="01:00"],
.week-hour-cell[data-add-time="02:00"],
.week-hour-cell[data-add-time="03:00"],
.week-hour-cell[data-add-time="04:00"],
.week-hour-cell[data-add-time="05:00"],
.week-hour-cell[data-add-time="06:00"],
.week-hour-cell[data-add-time="21:00"],
.week-hour-cell[data-add-time="22:00"],
.week-hour-cell[data-add-time="23:00"] {
  background: #f0f1f2;
}

.week-hour-cell[data-add-time^="0"]:hover,
.week-hour-cell[data-add-time="07:00"]:hover,
.week-hour-cell[data-add-time^="20"]:hover,
.week-hour-cell[data-add-time^="21"]:hover,
.week-hour-cell[data-add-time^="22"]:hover,
.week-hour-cell[data-add-time^="23"]:hover {
  background: #e2e5e6;
}

/* Griser également toute la colonne du week-end */
.week-day-column.is-weekend {
  background-color: #f1f2f2;
}

.week-day-heading.is-weekend {
  background: #f1f2f2;
}

/* Garder la grille utilisable sur ordinateur */
.calendar-scroll {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.week-calendar {
  min-width: 780px;
}

/* Téléphone : calendrier horizontalement défilant,
   formulaire adapté à la largeur du mobile */
@media (max-width: 700px) {
  .calendar-app {
    grid-template-columns: minmax(0, 1fr);
  }

  .calendar-scroll {
    max-height: 65vh;
    overflow: auto;
  }

  .week-calendar {
    min-width: 780px;
  }

  .calendar-modal-overlay {
    padding: 8px;
    align-items: flex-start;
  }

  .calendar-modal {
    width: 100%;
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    padding: 16px;
  }

  .calendar-modal-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .calendar-field.full {
    grid-column: auto;
  }

  .calendar-modal-actions {
    flex-wrap: wrap;
  }

  .calendar-modal-actions-right {
    flex-wrap: wrap;
  }
}
/* Calendrier : largeur et hauteur optimisées */

.calendar-main {
  min-width: 0;
  width: 100%;
  flex: 1;
}

.calendar-scroll {
  width: 100%;
  overflow-x: auto;
}

.week-calendar {
  width: 100%;
  min-width: 0;
}

.week-header,
.week-grid {
  width: 100%;
  display: grid;
  min-width: 0;
}

.week-day-column,
.week-day-heading {
  min-width: 0;
}

.week-day-column {
  position: relative;
}

.week-hour-cell {
  height: var(--hour-height, 40px);
  min-height: var(--hour-height, 40px);
}

.week-time-label {
  height: var(--hour-height, 40px);
}

.week-grid {
  --hour-height: 40px;
}

.calendar-event {
  position: absolute;
  left: 3px;
  right: 3px;
  overflow: hidden;
  z-index: 2;
}

.week-day-column.is-weekend,
.week-day-heading.is-weekend {
  background-color: #f7f7f7;
}

/* Bouton d'affichage du week-end */

#toggle-weekend {
  white-space: nowrap;
  margin-left: auto;
}

/* Le calendrier utilise toute la largeur disponible */

.calendar-app {
  width: 100%;
  max-width: none;
}

@media (max-width: 768px) {
  .calendar-toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  #toggle-weekend {
    margin-left: 0;
  }

  .week-calendar {
    min-width: 650px;
  }
}
.week-time-column {
  padding-top: 6px;
  box-sizing: border-box;
}
.logo-mark {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #789b87;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


/* Groupe Opportunités & devis */
.sidebar-nav-group {
  margin: 5px 0 8px;
}

.sidebar-nav-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #2d7650;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-nav-group-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 8px;
  background: #e8f3ec;
  color: #287a50;
  font-size: 16px;
}

.sidebar-nav-submenu {
  margin-left: 15px;
  padding-left: 10px;
  border-left: 1px solid #dfe8e2;
}

.sidebar-nav-submenu .nav-link {
  width: 100%;
  text-align: left;
  padding-left: 14px;
  font-size: 13px;
}

/* Conserver le style actif existant */
.sidebar-nav-submenu .nav-link.active {
  background: #e8f3ec;
  color: #287a50;
}

/* --------------------------------------------------
   CRM — CLIENTS DIRECTS
-------------------------------------------------- */

.crm-card {
  min-width: 0;
}

.crm-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.crm-toolbar label {
  font-weight: 600;
}

.crm-toolbar select {
  min-width: 190px;
}

.crm-toolbar input {
  flex: 1;
  min-width: 200px;
}

.crm-contact-form {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.crm-contact-dialog {
  width: min(760px, calc(100% - 32px));
}

.crm-contact-dialog .crm-contact-form {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.crm-contact-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.crm-contact-fields label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.crm-contact-fields input,
.crm-contact-fields textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.crm-contact-fields textarea {
  resize: vertical;
}

.crm-project-field {
  grid-column: 1 / -1;
}

.crm-project-field select {
  min-height: 100px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.crm-project-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.crm-organization-row {
  cursor: pointer;
}

.crm-client-row {
  cursor: pointer;
}

.crm-client-row:hover td,
.crm-client-row:focus td,
.crm-organization-row:hover td {
  background: #f0f6f1;
}

.crm-client-row:focus {
  outline: 2px solid #7c9b89;
  outline-offset: -2px;
}

.crm-contact-edit {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.crm-contact-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.crm-contact-form-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.crm-count {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.crm-table-wrap {
  max-height: calc(100vh - 260px);
}

.crm-table {
  width: max-content;
  min-width: 1400px;
  table-layout: auto;
}

.crm-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f7f4;
  color: #42634f;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid #dfe8e2;
  white-space: nowrap;
}

.crm-table tbody td {
  padding: 14px 16px;
  font-size: 13px;
  color: #39443d;
  vertical-align: top;
  border-bottom: 1px solid #edf0ed;
  overflow-wrap: anywhere;
  background: #fff;
}

.crm-table th:nth-child(-n+4),
.crm-table td:nth-child(-n+4) {
  white-space: nowrap;
  overflow-wrap: normal;
}

.crm-table tbody tr:nth-child(even) td {
  background: #fafcfb;
}

.crm-project-link {
  display: block;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.crm-project-link:hover {
  color: #287a50;
}

.crm-table tbody tr[hidden],
.crm-empty[hidden] {
  display: none;
}

body.dark-mode .crm-table thead th {
  background: #303440;
  color: #e5e7eb;
  border-color: #3a3e49;
}

body.dark-mode .crm-table tbody td {
  background: #252832;
  color: #e5e7eb;
  border-color: #3a3e49;
}

body.dark-mode .crm-table tbody tr:nth-child(even) td {
  background: #20232b;
}

@media (max-width: 1150px) {
  .quote-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .quote-editor {
    padding: 16px;
  }

  .quote-editor-section {
    overflow-x: auto;
  }

  .quote-line-labels,
  .line-items {
    min-width: 420px;
  }

  .quote-preview-card {
    padding: 20px 14px;
  }

  .quote-terms-signature {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
  }

  .quote-parties {
    gap: 12px;
  }
}

@page {
  size: A4;
  margin: 14mm;

  @bottom-right {
    content: counter(page) "/" counter(pages);
    color: #515c65;
    font-size: 8pt;
  }
}

@media print {
  .quote-preview-dialog {
    display: none !important;
  }

  .quote-page-number {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #202631 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app > .sidebar,
  .sidebar-toggle,
  .topbar,
  .quote-editor,
  .quote-preview-toolbar {
    display: none !important;
  }

  .app > .main {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .quote-workspace {
    display: block !important;
  }

  .quote-preview-column {
    display: block !important;
  }

  .quote-preview-source {
    display: none !important;
  }

  .quote-preview-inline-pages {
    display: block !important;
  }

  .quote-preview-inline-pages .quote-preview-dialog-sheet {
    display: block !important;
    width: 182mm;
    height: 269mm !important;
    min-height: 269mm !important;
    aspect-ratio: auto;
    padding: 0;
    margin: 0;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: page;
    page-break-after: always;
  }

  .quote-preview-inline-pages .quote-preview-dialog-sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .quote-preview-card {
    width: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-size: 10px;
  }

  .quote-preview-card {
    display: flex;
    flex-direction: column;
    width: 182mm !important;
    height: 269mm !important;
    aspect-ratio: auto;
    min-height: 269mm !important;
    box-sizing: border-box;
    padding-bottom: 5mm;
  }

  .quote-bottom-block {
    margin-top: auto;
    gap: 4px;
    break-inside: avoid;
  }

  .quote-terms-signature {
    margin-top: 0;
  }

  .quote-terms {
    padding-top: 0;
    border-top: 0;
  }

  .quote-retention-clause {
    padding-top: 4px;
    border-top: 1px solid #e8ebef;
    break-inside: avoid;
  }

  .quote-parties,
  .quote-meta,
  .quote-bottom-block {
    break-inside: avoid;
  }

  .quote-preview-table {
    break-inside: auto;
    flex: 0 0 auto;
  }

  .quote-preview-table thead {
    display: table-header-group;
  }

  .quote-preview-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .quote-preview-table .quote-money {
    white-space: nowrap;
    overflow-wrap: normal;
  }
}

/* --------------------------------------------------
   TABLEAU DES PROJETS
-------------------------------------------------- */

.projects-card {
  overflow: hidden;
  padding: 0;
}

.projects-table-wrap {
  width: 100%;
  max-height: calc(100vh - 190px);
  overflow: auto;
}

/* Structure du tableau */
.projects-table {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

/* En-tête figé */
.projects-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f3f7f4;
  color: #42634f;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid #dfe8e2;
  white-space: nowrap;
}

/* Cellules */
.projects-table tbody td {
  padding: 14px 16px;
  font-size: 13px;
  color: #39443d;
  vertical-align: top;
  border-bottom: 1px solid #edf0ed;
  overflow-wrap: anywhere;
  background: #fff;
}

/* Alternance discrète */
.projects-table tbody tr:nth-child(even) td {
  background: #fafcfb;
}

/* Survol */
.projects-table tbody tr:hover td {
  background: #f0f7f2;
}

/* Clic sur une ligne pour ouvrir le projet */
.project-table-row {
  cursor: pointer;
}

/* Largeur des colonnes */
.projects-table .project-quote-number {
  width: 110px;
  color: #64736a;
  font-variant-numeric: tabular-nums;
}

.projects-table .project-name-column {
  width: 190px;
}

.projects-table .project-address-column {
  width: 210px;
}

.projects-table .project-status-column {
  width: 150px;
}

.projects-table .project-description-column {
  min-width: 260px;
}

/* Statut */
.project-status {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 6px;
  background: #eef3ef;
  color: #4b6654;
  font-size: 12px;
}

/* Description / nota */
.project-description-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.5;
  color: #66736a;
  max-height: none;
  overflow: visible;
  display: block;
}

/* En-tête arrondi visuellement */
.projects-table thead th:first-child {
  border-top-left-radius: 8px;
}

.projects-table thead th:last-child {
  border-top-right-radius: 8px;
}

/* --------------------------------------------------
   FINITIONS VISUELLES DU TABLEAU DES PROJETS
-------------------------------------------------- */

.projects-table {
  border-collapse: separate;
  border-spacing: 0;
}

/* Délimitation fine des colonnes et des lignes */
.projects-table thead th,
.projects-table tbody td {
  border-right: 1px solid #e1e5e2;
  border-bottom: 1px solid #e1e5e2;
}

/* Bordure gauche du tableau */
.projects-table thead th:first-child,
.projects-table tbody td:first-child {
  border-left: 1px solid #e1e5e2;
}

/* Bordure supérieure */
.projects-table thead th {
  border-top: 1px solid #e1e5e2;
}

/* Alignement du contenu */
.projects-table tbody td {
  text-align: left;
  vertical-align: middle;
}

/* En-têtes également alignés à gauche */
.projects-table thead th {
  text-align: left;
  vertical-align: middle;
}

/* Notes personnelles : tout le texte visible */
.project-description-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.5;
  color: #66736a;
  max-height: none;
  overflow: visible;
  display: block;
}

/* Fond discret de l'en-tête */
.projects-table thead th {
  background: #f3f7f4;
}

/* Survol léger conservé */
.projects-table tbody tr:hover td {
  background: #f0f7f2;
}
/* Alignement à gauche de la colonne Description / Nota */
.projects-table tbody td.project-description-column {
  text-align: left !important;
  padding-left: 16px;
  padding-right: 16px;
}

.projects-table tbody td.project-description-column .project-description-text {
  text-align: left !important;
  margin: 0;
  width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ==========================================
   MENU LATERAL RABATTABLE 
   ========================================== */

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar ouverte et fixe à l'écran */
.app > .sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;

  flex: 0 0 250px;
  width: 250px;
  min-width: 250px;
  height: 100vh;

  padding: 28px 18px;
  overflow-y: auto;
  overflow-x: hidden;

  background: #fff;
  border-right: 1px solid var(--border);

  opacity: 1;
  visibility: visible;

  z-index: 1000;

  transition:
    width 0.25s ease,
    min-width 0.25s ease,
    flex-basis 0.25s ease,
    padding 0.25s ease,
    opacity 0.2s ease;
}

/* Sidebar complètement rabattue */
.app.sidebar-collapsed > .sidebar {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
}

/* Contenu principal décalé à droite de la sidebar */
.app > .main {
  flex: 1 1 0%;
  width: calc(100% - 250px);
  min-width: 0;
  margin-left: 250px;

  transition: margin-left 0.25s ease, width 0.25s ease;
}

/* Quand la sidebar est rabattue */
.app.sidebar-collapsed > .main {
  width: 100%;
  margin-left: 0;
}

/* Bouton de bascule */
.sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 234px;
  z-index: 9999;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e1e5e2;
  border-radius: 9px;
  background: #fff;
  color: #42634f;
  font-size: 18px;
  cursor: pointer;
  transition: left 0.25s ease;
}

/* Bouton quand la sidebar est fermée */
.app.sidebar-collapsed .sidebar-toggle {
  left: 12px;
}

/* Adaptation mobile */
@media (max-width: 700px) {
  .app {
    display: block;
  }

  .app.sidebar-collapsed .sidebar {
    display: block !important;
  }
}

@media (max-width: 700px) {
  .app > .sidebar {
    position: relative;
    width: 100%;
    min-width: 0;
    height: auto;
    bottom: auto;
  }

  .app > .main {
    width: 100%;
    margin-left: 0;
  }

  .app.sidebar-collapsed > .sidebar {
    display: none !important;
  }
}

/* --------------------------------------------------
   PARAMÈTRES - CASE MODE SOMBRE
-------------------------------------------------- */

.settings-option {
  padding: 16px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

.settings-option label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.settings-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* --------------------------------------------------
   MODE SOMBRE
-------------------------------------------------- */

body.dark-mode {
  background: #17191f;
  color: #e5e7eb;
}

body.dark-mode .main {
  background: #17191f;
  color: #e5e7eb;
}

body.dark-mode .sidebar {
  background: #20232b;
  color: #e5e7eb;
  border-color: #363a45;
}

body.dark-mode .card {
  background: #252832;
  color: #e5e7eb;
  border-color: #363a45;
}

body.dark-mode .card-heading,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode p,
body.dark-mode label {
  color: #e5e7eb;
}

body.dark-mode .settings-note {
  color: #c4c8d0;
}

body.dark-mode .settings-option {
  border-color: #444956;
  background: #20232b;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #20232b;
  color: #e5e7eb;
  border-color: #444956;
}

body.dark-mode table {
  color: #e5e7eb;
}

body.dark-mode th {
  background: #303440;
  color: #e5e7eb;
}

body.dark-mode td {
  border-color: #3a3e49;
}
body.dark-mode .sidebar-nav-group-title {
  color: #e5e7eb;
}
body.dark-mode .sidebar-nav-submenu .nav-link 
{
  color: #e5e7eb;
}
body.dark-mode .sidebar-nav-submenu .nav-link.active {
  background: #42634f;
  color: #e5e7eb;
}

/* Adresse de facturation identique à l'adresse du projet */
.billing-address.same-as-project input,
.billing-address.same-as-project select,
.billing-address.same-as-project textarea {
  background: #f1f3f2;
  color: #7b827e;
  border-color: #e1e5e2;
  cursor: default;
}

/* Mode sombre */
body.dark-mode .billing-address.same-as-project input,
body.dark-mode .billing-address.same-as-project select,
body.dark-mode .billing-address.same-as-project textarea {
  background: #2b2e35;
  color: #aeb4bd;
  border-color: #3d424c;
}
/* Adresse de facturation identique */
#detail-billing-address:disabled {
  background-color: #e9e9e9 !important;
  color: #777 !important;
  border-color: #d5d5d5 !important;
  opacity: 1 !important;
  cursor: not-allowed;
}
input:disabled {
  background: #dcdcdc !important;
  color: #555 !important;
  opacity: 1 !important;
  -webkit-text-fill-color: #555 !important;
}

.btn-planifier {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-planifier:hover {
  background: #1d4ed8;
}

.btn-planifier.is-planned {
  background: #15803d;
}

.planning-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.planning-status {
  font-size: 13px;
  color: #15803d;
}


/* En-tête de la fiche projet */
.project-detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.project-detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Bouton Planifier — vert Arkelys */
.btn-planifier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 10px 16px;
  min-height: 40px;

  border: 1px solid #477b68;
  border-radius: 8px;

  background-color: #477b68;
  color: #ffffff;

  font-family: inherit;
  font-size: 14px;
  font-weight: 600;

  cursor: pointer;
  transition: background-color 0.2s ease,
              border-color 0.2s ease,
              transform 0.15s ease;
}

.btn-planifier:hover {
  background-color: #3b6858;
  border-color: #3b6858;
}

.btn-planifier:active {
  transform: translateY(1px);
}

.btn-planifier .planning-icon {
  color: #ffffff;
  stroke: #ffffff;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .project-detail-heading {
    align-items: flex-start;
  }

  .project-detail-actions {
    width: 100%;
  }
}
.sidebar-nav-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.sidebar-nav-group-title:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-group-icon {
  display: inline-flex;
  width: 16px;
  justify-content: center;
}

.sidebar-nav-submenu {
  padding-left: 18px;
}

.sidebar-nav-submenu[hidden] {
  display: none;
}

/* FACTURATION */
.billing-page {
  display: grid;
  gap: 20px;
}

.billing-section {
  min-width: 0;
}

.billing-heading {
  margin-bottom: 18px;
}

.billing-heading h2 {
  margin-bottom: 6px;
}

.billing-heading p,
.billing-project > div > span {
  color: var(--muted);
  font-size: 12px;
}

.billing-project-list {
  display: grid;
  gap: 10px;
}

.billing-project {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.billing-project > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.billing-project > div > strong,
.billing-project > div > span {
  overflow-wrap: anywhere;
}

.billing-table {
  min-width: 960px;
}

.receipt-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 8px;
}

.receipt-metric {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.receipt-metric > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.receipt-metric > strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: clamp(18px, 2vw, 24px);
  font-variant-numeric: tabular-nums;
}

.receipt-metric-highlight {
  border-color: color-mix(in srgb, var(--primary) 36%, var(--border));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.receipt-metric-highlight > strong {
  color: var(--primary);
}

.receipt-disclaimer {
  margin: 10px 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.receipt-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.receipt-table .receipt-col-date {
  width: 13%;
}

.receipt-table .receipt-col-operation {
  width: 20%;
}

.receipt-table .receipt-col-client {
  width: 20%;
}

.receipt-table .receipt-col-nature {
  width: 29%;
}

.receipt-table .receipt-col-amount {
  width: 18%;
}

.receipt-table th,
.receipt-table td {
  overflow-wrap: anywhere;
}

.receipt-table .receipt-amount-heading,
.receipt-table .receipt-amount-cell {
  text-align: right;
  overflow-wrap: normal;
  white-space: nowrap;
}

.receipt-table .receipt-amount-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.receipt-row {
  cursor: pointer;
  transition: background-color 140ms ease;
}

.receipt-row:hover,
.receipt-row:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.receipt-operation,
.receipt-invoice-number {
  display: block;
}

.receipt-operation {
  font-weight: 700;
}

.receipt-operation.is-refund,
.receipt-amount-cell.is-refund {
  color: #a64b45;
}

.receipt-invoice-number {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.receipt-client-cell {
  font-weight: 600;
}

.receipt-nature-cell {
  color: var(--muted);
}

.receipt-category-list {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.receipt-category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.receipt-category-item > span {
  overflow-wrap: anywhere;
}

.receipt-detail-dialog {
  width: min(820px, calc(100% - 32px));
  max-width: 820px;
}

.receipt-report-action {
  align-self: end;
}

#receipts-month-filter-field[hidden],
#receipts-quarter-filter-field[hidden] {
  display: none;
}

.receipt-report-preview {
  width: min(1100px, calc(100vw - 32px));
}

.receipt-report-sheet {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  box-sizing: border-box;
  width: 210mm;
  height: 297mm;
  padding: 14mm;
  overflow: hidden;
  background: #fff;
  color: #202631;
  box-shadow: 0 3px 14px rgba(32, 38, 49, 0.12);
}

.receipt-report-measurement {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 210mm;
  visibility: hidden;
  pointer-events: none;
}

.receipt-report-page-content {
  flex: 1 1 0;
  min-height: 0;
  padding-bottom: 10mm;
  overflow: hidden;
}

.receipt-report-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 5mm;
  border-bottom: 2px solid #426b59;
}

.receipt-report-header .quote-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.receipt-report-header .quote-brand > div {
  min-width: 0;
}

.receipt-report-header .quote-brand-logo {
  display: block;
  flex: 0 0 112px;
  width: 112px;
  height: 72px;
  object-fit: contain;
  object-position: left center;
}

.receipt-report-header h1 {
  margin: 4px 0 5px;
  color: #202631;
  font-size: 18px;
  line-height: 1.2;
}

.receipt-report-header p {
  margin: 0;
  color: #65716a;
  font-size: 10px;
}

.receipt-report-header .receipt-report-eyebrow {
  margin: 0 0 4px;
  color: #426b59;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.receipt-report-header > p {
  align-self: flex-start;
  white-space: nowrap;
}

.receipt-report-summary {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin: 6mm 0;
}

.receipt-report-summary > div {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #dfe4df;
  border-radius: 5px;
}

.receipt-report-summary span {
  color: #65716a;
  font-size: 8px;
  line-height: 1.2;
}

.receipt-report-summary strong {
  color: #202631;
  font-size: 10px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.receipt-report-footer,
.receipt-report-page-number {
  color: #65716a;
  font-size: 8px;
  line-height: 1.3;
}

.receipt-report-footer {
  flex: 0 0 auto;
  margin: 0 0 4mm;
}

.receipt-report-page-number {
  position: absolute;
  right: 14mm;
  bottom: 8mm;
  margin: 0;
  white-space: nowrap;
  text-align: right;
}

.receipt-report-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 9px;
}

.receipt-report-table th,
.receipt-report-table td {
  padding: 5px;
  border-bottom: 1px solid #dfe4df;
  color: #202631;
  text-align: left;
  vertical-align: top;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.receipt-report-table th {
  background: #f1f4f1;
  font-weight: 700;
}

.receipt-report-table th:first-child { width: 13%; }
.receipt-report-table th:nth-child(2) { width: 18%; }
.receipt-report-table th:nth-child(3) { width: 19%; }
.receipt-report-table th:nth-child(4) { width: 34%; }
.receipt-report-table th:last-child {
  width: 16%;
  text-align: right;
}

.receipt-report-table td span {
  color: #65716a;
  font-size: 8px;
}

.receipt-report-table td:first-child {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.receipt-report-table td:last-child {
  text-align: right;
  white-space: nowrap;
  overflow-wrap: normal;
}

.receipt-report-table .receipt-report-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.receipt-report-table thead { display: table-header-group; }
.receipt-report-table tr { break-inside: avoid; page-break-inside: avoid; }

.receipt-report-preview .receipt-report-sheet {
  width: min(210mm, 100%);
  height: 297mm;
  box-shadow: 0 2px 16px rgba(32, 38, 49, 0.16);
}

.receipt-report-print-area .receipt-report-sheet {
  width: 182mm;
  height: 269mm;
  margin: 0;
  padding: 0;
  box-shadow: none;
  break-after: page;
  page-break-after: always;
}

.receipt-report-print-area .receipt-report-sheet:last-child {
  break-after: auto;
  page-break-after: auto;
}

.receipt-report-print-area .receipt-report-page-number {
  right: 0;
  bottom: 0;
}

.receipt-report-measurement .receipt-report-sheet {
  width: 210mm;
  height: 297mm;
  padding: 14mm;
}

.receipt-report-print-area .receipt-report-table th,
.receipt-report-print-area .receipt-report-summary > div {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.receipt-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
  margin: 0;
  border-top: 1px solid var(--border);
}

.receipt-detail-grid > div {
  min-width: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.receipt-detail-grid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.receipt-detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.receipt-history-section,
.receipt-edit-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.receipt-history-section h3,
.receipt-edit-section h3 {
  margin: 0 0 12px;
}

.receipt-history-section > p,
.receipt-edit-section > p {
  color: var(--muted);
  font-size: 12px;
}

.receipt-history {
  display: grid;
  gap: 12px;
  padding-left: 20px;
  font-size: 12px;
}

.receipt-history ul {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  padding-left: 18px;
  color: var(--muted);
}

.receipt-invoice-lines {
  display: grid;
  gap: 8px;
  padding-left: 18px;
}

.receipt-invoice-lines li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.receipt-invoice-lines li span {
  overflow-wrap: anywhere;
}

.billing-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.billing-actions .secondary-btn {
  white-space: nowrap;
}

.invoice-status {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.invoice-status.is-paid {
  background: #e9f1ec;
  color: #426b59;
}

.invoice-status.is-unpaid {
  background: #fff3e5;
  color: #9a642b;
}

.invoice-kind {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.invoice-dialog {
  width: min(680px, calc(100% - 32px));
  max-width: 680px;
  max-height: min(90vh, 800px);
  padding: 26px;
  overflow: auto;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.22);
}

.invoice-dialog::backdrop {
  background: rgba(25, 34, 29, 0.48);
}

.invoice-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.invoice-project-summary {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.invoice-project-summary h3 {
  margin: 0 0 12px;
}

.invoice-project-summary p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.invoice-project-summary p strong {
  color: var(--text);
}

.invoice-summary-lines {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.invoice-summary-lines > div,
.invoice-summary-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.invoice-summary-lines > div {
  color: var(--muted);
  font-size: 12px;
}

.invoice-summary-total {
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text) !important;
  font-size: 14px !important;
}

.invoice-summary-total strong {
  color: var(--primary);
  font-size: 18px;
}

.invoice-print-area {
  display: none;
}

.receipt-report-print-area {
  display: none;
}

@media (max-width: 700px) {
  .receipt-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receipt-table {
    min-width: 680px;
  }

  .receipt-detail-grid {
    grid-template-columns: 1fr;
  }

  .receipt-report-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receipt-report-sheet {
    padding: 20px;
  }

  .billing-project {
    align-items: flex-start;
    flex-direction: column;
  }

  .billing-actions {
    align-items: flex-start;
    flex-direction: column;
  }

}

@media print {
  .invoice-print-mode #page-content > :not(.invoice-print-area) {
    display: none !important;
  }

  .receipt-report-print-mode #page-content > :not(.receipt-report-print-area) {
    display: none !important;
  }

  .invoice-print-mode .app > .sidebar,
  .invoice-print-mode .sidebar-toggle,
  .invoice-print-mode .topbar,
  .receipt-report-print-mode .app > .sidebar,
  .receipt-report-print-mode .sidebar-toggle,
  .receipt-report-print-mode .topbar {
    display: none !important;
  }

  .invoice-print-mode .app,
  .invoice-print-mode .app > .main,
  .receipt-report-print-mode .app,
  .receipt-report-print-mode .app > .main {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .invoice-print-mode #page-content {
    margin: 0 !important;
  }

  .receipt-report-print-mode #page-content {
    margin: 0 !important;
  }

  .invoice-print-mode .invoice-print-area {
    display: block !important;
  }

  .receipt-report-print-mode .receipt-report-print-area {
    display: block !important;
  }

  .receipt-report-print-mode .receipt-report-sheet {
    width: 182mm;
    height: 269mm;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .receipt-report-print-mode .receipt-report-summary {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .receipt-report-print-mode .receipt-report-table thead {
    display: table-header-group;
  }

  .receipt-report-print-mode .receipt-report-table tr {
    break-inside: avoid;
  }

  .invoice-print-mode .invoice-print-area .quote-preview-card {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ==================================================
   APPLICATION MOBILE — TÉLÉPHONE, TABLETTE, ORDINATEUR
   Ce bloc est volontairement à la fin du fichier :
   il complète et remplace les anciennes règles responsive.
================================================== */

/* ---------- Icônes du menu (tous écrans) ---------- */

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.nav-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-text {
  min-width: 0;
}

.topbar-logo,
.bottom-nav,
.menu-backdrop {
  display: none;
}

.backup-option {
  display: grid;
  gap: 14px;
}

.backup-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

body.dark-mode .backup-note {
  color: #a9afba;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Aperçus A4 (devis, factures) : défilement horizontal si l'écran est étroit */
.quote-preview-column {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Petits plus pour le tactile */
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

/* ---------- TABLETTE : menu en icônes ---------- */

@media screen and (min-width: 701px) and (max-width: 1100px) {

  body .app > .sidebar,
  body .app.sidebar-collapsed > .sidebar {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    width: 76px;
    min-width: 76px;
    flex: 0 0 76px;
    padding: 18px 10px;
    opacity: 1;
    visibility: visible;
    border-right: 1px solid var(--border);
  }

  body .app > .main,
  body .app.sidebar-collapsed > .main {
    width: calc(100% - 76px);
    margin-left: 76px;
    padding: 24px 28px;
  }

  .sidebar-toggle,
  .sidebar .brand-text,
  .sidebar .menu-label,
  .sidebar .sidebar-nav-group-title,
  .sidebar .sidebar-bottom,
  .sidebar .nav-text {
    display: none !important;
  }

  .sidebar .brand {
    margin-bottom: 22px;
  }

  .sidebar nav {
    width: 100%;
    margin-bottom: 10px;
    gap: 4px;
  }

  .sidebar .sidebar-nav-submenu,
  .sidebar .sidebar-nav-submenu[hidden] {
    display: grid !important;
    gap: 4px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .sidebar .nav-link,
  .sidebar .sidebar-nav-submenu .nav-link {
    justify-content: center;
    padding: 12px 0;
    min-height: 44px;
  }

  .nav-ico {
    width: 21px;
    height: 21px;
    flex-basis: 21px;
  }

  .sidebar .sidebar-divider {
    width: 32px;
    margin: 8px auto;
  }
}

/* ---------- TÉLÉPHONE : barre du bas + menu tiroir ---------- */

@media screen and (max-width: 700px) {

  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  body .app {
    display: block;
  }

  .sidebar-toggle {
    display: none !important;
  }

  /* Le menu latéral devient un tiroir qui glisse depuis la gauche */
  body .app > .sidebar,
  body .app.sidebar-collapsed > .sidebar {
    display: flex !important;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px);
    min-width: 0;
    height: 100%;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(90px + env(safe-area-inset-bottom, 0px));
    opacity: 1;
    visibility: visible;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    z-index: 1200;
    overflow-y: auto;
    border-right: 1px solid var(--border);
  }

  body.menu-open .app > .sidebar {
    transform: translateX(0);
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: 1fr;
    margin-bottom: 16px;
  }

  .sidebar .nav-link {
    min-height: 46px;
    font-size: 15px;
  }

  .menu-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 28, 24, 0.45);
    z-index: 1100;
  }

  body .app > .main,
  body .app.sidebar-collapsed > .main {
    width: 100%;
    margin-left: 0;
    padding: 0 14px 20px;
  }

  /* Barre du haut avec le logo */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    margin: 0 -14px 16px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  .topbar-title-area {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .topbar-logo {
    display: block;
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .topbar h1 {
    margin: 0;
    font-size: 19px;
  }

  /* Barre de navigation du bas */
  body .app > .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 1300;
  }

  .bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-height: 52px;
    padding: 6px 2px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
  }

  .bottom-tab svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .bottom-tab.active {
    color: var(--primary);
    font-weight: 700;
  }

  .bottom-tab.active svg {
    stroke-width: 2.2;
  }

  /* Champs de saisie : 16 px minimum, sinon l'iPhone zoome tout seul */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Cartes et grilles sur une colonne */
  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .page-grid {
    grid-template-columns: 1fr !important;
  }

  /* Boîtes de dialogue en plein écran */
  dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }

  /* Tableaux transformés en cartes */
  .card-table,
  .card-table tbody,
  .card-table tr,
  .card-table td {
    display: block;
    width: 100%;
  }

  .card-table thead {
    display: none;
  }

  .card-table tr {
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
  }

  .card-table tbody tr:nth-child(even) td,
  .card-table tbody td {
    background: transparent;
  }

  .card-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0 !important;
    border: 0 !important;
    text-align: right;
    min-width: 0;
  }

  .card-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 45%;
    color: var(--muted);
    font-size: 12px;
    text-align: left;
  }

  .card-table td[data-label=""]::before {
    content: none;
  }

  .card-table td[data-label=""] {
    justify-content: flex-end;
  }

  .card-table td > * {
    min-width: 0;
  }

  .crm-table-wrap,
  .projects-table-wrap,
  .table-wrap {
    overflow-x: visible;
  }
}

/* ---------- Mode sombre : nouveaux éléments ---------- */

body.dark-mode .bottom-nav {
  background: #20232b;
  border-color: #363a45;
}

body.dark-mode .bottom-tab.active {
  color: #8fc0a6;
}

body.dark-mode .card-table tr {
  background: #252832;
  border-color: #363a45;
}

@media screen and (max-width: 700px) {
  body.dark-mode .topbar {
    background: #17191f;
    border-color: #363a45;
  }
}

/* Impression : on masque les éléments de navigation mobile */
@media print {
  .bottom-nav,
  .menu-backdrop,
  .topbar-logo {
    display: none !important;
  }
}

/* Moins d'animations si demandé par l'appareil */
@media (prefers-reduced-motion: reduce) {
  body .app > .sidebar {
    transition: none;
  }
}

/* ---------- Téléphone : ajustements tableaux et recherche ---------- */

@media screen and (max-width: 700px) {

  table.card-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    table-layout: auto !important;
  }

  .card-table td,
  .card-table th:nth-child(-n+4),
  .card-table td:nth-child(-n+4) {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  .card-table tbody tr th {
    display: block;
    padding: 4px 0 8px;
    text-align: left;
    background: transparent;
  }

  .crm-toolbar label,
  .crm-toolbar select,
  .crm-toolbar input {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  .crm-toolbar select,
  .crm-toolbar input {
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
  }
}

/* Bibliothèque de prestations : libellé au-dessus de la valeur */
@media screen and (max-width: 700px) {
  .services-table.card-table td {
    display: block;
    text-align: left;
  }

  .services-table.card-table td::before {
    display: block;
    max-width: none;
    margin-bottom: 4px;
  }

  .services-table.card-table td input,
  .services-table.card-table td select,
  .services-table.card-table td textarea {
    width: 100%;
  }
}
