/* =========================================================
   CONNECTELL — Espace Client (workspace UI)
   Extends tokens from /css/style.css
   ========================================================= */

.app-body { background: var(--c-bg-alt); min-height: 100vh; }

/* ---------- Confidentiality banner ---------- */
.confidential-bar {
  background: var(--c-primary-950);
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.confidential-bar svg { width: 13px; height: 13px; color: var(--c-accent-400); flex-shrink: 0; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--c-primary-950);
  color: rgba(255,255,255,0.75);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.app-sidebar .as-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.app-sidebar .as-brand .logo-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--c-primary-500), var(--c-accent-500)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-sidebar .as-brand .logo-mark svg { width: 16px; height: 16px; }
.app-sidebar .as-org {
  padding: 16px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.app-sidebar .as-org .as-org-name { font-size: 13.5px; font-weight: 700; color: #fff; }
.app-sidebar .as-org .as-org-plan { font-size: 11.5px; color: var(--c-accent-400); font-weight: 700; margin-top: 2px; }

.app-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.app-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.68);
  margin-bottom: 2px;
  transition: background .15s ease, color .15s ease;
}
.app-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.app-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.app-nav a.active { background: rgba(20,199,168,0.14); color: var(--c-accent-400); }
.app-nav .nav-sep { height: 1px; background: rgba(255,255,255,0.08); margin: 12px 8px; }

.app-sidebar .as-footer {
  padding: 16px 22px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.as-footer .as-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--c-primary-500), var(--c-accent-500)); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #fff; flex-shrink: 0; }
.as-footer .as-user-name { font-size: 13px; font-weight: 700; color: #fff; }
.as-footer .as-user-role { font-size: 11px; color: rgba(255,255,255,0.5); }
.as-footer .as-logout { margin-left: auto; color: rgba(255,255,255,0.4); }
.as-footer .as-logout svg { width: 17px; height: 17px; }
.as-footer .as-logout:hover { color: #fff; }

/* ---------- Main content ---------- */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  height: 68px;
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.app-topbar .at-title { font-size: 18px; font-weight: 800; color: var(--c-primary-950); }
.app-topbar .at-spacer { flex: 1; }
.sidebar-toggle { display: none; background: none; border: 1px solid var(--c-border); border-radius: 9px; width: 38px; height: 38px; align-items: center; justify-content: center; }
.sidebar-toggle svg { width: 18px; height: 18px; color: var(--c-ink-soft); }

.app-content { padding: 28px; flex: 1; }
.app-content .content-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.app-content .content-head h1 { font-size: 22px; font-weight: 800; color: var(--c-primary-950); margin-bottom: 4px; }
.app-content .content-head p { font-size: 13.5px; color: var(--c-muted); }

/* ---------- Cards ---------- */
.wcard { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.wcard-pad { padding: 24px; }
.wcard-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--c-border); }
.wcard-head h3 { font-size: 15px; font-weight: 750; color: var(--c-primary-950); }
.wcard-body { padding: 18px 22px; }

/* ---------- Stat cards ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.stat-card { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.stat-card .sc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stat-card .sc-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--c-bg-alt); display: flex; align-items: center; justify-content: center; }
.stat-card .sc-icon svg { width: 17px; height: 17px; color: var(--c-primary-700); }
.stat-card .sc-delta { font-size: 11.5px; font-weight: 800; padding: 2px 8px; border-radius: var(--radius-full); }
.stat-card .sc-delta.up { color: var(--c-success); background: #e9faf3; }
.stat-card .sc-delta.down { color: #dc2626; background: #fee2e2; }
.stat-card .sc-num { font-size: 26px; font-weight: 800; color: var(--c-primary-950); letter-spacing: -0.02em; }
.stat-card .sc-label { font-size: 12.5px; color: var(--c-muted); font-weight: 600; margin-top: 3px; }
@media (max-width: 1200px) { .stat-cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .stat-cards { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Quick actions ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.qa-btn {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-md);
  padding: 18px 10px; text-align: center; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.qa-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: transparent; }
.qa-btn .qa-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--c-accent-100); display: flex; align-items: center; justify-content: center; }
.qa-btn .qa-icon svg { width: 18px; height: 18px; color: var(--c-accent-600); }
.qa-btn span.qa-label { font-size: 12px; font-weight: 700; color: var(--c-ink); }
@media (max-width: 900px) { .quick-actions { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .quick-actions { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Tables ---------- */
.wtable-wrap { overflow-x: auto; }
.wtable { width: 100%; border-collapse: collapse; min-width: 640px; }
.wtable th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); font-weight: 800; padding: 10px 14px; border-bottom: 1px solid var(--c-border); background: var(--c-bg-alt); }
.wtable td { padding: 13px 14px; font-size: 13.5px; color: var(--c-ink); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.wtable tbody tr:hover { background: var(--c-bg-alt); }
.wtable tbody tr:last-child td { border-bottom: none; }
.cell-primary { font-weight: 700; color: var(--c-primary-950); }
.cell-sub { font-size: 12px; color: var(--c-muted); }
.row-avatar { display: flex; align-items: center; gap: 10px; }
.row-avatar .ra-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--c-primary-100); color: var(--c-primary-700); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }

