/* App layout/scaffolding on top of ds.css's design-system components. */

body { background: var(--color-bg); color: var(--color-text); }
a { text-decoration: none; }

/* ================= Content Library — rounded redesign =================
   Scoped to .cl-page only (client/library.php's own wrapper) — the rest of
   the app deliberately uses sharp corners (--radius-md/--radius-lg are 0 in
   ds.css), so these overrides never leak into any other page. Radius is
   capped at 10px everywhere on this page (no pill/circle shapes) except the
   numbered row badge, which is a small round "index" marker, not a button. */
.cl-page .input { border-radius: 10px; }
.cl-page .toolbar-btn { border-radius: 10px; }
.cl-page .email-card { border-radius: 10px; }
.cl-page .add-item-btn { border-radius: 10px; }

.cl-info-banner {
  background: var(--color-surface); border: 1px solid rgba(32,30,29,.15); border-radius: 10px;
  padding: 16px 20px; font-size: 13px; line-height: 1.7;
  color: color-mix(in srgb, var(--color-text) 82%, transparent);
  margin-bottom: 20px; max-width: 780px;
}
.cl-info-banner b { color: var(--color-text); }

/* Tabs sit flush against the panel below (no gap) and the active tab erases
   the seam between them — same "connected" look as a browser tab strip. */
.cl-tabs { display: flex; gap: 6px; max-width: 780px; }
.cl-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px 10px 0 0;
  border: 1px solid rgba(32,30,29,.15); border-bottom: none;
  background: var(--color-surface); color: var(--color-text);
  font-family: 'Archivo'; font-weight: 800; font-size: 14px; cursor: pointer;
  position: relative; margin-bottom: -1px; z-index: 1;
}
.cl-tab-count { background: rgba(32,30,29,.12); color: inherit; border-radius: 10px; padding: 2px 9px; font-size: 12px; font-weight: 800; }
.cl-tab.active { background: #fff; color: var(--color-accent); z-index: 2; }
.cl-tab.active .cl-tab-count { background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent); }
/* Redraws the tab's own bottom edge in white, on top of the panel's border
   line right below it, so only the active tab visually merges into the panel. */
.cl-tab.active::after {
  content: ''; position: absolute; left: -1px; right: -1px; bottom: -1px; height: 1px; background: #fff;
}

