/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --white: #ffffff;
  --primary: #1a3a6b;
  --primary-light: #2d5492;
  --accent: #e8721a;
  --accent-light: #fff4ec;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --danger: #e11d48;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 4px 20px -2px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 36px -4px rgba(15,23,42,.14);
  --header-h: 60px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset & base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
input, button, textarea, select { font-family: inherit; font-size: inherit; }

/* ── Auth ───────────────────────────────────────────────────────────────────── */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  position: relative;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #0d2247 0%, #1a3a6b 60%, #1e4d8c 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.logo-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.logo-text  { font-size: 28px; font-weight: 700; color: var(--primary); letter-spacing: -1px; }
.logo-sub   { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Tabs */
.tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}
.tab {
  flex: 1;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.tab.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

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

/* ── Form elements ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--primary); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus, .field select:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(26,26,46,.08);
}
.field input::placeholder { color: #b0b7c3; }
.req { color: var(--accent); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-primary:active { transform: scale(.98); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-full { width: 100%; }
.btn-lg { padding: 15px 20px; font-size: 16px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.alert-error, .alert-danger { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: var(--success-bg); color: #047857; border: 1px solid #6ee7b7; }

/* ── App layout ─────────────────────────────────────────────────────────────── */
.app-layout { display: flex; flex-direction: column; min-height: 100dvh; }

.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.header-inner {
  height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 640px; margin: 0 auto; width: 100%;
}
.header-right { display: flex; align-items: center; gap: 8px; }
.header-title { font-size: 17px; font-weight: 700; color: var(--primary); }
.logo-text-sm { font-size: 20px; font-weight: 700; color: var(--primary); letter-spacing: -.5px; }
.user-chip {
  background: var(--accent-light); color: var(--accent);
  font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px;
}

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: transparent; border: none; cursor: pointer;
  color: var(--primary); transition: background .15s;
}
.icon-btn:hover { background: var(--bg); }

.app-main {
  flex: 1;
  max-width: 640px; width: 100%;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

/* ── KPI Banner ─────────────────────────────────────────────────────────────── */
.kpi-banner {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--primary); letter-spacing: -1px; }

/* ── Accord list ─────────────────────────────────────────────────────────────── */
.section-title { font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.accord-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.accord-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .15s;
}
.accord-card:hover { box-shadow: var(--shadow); }
.accord-card:active { transform: scale(.99); }