.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: var(--radius-full); }
.status-pill.active, .status-pill.success, .status-pill.sent, .status-pill.valid { background: var(--c-accent-100); color: var(--c-accent-600); }
.status-pill.pending, .status-pill.processing { background: #fdf1e0; color: #b5690a; }
.status-pill.expired, .status-pill.error, .status-pill.revoked { background: #fee2e2; color: #dc2626; }
.status-pill.draft { background: var(--c-bg-alt); color: var(--c-muted); }

.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--c-border); background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { width: 14px; height: 14px; color: var(--c-ink-soft); }
.icon-btn:hover { background: var(--c-bg-alt); }
.icon-btn.danger:hover { background: #fee2e2; border-color: #fee2e2; }
.icon-btn.danger:hover svg { color: #dc2626; }

/* ---------- Table toolbar ---------- */
.table-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.search-input { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--c-muted); }
.search-input input { width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); font-size: 13.5px; background: #fff; }
.search-input input:focus { outline: none; border-color: var(--c-accent-500); }
.filter-select { padding: 10px 12px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); font-size: 13.5px; background: #fff; color: var(--c-ink-soft); font-weight: 600; }
.toolbar-spacer { flex: 1; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 4px 4px; font-size: 13px; color: var(--c-muted); }
.pagination .pg-btns { display: flex; gap: 6px; }
.pagination button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--c-border); background: #fff; font-weight: 700; font-size: 13px; color: var(--c-ink-soft); }
.pagination button.active { background: var(--c-primary-950); color: #fff; border-color: var(--c-primary-950); }
.pagination button:disabled { opacity: .4; }

/* ---------- Forms (app) ---------- */
.wform-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.wform-field label { font-size: 12.5px; font-weight: 700; color: var(--c-ink-soft); }
.wform-field .req { color: #dc2626; }
.wform-field input, .wform-field select, .wform-field textarea {
  border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--c-ink);
}
.wform-field input:focus, .wform-field select:focus, .wform-field textarea:focus { outline: none; border-color: var(--c-accent-500); box-shadow: 0 0 0 3px rgba(20,199,168,0.12); }
.wform-field .field-error { font-size: 12px; color: #dc2626; display: none; }
.wform-field.invalid input, .wform-field.invalid select { border-color: #dc2626; }
.wform-field.invalid .field-error { display: block; }
.wform-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .wform-row { grid-template-columns: 1fr; } }

.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--c-ink); font-weight: 600; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--c-accent-500); }

/* ---------- Buttons small variants used in app ---------- */
.btn-outline-danger { background: #fff; color: #dc2626; border: 1px solid #fecaca; }
.btn-outline-danger:hover { background: #fee2e2; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-state .es-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--c-bg-alt); display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.empty-state .es-icon svg { width: 26px; height: 26px; color: var(--c-muted); }
.empty-state h4 { font-size: 16px; font-weight: 750; color: var(--c-primary-950); margin-bottom: 8px; }
.empty-state p { font-size: 13.5px; color: var(--c-muted); margin-bottom: 20px; max-width: 340px; margin-left: auto; margin-right: auto; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,17,48,0.55); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
}
.modal-box.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--c-border); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-head h3 { font-size: 17px; font-weight: 800; color: var(--c-primary-950); }
.modal-close { width: 32px; height: 32px; border-radius: 8px; border: none; background: var(--c-bg-alt); display: flex; align-items: center; justify-content: center; }
.modal-close svg { width: 15px; height: 15px; color: var(--c-ink-soft); }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px; border-top: 1px solid var(--c-border); position: sticky; bottom: 0; background: #fff; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--c-primary-950); color: #fff;
  padding: 13px 18px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 600; min-width: 260px;
  animation: toast-in .25s ease;
}
.toast.success svg { color: var(--c-accent-400); }
.toast.error { background: #dc2626; }
.toast svg { width: 17px; height: 17px; flex-shrink: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Login page ---------- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--c-bg-alt); padding: 24px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .lc-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 28px; font-weight: 800; font-size: 19px; color: var(--c-primary-950); }
.login-card .lc-brand .logo-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--c-primary-700), var(--c-accent-500)); display: flex; align-items: center; justify-content: center; }
.login-card .lc-box { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-md); }
.login-card h1 { font-size: 20px; font-weight: 800; color: var(--c-primary-950); margin-bottom: 6px; text-align: center; }
.login-card .lc-sub { font-size: 13.5px; color: var(--c-muted); text-align: center; margin-bottom: 24px; }
.login-card .lc-forgot { text-align: right; font-size: 12.5px; font-weight: 700; color: var(--c-accent-600); margin: -8px 0 18px; display: block; }
.login-card .lc-demo-note { background: var(--c-bg-alt); border: 1px dashed var(--c-border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12px; color: var(--c-ink-soft); margin-top: 18px; }
.login-card .lc-footer { text-align: center; font-size: 12.5px; color: var(--c-muted); margin-top: 20px; }
.two-fa-toggle { display: flex; align-items: center; justify-content: space-between; background: var(--c-bg-alt); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 18px; }
.two-fa-toggle .tft-label { font-size: 13px; font-weight: 700; color: var(--c-ink); }
.two-fa-toggle .tft-sub { font-size: 11.5px; color: var(--c-muted); }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--c-border); border-radius: 999px; transition: .15s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--c-accent-500); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------- Progress bar ---------- */
.progress-wrap { background: var(--c-border); border-radius: var(--radius-full); height: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--c-accent-500), var(--c-accent-600)); border-radius: var(--radius-full); width: 0%; transition: width .2s ease; }
.progress-label { font-size: 12.5px; color: var(--c-ink-soft); font-weight: 600; margin-top: 8px; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--c-border); border-radius: var(--radius-lg); padding: 44px 24px; text-align: center;
  background: #fff; transition: border-color .15s ease, background .15s ease; cursor: pointer;
}
.dropzone.dragover { border-color: var(--c-accent-500); background: var(--c-accent-100); }
.dropzone svg { width: 34px; height: 34px; color: var(--c-primary-700); margin: 0 auto 14px; }
.dropzone h4 { font-size: 15px; font-weight: 750; color: var(--c-primary-950); margin-bottom: 6px; }
.dropzone p { font-size: 13px; color: var(--c-muted); }
.dropzone input[type=file] { display: none; }

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: center; margin-bottom: 28px; }
.stepper .st-item { display: flex; align-items: center; gap: 9px; }
.stepper .st-num { width: 28px; height: 28px; border-radius: 50%; background: var(--c-border); color: var(--c-muted); font-size: 12.5px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stepper .st-item.done .st-num { background: var(--c-accent-500); color: var(--c-primary-950); }
.stepper .st-item.current .st-num { background: var(--c-primary-950); color: #fff; }
.stepper .st-label { font-size: 13px; font-weight: 700; color: var(--c-muted); }
.stepper .st-item.current .st-label, .stepper .st-item.done .st-label { color: var(--c-primary-950); }
.stepper .st-line { flex: 1; height: 2px; background: var(--c-border); margin: 0 12px; min-width: 24px; }

/* ---------- Document generator layout ---------- */
.doc-gen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 980px) { .doc-gen-grid { grid-template-columns: 1fr; } }

.doc-type-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 22px; }
.doc-type-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px; border-radius: var(--radius-md); border: 1.5px solid var(--c-border); background: #fff;
  font-size: 12px; font-weight: 700; color: var(--c-ink-soft);
}
.doc-type-btn svg { width: 20px; height: 20px; }
.doc-type-btn.active { border-color: var(--c-accent-500); background: var(--c-accent-100); color: var(--c-accent-600); }
@media (max-width: 700px) { .doc-type-grid { grid-template-columns: repeat(3, 1fr); } }

