:root {
  --rouge: #a31b2a;
  --rouge-fonce: #7a1220;
  --marine: #1a2340;
  --or: #c9a84c;
  --blanc: #f8f5f0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--marine);
  background-image:
    radial-gradient(ellipse at 10% 20%, rgba(163,27,42,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 80%, rgba(201,168,76,0.08) 0%, transparent 50%);
  color: var(--blanc);
  font-family: 'DM Sans', sans-serif;
  margin: 0;
  padding: 24px;
  min-height: 100vh;
}

.header {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 28px; padding-bottom: 20px;
  border-bottom: 1px solid rgba(201,168,76,0.3);
  justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 18px; }
.logo-svg {
  width: 54px; height: 54px; border-radius: 12px; background: white;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 1px rgba(201,168,76,0.3); overflow: hidden;
}
.header-text h1 {
  font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700;
  color: var(--blanc); letter-spacing: 0.01em; line-height: 1.1;
}
.header-text span {
  font-size: 11px; font-weight: 400; color: var(--or);
  letter-spacing: 0.15em; text-transform: uppercase;
}
.gold-line {
  height: 2px; background: linear-gradient(90deg, var(--or), transparent);
  margin-top: 4px; width: 120px;
}

#ecranLogin {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 420px; gap: 20px;
}
#ecranLogin .card { width: 320px; }
#ecranLogin h2 {
  font-family: 'Playfair Display', serif; font-size: 18px;
  color: var(--or); letter-spacing: 0.04em; text-align: center; margin-bottom: 16px;
}

#ecranChoixDoc {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 420px; gap: 32px;
}
#ecranChoixDoc h2 {
  font-family: 'Playfair Display', serif; font-size: 20px;
  color: var(--or); letter-spacing: 0.06em; text-align: center;
}
.choix-grid { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.choix-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px; padding: 28px 32px;
  cursor: pointer; text-align: center;
  transition: all 0.25s; min-width: 180px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.choix-card:hover {
  border-color: rgba(201,168,76,0.5);
  background: rgba(201,168,76,0.07);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.choix-card .icon { font-size: 36px; line-height: 1; }
.choix-card .label { font-family: 'Playfair Display', serif; font-size: 15px; font-weight: 700; color: var(--blanc); letter-spacing: 0.04em; }
.choix-card .sublabel { font-size: 11px; color: rgba(248,245,240,0.45); letter-spacing: 0.08em; text-transform: uppercase; }

#ecranFormulaire { display: none; }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.07); color: var(--blanc);
  padding: 7px 14px; border-radius: 8px; font-size: 12px;
  font-weight: 500; border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer; transition: all 0.2s; margin-bottom: 16px;
  font-family: 'DM Sans', sans-serif;
}
.back-btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(201,168,76,0.3); }

.doc-type-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(201,168,76,0.12); border: 1px solid rgba(201,168,76,0.35);
  border-radius: 999px; padding: 5px 16px; font-size: 12px;
  font-weight: 700; color: var(--or); letter-spacing: 0.1em;
  text-transform: uppercase; margin-bottom: 20px;
}

.card {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; padding: 20px; margin-bottom: 16px;
  transition: border-color 0.2s; animation: fadeUp 0.3s ease both;
}
.card:hover { border-color: rgba(201,168,76,0.2); }
.card-title {
  font-family: 'Playfair Display', serif; font-size: 14px;
  font-weight: 600; color: var(--or); letter-spacing: 0.08em;
  text-transform: uppercase; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.card-title::before { content: ''; display: inline-block; width: 3px; height: 14px; background: var(--or); border-radius: 2px; }

.saved-row { display: flex; gap: 10px; align-items: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; flex: 1; min-width: calc(33.33% - 10px); }
.field label { font-size: 10px; font-weight: 600; color: var(--or); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 6px; }

input, select, textarea {
  padding: 9px 12px; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; width: 100%; background: rgba(255,255,255,0.07);
  color: var(--blanc); font-family: 'DM Sans', sans-serif;
  font-size: 13px; transition: all 0.2s; outline: none;
}
input::placeholder { color: rgba(248,245,240,0.3); }
input:focus, select:focus {
  border-color: rgba(201,168,76,0.5);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.08);
}
select option { background: var(--marine); color: var(--blanc); }
input[readonly] { color: rgba(248,245,240,0.45); cursor: not-allowed; }

button { cursor: pointer; font-family: 'DM Sans', sans-serif; border: none; }

