:root {
  --navy: #102a43;
  --navy-mid: #243b53;
  --or: #b08d57;
  --papier: #f4f1ea;
  --panneau: #fffcf7;
  --ligne: #d8d2c6;
  --texte: #102a43;
  --texte-doux: #627d98;
  --succes-fond: #f3f7f2;
  --succes-bord: #c5d5c4;
  --succes-texte: #2d4a32;
  --erreur-fond: #faf3f1;
  --erreur-bord: #e0c4bc;
  --erreur-texte: #7a3226;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--papier);
  color: var(--texte);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.barre {
  background: var(--navy);
  color: #f7f3ea;
  padding: 0 32px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--or);
}

.barre-marque {
  display: flex;
  align-items: center;
  gap: 14px;
}

.barre-sigle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--or);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--or);
}

.barre-titre {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.barre-sous {
  font-size: 0.72rem;
  color: #bcccdc;
  letter-spacing: 0.04em;
}

.barre-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.barre-session {
  font-size: 0.78rem;
  font-weight: 600;
}

.bouton-deco {
  margin-top: 4px;
  padding: 4px 10px;
  border: 1px solid var(--or);
  background: transparent;
  color: #f7f3ea;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-family: inherit;
  cursor: pointer;
}

.bouton-deco:hover { background: var(--navy-mid); }

.onglets {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  border-bottom: 1px solid var(--ligne);
}

.onglet {
  padding: 12px 16px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--texte-doux);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.onglet.actif {
  color: var(--navy);
  border-bottom-color: var(--or);
}

.badge-appels {
  display: inline-block;
  margin-left: 6px;
  min-width: 1.2em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--or);
  color: var(--navy);
  font-size: 0.72rem;
  line-height: 1.4;
  vertical-align: middle;
}

.appels-liste {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.appel-carte {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border: 1px solid var(--ligne);
  background: #fff;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

.appel-carte:hover { border-color: var(--or); }

.appel-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.appel-carte strong {
  display: block;
  font-size: 1rem;
}

.appel-etat {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0d6b4c;
  background: #e5f6ee;
  padding: 4px 8px;
}

.appel-note {
  padding: 0 18px 16px;
  display: grid;
  gap: 8px;
}

.onglet-court { display: none; }

.appel-carte p {
  margin: 0 0 4px;
  font-size: 0.84rem;
  color: var(--texte-doux);
}

.appel-wrap {
  border: 1px solid var(--ligne);
  background: #fff;
}

.appel-wrap .appel-carte { border: 0; }

.clients-liste {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.client-ligne {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--ligne);
  background: #fff;
  font-family: inherit;
  cursor: pointer;
}

.client-ligne:hover,
.client-ligne:focus {
  border-color: var(--navy-mid);
}

.client-ligne strong { font-size: 1rem; }

.client-ligne span {
  font-size: 0.78rem;
  color: var(--texte-doux);
}

.appel-mail {
  padding: 0 18px 16px;
  display: grid;
  gap: 8px;
}

.appel-mail label { font-size: 0.78rem; }

.mail-preview {
  background: #ece8e0;
  border: 1px solid var(--ligne);
  padding: 12px;
  font-size: 0.82rem;
  font-family: inherit;
  margin: 10px 0 0;
}

.mail-preview-meta {
  white-space: pre-wrap;
  margin: 0 0 10px;
  font-family: inherit;
  font-size: inherit;
  color: var(--texte-doux);
}

.mail-preview-html {
  display: block;
  width: 100%;
  min-height: 640px;
  height: 640px;
  margin: 0;
  border: 0;
  background: #efefef;
}

.mail-bloc { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--ligne); }

.form-smtp {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin: 18px 0 20px;
  align-items: end;
}

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

.form-smtp input[type="file"] {
  padding: 10px 0;
  border-bottom: 1px dashed #b8b2a6;
  cursor: pointer;
}

.form-smtp #smtp-import { margin-top: 12px; }

@media (max-width: 720px) {
  .form-smtp { grid-template-columns: 1fr; }
}

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

.login-carte {
  width: 100%;
  max-width: 420px;
  background: var(--panneau);
  border: 1px solid var(--ligne);
  padding: 36px 34px 32px;
}

.login-sigle { margin-bottom: 16px; }

.login-carte h1 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.login-actions { justify-content: stretch; border-top: 0; padding-top: 18px; }
.login-actions .bouton { width: 100%; }

.contenu.plein { grid-template-columns: 1fr; }

.panneau.large { padding: 28px 30px 32px; }

.filtres {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 18px 0 22px;
}

.form-inline {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
  margin: 18px 0 20px;
}

.form-inline-action { padding-bottom: 2px; }

@media (max-width: 720px) {
  .form-inline { grid-template-columns: 1fr; }
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.table-data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.table-data th,
.table-data td {
  text-align: left;
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--ligne);
  vertical-align: top;
}

.table-data th {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texte-doux);
  font-weight: 700;
}