.doc-preview-frame {
  background: var(--c-bg-alt); border-radius: var(--radius-lg); padding: 28px;
  display: flex; align-items: center; justify-content: center; min-height: 380px; position: sticky; top: 88px;
}
.doc-preview-card {
  width: 100%; max-width: 420px; aspect-ratio: 1.55/1; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 26px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(135deg, #fff 60%, var(--c-bg-alt) 100%);
  border: 1px solid var(--c-border);
}
.doc-preview-card .dp-top { display: flex; justify-content: space-between; align-items: flex-start; }
.doc-preview-card .dp-brand { font-size: 10px; font-weight: 800; letter-spacing: .08em; color: var(--c-primary-700); text-transform: uppercase; }
.doc-preview-card .dp-type { font-size: 10px; font-weight: 800; background: var(--c-accent-100); color: var(--c-accent-600); padding: 3px 9px; border-radius: var(--radius-full); }
.doc-preview-card .dp-title { font-size: 12px; color: var(--c-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-top: 18px; }
.doc-preview-card .dp-name { font-size: 22px; font-weight: 800; color: var(--c-primary-950); margin-top: 4px; }
.doc-preview-card .dp-meta { font-size: 12px; color: var(--c-ink-soft); margin-top: 6px; }
.doc-preview-card .dp-bottom { display: flex; justify-content: space-between; align-items: flex-end; }
.doc-preview-card .dp-id { font-size: 10px; font-family: monospace; color: var(--c-muted); }
.doc-preview-card canvas.dp-qr { width: 52px; height: 52px; border-radius: 6px; }

/* Style variants reflecting the chosen template (mirrors the gallery thumbnails, at document scale) */
.doc-preview-card { --dp-color: #1b2a6b; }
.doc-preview-card .dp-type { background: var(--dp-color); opacity: .9; color: #fff; }
.doc-preview-card.style-classique { border: 1.5px solid var(--dp-color); background: #fdfcf7; }
.doc-preview-card.style-classique .dp-name { font-family: Georgia, "Times New Roman", serif; text-align: center; }
.doc-preview-card.style-classique .dp-top, .doc-preview-card.style-classique .dp-title { text-align: center; justify-content: center; }
.doc-preview-card.style-classique .dp-bottom { justify-content: center; gap: 16px; }
.doc-preview-card.style-moderne { border: none; }
.doc-preview-card.style-moderne::before {
  content: ""; position: absolute; top: -20%; left: -14%; width: 55%; height: 150%;
  background: var(--dp-color); transform: rotate(-10deg); opacity: .95; z-index: 0;
}
.doc-preview-card.style-moderne .dp-top, .doc-preview-card.style-moderne > div, .doc-preview-card.style-moderne .dp-bottom { position: relative; z-index: 1; }
.doc-preview-card.style-moderne .dp-title, .doc-preview-card.style-moderne .dp-name, .doc-preview-card.style-moderne .dp-meta { text-align: right; }
.doc-preview-card.style-minimaliste { border: 1px solid var(--c-border); background: #fff; }
.doc-preview-card.style-minimaliste .dp-brand { color: var(--c-muted); }
.doc-preview-card.style-minimaliste .dp-type { background: var(--c-bg-alt); color: var(--dp-color); }
.doc-preview-card.style-institutionnel { border: 1px solid var(--c-border); }
.doc-preview-card.style-institutionnel .dp-top { background: var(--dp-color); margin: -26px -26px 18px; padding: 16px 26px; }
.doc-preview-card.style-institutionnel .dp-brand { color: #fff; }
.doc-preview-card.style-institutionnel .dp-type { background: rgba(255,255,255,0.2); color: #fff; }

.member-select-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--c-border); border-radius: var(--radius-sm); }
.ms-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--c-border); font-size: 13px; }
.ms-row:last-child { border-bottom: none; }
.ms-row input { width: 15px; height: 15px; accent-color: var(--c-accent-500); }

/* ---------- Radio card group (recipient/schedule choices) ---------- */
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.radio-card { border: 1.5px solid var(--c-border); border-radius: var(--radius-md); padding: 14px; cursor: pointer; }
.radio-card input { display: none; }
.radio-card .rc-title { font-size: 13px; font-weight: 750; color: var(--c-primary-950); }
.radio-card .rc-sub { font-size: 11.5px; color: var(--c-muted); margin-top: 2px; }
.radio-card:has(input:checked) { border-color: var(--c-accent-500); background: var(--c-accent-100); }
@media (max-width: 700px) { .radio-cards { grid-template-columns: 1fr; } }

/* ---------- Usage bars (billing) ---------- */
.usage-item { margin-bottom: 20px; }
.usage-item .ui-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--c-ink); margin-bottom: 8px; }
.usage-item .ui-head span.ui-val { color: var(--c-muted); font-weight: 600; }
.usage-bar { background: var(--c-bg-alt); border-radius: var(--radius-full); height: 10px; overflow: hidden; }
.usage-bar .fill { height: 100%; border-radius: var(--radius-full); background: linear-gradient(90deg, var(--c-primary-600), var(--c-primary-800)); }
.usage-bar .fill.warn { background: linear-gradient(90deg, #f59e0b, #b5690a); }

/* ---------- CGU flow (full acceptance + reconfirmation) ---------- */
.cgu-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--c-bg-alt); padding: 32px 20px; }
.cgu-card { width: 100%; max-width: 620px; }
.cgu-card .lc-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; font-weight: 800; font-size: 19px; color: var(--c-primary-950); }
.cgu-box { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 32px; }
.cgu-box h1 { font-size: 19px; font-weight: 800; color: var(--c-primary-950); margin-bottom: 6px; text-align: center; }
.cgu-box .cgu-sub { font-size: 13.5px; color: var(--c-muted); text-align: center; margin-bottom: 22px; }

.legal-callout {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--c-primary-50); border: 1px solid var(--c-primary-100);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12.5px; color: var(--c-primary-800);
  margin-bottom: 20px;
}
.legal-callout svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--c-primary-700); }

