/* =========================================================================
   Gestion locative, messagerie, contrats, carte et trésorerie.
   ========================================================================= */

/* --- Contact : trois portes d'entrée --------------------------------------- */

.contact-trio {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 420px) {
  .contact-trio {
    grid-template-columns: 1fr 1fr;
  }
  .contact-trio > :first-child {
    grid-column: 1 / -1;
  }
}
.contact-btn {
  justify-content: center;
  gap: 0.4rem;
  padding-inline: 0.8rem;
}
.contact-icon {
  font-size: 1rem;
}
.contact-trio > :first-child {
  grid-column: 1 / -1;
}
.contact-btn.is-locked {
  opacity: 0.85;
}
.contact-note {
  margin: 0.6rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.callback-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.callback-form summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
  font-size: 0.9rem;
}
.callback-form form {
  margin-top: 0.8rem;
}

.exchange-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.83rem;
  cursor: pointer;
  transition: border-color var(--fast) var(--ease);
}
.exchange-summary:hover {
  border-color: var(--brand);
}
.exchange-link {
  color: var(--brand);
  font-weight: 600;
}

.history-dialog {
  width: min(94vw, 520px);
  max-height: 82vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-3);
}
.history-dialog::backdrop {
  background: rgba(10, 18, 15, 0.55);
}
.history-body {
  max-height: 52vh;
  overflow-y: auto;
  padding: 0 1.3rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.history-line {
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.88rem;
}
.history-line.is-mine {
  background: var(--brand-light);
  margin-left: 2rem;
}
.history-line.is-call {
  background: var(--accent-light);
  font-size: 0.82rem;
}
.history-line.is-system {
  background: none;
  color: var(--ink-3);
  font-size: 0.8rem;
  text-align: center;
}
.history-line time {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-4);
  margin-top: 0.2rem;
}
.dialog-foot {
  padding: 1rem 1.3rem 1.3rem;
  border-top: 1px solid var(--line);
}

/* --- Messagerie ------------------------------------------------------------ */

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 3rem;
}
.thread-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.thread-row:hover {
  border-color: var(--brand);
  transform: translateX(2px);
  text-decoration: none;
}
.thread-row.is-unread {
  background: var(--brand-light);
  border-color: color-mix(in srgb, var(--brand) 35%, transparent);
}
.thread-media {
  width: 62px;
  height: 52px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  display: grid;
  place-items: center;
}
.thread-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thread-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}
.thread-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.role-tag {
  padding: 0.05rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-tag.is-owner {
  background: var(--brand);
  color: #fff;
}
.unread-dot {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 0.35rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}
.thread-listing,
.thread-last {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
}
.thread-last {
  color: var(--ink-3);
}
.thread-meta {
  text-align: right;
  white-space: nowrap;
}

.thread-layout {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: 1fr;
  padding-bottom: 3rem;
}
@media (min-width: 960px) {
  .thread-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }
}
.thread-main {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.thread-header > div:first-child {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}
.thread-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.2rem;
  max-height: 58vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.message {
  display: flex;
}
.message.is-mine {
  justify-content: flex-end;
}
.message-bubble {
  max-width: 78%;
  padding: 0.65rem 0.9rem;
  border-radius: 16px 16px 16px 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.message.is-mine .message-bubble {
  border-radius: 16px 16px 4px 16px;
  background: var(--brand-light);
  border-color: color-mix(in srgb, var(--brand) 28%, transparent);
}
.message-bubble p {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.5;
}
.message-bubble time {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.7rem;
  color: var(--ink-4);
}
.message-tag {
  display: inline-block;
  margin-bottom: 0.3rem;
  padding: 0.05rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}
.message.is-system {
  justify-content: center;
}
.message.is-system span {
  max-width: 90%;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 0.78rem;
  text-align: center;
}
.message.is-call span {
  background: var(--accent-light);
  color: var(--warn);
}
.message-map {
  height: 160px;
  margin-top: 0.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.message-tools {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem 1.2rem 0;
}
.message-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--line);
}
.message-form textarea {
  flex: 1;
  min-height: 44px;
  resize: none;
  border-radius: var(--radius);
}
.thread-safety {
  padding: 0 1.2rem 1rem;
  margin: 0;
}

.thread-side {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.side-listing {
  overflow: hidden;
  padding: 0;
}
.side-listing > a {
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
}
.side-listing img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.side-listing-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem;
}
.side-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--brand);
}
.side-visit,
.side-conclude {
  padding: 1.1rem;
}
.side-visit h3,
.side-conclude h3 {
  font-size: 1rem;
}
.visit-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.visit-list li {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.84rem;
}