.cell-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  white-space: nowrap;
  align-items: center;
}

.actions-vide {
  color: var(--texte-doux);
  font-weight: 500;
}

.cell-nip {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  font-weight: 650;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .barre {
    height: auto;
    min-height: 68px;
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .barre-meta { align-items: flex-start; }
  .onglets { padding: 0 12px; }
  .contenu {
    padding: 18px 12px 40px;
    gap: 16px;
  }
  .panneau,
  .panneau.large { padding: 18px 16px 22px; }
  .lien-ligne { flex-wrap: wrap; }

  .table-data thead { display: none; }
  .table-data,
  .table-data tbody,
  .table-data tr,
  .table-data td {
    display: block;
    width: 100%;
  }
  .table-data tr {
    border: 1px solid var(--ligne);
    background: #fff;
    margin-bottom: 12px;
    padding: 4px 12px 8px;
  }
  .table-data td {
    border-bottom: 1px solid var(--ligne);
    padding: 8px 0 8px 40%;
    position: relative;
    min-height: 2.2em;
  }
  .table-data td:last-child { border-bottom: 0; }
  .table-data td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 8px;
    width: 38%;
    color: var(--texte-doux);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .cell-actions { padding-left: 40%; }
}

.bouton-danger {
  padding: 8px 12px;
  border: 1px solid var(--erreur-texte);
  background: #fff;
  color: var(--erreur-texte);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.bouton-danger:hover { background: var(--erreur-fond); }

.barre-env {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--or);
}

.contenu {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 24px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  .contenu { grid-template-columns: 1fr; }
  .barre { padding: 0 18px; }
}

.panneau,
.carte-aside {
  background: var(--panneau);
  border: 1px solid var(--ligne);
  box-shadow: 0 1px 0 rgba(16, 42, 67, 0.04);
}

.panneau { padding: 32px 34px 36px; }
.carte-aside { padding: 22px 22px 24px; }

.panneau-entete {
  margin-bottom: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ligne);
}

.fil {
  margin: 0 0 6px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--or);
  font-weight: 600;
}

.panneau h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.aide {
  margin: 0;
  color: var(--texte-doux);
  font-size: 0.88rem;
  max-width: 46ch;
}

fieldset {
  border: 0;
  margin: 22px 0 0;
  padding: 0;
}

legend {
  padding: 0;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--navy);
}

.grille-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 520px) {
  .grille-2 { grid-template-columns: 1fr; }
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--texte-doux);
  margin: 14px 0 6px;
}

.optionnel {
  font-weight: 500;
  color: #9fb3c8;
}

input, select {
  width: 100%;
  padding: 9px 0 8px;
  border: 0;
  border-bottom: 1px solid #b8b2a6;
  border-radius: 0;
  background: transparent;
  color: var(--texte);
  font-size: 0.95rem;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-bottom-color: var(--navy);
  box-shadow: 0 1px 0 var(--navy);
}

.hint {
  margin: 10px 0 0;
  font-size: 0.75rem;
  color: var(--texte-doux);
}

.actions {
  margin-top: 32px;
  display: flex;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid var(--ligne);
}

.bouton {
  padding: 11px 22px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #f7f3ea;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: inherit;
  cursor: pointer;
}

.bouton:hover:not(:disabled) { background: var(--navy-mid); }
.bouton:disabled { opacity: 0.5; cursor: wait; }

.erreur,
.lien-box {
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid var(--erreur-bord);
  background: var(--erreur-fond);
  color: var(--erreur-texte);
  font-size: 0.88rem;
}

.lien-box {
  border-color: var(--succes-bord);
  background: var(--succes-fond);
  color: var(--succes-texte);
}

.lien-titre {
  margin: 0 0 2px;
  font-weight: 700;
}

.lien-texte {
  margin: 0;
  font-size: 0.8rem;
  color: var(--texte-doux);
}