.cgu-article {
  max-height: 340px; overflow-y: auto;
  border: 1px solid var(--c-border); border-radius: var(--radius-md);
  padding: 20px 22px; margin-bottom: 20px;
  background: var(--c-bg-alt); font-size: 13.5px; color: var(--c-ink-soft); line-height: 1.65;
}
.cgu-article .cgu-meta { font-size: 11.5px; color: var(--c-muted); font-weight: 700; margin-bottom: 14px; text-transform: uppercase; letter-spacing: .04em; }
.cgu-article h3 { font-size: 14px; font-weight: 800; color: var(--c-primary-950); margin: 18px 0 8px; }
.cgu-article h3:first-of-type { margin-top: 0; }
.cgu-article p { margin-bottom: 10px; }
.cgu-article ul { margin: 8px 0 10px 20px; }
.cgu-article li { margin-bottom: 6px; list-style: disc; }

.cgu-checkbox-item {
  display: flex; align-items: flex-start; gap: 11px;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-md);
  padding: 14px 16px; margin-bottom: 10px; transition: border-color .15s ease, background .15s ease;
}
.cgu-checkbox-item:has(input:checked) { border-color: var(--c-accent-500); background: var(--c-accent-100); }
.cgu-checkbox-item input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--c-accent-500); flex-shrink: 0; }
.cgu-checkbox-item label { font-size: 13px; color: var(--c-ink); line-height: 1.5; cursor: pointer; }
.cgu-checkbox-item.single { align-items: center; }

.cgu-reread-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--c-accent-600); margin-bottom: 18px; }
.cgu-reread-link svg { width: 13px; height: 13px; }