.btn-gold {
  background: linear-gradient(135deg, var(--or), #a8832a);
  color: var(--marine); padding: 10px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
  transition: all 0.2s; box-shadow: 0 2px 12px rgba(201,168,76,0.3); width: 100%;
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(201,168,76,0.5); }

.btn-ghost {
  background: rgba(255,255,255,0.07); color: var(--blanc);
  padding: 8px 14px; border-radius: 8px; font-size: 12px;
  font-weight: 500; border: 1px solid rgba(255,255,255,0.12); transition: all 0.2s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); border-color: rgba(201,168,76,0.3); }

.btn-preview {
  background: rgba(201,168,76,0.12); color: var(--or);
  padding: 10px 18px; border-radius: 8px; font-size: 13px;
  font-weight: 600; border: 1px solid rgba(201,168,76,0.35);
  transition: all 0.2s; letter-spacing: 0.02em;
}
.btn-preview:hover { background: rgba(201,168,76,0.22); border-color: rgba(201,168,76,0.6); transform: translateY(-1px); }

.btn-danger {
  background: rgba(163,27,42,0.3); color: #ff8a96;
  padding: 6px 10px; border-radius: 6px; font-size: 12px;
  border: 1px solid rgba(163,27,42,0.4); transition: all 0.2s;
}
.btn-danger:hover { background: rgba(163,27,42,0.6); color: white; }

table { width: 100%; border-collapse: separate; border-spacing: 0 4px; margin-top: 10px; }
thead tr th {
  padding: 8px 10px; font-size: 10px; font-weight: 600;
  color: var(--or); letter-spacing: 0.1em; text-transform: uppercase;
  text-align: left; background: transparent;
  border-bottom: 1px solid rgba(201,168,76,0.2);
}
tbody tr td { padding: 4px 4px; background: rgba(255,255,255,0.04); }
tbody tr td:first-child { border-radius: 8px 0 0 8px; padding-left: 8px; }
tbody tr td:last-child { border-radius: 0 8px 8px 0; padding-right: 8px; }
tbody tr td input {
  background: transparent; border: none;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  border-radius: 0; padding: 6px 4px; font-size: 12px;
}
tbody tr td input:focus { border-bottom-color: var(--or); background: transparent; box-shadow: none; }

#acompteForm table th:nth-child(1), #acompteForm table td:nth-child(1) { width: 43%; }
#acompteForm table th:nth-child(2), #acompteForm table td:nth-child(2) { width: 10%; }
#acompteForm table th:nth-child(3), #acompteForm table td:nth-child(3) { width: 15%; }
#acompteForm table th:nth-child(4), #acompteForm table td:nth-child(4) { width: 10%; }
#acompteForm table th:nth-child(5), #acompteForm table td:nth-child(5) { width: 15%; }
#acompteForm table th:nth-child(6), #acompteForm table td:nth-child(6) { width: 7%; }

#intermediaireForm table th:nth-child(1), #intermediaireForm table td:nth-child(1),
#finaleForm table th:nth-child(1), #finaleForm table td:nth-child(1) { width: 50%; }
#intermediaireForm table th:nth-child(2), #intermediaireForm table td:nth-child(2),
#finaleForm table th:nth-child(2), #finaleForm table td:nth-child(2) { width: 20%; }
#intermediaireForm table th:nth-child(3), #intermediaireForm table td:nth-child(3),
#finaleForm table th:nth-child(3), #finaleForm table td:nth-child(3) { width: 20%; }
#intermediaireForm table th:nth-child(4), #intermediaireForm table td:nth-child(4),
#finaleForm table th:nth-child(4), #finaleForm table td:nth-child(4) { width: 10%; }

.hidden { display: none !important; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.right { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(201,168,76,0.2), transparent); margin: 6px 0 14px; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; background: rgba(201,168,76,0.15);
  color: var(--or); border: 1px solid rgba(201,168,76,0.3);
  margin-left: 8px; vertical-align: middle;
}

.ui-datepicker { font-family: 'DM Sans', sans-serif !important; font-size: 12px !important; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

#modalOverlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(10, 15, 30, 0.82); backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
}
#modalOverlay.open { display: flex; }
#modalBox {
  background: #1e2c4a; border: 1px solid rgba(201,168,76,0.3); border-radius: 20px;
  width: 780px; max-width: 96vw; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6); animation: fadeUp 0.25s ease;
}
#modalHeader { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px 14px; border-bottom: 1px solid rgba(201,168,76,0.2); flex-shrink: 0; }
#modalHeader h2 { font-family: 'Playfair Display', serif; font-size: 17px; font-weight: 700; color: var(--or); letter-spacing: 0.04em; }
#modalClose { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); color: var(--blanc); border-radius: 8px; padding: 5px 11px; font-size: 16px; cursor: pointer; transition: all 0.2s; line-height: 1; }
#modalClose:hover { background: rgba(163,27,42,0.4); border-color: rgba(163,27,42,0.5); }
#modalBody { overflow-y: auto; padding: 22px 24px; flex: 1; }
#modalBody::-webkit-scrollbar { width: 5px; }
#modalBody::-webkit-scrollbar-track { background: transparent; }
#modalBody::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.3); border-radius: 4px; }