.visit-strip {
  margin-bottom: 1.6rem;
}
.visit-strip h2 {
  font-size: 1.05rem;
}
.visit-cards {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.visit-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
}
.visit-when {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand);
}

/* --- Gestion : contrats ---------------------------------------------------- */

.lease-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.lease-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.8rem;
  align-items: center;
}
@media (min-width: 720px) {
  .lease-row {
    grid-template-columns: 96px minmax(0, 1fr) auto;
  }
}
.lease-row.is-live {
  border-left: 3px solid var(--brand);
}
.lease-row.is-pending {
  border-left: 3px solid var(--accent);
}
.lease-row.is-rejected {
  border-left: 3px solid var(--error);
}
.lease-media {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  display: grid;
  place-items: center;
}
.lease-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lease-body h3 {
  margin: 0.25rem 0 0.2rem;
  font-size: 1rem;
}
.lease-body h3 a {
  color: var(--ink);
}
.lease-body p {
  margin: 0;
}
.lease-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.lease-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
@media (min-width: 720px) {
  .lease-actions {
    grid-column: auto;
    flex-direction: column;
  }
}

.lease-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding: 1.3rem;
  margin-bottom: 1.2rem;
}
.lease-head h2 {
  margin: 0.4rem 0 0.2rem;
  font-size: 1.3rem;
}
.lease-head-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.lease-progress {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.6rem;
}
.lease-progress .quota-track {
  flex: 1;
  height: 8px;
}

.stat-box.is-alert {
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
  background: color-mix(in srgb, var(--error) 7%, var(--surface));
}
.stat-box.is-alert strong {
  color: var(--error);
}

.due-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.due-row {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 0.9rem 1.1rem;
}
@media (min-width: 780px) {
  .due-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }
}
.due-row.is-late {
  border-left: 3px solid var(--error);
  background: color-mix(in srgb, var(--error) 5%, var(--surface));
}
.due-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.due-amount strong {
  font-size: 1.15rem;
}
.due-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
@media (min-width: 780px) {
  .due-actions {
    grid-column: auto;
  }
}
.is-late-text {
  color: var(--error);
  font-weight: 600;
}
.is-late-row {
  background: color-mix(in srgb, var(--error) 5%, transparent);
}

.calm-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem;
  margin-bottom: 1.6rem;
}
.calm-icon {
  font-size: 1.8rem;
}
.calm-card p {
  margin: 0.2rem 0 0;
}

.incident-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}
.incident-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.9rem 1.1rem;
  align-items: start;
}
@media (min-width: 780px) {
  .incident-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
  }
}
.incident-row.is-grave {
  border-left: 3px solid var(--error);
}
.incident-row.is-closed {
  opacity: 0.65;
}
.incident-icon {
  font-size: 1.3rem;
}
.incident-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.incident-body p {
  margin: 0.3rem 0 0;
}
.resolution {
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--brand-light);
  color: var(--brand);
}
.incident-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
@media (min-width: 780px) {
  .incident-actions {
    grid-column: auto;
    flex-direction: column;
    align-items: flex-end;
  }
}
.incident-form summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
}

.end-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 820px) {
  .end-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.mini-input {
  width: auto;
  max-width: 130px;
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
}

.chosen-listing {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.chosen-listing img,
.chosen-listing .no-photo {
  width: 68px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--surface-3);
}
.chosen-listing > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chosen-listing .btn {
  margin-left: auto;
}

.entry-cost {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
  border-radius: var(--radius);
  background: var(--brand-light);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}
.entry-cost strong {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand);
}
.entry-cost.is-heavy {
  background: var(--accent-light);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.entry-cost.is-heavy strong {
  color: var(--warn);
}
.entry-detail {
  flex-basis: 100%;
}

/* --- Espace locataire ------------------------------------------------------ */

.home-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
  padding: 0;
  overflow: hidden;
  margin-bottom: 1.4rem;
}
@media (min-width: 720px) {
  .home-hero {
    grid-template-columns: 260px minmax(0, 1fr);
  }
}
.home-media {
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: grid;
  place-items: center;
}
.home-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.home-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.2rem 1.2rem 1.2rem 0;
  padding-left: 1.2rem;
}
@media (min-width: 720px) {
  .home-info {
    padding-left: 0;
  }
}
.home-info h2 {
  margin: 0.3rem 0 0;
  font-size: 1.25rem;
}
.home-rent strong {
  font-size: 1.5rem;
  color: var(--brand);
}
.home-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.next-due {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.4rem;
  border-left: 3px solid var(--brand);
}
.next-due > div {
  display: flex;
  flex-direction: column;
}
.next-due strong {
  font-size: 1.2rem;
}
.next-due.is-late {
  border-left-color: var(--error);
  background: color-mix(in srgb, var(--error) 5%, var(--surface));
}