.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---------- Standalone CGU document page ---------- */
.doc-page-shell { min-height: 100vh; background: #fff; }
.doc-page-header { border-bottom: 1px solid var(--c-border); padding: 18px 0; }
.doc-page-header .container { display: flex; align-items: center; justify-content: space-between; }
.doc-page-body { max-width: 720px; margin: 0 auto; padding: 44px 24px 80px; }
.doc-page-body h1 { font-size: 28px; font-weight: 800; color: var(--c-primary-950); margin-bottom: 8px; }
.doc-page-body .cgu-meta { font-size: 12.5px; color: var(--c-muted); font-weight: 700; margin-bottom: 32px; text-transform: uppercase; letter-spacing: .04em; }
.doc-page-body h3 { font-size: 17px; font-weight: 800; color: var(--c-primary-950); margin: 30px 0 10px; }
.doc-page-body p { font-size: 15px; color: var(--c-ink-soft); line-height: 1.7; margin-bottom: 12px; }
.doc-page-body ul { margin: 10px 0 14px 22px; }
.doc-page-body li { font-size: 15px; color: var(--c-ink-soft); line-height: 1.7; margin-bottom: 8px; list-style: disc; }

/* ---------- App footer (workspace) ---------- */
.app-footer {
  padding: 16px 28px; border-top: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  font-size: 12px; color: var(--c-muted);
}
.app-footer a { color: var(--c-muted); font-weight: 700; }
.app-footer a:hover { color: var(--c-primary-800); }
.app-footer .af-links { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Template library (Canva-style: search, Mes créations, Modèles) ---------- */
.lib-search-bar { margin-bottom: 30px; }
.search-input-lg { position: relative; max-width: 560px; }
.search-input-lg svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--c-muted); }
.search-input-lg input {
  width: 100%; padding: 13px 16px 13px 46px; border: 1.5px solid var(--c-border); border-radius: var(--radius-full);
  font-size: 14.5px; background: var(--c-bg-alt); transition: border-color .15s ease, background .15s ease;
}
.search-input-lg input:focus { outline: none; border-color: var(--c-accent-500); background: #fff; box-shadow: 0 0 0 3px rgba(20,199,168,0.12); }

.lib-section { margin-bottom: 36px; }
.lib-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.lib-section-head h3 { font-size: 16px; font-weight: 800; color: var(--c-primary-950); }
.lib-show-all { background: none; border: none; font-size: 12.5px; font-weight: 700; color: var(--c-accent-600); padding: 0; }
.lib-show-all:hover { text-decoration: underline; }

.tpl-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tpl-tabs button {
  background: #fff; border: 1px solid var(--c-border); color: var(--c-ink-soft);
  font-size: 13px; font-weight: 700; padding: 8px 14px; border-radius: var(--radius-full);
  display: flex; align-items: center; gap: 6px;
}
.tpl-tabs button svg { width: 14px; height: 14px; }
.tpl-tabs button.active { background: var(--c-primary-950); border-color: var(--c-primary-950); color: #fff; }
.tpl-tabs button .tpl-tab-count { font-size: 11px; opacity: .65; }

/* Dense, auto-reflowing grid — column count adapts to available width instead of
   fixed breakpoints, which naturally gives the "11 → 6 → 3 → 2" reduction asked for. */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 16px; }
.creations-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }

.tpl-card {
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-md); overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease; position: relative; cursor: pointer;
}
.tpl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.tpl-card.locked { opacity: .85; }

.tpl-fav-btn {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(255,255,255,0.92);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
}
.tpl-fav-btn svg { width: 13px; height: 13px; color: var(--c-muted); }
.tpl-fav-btn.active svg { color: #f59e0b; fill: #f59e0b; }

.tpl-badge { position: absolute; top: 8px; left: 8px; z-index: 3; font-size: 9.5px; font-weight: 800; letter-spacing: .03em; padding: 3px 8px; border-radius: var(--radius-full); }
.tpl-badge.free { background: var(--c-accent-100); color: var(--c-accent-600); }
.tpl-badge.premium { background: #fdf1e0; color: #b5690a; }

/* Hover overlay revealing a quick-preview action, bottom-right of the thumbnail */
.tpl-hover-action {
  position: absolute; right: 8px; bottom: 8px; z-index: 3;
  width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(10,17,48,0.75); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(4px); transition: opacity .15s ease, transform .15s ease;
}
.tpl-card:hover .tpl-hover-action { opacity: 1; transform: translateY(0); }
.tpl-hover-action svg { width: 14px; height: 14px; color: #fff; }
.tpl-hover-action:hover { background: var(--c-primary-950); }

.tpl-thumb {
  --tpl-color: #1b2a6b;
  aspect-ratio: 1.5 / 1;
  position: relative;
  background: var(--c-bg-alt);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.tpl-thumb .tpl-icon { width: 22px; height: 22px; flex-shrink: 0; }
.tpl-thumb .tpl-icon svg { width: 100%; height: 100%; }

/* Sample document text, shared across styles — real copy instead of grey bars */
.tpl-thumb .tpl-eyebrow { font-size: 6.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .65; }
.tpl-thumb .tpl-sample-name { font-weight: 800; line-height: 1.15; margin: 3px 0; }
.tpl-thumb .tpl-sample-sub { font-size: 7px; font-weight: 600; opacity: .6; }
.tpl-thumb .tpl-rule { height: 1.5px; margin-top: 6px; }

/* A real-looking medallion seal: concentric rings + star + ribbon tails */
.tpl-seal { position: relative; width: 30px; height: 30px; flex-shrink: 0; }
.tpl-seal::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--tpl-color) 55%, white), var(--tpl-color));
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--tpl-color) 60%, white) inset;
}
.tpl-seal::after {
  content: "★"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; line-height: 1;
}
.tpl-seal .seal-ribbon { position: absolute; top: 82%; left: 50%; width: 20px; height: 14px; transform: translateX(-50%); z-index: -1; }
.tpl-seal .seal-ribbon::before, .tpl-seal .seal-ribbon::after {
  content: ""; position: absolute; top: 0; width: 9px; height: 14px; background: var(--tpl-color); opacity: .8;
}
.tpl-seal .seal-ribbon::before { left: 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); transform: rotate(-8deg); }
.tpl-seal .seal-ribbon::after { right: 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); transform: rotate(8deg); }