.facture-sheet { background: white; color: #1a1a1a; border-radius: 10px; padding: 32px 36px; font-family: 'DM Sans', sans-serif; font-size: 12px; line-height: 1.5; box-shadow: 0 4px 30px rgba(0,0,0,0.4); }
.fs-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid #a31b2a; }
.fs-logo-block { display: flex; flex-direction: column; gap: 3px; }
.fs-logo-name { font-family: 'Playfair Display', serif; font-size: 15px; font-weight: 700; color: #a31b2a; }
.fs-logo-sub { font-size: 9px; color: #666; letter-spacing: 0.06em; text-transform: uppercase; }
.fs-num { font-size: 13px; font-weight: 700; color: #1a2340; letter-spacing: 0.04em; }
.fs-type-badge { display: inline-block; background: #a31b2a; color: white; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; padding: 4px 14px; border-radius: 4px; margin: 12px 0; }
.fs-two-col { display: flex; gap: 24px; margin-bottom: 20px; }
.fs-client-block, .fs-meta-block { flex: 1; background: #f8f5f0; border-radius: 8px; padding: 12px 14px; }
.fs-section-label { font-size: 9px; font-weight: 700; color: #a31b2a; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 6px; }
.fs-client-name { font-size: 13px; font-weight: 700; color: #1a2340; margin-bottom: 2px; }
.fs-client-detail { font-size: 11px; color: #555; }
.fs-meta-row { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; }
.fs-meta-row span:first-child { color: #888; }
.fs-meta-row span:last-child { font-weight: 600; color: #1a2340; }
.fs-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 11px; }
.fs-table thead th { background: #1a2340; color: white; padding: 7px 10px; text-align: left; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }
.fs-table thead th:last-child { text-align: right; }
.fs-table tbody tr { border-bottom: 1px solid #eee; }
.fs-table tbody tr:nth-child(even) { background: #fafafa; }
.fs-table tbody tr.deduction { background: #fff5f5; color: #a31b2a; font-weight: 600; }
.fs-table tbody td { padding: 7px 10px; }
.fs-table tbody td:last-child { text-align: right; font-weight: 600; }
.fs-totaux { display: flex; justify-content: flex-end; margin-top: 8px; }
.fs-totaux-box { min-width: 240px; }
.fs-total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 11px; border-bottom: 1px solid #eee; }
.fs-total-row span:first-child { color: #666; }
.fs-total-row span:last-child { font-weight: 600; color: #1a2340; }
.fs-total-ttc { display: flex; justify-content: space-between; align-items: center; background: #1a2340; color: white; border-radius: 6px; padding: 9px 12px; margin-top: 6px; }
.fs-total-ttc span:first-child { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }
.fs-total-ttc span:last-child { font-size: 15px; font-weight: 700; }
.fs-montant-lettre { margin-top: 10px; font-size: 10px; color: #555; font-style: italic; text-align: right; }
.fs-warning { background: #fff8e1; border: 1px solid #f0c040; border-radius: 8px; padding: 10px 14px; font-size: 11px; color: #7a5900; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

#modalFooter { padding: 14px 24px 18px; border-top: 1px solid rgba(201,168,76,0.2); display: flex; gap: 10px; justify-content: flex-end; flex-shrink: 0; }

/* ===== ADMIN ===== */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-tab {
  background: rgba(255,255,255,0.05); color: var(--blanc);
  padding: 9px 16px; border-radius: 8px; font-size: 12px;
  font-weight: 600; border: 1px solid rgba(255,255,255,0.1);
  letter-spacing: 0.04em; transition: all 0.2s;
}
.admin-tab.active { background: rgba(201,168,76,0.18); border-color: rgba(201,168,76,0.5); color: var(--or); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; }
.data-table th { text-align: left; padding: 8px 10px; color: var(--or); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px solid rgba(201,168,76,0.2); }
.data-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.data-table a { color: var(--or); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.muted { color: rgba(248,245,240,0.45); font-size: 11px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  background: #1e2c4a; border: 1px solid rgba(201,168,76,0.4); color: var(--blanc);
  padding: 12px 18px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4); max-width: 320px;
}