/* --- Contrat --------------------------------------------------------------- */

.contract-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}
.compact-head {
  padding-bottom: 0.6rem;
}
.contract-wrap {
  padding-bottom: 3rem;
}
.contract {
  max-width: 800px;
  margin-inline: auto;
  padding: 3rem 2.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-size: 0.94rem;
  line-height: 1.65;
}
.contract-head {
  text-align: center;
  padding-bottom: 1.6rem;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 1.8rem;
}
.contract-brand {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  margin: 0 0 0.6rem;
}
.contract-head h1 {
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  margin: 0 0 0.4rem;
}
.contract-ref,
.contract-frame {
  font-size: 0.8rem;
  color: var(--ink-3);
  margin: 0;
}
.contract-frame {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.1rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}
.contract-parties {
  display: grid;
  gap: 1.6rem;
  grid-template-columns: 1fr;
  margin-bottom: 2rem;
}
@media (min-width: 640px) {
  .contract-parties {
    grid-template-columns: 1fr 1fr;
  }
}
.contract-parties h2,
.contract-block h2 {
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.3rem;
  margin-bottom: 0.7rem;
}
.contract-quality {
  font-style: italic;
  color: var(--ink-3);
  font-size: 0.85rem;
}
.contract-block {
  margin-bottom: 2rem;
}
.contract-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.contract-table th,
.contract-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.contract-table th {
  width: 42%;
  font-weight: 600;
  color: var(--ink-3);
}
.contract-total th,
.contract-total td {
  border-top: 2px solid var(--line-strong);
  border-bottom: none;
  padding-top: 0.7rem;
}
.contract-clauses ol {
  padding-left: 0;
  list-style: none;
  counter-reset: none;
}
.contract-clauses li {
  margin-bottom: 1.2rem;
}
.contract-clauses h3 {
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
}
.contract-clauses p {
  margin: 0;
  text-align: justify;
  color: var(--ink-2);
}
.contract-note {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  background: var(--accent-light);
  font-size: 0.86rem;
  margin-bottom: 1.6rem;
}
.contract-place {
  margin-bottom: 1.6rem;
}
.contract-signatures {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) {
  .contract-signatures {
    grid-template-columns: 1fr 1fr;
  }
}
.sig-role {
  font-weight: 700;
  margin: 0 0 0.2rem;
}
.sig-mention {
  font-size: 0.8rem;
  color: var(--ink-3);
  margin: 0 0 2.4rem;
}
.sig-line {
  border-bottom: 1px solid var(--ink-3);
  margin-bottom: 0.4rem;
}
.sig-name {
  font-size: 0.85rem;
  margin: 0;
}
.sig-date {
  font-size: 0.76rem;
  color: var(--brand);
  margin: 0.2rem 0 0;
}
.contract-footer {
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--ink-3);
}
.contract-footer p {
  margin: 0;
}
.receipt {
  max-width: 640px;
}

.clause-editor {
  max-width: 800px;
  margin-inline: auto;
}
.clause-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.9rem;
}
.clause-block legend {
  padding: 0 0.4rem;
}
.clause-block textarea {
  font-size: 0.88rem;
}

/* --- Signature ------------------------------------------------------------- */

.sign-state {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
}
@media (min-width: 640px) {
  .sign-state {
    grid-template-columns: 1fr 1fr;
  }
}
.sign-party {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.sign-party > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sign-check {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-4);
  font-weight: 800;
}
.sign-party.is-signed .sign-check {
  background: var(--brand);
  color: #fff;
}
.sign-thumb {
  height: 34px;
  margin-left: auto;
  opacity: 0.8;
}
.sign-box {
  max-width: 800px;
  margin-inline: auto;
}
.sign-pad-wrap {
  position: relative;
  margin: 0.8rem 0 1rem;
}
.sign-pad {
  width: 100%;
  height: 180px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: crosshair;
  touch-action: none;
}
.sign-pad.has-signature {
  border-style: solid;
  border-color: var(--brand);
}
.sign-pad-wrap .btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}
.sign-preview {
  max-height: 90px;
  margin-top: 0.6rem;
}

.doc-section {
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.doc-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
@media (min-width: 640px) {
  .doc-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}
.doc-icon {
  font-size: 1.5rem;
}
.doc-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.doc-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}
@media (min-width: 640px) {
  .doc-actions {
    grid-column: auto;
  }
}
.doc-upload .dropzone {
  padding: 1.6rem 1rem;
}
.doc-progress {
  margin-top: 0.7rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--brand-light);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--brand);
}