/* Classique : sceau + cadre orné, typographie serif centrée, esprit "diplôme" */
.tpl-thumb.style-classique { background: #fdfcf7; align-items: center; justify-content: center; padding: 16px 14px; text-align: center; }
.tpl-thumb.style-classique::before { content: ""; position: absolute; inset: 7px; border: 1.5px solid var(--tpl-color); opacity: .55; }
.tpl-thumb.style-classique::after { content: ""; position: absolute; inset: 11px; border: 1px solid var(--tpl-color); opacity: .28; }
.tpl-thumb.style-classique .tpl-seal { margin: 0 auto 6px; }
.tpl-thumb.style-classique .tpl-eyebrow { color: var(--tpl-color); }
.tpl-thumb.style-classique .tpl-sample-name { font-family: Georgia, "Times New Roman", serif; font-size: 14px; color: var(--c-ink); }
.tpl-thumb.style-classique .tpl-sample-sub { font-style: italic; color: var(--c-ink-soft); }
.tpl-thumb.style-classique .tpl-rule { width: 46%; margin-left: auto; margin-right: auto; background: var(--tpl-color); opacity: .5; }

/* Moderne : bandeau diagonal coloré, typographie sans-serif grasse, aligné à droite */
.tpl-thumb.style-moderne { background: #fff; padding: 14px 16px; justify-content: flex-end; text-align: right; }
.tpl-thumb.style-moderne::before {
  content: ""; position: absolute; top: -30%; left: -20%; width: 75%; height: 160%;
  background: var(--tpl-color); transform: rotate(-12deg); opacity: .94;
}
.tpl-thumb.style-moderne .tpl-icon { color: #fff; position: relative; z-index: 2; margin: 0 auto 0 0; }
.tpl-thumb.style-moderne .tpl-eyebrow, .tpl-thumb.style-moderne .tpl-sample-name, .tpl-thumb.style-moderne .tpl-sample-sub, .tpl-thumb.style-moderne .tpl-rule { position: relative; z-index: 2; }
.tpl-thumb.style-moderne .tpl-eyebrow { color: var(--tpl-color); }
.tpl-thumb.style-moderne .tpl-sample-name { font-family: "Arial Black", Helvetica, sans-serif; font-size: 13px; color: var(--c-ink); text-transform: uppercase; letter-spacing: -.01em; }
.tpl-thumb.style-moderne .tpl-sample-sub { color: var(--c-ink-soft); }
.tpl-thumb.style-moderne .tpl-rule { width: 40%; margin-left: auto; background: var(--tpl-color); }

/* Minimaliste : composition asymétrique, typographie légère, un seul trait d'accent */
.tpl-thumb.style-minimaliste { background: #fff; padding: 16px; justify-content: space-between; }
.tpl-thumb.style-minimaliste::before { content: ""; position: absolute; inset: 10px; border: 1px solid var(--c-border); }
.tpl-thumb.style-minimaliste .tpl-icon { color: var(--tpl-color); width: 15px; height: 15px; opacity: .8; }
.tpl-thumb.style-minimaliste .tpl-eyebrow { color: var(--c-muted); }
.tpl-thumb.style-minimaliste .tpl-sample-name { font-family: Helvetica, Arial, sans-serif; font-weight: 400; font-size: 15px; color: var(--c-ink); }
.tpl-thumb.style-minimaliste .tpl-sample-sub { color: var(--c-muted); font-weight: 400; }
.tpl-thumb.style-minimaliste .tpl-rule { width: 30%; background: var(--tpl-color); }

/* Institutionnel : bandeau plein en tête (en-tête officiel), sceau, structure formelle */
.tpl-thumb.style-institutionnel { background: #fff; padding: 0; }
.tpl-thumb.style-institutionnel .ti-band { background: var(--tpl-color); height: 34%; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; }
.tpl-thumb.style-institutionnel .ti-band .tpl-icon { color: #fff; width: 15px; height: 15px; }
.tpl-thumb.style-institutionnel .ti-band .ti-wordmark { color: #fff; font-size: 7px; font-weight: 800; letter-spacing: .1em; }
.tpl-thumb.style-institutionnel .ti-seal { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.75); display: flex; align-items: center; justify-content: center; }
.tpl-thumb.style-institutionnel .ti-seal::after { content: "✓"; color: #fff; font-size: 9px; }
.tpl-thumb.style-institutionnel .ti-body { flex: 1; padding: 10px 14px; display: flex; flex-direction: column; justify-content: center; }
.tpl-thumb.style-institutionnel .tpl-eyebrow { color: var(--tpl-color); }
.tpl-thumb.style-institutionnel .tpl-sample-name { font-family: Georgia, serif; font-size: 12.5px; color: var(--c-ink); }
.tpl-thumb.style-institutionnel .tpl-sample-sub { color: var(--c-ink-soft); }
.tpl-thumb.style-institutionnel .tpl-rule { width: 55%; background: var(--tpl-color); opacity: .6; }

.tpl-info { padding: 9px 10px 11px; }
.tpl-info .tpl-name { font-size: 12px; font-weight: 700; color: var(--c-primary-950); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-lock-note { font-size: 9.5px; color: var(--c-muted); margin-top: 2px; }

.load-more-wrap { text-align: center; margin-top: 26px; }

/* ---------- "Mes créations" cards (recent generated documents) ---------- */
.creation-card { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-md); overflow: hidden; position: relative; transition: transform .15s ease, box-shadow .15s ease; }
.creation-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.creation-card .tpl-thumb { aspect-ratio: 1.5/1; cursor: pointer; }
.creation-card .creation-info { padding: 10px 12px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.creation-card .creation-info > div:first-child { min-width: 0; flex: 1; }
.creation-card .ci-name { font-size: 12.5px; font-weight: 700; color: var(--c-primary-950); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.creation-card .ci-meta { font-size: 11px; color: var(--c-muted); margin-top: 2px; }
.creation-menu-wrap { position: relative; flex-shrink: 0; }
.creation-menu-btn { background: none; border: none; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--c-muted); }
.creation-menu-btn:hover { background: var(--c-bg-alt); }
.creation-menu-btn svg { width: 15px; height: 15px; }
.creation-menu {
  display: none; position: absolute; right: 0; bottom: 26px; z-index: 20;
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  min-width: 140px; padding: 6px; overflow: visible;
}
.creation-menu.open { display: block; }
.creation-menu button { display: flex; width: 100%; text-align: left; background: none; border: none; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--c-ink); }
.creation-menu button:hover { background: var(--c-bg-alt); }
.creation-menu button.danger { color: #dc2626; }
.creation-card .tpl-fav-btn { top: 8px; right: 8px; }

/* ---------- Quick preview modal ---------- */
.preview-modal-body { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--c-bg-alt); }
.preview-modal-body .tpl-thumb { width: 100%; max-width: 420px; aspect-ratio: 1.5/1; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.preview-modal-body .tpl-thumb .tpl-eyebrow { font-size: 11px; }
.preview-modal-body .tpl-thumb .tpl-sample-name { font-size: 26px !important; }
.preview-modal-body .tpl-thumb .tpl-sample-sub { font-size: 13px; }
.preview-modal-body .tpl-seal { width: 56px; height: 56px; }
.preview-modal-body .tpl-seal::after { font-size: 20px; }
.preview-modal-body .tpl-icon { width: 34px; height: 34px; }

/* ---------- Documents section: sub-tabs (Modèles / Générer) ---------- */
.doc-subnav { display: flex; gap: 6px; background: var(--c-bg-alt); border-radius: var(--radius-full); padding: 5px; width: fit-content; margin-bottom: 22px; }
.doc-subnav button { background: none; border: none; font-size: 13.5px; font-weight: 700; color: var(--c-ink-soft); padding: 9px 18px; border-radius: var(--radius-full); }
.doc-subnav button.active { background: #fff; color: var(--c-primary-950); box-shadow: var(--shadow-sm); }

.workspace-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--c-muted); margin-bottom: 20px; flex-wrap: wrap; }
.workspace-breadcrumb button.link { background: none; border: none; padding: 0; font: inherit; color: var(--c-accent-600); font-weight: 700; }
.workspace-breadcrumb .current { color: var(--c-primary-950); font-weight: 700; }
.workspace-breadcrumb .sep { opacity: .5; }
.workspace-breadcrumb .change-tpl { margin-left: auto; }

/* ---------- Color swatch picker + signature ---------- */
.color-swatches { display: flex; gap: 10px; margin-bottom: 4px; }
.color-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; position: relative; }
.color-swatch.active { border-color: var(--c-ink); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c-ink); }
.color-swatch.active::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.85); }

.signature-upload { display: flex; align-items: center; gap: 12px; }
.signature-preview { width: 90px; height: 44px; border: 1px dashed var(--c-border); border-radius: 8px; background: var(--c-bg-alt); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--c-muted); overflow: hidden; }
.signature-preview img { max-width: 100%; max-height: 100%; }

.tpl-empty-fav { padding: 24px; text-align: center; color: var(--c-muted); font-size: 13px; background: var(--c-bg-alt); border-radius: var(--radius-md); }

/* ---------- Points balance (topbar badge) ---------- */
.points-topbar-badge {
  display: flex; align-items: center; gap: 7px;
  background: var(--c-bg-alt); border: 1px solid var(--c-border);
  border-radius: var(--radius-full); padding: 7px 14px 7px 10px;
  font-size: 13px; font-weight: 800; color: var(--c-primary-950);
}
.points-topbar-badge svg { width: 16px; height: 16px; color: var(--c-accent-600); }
.points-topbar-badge.low { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.points-topbar-badge.low svg { color: #dc2626; }

/* ---------- Low balance banner ---------- */
.low-balance-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  border-radius: var(--radius-md); padding: 14px 18px; margin-bottom: 22px;
}
.low-balance-banner svg { width: 20px; height: 20px; flex-shrink: 0; }
.low-balance-banner strong { font-weight: 800; }
.low-balance-banner .lbb-spacer { flex: 1; }

/* ---------- Points balance hero (points page) ---------- */
.points-hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; margin-bottom: 26px; }
.points-hero .wcard { padding: 28px; }
.points-balance-num { font-size: 44px; font-weight: 800; color: var(--c-primary-950); letter-spacing: -0.02em; line-height: 1; }
.points-balance-label { font-size: 13px; color: var(--c-muted); font-weight: 700; margin-top: 8px; }
.points-reset-note { font-size: 12.5px; color: var(--c-ink-soft); margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--c-border); }
@media (max-width: 900px) { .points-hero { grid-template-columns: 1fr; } }

/* ---------- Credit pack cards ---------- */
.pack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.pack-card { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 24px; text-align: center; position: relative; transition: transform .15s ease, box-shadow .15s ease; }
.pack-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.pack-card.best-value { border-color: var(--c-accent-500); }
.pack-card .pack-ribbon { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--c-accent-500); color: var(--c-primary-950); font-size: 11px; font-weight: 800; padding: 4px 12px; border-radius: var(--radius-full); white-space: nowrap; }
.pack-card .pack-points { font-size: 28px; font-weight: 800; color: var(--c-primary-950); margin: 8px 0 2px; }
.pack-card .pack-price { font-size: 15px; font-weight: 700; color: var(--c-accent-600); margin-bottom: 6px; }
.pack-card .pack-unit { font-size: 11.5px; color: var(--c-muted); margin-bottom: 18px; }
@media (max-width: 760px) { .pack-grid { grid-template-columns: 1fr; } }