.accord-card-left { display: flex; align-items: center; gap: 12px; }
.accord-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.accord-type-badge {
  padding: 5px 11px; border-radius: 99px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 4px;
}
.accord-type-badge.dette { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.accord-type-badge.vente { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.accord-type-badge.achat { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }

.accord-name { font-size: 15px; font-weight: 600; color: var(--text); }
.accord-designation { font-size: 12px; color: #475569; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.accord-date { font-size: 12px; color: var(--muted); }
.accord-amount { font-size: 16px; font-weight: 700; color: var(--primary); }
.accord-status {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; text-transform: capitalize;
}
.accord-status.signé { background: var(--success-bg); color: var(--success); }
.accord-status.brouillon { background: #fff7ed; color: var(--warning); }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  background: var(--surface); border-radius: var(--radius);
  border: 2px dashed var(--border);
}
.empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { color: var(--muted); }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* ── FAB ────────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: 28px; right: 24px; z-index: 100;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(233,69,96,.45);
  transition: transform .2s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { transform: scale(1.07); box-shadow: 0 6px 28px rgba(233,69,96,.55); }
.fab:active { transform: scale(.96); }
.fab-mobile { display: none; }
@media (max-width: 768px) { .fab-mobile { display: flex; } }

/* ── Form (new agreement) ───────────────────────────────────────────────────── */
.form-main { padding-bottom: 40px; }
.accord-form { display: flex; flex-direction: column; gap: 20px; }

.form-section {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 14px;
}
.form-section-title { font-size: 16px; font-weight: 700; color: var(--primary); }

/* Type selector */
.type-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 520px) { .type-selector { grid-template-columns: 1fr; } }
.type-option input { display: none; }
.type-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 18px 10px;
  background: var(--bg); border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer; text-align: center; transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}
.type-card:hover { border-color: #cbd5e1; background: #f8fafc; }
.type-card.selected, .type-option input:checked + .type-card {
  border-color: var(--primary); background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(26,58,107,.08);
}
.type-icon { font-size: 28px; color: var(--primary); }
.type-label { font-size: 13px; font-weight: 700; line-height: 1.3; color: var(--primary); }

/* Stepper */
.stepper {
  display: flex; align-items: center; gap: 0;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; width: fit-content;
}
.stepper-btn {
  width: 44px; height: 44px; background: transparent; border: none;
  font-size: 20px; font-weight: 400; cursor: pointer; color: var(--primary);
  transition: background .15s;
  display: flex; align-items: center; justify-content: center;
}
.stepper-btn:hover { background: var(--border); }
.stepper input {
  width: 56px; text-align: center; border: none !important;
  background: transparent !important; font-weight: 700 !important;
  font-size: 16px !important; padding: 0 !important;
  box-shadow: none !important;
}

/* Schedule preview */
.schedule-preview { background: var(--bg); border-radius: var(--radius-sm); padding: 14px; }
.schedule-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.schedule-table, .schedule-preview-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.schedule-table th, .schedule-preview-table th {
  text-align: left; padding: 8px 12px;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
}
.schedule-table th:first-child, .schedule-preview-table th:first-child { border-radius: 8px 0 0 0; }
.schedule-table th:last-child, .schedule-preview-table th:last-child { border-radius: 0 8px 0 0; text-align: right; }
.schedule-table td:last-child, .schedule-preview-table td:last-child { text-align: right; }
.schedule-table td, .schedule-preview-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.schedule-table tr:last-child td, .schedule-preview-table tr:last-child td { border-bottom: none; }
.schedule-table tr:nth-child(even) td, .schedule-preview-table tr:nth-child(even) td { background: rgba(15,23,42,.02); }
.schedule-table tr.paid td { color: var(--success); background: rgba(16,185,129,.04); }

.form-actions { padding: 8px 0; }

/* ── Sign page ──────────────────────────────────────────────────────────────── */
.sign-main { padding-bottom: 40px; }

.summary-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px;
}
.summary-row { display: flex; justify-content: space-between; align-items: center; }
.summary-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.summary-val { font-size: 14px; font-weight: 600; color: var(--text); text-align: right; max-width: 60%; }
.summary-amount { font-size: 20px; font-weight: 700; color: var(--primary); }

.sig-section { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }

.sig-block {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 18px 14px; box-shadow: var(--shadow-sm);
}
.sig-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin-bottom: 4px;
}
.sig-name { font-size: 15px; font-weight: 600; color: var(--primary); margin-bottom: 12px; }

.canvas-wrapper {
  position: relative; border-radius: var(--radius-sm);
  border: 2px dashed var(--border); overflow: hidden; cursor: crosshair;
  background: #fafafa;
}
.canvas-wrapper:hover { border-color: var(--primary); }
.sig-canvas { display: block; width: 100%; touch-action: none; }
.canvas-hint {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 13px; color: #b0b7c3; pointer-events: none;
  transition: opacity .2s; white-space: nowrap;
}

.sig-divider {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; color: var(--muted); font-size: 14px; font-weight: 500;
}
.sig-divider::before, .sig-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.sign-actions { display: flex; flex-direction: column; gap: 12px; }
.legal-notice { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }

.rgpd-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  cursor: pointer;
  margin-bottom: 4px;
}
.rgpd-check input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}
.rgpd-check a { color: var(--primary); text-decoration: underline; }

.form-section-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: -4px 0 10px;
  line-height: 1.45;
}

/* Loader */
.loader-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(26,26,46,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.loader-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 36px 48px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  box-shadow: var(--shadow-lg);
}
.loader-card p { font-size: 15px; font-weight: 500; color: var(--muted); max-width: 220px; line-height: 1.5; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Detail page ────────────────────────────────────────────────────────────── */
.detail-main { padding-bottom: 40px; display: flex; flex-direction: column; gap: 14px; }

.status-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
}
.status-banner.signé { background: var(--success-bg); color: var(--success); }
.status-banner.brouillon { background: #fff7ed; color: var(--warning); }
.status-banner.relecture { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.status-banner.paiement_requis { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }

.detail-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 6px;
}
.detail-section-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }
.detail-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.detail-meta { font-size: 13px; color: var(--muted); }
.parties-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.big-amount { font-size: 32px; font-weight: 700; color: var(--primary); letter-spacing: -1.5px; }
.amount-words { font-style: italic; margin-top: 2px; }

.sigs-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sig-preview-block { display: flex; flex-direction: column; gap: 6px; }
.sig-img { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-xs); background: #fafafa; }