.lien-ligne {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.lien-ligne input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--succes-bord);
  background: #fff;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.78rem;
}

.bouton-copie {
  padding: 8px 12px;
  border: 1px solid var(--navy);
  background: #fff;
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.bouton-copie:hover { background: var(--papier); }

.sms-bloc {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--succes-bord);
}

.sms-bloc label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--texte);
}

.sms-bloc label:first-child { margin-top: 0; }

.sms-bloc input,
.sms-bloc textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--succes-bord);
  background: #fff;
  font-family: inherit;
  font-size: 0.84rem;
}

.sms-bloc textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.4;
}

.sms-bloc .hint {
  margin: 8px 0 0;
}

.sms-bloc .erreur {
  margin-top: 10px;
}

.sms-ok {
  margin: 10px 0 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--succes-texte);
}

.aside {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.carte-aside h2 {
  margin: 0 0 14px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--or);
}

.apple-map {
  position: relative;
  height: 220px;
  border: 1px solid var(--ligne);
  background: #e7eef2;
  overflow: hidden;
}

.apple-map iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.apple-map a {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--ligne);
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
}

.recap-vide {
  color: var(--texte-doux);
  font-size: 0.85rem;
}

.recap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.recap-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--ligne);
  vertical-align: top;
}

.recap-table tr:last-child td { border-bottom: none; }
.recap-table td:first-child { color: var(--texte-doux); width: 38%; }

[hidden] { display: none !important; }

/* Mini-app Telegram : barre du bas, cibles tactiles, champs pleine largeur */
body.telegram-miniapp {
  font-size: 16px;
}
body.telegram-miniapp #ecran-app {
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 12px));
}
body.telegram-miniapp .barre {
  height: auto;
  min-height: 52px;
  padding: 10px 14px;
}
body.telegram-miniapp .barre-sous,
body.telegram-miniapp .barre-deco { display: none; }
body.telegram-miniapp .bouton-deco { min-height: 44px; }
body.telegram-miniapp .onglets {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-around;
  gap: 0;
  margin: 0;
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 10px));
  background: #fff;
  border-top: 1px solid var(--ligne);
  box-shadow: 0 -6px 20px rgba(20, 28, 45, 0.08);
  overflow: visible;
}
body.telegram-miniapp .onglet-long { display: none; }
body.telegram-miniapp .onglet-court { display: block; }
body.telegram-miniapp .onglet {
  flex: 1 1 0;
  min-height: 56px;
  min-width: 0;
  padding: 8px 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  border-radius: 10px;
}
body.telegram-miniapp main.contenu:not(.vue-on) {
  display: none !important;
}
body.telegram-miniapp main.contenu.vue-on {
  display: grid;
  grid-template-columns: 1fr;
}
body.telegram-miniapp #vue-nouvelle .aside {
  display: none;
}
body.telegram-miniapp .contenu {
  padding: 12px;
  width: 100%;
  max-width: 100%;
}
body.telegram-miniapp .mail-preview-html {
  min-height: 72vh;
  height: 72vh;
}
body.telegram-miniapp .panneau,
body.telegram-miniapp .grille-2,
body.telegram-miniapp .form-inline,
body.telegram-miniapp .form-smtp,
body.telegram-miniapp fieldset {
  width: 100%;
  max-width: 100%;
}
body.telegram-miniapp .grille-2 { grid-template-columns: 1fr; }
body.telegram-miniapp input,
body.telegram-miniapp select,
body.telegram-miniapp textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 52px;
  font-size: 1.05rem;
  padding: 14px 12px;
}
body.telegram-miniapp textarea { min-height: 96px; }
body.telegram-miniapp .bouton,
body.telegram-miniapp .bouton-copie,
body.telegram-miniapp .bouton-danger,
body.telegram-miniapp .bouton-deco {
  min-height: 52px;
  padding: 16px 20px;
  font-size: 1.05rem;
  width: 100%;
}
body.telegram-miniapp .lien-ligne {
  display: grid;
  gap: 10px;
}
body.telegram-miniapp .aside .apple-map { display: none; }
body.telegram-miniapp .login-carte { width: 100%; max-width: none; margin: 0; border-radius: 0; }
body.telegram-miniapp .ecran-login { padding: 16px; align-items: flex-start; }
body.telegram-miniapp .appel-carte { padding: 18px 16px; }
body.telegram-miniapp .table-scroll { margin: 0 -4px; }