/* ---------- Engine badge (Canva / Gamma indicator) ---------- */
.engine-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); }
.engine-badge svg { width: 13px; height: 13px; }
.engine-badge.engine-canva { background: #e8f0fe; color: #1a56c4; }
.engine-badge.engine-gamma { background: #f3e8ff; color: #7c3aed; }

/* ---------- Generation cost preview ---------- */
.cost-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--c-bg-alt); border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 14px; font-size: 13px; }
.cost-preview .cp-label { color: var(--c-ink-soft); }
.cost-preview .cp-amount { font-weight: 800; color: var(--c-primary-950); }
.cost-preview.insufficient { background: #fef2f2; color: #991b1b; }
.cost-preview.insufficient .cp-amount { color: #dc2626; }

/* ---------- Template Standard editing note ---------- */
.standard-edit-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--c-primary-50); border: 1px solid var(--c-primary-100);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12px; color: var(--c-primary-800);
  margin-bottom: 18px;
}
.standard-edit-note svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; color: var(--c-primary-700); }

/* ---------- CONNECT Communication (SMS / WhatsApp) ---------- */
.comms-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.comms-kpi-card { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 18px 20px; }
.comms-kpi-card .ck-label { font-size: 11.5px; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: .03em; }
.comms-kpi-card .ck-value { font-size: 22px; font-weight: 800; color: var(--c-primary-950); margin-top: 6px; letter-spacing: -0.01em; }
.comms-kpi-card .ck-sub { font-size: 11.5px; color: var(--c-ink-soft); margin-top: 4px; }
@media (max-width: 1100px) { .comms-kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.channel-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 700px) { .channel-cards { grid-template-columns: 1fr; } }