/* --- Carte ----------------------------------------------------------------- */

.carte {
  position: relative;
  height: 300px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}
.carte.is-dragging {
  cursor: grabbing;
}
.carte-tiles {
  position: absolute;
  inset: 0;
}
.carte-tile {
  position: absolute;
  top: 0;
  left: 0;
  width: 256px;
  height: 256px;
  max-width: none;
  pointer-events: none;
}
.carte-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  pointer-events: none;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}
.carte-controls {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-2);
}
.carte-controls button {
  width: 34px;
  height: 34px;
  border: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}
.carte-controls button:hover {
  background: var(--surface-2);
}
.carte-attribution {
  position: absolute;
  bottom: 0;
  right: 0;
  padding: 0.1rem 0.4rem;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  font-size: 0.66rem;
  color: var(--ink-3);
}
.carte-links {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
.carte-readout {
  margin-top: 0.5rem;
}
.map-picker {
  height: 280px;
  margin: 0.6rem 0;
}
.map-box {
  height: 300px;
}

/* --- Trésorerie ------------------------------------------------------------ */

.month-picker input {
  width: auto;
  border-radius: var(--radius-pill);
}

.budget-hero {
  display: grid;
  gap: 1.4rem;
  grid-template-columns: 1fr;
  padding: 1.4rem;
  margin-bottom: 1.2rem;
  border-left: 4px solid var(--brand);
}
@media (min-width: 720px) {
  .budget-hero {
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: center;
  }
}
.budget-hero.is-negative {
  border-left-color: var(--error);
}
.budget-solde {
  display: flex;
  flex-direction: column;
}
.budget-solde strong {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--brand);
}
.budget-hero.is-negative .budget-solde strong {
  color: var(--error);
}
.budget-bars {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.budget-bar {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  font-size: 0.86rem;
}
.bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--brand);
  transition: width var(--slow) var(--ease-out);
}
.bar-fill.is-income {
  background: var(--brand);
}
.bar-fill.is-expense {
  background: var(--accent);
}
.bar-fill.is-saving {
  background: #7c3aed;
}
.bar-fill.is-over {
  background: var(--error);
}

.budget-tips {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}
.budget-tip {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.9rem;
}
.budget-tip p {
  margin: 0;
}
.budget-tip.is-warning {
  background: var(--accent-light);
}
.budget-tip.is-success {
  background: var(--brand-light);
}

.quick-entry {
  padding: 1.2rem;
  margin-bottom: 1.6rem;
}
.quick-row {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
  align-items: end;
}
@media (min-width: 900px) {
  .quick-row {
    grid-template-columns: auto 130px 1fr 1fr auto;
  }
}
.direction-switch {
  display: flex;
  gap: 0.3rem;
}
.quick-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}
.chip-btn {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--fast) var(--ease);
}
.chip-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.envelope-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.envelope {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.envelope.is-over {
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
}
.envelope.is-saving {
  border-left: 3px solid #7c3aed;
}
.envelope-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.envelope-head > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.envelope-icon {
  font-size: 1.3rem;
}
.envelope-spent {
  margin-left: auto;
  font-weight: 800;
}
.envelope p {
  margin: 0.4rem 0 0;
}
.envelope-form {
  display: grid;
  gap: 0 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.is-suggestion {
  border-color: var(--brand);
  background: linear-gradient(160deg, var(--brand-light), var(--surface) 60%);
}

.movement-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.movement {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}
.movement-icon {
  font-size: 1.15rem;
}
.movement-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.movement-amount {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.movement.is-income .movement-amount {
  color: var(--brand);
}
.movement-auto {
  opacity: 0.5;
}

.history-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  height: 150px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.history-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  height: 100%;
  justify-content: flex-end;
}
.history-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
  width: 100%;
  justify-content: center;
}
.history-bar {
  width: 42%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: height var(--slow) var(--ease-out);
}
.history-bar.is-income {
  background: var(--brand);
}
.history-bar.is-expense {
  background: var(--accent);
}
.history-label {
  font-size: 0.7rem;
  color: var(--ink-3);
}

/* --- Impression du contrat -------------------------------------------------- */

@media print {
  .contract-toolbar,
  .sign-state,
  .sign-box,
  .doc-section,
  .clause-editor,
  .page-head,
  .calm-card {
    display: none !important;
  }
  .contract {
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: 100%;
  }
  .contract-wrap {
    padding: 0;
  }
}