.cl-panel { background: #fff; border: 1px solid rgba(32,30,29,.15); border-radius: 10px; padding: 26px; max-width: 780px; }
.cl-panel-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.cl-panel-header h4 { margin: 0; font-size: 16px; font-weight: 800; }
.cl-panel-count { font-size: 12px; color: color-mix(in srgb, var(--color-text) 55%, transparent); font-weight: 700; white-space: nowrap; }

.cl-sig-status { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 10px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.cl-sig-status.on { background: #e2e8dd; color: #2f4a1f; }
.cl-sig-status.off { background: rgba(32,30,29,.08); color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* ---------- Top loading bar (see app.js) ---------- */
#pageLoadBar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: var(--color-accent); z-index: 9999;
  opacity: 0;
  transition: width .3s ease, opacity .2s ease;
}
#pageLoadBar.active { opacity: 1; }

/* ---------- Suspended-account view-only mode ---------- */
/* Every page stays browsable, but nothing on it is clickable — except
   whatever's wrapped in .js-allow-when-suspended (the plan-change request). */
.app-content.suspended-readonly a,
.app-content.suspended-readonly button,
.app-content.suspended-readonly input,
.app-content.suspended-readonly select,
.app-content.suspended-readonly textarea {
  pointer-events: none;
  opacity: 0.55;
  cursor: not-allowed;
}
.app-content.suspended-readonly .js-allow-when-suspended,
.app-content.suspended-readonly .js-allow-when-suspended a,
.app-content.suspended-readonly .js-allow-when-suspended button,
.app-content.suspended-readonly .js-allow-when-suspended input,
.app-content.suspended-readonly .js-allow-when-suspended select,
.app-content.suspended-readonly .js-allow-when-suspended textarea {
  pointer-events: auto;
  opacity: 1;
  cursor: auto;
}

/* Same dimmed look during admin impersonation of a suspended client, but
   without pointer-events:none — admin still needs to be able to click
   through to actually help the account. This is a preview, not a lock. */
.app-content.suspended-preview a,
.app-content.suspended-preview button,
.app-content.suspended-preview input,
.app-content.suspended-preview select,
.app-content.suspended-preview textarea {
  opacity: 0.55;
}
.app-content.suspended-preview .js-allow-when-suspended,
.app-content.suspended-preview .js-allow-when-suspended a,
.app-content.suspended-preview .js-allow-when-suspended button,
.app-content.suspended-preview .js-allow-when-suspended input,
.app-content.suspended-preview .js-allow-when-suspended select,
.app-content.suspended-preview .js-allow-when-suspended textarea {
  opacity: 1;
}

/* ---------- Motion system (from the source design's page-level <style>) ---------- */
@keyframes qpFadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes qpPulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.7); } }
@keyframes qpDash { from { stroke-dashoffset: 260; } to { stroke-dashoffset: 0; } }
@keyframes qpTicker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes qpScan { 0% { transform: translateY(-10%); opacity: 0; } 10% { opacity: 0.5; } 90% { opacity: 0.5; } 100% { transform: translateY(110%); opacity: 0; } }
@keyframes qpDrift { 0%,100% { transform: translate(0,0); } 50% { transform: translate(6px,-8px); } }
.qp-cell { opacity: 0; animation: qpFadeUp 0.6s ease-out forwards; transition: background 0.2s ease; }
.qp-cell:hover { background: rgba(236,48,19,0.08); }
.qp-dot { animation: qpPulse 1.8s ease-in-out infinite; }
.qp-line { stroke-dasharray: 260; animation: qpDash 1.6s ease-out 0.4s forwards; }
.qp-ticker-track { display: flex; width: max-content; animation: qpTicker 22s linear infinite; }
.qp-chartbar { transition: background 0.15s ease, filter 0.15s ease; }
.qp-chartbar:hover { background: #ae1800 !important; filter: brightness(1.1); }
.qp-scan { position: absolute; left: 0; right: 0; height: 120px; background: linear-gradient(to bottom, transparent, rgba(236,48,19,0.10), transparent); animation: qpScan 7s linear infinite; pointer-events: none; }
.qp-bg-icon { position: absolute; stroke: #f3f2f2; animation: qpDrift 9s ease-in-out infinite; pointer-events: none; }
.qp-grid-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; background-image: radial-gradient(rgba(243,242,242,0.14) 1px, transparent 1px); background-size: 28px 28px; opacity: 0.5; }

/* ---------- Global interaction polish (rounded controls, focus glow, card lift) ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), select, textarea.input {
  border-radius: 10px !important;
  transition: box-shadow 0.2s ease, border-color 0.2s ease !important;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]):hover, select:hover, textarea.input:hover {
  border-color: rgba(236,48,19,0.45) !important;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]):focus-visible, select:focus-visible, textarea.input:focus-visible {
  border-color: #ec3013 !important;
  box-shadow: 0 0 0 4px rgba(236,48,19,0.15) !important;
}
button, .btn {
  border-radius: 10px !important;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease !important;
}
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }
button:active:not(:disabled), .btn:active:not(:disabled) { outline: 1px solid rgba(236,48,19,0.8); outline-offset: -1px; }
.btn-primary:hover { box-shadow: 0 0 0 6px rgba(236,48,19,0.16); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); box-shadow: 0 0 0 3px rgba(236,48,19,0.2); }
.btn-secondary:hover { border-color: var(--color-accent); box-shadow: 0 0 0 6px rgba(236,48,19,0.10); transform: translateY(-1px); }
.btn-secondary:active { transform: translateY(0); }
.card, .stat-card, .daily-card, .banner-usage, div[style*="background:var(--color-surface)"] {
  border-radius: 12px !important;
  border: 1px solid rgba(32,30,29,0.10);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.card:hover, .stat-card:hover, .daily-card:hover, .banner-usage:hover, div[style*="background:var(--color-surface)"]:hover {
  box-shadow: 0 6px 18px rgba(32,30,29,0.10);
  transform: translateY(-2px);
  border-color: rgba(236,48,19,0.35);
}

/* ---------- Dialogs / popups (ds.css's base tokens are 0-radius, 16px padding —
   too tight for this app's rounder, more generously-spaced look elsewhere) ---------- */
.dialog-backdrop { padding: 24px; z-index: 200; }
.dialog { border-radius: 16px; padding: 28px; gap: 4px; }
.dialog-title { margin-bottom: 2px; }
.dialog-body { margin-top: 10px; }
.dialog-actions { margin-top: 24px; gap: 10px; }

/* ---------- Auth screens ---------- */
.auth-split { min-height: 100vh; display: flex; }
.auth-split-brand {
  flex: 0 0 60%; min-height: 100vh; background: #201e1d; color: #f3f2f2;
  padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-split-form { flex: 1; min-height: 100vh; background: var(--color-bg); display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: min(400px, 100%); background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 40px 36px; display: flex; flex-direction: column; gap: 18px; }
.auth-card.wide { width: min(420px, 100%); }
.brand-mark { font-weight: 800; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--color-accent); }
.auth-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--color-bg); }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar { display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: #fff; border-bottom: 1px solid rgba(32,30,29,.12); flex: none; }
.app-logo { width: 34px; height: 34px; background: var(--color-accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; border-radius: 10px; }
.app-body { display: flex; flex: 1; min-height: 0; }
.app-sidebar {
  width: 236px; flex: none; background: #f9f8f8; border-right: 1px solid rgba(32,30,29,.12);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; overflow: auto;
  position: sticky; top: 0; align-self: flex-start; height: 100vh;
}
.nav-group-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .45; padding: 0 10px; margin-bottom: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; color: var(--color-text);
  border: none; border-radius: 10px; padding: 10px 12px; font-family: var(--font-heading); font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.nav-item svg { flex: none; }
.nav-item span.label { flex: 1; }
.nav-item:hover { background: rgba(32,30,29,.06); }
.nav-item.active { background: rgba(236,48,19,.10); color: var(--color-accent); }
.nav-item.active:hover { background: rgba(236,48,19,.10); }
.app-content { flex: 1; min-width: 0; overflow: auto; padding: 32px 40px; }

/* ---------- Dashboard ---------- */
.banner { background: #c9573f; color: #fff; border-radius: 16px; padding: 28px 32px; display: flex; align-items: center; gap: 24px; margin-bottom: 28px; flex-wrap: wrap; }
.banner-avatar { width: 56px; height: 56px; border-radius: 50%; background: #fff; color: var(--color-accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; flex: none; }
.banner-usage { flex: 0 0 380px; max-width: 100%; background: #fff; color: var(--color-text); border-radius: 12px; padding: 18px; box-shadow: 0 8px 20px rgba(32,30,29,.18); }
.progress-track { height: 7px; background: var(--color-neutral-200); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-accent); border-radius: 999px; }
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--color-surface); padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.chart-wrap { display: flex; gap: 10px; margin-bottom: 28px; }
.chart-yaxis { display: flex; flex-direction: column; justify-content: space-between; height: 140px; font-size: 10px; opacity: .55; text-align: right; flex: none; width: 40px; }
.chart-bars { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 140px; border-bottom: 2px solid rgba(32,30,29,.4); }
.chart-gridlines { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-gridlines div { border-top: 1px dashed rgba(32,30,29,.15); }
.chart-bar-col { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-bar { width: 100%; background: var(--color-accent); border-radius: 3px 3px 0 0; transition: background .15s ease, filter .15s ease; }
.chart-bar:hover { background: #ae1800; }
.chart-labels { display: flex; gap: 3px; margin-top: 6px; }
.chart-labels div { flex: 1; text-align: center; font-size: 9px; opacity: .55; white-space: nowrap; overflow: hidden; }
.daily-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 10px; margin-bottom: 28px; }
.daily-card { background: var(--color-surface); padding: 14px 12px; display: flex; flex-direction: column; gap: 9px; }
.daily-card.today { border-bottom: 3px solid var(--color-accent); }

/* ---------- Filters / tabs / pagination ---------- */
.tab-row { display: inline-flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn { background: var(--color-surface); color: var(--color-text); border: none; border-radius: 999px; padding: 9px 18px; font-size: 13px; font-family: var(--font-heading); cursor: pointer; }
.tab-btn.active { background: var(--color-accent); color: #fff; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager a, .pager span.pager-btn { background: transparent; border: 1px solid rgba(32,30,29,.4); padding: 6px 10px; font-family: var(--font-heading); font-size: 12px; cursor: pointer; color: var(--color-text); display: inline-block; }
.pager a.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.pager a.disabled { opacity: .4; pointer-events: none; }

/* ---------- Forms / misc ---------- */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-label { display: block; font-size: 12px; margin-bottom: 5px; color: rgba(32,30,29,.7); }
.error-text { color: #ae1800; font-size: 12.5px; }
.success-text { color: #2f4a1f; font-size: 12px; }
.muted { opacity: .65; }
table.table td, table.table th { white-space: nowrap; }
table.table td.wrap { white-space: normal; }
.toolbar-btn { width: 28px; height: 28px; background: transparent; border: 1px solid rgba(32,30,29,.4); font-size: 12px; cursor: pointer; }

/* ---------- Range sliders (plan-change modal) ---------- */
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  border-radius: 999px; outline: none; margin: 10px 0 4px; cursor: pointer;
  background: rgba(32,30,29,.15);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--color-accent); cursor: pointer; border: 3px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--color-accent); cursor: pointer;
  border: 3px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
input[type="range"]::-moz-range-track { background: transparent; height: 4px; border-radius: 999px; }

/* ---------- Toggle switch (feature modules) ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: rgba(32,30,29,.25); border-radius: 999px; transition: background .15s ease; cursor: pointer; }
.switch .track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s ease; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--color-accent); }
.switch input:checked + .track::before { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--color-accent); outline-offset: 2px; }
/* Content Library email-message card — one unified shell (border + radius on
   the outer wrapper, overflow:hidden clips every child to match) so the
   header, toolbar, and canvas read as one card instead of three separately-
   bordered boxes stacked with mismatched square/round corners. */
.email-card { border: 1px solid rgba(32,30,29,.25); border-radius: 8px; overflow: hidden; margin-bottom: 10px; background: #fff; }
.email-card-header { background: var(--color-surface); padding: 8px 10px 8px 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid rgba(32,30,29,.15); }

.rte-toolbar { display: flex; gap: 4px; align-items: center; padding: 6px 8px; background: var(--color-surface); border-bottom: 1px solid rgba(32,30,29,.15); flex-wrap: wrap; }
.rte-body { min-height: 160px; padding: 14px; font-size: 13px; font-family: var(--font-body); background: #fff; overflow: auto; }
.rte-canvas-wrap { background: var(--color-surface); padding: 20px 16px; }
.rte-canvas { max-width: 600px; margin: 0 auto; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* The editable canvas is capped to the ~600px width newsletters actually
   render at (same figure the preview modal uses), centered under the
   toolbar, so the visible edges of .rte-canvas always mark the real content
   width instead of stretching to fill the surrounding card. */
.rte-canvas-label {
  max-width: 600px; margin: 0 auto 8px; text-align: center;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}

/* "Expand" toolbar button — takes the editor fullscreen for more room,
   keeping the same 600px-capped canvas centered in the extra space. */
[data-rte].rte-fullscreen {
  position: fixed; inset: 0; z-index: 300; background: var(--color-surface);
  display: flex; flex-direction: column; padding: 0;
}
[data-rte].rte-fullscreen .rte-toolbar { flex: none; }
[data-rte].rte-fullscreen .rte-canvas-wrap { flex: 1; overflow: auto; padding: 24px 16px; }
[data-rte].rte-fullscreen .rte-canvas { min-height: 60vh; }
body.rte-fullscreen-lock { overflow: hidden; }

/* ---------- Calendar popover ---------- */
.cal-popover { position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 6px; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 16px; width: 290px; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.cal-day-btn { aspect-ratio: 1; min-height: 0; padding: 0; font-size: 12px; font-family: var(--font-heading); border-radius: 6px; background: transparent; color: var(--color-text); cursor: pointer; border: 1px solid transparent; }
.cal-day-btn.selected { background: var(--color-accent); color: #fff; }
.cal-day-btn.today:not(.selected) { border-color: var(--color-accent); }

/* ---------- Toast / flash ---------- */
.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.flash { padding: 12px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md); }
.flash-success { background: #e2e8dd; color: #2f4a1f; }
.flash-error { background: #ffe0d9; color: #7c1405; }
.flash-info { background: var(--color-surface); color: var(--color-text); }

/* ---------- Utility ---------- */
.flex { display: flex; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.items-center { align-items: center; } .items-baseline { align-items: baseline; } .items-end { align-items: flex-end; } .justify-between { justify-content: space-between; }
.mb-4{margin-bottom:4px;} .mb-8{margin-bottom:8px;} .mb-12{margin-bottom:12px;} .mb-14{margin-bottom:14px;} .mb-16{margin-bottom:16px;} .mb-20{margin-bottom:20px;} .mb-24{margin-bottom:24px;} .mb-28{margin-bottom:28px;}
.w-full { width: 100%; }
.text-right { text-align: right; }
.small { font-size: 12px; }
.badge { display: inline-block; font-size: 11px; padding: 3px 10px; }

@media (max-width: 900px) {
  .auth-split-brand { display: none; }
  .app-sidebar { position: static; height: auto; width: 100%; }
  .app-body { flex-direction: column; }
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .daily-grid { grid-template-columns: repeat(3,1fr); }
}