.segment-meter { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--c-muted); margin-top: 6px; flex-wrap: wrap; }
.segment-meter .sm-badge { font-weight: 800; padding: 2px 8px; border-radius: var(--radius-full); background: var(--c-bg-alt); color: var(--c-ink-soft); }
.segment-meter .sm-badge.warn { background: #fdf1e0; color: #b5690a; }

.tier-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); background: var(--c-primary-100); color: var(--c-primary-800); }
.tier-badge.blocked { background: #fee2e2; color: #dc2626; }

.consent-note { display: flex; gap: 10px; align-items: flex-start; background: var(--c-primary-50); border: 1px solid var(--c-primary-100); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12px; color: var(--c-primary-800); margin: 4px 0 14px; }
.consent-note svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; color: var(--c-primary-700); }
.consent-note.exclude { background: #fdf1e0; border-color: #f4d9ab; color: #8a4c06; }
.consent-note.exclude svg { color: #b5690a; }
.consent-note.enterprise { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.consent-note.enterprise svg { color: #dc2626; }
.consent-note a { color: inherit; font-weight: 800; text-decoration: underline; }

.msgtype-toggle { display: flex; gap: 8px; margin-bottom: 4px; }
.msgtype-toggle label { flex: 1; }

.phone-preview { background: var(--c-primary-950); color: #fff; border-radius: var(--radius-lg); padding: 20px; }
.phone-preview .pp-sender { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--c-accent-400); }
.phone-preview .pp-bubble { background: rgba(255,255,255,0.08); border-radius: 14px; padding: 14px 16px; margin-top: 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; color: rgba(255,255,255,0.92); }
.phone-preview .pp-meta { display: flex; justify-content: space-between; margin-top: 14px; font-size: 11px; color: rgba(255,255,255,0.5); }

.automation-rule { display: flex; align-items: flex-start; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--c-border); }
.automation-rule:last-child { border-bottom: none; }
.automation-rule .ar-body { flex: 1; min-width: 0; }
.automation-rule .ar-title { font-size: 13.5px; font-weight: 750; color: var(--c-primary-950); display: flex; align-items: center; gap: 8px; }
.automation-rule .ar-trigger { font-size: 11.5px; color: var(--c-muted); margin-top: 2px; }
.automation-rule .ar-msg { font-size: 12px; color: var(--c-ink-soft); margin-top: 8px; background: var(--c-bg-alt); border-radius: var(--radius-sm); padding: 8px 12px; }
.automation-rule .ar-channel { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: var(--radius-full); background: var(--c-bg-alt); color: var(--c-ink-soft); }

.delivery-bar { display: flex; height: 8px; border-radius: var(--radius-full); overflow: hidden; background: var(--c-bg-alt); min-width: 110px; }
.delivery-bar span { height: 100%; }
.delivery-bar .db-delivered { background: var(--c-accent-500); }
.delivery-bar .db-failed { background: #dc2626; }
.delivery-bar .db-skipped { background: var(--c-border); }
.delivery-legend { display: flex; gap: 10px; font-size: 10.5px; color: var(--c-muted); margin-top: 4px; flex-wrap: wrap; }
.delivery-legend span { display: inline-flex; align-items: center; gap: 4px; }
.delivery-legend i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.delivery-legend .i-delivered { background: var(--c-accent-500); }
.delivery-legend .i-failed { background: #dc2626; }
.delivery-legend .i-skipped { background: var(--c-border); }

.high-failure-flag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 800; color: #dc2626; margin-top: 4px; }
.high-failure-flag svg { width: 12px; height: 12px; }

.var-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.var-chip { font-size: 11px; font-weight: 700; color: var(--c-primary-700); background: var(--c-primary-50); border: 1px solid var(--c-primary-100); border-radius: var(--radius-full); padding: 3px 10px; cursor: pointer; font-family: monospace; }
.var-chip:hover { background: var(--c-primary-100); }

/* responsive sidebar */
@media (max-width: 980px) {
  .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(10,17,48,0.5); z-index: 39; }
  .sidebar-overlay.open { display: block; }
  .doc-preview-frame { position: static; }
}