/* ── Flash messages ─────────────────────────────────────────────────────────── */
.flash-stack {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 300; width: min(calc(100vw - 32px), 480px);
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.flash {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  pointer-events: all; animation: slideDown .25s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-12px); } to { opacity:1; transform:translateY(0); } }
.flash-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid #6ee7b7; }
.flash-error   { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.flash-close {
  background: none; border: none; font-size: 18px; line-height: 1;
  cursor: pointer; color: inherit; opacity: .6; padding: 0 2px; flex-shrink: 0;
}
.flash-close:hover { opacity: 1; }

/* ── Premium card ────────────────────────────────────────────────────────────── */
.premium-card {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff; border-radius: var(--radius); padding: 20px;
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.premium-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.premium-badge {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.2);
  padding: 4px 12px; border-radius: 99px; font-size: 13px; font-weight: 700;
}
.premium-price { font-size: 16px; font-weight: 700; opacity: .9; }
.premium-desc { font-size: 14px; line-height: 1.5; opacity: .85; margin-bottom: 12px; }
.premium-features {
  list-style: none; margin-bottom: 16px; display: flex; flex-direction: column; gap: 4px;
}
.premium-features li { font-size: 13px; opacity: .8; }
.btn-premium {
  background: var(--accent); color: #fff; padding: 13px 20px;
  border-radius: var(--radius-sm); font-size: 15px; font-weight: 700; border: none; cursor: pointer;
  transition: opacity .2s; display: flex; align-items: center; justify-content: center;
}
.btn-premium:hover { opacity: .9; }

.premium-active-banner {
  display: flex; align-items: center; gap: 8px;
  background: var(--success-bg); color: var(--success);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; margin-bottom: 20px;
  border: 1px solid #6ee7b7;
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(26,26,46,.65); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 480px) { .modal-overlay { align-items: center; } }
.modal-card {
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  padding: 28px 24px 32px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg); text-align: center;
}
@media (min-width: 480px) { .modal-card { border-radius: var(--radius); } }
.modal-icon { font-size: 36px; margin-bottom: 10px; }
.modal-title { font-size: 20px; font-weight: 700; color: var(--primary); margin-bottom: 10px; }
.modal-body { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.modal-actions .btn { min-width: 120px; }

/* ── Danger zone ─────────────────────────────────────────────────────────────── */
.danger-zone { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 8px; }
.btn-danger {
  background: #fff1f2; color: #be123c;
  border: 1.5px solid #fecdd3;
}
.btn-danger:hover { background: #ffe4e6; }
.btn-danger:active { transform: scale(.98); }

/* ── PDF button group ────────────────────────────────────────────────────────── */
.pdf-btn-group { display: flex; align-items: center; gap: 4px; }

/* ── Sale object display ─────────────────────────────────────────────────────── */
.sale-object-tag {
  font-size: 13px; color: var(--primary);
  background: #eff6ff; border: 1px solid #bfdbfe;
  padding: 6px 10px; border-radius: var(--radius-xs);
  margin: 6px 0 4px;
}
.sale-obj-label { font-weight: 700; color: #1d4ed8; }

/* ── Editable schedule ───────────────────────────────────────────────────────── */
.schedule-editable .inst-num { font-weight: 600; color: var(--muted); text-align: center; }
.schedule-input {
  width: 100%; padding: 7px 9px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-xs); font-size: 13px; color: var(--text);
  outline: none; transition: border-color .15s;
  -webkit-appearance: none; appearance: none;
}
.schedule-input:focus { border-color: var(--primary); }
.schedule-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 0; font-size: 13px; color: var(--muted);
}
.schedule-sum-val { font-weight: 700; color: var(--primary); }
.schedule-diff {
  padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700;
}
.schedule-diff.over  { background: #fff1f2; color: #be123c; }
.schedule-diff.under { background: #fff7ed; color: #b45309; }

/* ── Field hint ─────────────────────────────────────────────────────────────── */
.field-hint { font-size: 12px; color: var(--muted); }

/* ── Upsell post-sign modal ──────────────────────────────────────────────────── */
.upsell-card { padding: 24px 20px 28px; }
.upsell-check-circle {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--success-bg); color: var(--success);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; margin: 0 auto 12px;
  border: 2px solid #6ee7b7;
}
.upsell-tier {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.upsell-tier.free { background: var(--success-bg); border: 1px solid #6ee7b7; }
.upsell-tier.paid { background: #fff7ed; border: 1px solid #fed7aa; flex-direction: column; gap: 6px; }
.tier-badge {
  padding: 3px 12px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: var(--success); color: #fff;
}
.tier-badge.paid { background: #f97316; }
.tier-desc { font-size: 13px; color: var(--muted); text-align: center; }
.tier-price { font-size: 28px; font-weight: 800; color: #f97316; letter-spacing: -1px; }

.reminder-upsell {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 14px;
}
.reminder-upsell.is-active { border-color: var(--success); background: var(--success-bg); }
.reminder-upsell-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.reminder-upsell-info { flex: 1; padding-right: 8px; }
.reminder-upsell-title { font-size: 14px; font-weight: 700; color: var(--primary); }
.reminder-upsell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.reminder-price-tag {
  background: var(--primary); color: #fff;
  padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.reminder-active-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge-active {
  background: var(--success-bg); color: var(--success);
  padding: 4px 12px; border-radius: 99px; font-size: 12px; font-weight: 700; border: 1px solid #6ee7b7;
}
.upsell-skip { margin-top: 4px; font-size: 13px; }

/* ── Settings page ───────────────────────────────────────────────────────────── */
.settings-main { padding-bottom: 40px; }
.settings-avatar-block {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 0 4px;
}
.settings-avatar {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; flex-shrink: 0;
}
.settings-name { font-size: 17px; font-weight: 700; color: var(--primary); }
.settings-email-chip { font-size: 13px; color: var(--muted); margin-top: 2px; }

.settings-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; margin-top: 16px; box-shadow: var(--shadow);
}
.settings-card-danger { background: transparent; box-shadow: none; padding: 0; margin-top: 12px; }
.settings-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--primary);
  margin-bottom: 16px;
}
.settings-error {
  background: #fff1f2; color: #be123c; border: 1px solid #fecdd3;
  padding: 10px 14px; border-radius: var(--radius-xs); font-size: 13px;
  margin-bottom: 14px;
}
.settings-info-text { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 6px; }

.input-pw-wrapper { position: relative; }
.input-pw-wrapper input { padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer; opacity: .5;
  display: flex; align-items: center; padding: 4px;
}
.pw-toggle:hover { opacity: 1; }

/* ── Utility ────────────────────────────────────────────────────────────────── */
/* ── Status: en attente ──────────────────────────────────────────────────────── */
.status-banner.en_attente {
  background: #fffbeb; color: #b45309;
  border: 1px solid #fde68a;
}
.accord-status.en_attente {
  background: #fffbeb; color: #b45309; border-color: #fde68a;
}

/* ── Waiting block (detail page) ─────────────────────────────────────────────── */
.waiting-block {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
}
.waiting-info {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #92400e; margin-bottom: 10px; font-weight: 500;
}

/* ── Sign-next info banner ───────────────────────────────────────────────────── */
.sign-next-info {
  display: flex; align-items: flex-start; gap: 10px;
  background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 13px; color: #166534; margin: 16px 0 0;
}

/* ── Debtor link box (detail page) ──────────────────────────────────────────── */
.debtor-link-box {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin: 10px 0;
}
.link-copy-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.link-input {
  flex: 1; font-size: 11px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 10px; font-family: monospace; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-share-row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn-wa { color: #128c7e !important; }
.btn-wa:hover { background: #e7f9f4 !important; }
.debtor-link-hint { font-size: 11px; color: var(--muted); }

/* ── Debtor sign page ────────────────────────────────────────────────────────── */
.debtor-invite-banner {
  background: #f0f9ff; border: 1px solid #bae6fd;
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
  font-size: 14px; color: #0c4a6e;
}
.debtor-invite-sub { font-size: 12px; color: #0369a1; margin-top: 4px; }

.debtor-error-card, .debtor-success-card {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 40px 20px;
}
.debtor-error-icon, .debtor-success-icon {
  font-size: 44px; margin-bottom: 16px;
}
.debtor-success-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--success-bg); color: var(--success);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; border: 2px solid #6ee7b7;
  margin-bottom: 16px;
}
.debtor-error-title, .debtor-success-title { font-size: 22px; font-weight: 800; color: var(--primary); margin-bottom: 10px; }
.debtor-error-body, .debtor-success-body { font-size: 14px; color: var(--muted); line-height: 1.6; }
.debtor-success-note { font-size: 12px; color: var(--muted); margin-top: 12px; font-style: italic; }

/* ── Payment modal ──────────────────────────────────────────────────────────── */
.upsell-payment-icon { font-size: 40px; text-align: center; margin-bottom: 12px; }
.upsell-payment-sub { font-size: 14px; color: var(--muted); text-align: center; line-height: 1.6; margin-bottom: 16px; }
.upsell-price-row { display: flex; align-items: baseline; gap: 6px; justify-content: center; margin-bottom: 16px; }
.upsell-price-big { font-size: 44px; font-weight: 900; color: var(--primary); letter-spacing: -2px; }
.upsell-price-unit { font-size: 16px; color: var(--muted); }
.upsell-features { list-style: none; display: grid; gap: 8px; margin-bottom: 20px; padding: 14px; background: var(--bg); border-radius: var(--radius-sm); }
.upsell-features li { font-size: 13px; color: var(--text); }
.upsell-features li::before { content: '✓ '; color: var(--success); font-weight: 700; }
.btn-danger-ghost { background: transparent; border: 1.5px solid #fca5a5; color: #dc2626; }
.btn-danger-ghost:hover { background: #fff1f2; border-color: #dc2626; }

/* ── Logo image ──────────────────────────────────────────────────────────── */
.auth-logo-img { height: 100px; object-fit: contain; margin-bottom: 4px; }
.header-logo-img { height: 44px; object-fit: contain; }

.hidden { display: none !important; }

/* ── App footer ─────────────────────────────────────────────────────────────── */
/* ── Auth back link ──────────────────────────────────────────────────────────── */
.auth-back-link {
  position: absolute; top: 20px; left: 20px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,.7);
  text-decoration: none; transition: color .15s;
  background: rgba(255,255,255,.1); border-radius: 99px;
  padding: 6px 14px; border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(4px);
}
.auth-back-link:hover { color: #fff; background: rgba(255,255,255,.18); }

.app-footer {
  text-align: center; padding: 20px 16px 32px;
  font-size: 12px; color: var(--muted);
  display: flex; gap: 10px; justify-content: center; align-items: center;
  flex-wrap: wrap;
}
.app-footer a { color: var(--muted); text-decoration: underline; }
.app-footer a:hover { color: var(--primary); }

/* ── Desktop tweaks ─────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .auth-screen { padding: 40px 24px; }
  .app-main { padding: 32px 24px 80px; }
  .kpi-value { font-size: 30px; }
  .big-amount { font-size: 38px; }
  .fab { bottom: 36px; right: 36px; }
}

/* ═══════════════════════════════════════════════════════════
   APP SIDEBAR LAYOUT (app_base.html)
   ═══════════════════════════════════════════════════════════ */
.app-body { background: #f1f5f9; }

.app-body, .app-wrap-flex {
  display: flex;
  min-height: 100dvh;
}

/* Overlay (mobile) */
.sb-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 39;
}
.sb-overlay.show { display: block; }

/* ── Sidebar ── */
.app-sidebar {
  width: 252px;
  min-width: 252px;
  background: #1a3a6b;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  z-index: 40;
  flex-shrink: 0;
}

.sb-logo-wrap {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sb-logo-link {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; flex: 1; min-width: 0;
}
.sb-logo-img {
  height: 30px;
  object-fit: contain;
  max-width: 110px;
}
.sb-logo-fallback {
  color: #fff;
  font-size: 18px; font-weight: 800; letter-spacing: -.5px;
  white-space: nowrap;
}
.sb-close-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.65); padding: 4px;
}

.sb-user {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sb-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: .5px;
}
.sb-user-info { min-width: 0; }
.sb-user-name {
  color: #fff; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-plan { color: rgba(255,255,255,.5); font-size: 11px; margin-top: 1px; }
.sb-badge-pro {
  background: #10b981; color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 99px;
  padding: 1px 7px; text-transform: uppercase; letter-spacing: .04em;
}

.sb-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}
.sb-new-link {
  margin: 10px 14px 4px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px;
  background: #10b981; color: #fff;
  border-radius: 10px; text-decoration: none;
  font-size: 13.5px; font-weight: 700;
  transition: background .15s;
}
.sb-new-link:hover { background: #059669; }

.sb-section-label {
  padding: 14px 18px 4px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.35);
}
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  color: rgba(255,255,255,.65); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.sb-link svg { flex-shrink: 0; opacity: .8; }
.sb-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sb-link:hover svg { opacity: 1; }
.sb-link.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.sb-link.active svg { opacity: 1; }

.sb-footer {
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sb-logout { color: rgba(255,255,255,.5); }
.sb-logout:hover { color: #fca5a5 !important; background: rgba(239,68,68,.12) !important; }

/* ── Main content area ── */
.app-content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: 56px;
  display: flex; align-items: center;
  padding: 0 22px; gap: 12px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky; top: 0; z-index: 20;
}
.app-topbar-hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  color: #334155; padding: 4px; align-items: center; justify-content: center;
}
.app-topbar-logo-mobile {
  display: none;
  height: 24px; object-fit: contain;
}
.app-topbar-title {
  flex: 1;
  font-size: 16px; font-weight: 700; color: #0f172a;
}
.app-topbar-actions { display: flex; align-items: center; gap: 10px; }

.app-page {
  flex: 1;
  padding: 36px 48px 60px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
@media (max-width: 1024px) {
  .app-page { padding: 28px 32px 60px; }
}
@media (max-width: 640px) {
  .app-page { padding: 20px 16px 50px; }
}

/* ── Dashboard specific ── */
.dash-empty {
  text-align: center; padding: 64px 24px;
}
.dash-empty-icon { margin-bottom: 20px; line-height: 1; }
.dash-empty h2 { font-size: 20px; font-weight: 800; color: #0f172a; margin-bottom: 10px; }
.dash-empty p { color: #64748b; font-size: 15px; line-height: 1.65; }

.dash-chips {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px;
}
.dash-chip {
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 14px 20px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 110px;
}
.dash-chip-num { font-size: 22px; font-weight: 800; color: #0f172a; line-height: 1; }
.dash-chip-lbl { font-size: 12px; color: #64748b; }
.dash-chip-warn .dash-chip-num { color: #d97706; }
.dash-chip-info .dash-chip-num { color: #1a3a6b; }

.dash-section-label {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: #64748b; margin: 20px 0 10px;
}
.accord-card-pending { border-left: 3px solid #f59e0b; }
.accord-card-draft { opacity: .7; }

/* ── Subscription page ── */
.plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 24px; }
.plan-card {
  background: #fff; border: 2px solid #e2e8f0;
  border-radius: 16px; padding: 24px;
}
.plan-card.active { border-color: #1a3a6b; }
.plan-card.featured { border-color: #10b981; }
.plan-price { font-size: 28px; font-weight: 900; color: #0f172a; margin: 8px 0 4px; }
.plan-per { font-size: 13px; color: #64748b; }
.plan-features { margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.plan-feature { display: flex; gap: 8px; font-size: 13.5px; color: #334155; }
.plan-feature::before { content: '✓'; color: #10b981; font-weight: 700; flex-shrink: 0; }

/* ── Mobile sidebar ── */
@media (max-width: 768px) {
  .app-body { display: block; }
  .app-sidebar {
    position: fixed; left: -260px; top: 0;
    height: 100%; width: 252px;
    transition: left .25s ease;
    z-index: 40;
  }
  .app-sidebar.open { left: 0; }
  .sb-close-btn { display: flex !important; align-items: center; justify-content: center; }
  .app-topbar-hamburger { display: flex; }
  .app-topbar-logo-mobile { display: block; }
  .app-page { padding: 20px 16px 48px; }
  .plan-cards { grid-template-columns: 1fr; }
  .dash-chips { gap: 8px; }
  .dash-chip { min-width: 90px; padding: 12px 14px; }
  .parties-grid { grid-template-columns: 1fr; }
  .sigs-preview { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   MODERN UI ENHANCEMENTS (2026)
   ═══════════════════════════════════════════════════════════ */
.app-sidebar {
  background: linear-gradient(180deg, #0d2247 0%, #1a3a6b 100%);
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
}
.app-topbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}
.detail-card, .accord-card, .form-section, .settings-card {
  border: 1px solid var(--border);
}
.accord-card {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.accord-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #cbd5e1;
}
.status-banner.paiement_requis {
  background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa;
}
.status-banner.signé {
  border: 1px solid #a7f3d0;
}
.status-banner.brouillon {
  border: 1px solid #fde68a;
}

/* ── Workflow Stepper ── */
.workflow-stepper {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 20px; margin-bottom: 22px;
  box-shadow: var(--shadow-sm); gap: 8px;
}
.wf-step {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.wf-step.active { color: var(--primary); font-weight: 700; }
.wf-step.done { color: var(--success); }
.wf-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.wf-step.active .wf-num { background: var(--primary); color: #fff; box-shadow: 0 0 0 3px rgba(26,58,107,.15); }
.wf-step.done .wf-num { background: var(--success); color: #fff; }
.wf-line { flex: 1; height: 2px; background: var(--border); max-width: 60px; }
@media (max-width: 560px) {
  .wf-label { display: none; }
  .wf-step.active .wf-label { display: inline; }
}

/* ── Dashboard Toolbar & Filters ── */
.dash-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.dash-filter-pills {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.filter-pill {
  padding: 7px 14px; border-radius: 99px;
  font-size: 13px; font-weight: 600;
  background: #fff; color: var(--muted);
  border: 1px solid var(--border); cursor: pointer;
  transition: all .15s;
}
.filter-pill:hover { color: var(--primary); border-color: #cbd5e1; }
.filter-pill.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.dash-search {
  position: relative; min-width: 220px; flex: 1; max-width: 300px;
}
.dash-search input {
  width: 100%; padding: 8px 12px 8px 34px;
  border-radius: 99px; border: 1px solid var(--border);
  background: #fff; font-size: 13.5px; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.dash-search input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,58,107,.08);
}
.dash-search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}

/* ── Payment Progress Bar & Toggle ── */
.payment-progress-wrap {
  margin: 6px 0 14px; background: #f8fafc;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.payment-progress-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 8px;
}
.payment-progress-top strong { color: var(--primary); }
.payment-progress-track {
  width: 100%; height: 8px; background: #e2e8f0;
  border-radius: 99px; overflow: hidden;
}
.payment-progress-fill {
  height: 100%; background: linear-gradient(90deg, #10b981, #059669);
  border-radius: 99px; transition: width .3s ease;
}
.btn-toggle-paid {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 99px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  transition: all .15s;
}
.btn-toggle-paid:hover {
  border-color: var(--primary); color: var(--primary);
}
.btn-toggle-paid.is-paid {
  background: var(--success-bg); color: #047857; border-color: #6ee7b7;
}
.btn-toggle-paid.is-paid:hover {
  background: #d1fae5;
}

/* ── PDF Action Banner on Detail Page ── */
.pdf-hero-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, #0d2247 0%, #1a3a6b 100%);
  color: #fff; border-radius: var(--radius);
  padding: 18px 22px; box-shadow: var(--shadow);
}
.pdf-hero-info h3 { font-size: 16px; font-weight: 800; margin-bottom: 3px; display: flex; align-items: center; gap: 8px; }
.pdf-hero-info p { font-size: 12.5px; color: rgba(255,255,255,.75); }
.pdf-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-pdf-light {
  background: #fff; color: var(--primary);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 7px;
  transition: transform .15s, background .15s;
}
.btn-pdf-light:hover { background: #eff6ff; transform: translateY(-1px); }
.btn-pdf-outline {
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s;
}
.btn-pdf-outline:hover { background: rgba(255,255,255,.22); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE OPTIMIZATION — TABLET (≤768px) & MOBILE (≤480px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Topbar & Header */
  .app-topbar {
    height: auto;
    min-height: 54px;
    padding: 8px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .app-topbar-title {
    font-size: 14.5px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .app-topbar-actions {
    gap: 6px;
    flex-wrap: wrap;
  }
  .app-topbar-actions .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }
  .header-inner {
    padding: 0 14px;
    height: 54px;
  }
  .header-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Dashboard Toolbar & Search */
  .dash-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .dash-search {
    max-width: 100%;
    width: 100%;
  }
  .dash-filter-pills {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .filter-pill {
    flex-shrink: 0;
  }

  /* Accord Cards */
  .accord-card {
    padding: 14px 15px;
    gap: 10px;
  }
  .accord-name {
    font-size: 15px;
  }
  .accord-amount {
    font-size: 16.5px;
  }

  /* Detail & Form Sections */
  .detail-card, .form-section, .settings-card, .summary-card, .sig-block {
    padding: 16px;
  }
  .pdf-hero-card {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 12px;
  }
  .pdf-hero-actions {
    width: 100%;
  }
  .pdf-hero-actions a {
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  /* Tables & Schedules */
  .schedule-table, .schedule-preview-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .schedule-table th, .schedule-table td,
  .schedule-preview-table th, .schedule-preview-table td {
    padding: 8px 8px;
    font-size: 12.5px;
  }

  /* Auth screen on mobile */
  .auth-screen {
    padding: 56px 14px 24px;
    align-items: flex-start;
  }
  .auth-back-link {
    top: 14px;
    left: 14px;
    padding: 6px 12px;
    font-size: 12.5px;
  }
  .auth-card {
    padding: 24px 18px 22px;
    margin-top: 8px;
  }
  .auth-logo-img {
    height: 76px;
  }
}

@media (max-width: 480px) {
  .app-page {
    padding: 16px 12px 44px;
  }
  /* Hide secondary mobile logo when topbar has action buttons to prevent crowding */
  .app-topbar:has(.app-topbar-actions a, .app-topbar-actions button) .app-topbar-logo-mobile {
    display: none;
  }
  .app-topbar-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 4px;
    border-top: 1px solid #f1f5f9;
  }
  .app-topbar-actions:empty {
    display: none;
  }
  .app-topbar-actions .btn-sm {
    flex: 1;
    justify-content: center;
  }

  /* Dashboard chips 2x2 grid on narrow phones */
  .dash-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .dash-chip {
    min-width: 0;
    padding: 12px;
  }

  /* Accord Card stacks cleanly if needed */
  .accord-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .accord-card-right {
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    text-align: left;
  }

  /* Summary rows on sign & sign_debtor */
  .summary-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 7px 0;
  }
  .summary-val {
    text-align: left !important;
    word-break: break-word;
  }
  .canvas-hint {
    white-space: normal;
    text-align: center;
    width: 88%;
    font-size: 12px;
    line-height: 1.35;
  }

  /* Type selector & Split toggle */
  .type-selector {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .type-card {
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
    padding: 12px 14px;
    gap: 12px;
  }
  .split-toggle {
    grid-template-columns: 1fr;
  }
  .installments-pills {
    flex-wrap: wrap;
  }
  .inst-pill {
    min-width: calc(33.33% - 6px);
    text-align: center;
  }

  /* Link copy row & Modal actions */
  .link-copy-row {
    flex-direction: column;
  }
  .link-copy-row .btn {
    width: 100%;
  }
  .modal-actions {
    flex-direction: column;
  }
  .modal-actions > * {
    width: 100%;
  }
  .status-banner {
    font-size: 12.5px;
    padding: 10px 12px;
    align-items: flex-start;
  }
  .big-amount {
    font-size: 24px !important;
  }
}

/* ── Super Admin Panel Responsive Styles ── */
.admin-topbar {
  background: linear-gradient(135deg, #0a1931 0%, #1a3a6b 100%);
  color: #fff;
  border-bottom: 3px solid #e11d48;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 6px 24px rgba(10,25,49,.3);
}
.admin-topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.admin-topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.admin-topbar-logo {
  height: 32px;
  filter: brightness(0) invert(1);
}
.admin-topbar-info {
  border-left: 1px solid rgba(255,255,255,.2);
  padding-left: 14px;
}
.admin-badge-pill {
  font-size: 10.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: #e11d48;
  color: #fff;
  padding: 3px 9px;
  border-radius: 99px;
  display: inline-block;
}
.admin-user-text {
  font-size: 12px;
  color: rgba(255,255,255,.8);
  margin-top: 2px;
}
.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.admin-container {
  max-width: 1080px;
  margin: 0 auto;
}

.admin-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 22px 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.admin-kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
}
.admin-kpi-title {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.admin-kpi-value {
  font-size: 30px;
  font-weight: 900;
  color: #0f172a;
  margin: 6px 0 4px;
  line-height: 1.1;
}
.admin-kpi-sub {
  font-size: 12.5px;
  color: #64748b;
}

.admin-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid #f1f5f9;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 740px;
}
.admin-table-scroll-hint {
  display: none;
  font-size: 11.5px;
  color: #64748b;
  margin-bottom: 8px;
  align-items: center;
  gap: 6px;
}

@media (max-width: 768px) {
  .admin-topbar {
    padding: 12px 14px;
  }
  .admin-topbar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .admin-topbar-brand {
    justify-content: space-between;
  }
  .admin-topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .admin-topbar-actions .btn {
    justify-content: center;
    font-size: 11.5px !important;
    padding: 7px 10px !important;
    white-space: nowrap;
  }
  .admin-main {
    padding: 16px 12px 50px;
  }
  .admin-card {
    padding: 16px 14px;
    border-radius: 14px;
    margin-bottom: 20px;
  }
  .admin-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .admin-card-header input[type="text"] {
    max-width: 100% !important;
    width: 100% !important;
  }
  .admin-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }
  .admin-kpi-card {
    padding: 12px 14px;
  }
  .admin-kpi-value {
    font-size: 22px;
  }
  .admin-kpi-sub {
    font-size: 11px;
  }
  .admin-table-scroll-hint {
    display: flex;
  }
  .admin-banner-flex {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .admin-banner-flex form {
    width: 100% !important;
  }
  .admin-banner-flex form input,
  .admin-banner-flex form button {
    width: 100% !important;
  }
}
@media (max-width: 480px) {
  .admin-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Address Autocomplete Suggestions Dropdown ── */
.address-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
}
.address-suggestions.hidden {
  display: none;
}
.address-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.address-item:last-child {
  border-bottom: none;
}
.address-item:hover, .address-item.selected {
  background: #f0fdf4;
  color: #166534;
}
.address-item-icon {
  flex-shrink: 0;
  color: #64748b;
}



