:root {
  --ink: #24332f;
  --ink-soft: #64706d;
  --forest: #305f52;
  --forest-dark: #21473d;
  --sage: #dfe8dc;
  --sage-pale: #f2f5ef;
  --cream: #f7f5ef;
  --paper: #fffefd;
  --rose: #b46f65;
  --gold: #c8a86b;
  --border: #e5e8e0;
  --shadow: 0 18px 55px rgba(46, 65, 57, .09);
  --sidebar: 248px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
code { background: #ecefe9; border-radius: 5px; padding: 2px 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; padding: 26px 18px 18px; color: #f5f4ef; background: linear-gradient(180deg, #294e45 0%, #1f3d36 100%); box-shadow: 9px 0 35px rgba(29, 56, 49, .1); z-index: 20; }
.brand-lockup { display: flex; gap: 12px; align-items: center; padding: 2px 8px 28px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px 14px 14px 5px; background: #ebeee2; color: var(--forest-dark); font: 600 23px Georgia, serif; box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup strong { font: 600 18px Georgia, serif; letter-spacing: .01em; }
.brand-lockup span { margin-top: 3px; color: #bdcec7; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; }
.nav-item { width: 100%; border: 0; border-radius: 10px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; background: transparent; color: #c8d4ce; text-align: left; font-size: 14px; transition: .18s ease; }
.nav-item span { width: 18px; font-size: 18px; text-align: center; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.105); }
.nav-item.active { box-shadow: inset 3px 0 #d5c596; }
.safety-card { display: flex; gap: 10px; align-items: flex-start; margin-top: auto; padding: 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: rgba(255,255,255,.07); }
.safety-card strong, .safety-card span { display: block; }
.safety-card strong { font-size: 13px; }
.safety-card span:last-child { margin-top: 3px; color: #b9cbc4; font-size: 11px; }
.status-dot { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: #79c59b; box-shadow: 0 0 0 4px rgba(121,197,155,.12); }
.sidebar-footer { padding: 15px 3px 0; color: #91a9a0; font-size: 10px; text-align: center; }

.main { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; height: 76px; display: flex; justify-content: space-between; align-items: center; padding: 0 34px; border-bottom: 1px solid var(--border); background: rgba(247,245,239,.92); backdrop-filter: blur(14px); z-index: 15; }
.list-switcher label { display: block; margin-bottom: 3px; color: var(--ink-soft); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.list-switcher select { min-width: 186px; border: 0; background: transparent; color: var(--ink); font-weight: 700; outline: none; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill-safe { color: #35684e; background: #e3f0e6; }
.pill .status-dot { margin: 0; width: 7px; height: 7px; }
.icon-button, .avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; }
.icon-button { border: 1px solid var(--border); background: var(--paper); color: var(--ink-soft); }
.avatar { background: var(--forest); color: white; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.content { max-width: 1500px; margin: 0 auto; padding: 38px 34px 80px; }
.view { display: none; animation: fade .22s ease both; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.page-heading { margin-bottom: 28px; }
.page-heading h1 { margin: 4px 0 6px; font: 500 clamp(30px, 4vw, 42px) Georgia, serif; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.page-heading .eyebrow { color: var(--rose); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.heading-with-action { display: flex; justify-content: space-between; gap: 28px; align-items: flex-end; }
.heading-actions, .toolbar-filters { display: flex; gap: 9px; align-items: center; }
.button { border-radius: 10px; padding: 11px 16px; border: 1px solid transparent; font-weight: 750; font-size: 13px; transition: .18s ease; }
.button:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(33,71,61,.12); }
.button-primary { background: var(--forest); color: white; }
.button-primary:hover { background: var(--forest-dark); }
.button-secondary { border-color: #cbd5cf; background: var(--paper); color: var(--forest); }
.button-quiet { border-color: transparent; background: transparent; color: var(--ink-soft); }
.text-button, .back-button { border: 0; background: transparent; color: var(--forest); font-size: 13px; font-weight: 750; }

.notice { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 24px; padding: 16px 18px; border: 1px solid #dedfd5; border-radius: 13px; background: #fffdf6; }
.notice-safe { border-color: #cfe1d5; background: #f1f7f0; }
.notice-warning { border-color: #e6d6b9; background: #fff9ed; }
.notice-icon { display: grid; place-items: center; flex: 0 0 auto; width: 27px; height: 27px; border-radius: 50%; background: var(--forest); color: white; font-weight: 800; font-size: 13px; }
.notice strong { font-size: 14px; }
.notice p { margin: 4px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.metric-card { position: relative; overflow: hidden; min-height: 132px; padding: 22px; border: 1px solid var(--border); border-radius: 15px; background: var(--paper); box-shadow: 0 8px 24px rgba(46,65,57,.035); }
.metric-card::after { content: ""; position: absolute; top: -42px; right: -35px; width: 100px; height: 100px; border-radius: 50%; background: var(--sage-pale); }
.metric-card > * { position: relative; z-index: 1; }
.metric-card span { display: block; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin: 8px 0 7px; font: 500 32px Georgia, serif; }
.metric-card strong span { display: inline; font: 500 15px Inter, sans-serif; }
.metric-card small { color: #86908d; font-size: 10px; }
.metric-grid-compact .metric-card { min-height: 104px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .8fr); gap: 20px; }
.panel { border: 1px solid var(--border); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 22px 24px 17px; }
.panel-heading h2 { margin: 0; font: 500 19px Georgia, serif; }
.panel-heading p { margin: 4px 0 0; color: var(--ink-soft); font-size: 11px; }
.campaign-list { padding: 0 18px 14px; }
.campaign-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 18px; align-items: center; padding: 15px 7px; border-top: 1px solid #edf0ea; }
.campaign-row:first-child { border-top: 0; }
.campaign-row strong, .campaign-row small { display: block; }
.campaign-row strong { font-size: 13px; }
.campaign-row small { margin-top: 4px; color: var(--ink-soft); font-size: 10px; }
.campaign-row .row-meta { color: var(--ink-soft); font-size: 11px; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: capitalize; }
.badge-draft { background: #eceeea; color: #68716e; }
.badge-completed, .badge-subscribed { background: #e4f0e6; color: #397050; }
.badge-scheduled { background: #e9edf8; color: #4e6191; }
.badge-unsubscribed { background: #f7e8e4; color: #96574f; }
.badge-cleaned { background: #f1e7d2; color: #80672f; }
.badge-non_subscribed, .badge-pending { background: #eceaf2; color: #6a607d; }
.check-list { list-style: none; margin: 0; padding: 0 22px 18px; }
.check-list li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid #edf0ea; }
.check-list li > span { display: grid; place-items: center; width: 23px; height: 23px; flex: 0 0 auto; border-radius: 50%; font-size: 11px; font-weight: 800; }
.check-list strong, .check-list small { display: block; }
.check-list strong { font-size: 12px; }
.check-list small { margin-top: 3px; color: var(--ink-soft); font-size: 10px; }
.check-list .done > span { background: #e1efe4; color: #397050; }
.check-list .pending > span { background: #f3ebd9; color: #8a6e37; }
.check-list .locked > span { background: #eee7e6; color: #946158; }

.toolbar { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.toolbar select, .search-field { border: 1px solid var(--border); border-radius: 10px; background: var(--paper); }
.toolbar select { padding: 10px 13px; color: var(--ink-soft); }
.search-field { display: flex; align-items: center; gap: 8px; min-width: min(410px, 55%); padding: 0 12px; }
.search-field input { width: 100%; padding: 10px 0; border: 0; outline: 0; background: transparent; }
.search-field span { color: #89928f; }
.table-panel { overflow: hidden; box-shadow: 0 12px 38px rgba(46,65,57,.055); }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 18px; background: #f5f6f2; color: #7d8783; font-size: 10px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 16px 18px; border-top: 1px solid #edf0ea; font-size: 12px; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--ink-soft); }
.row-menu { border: 0; background: transparent; color: var(--ink-soft); font-size: 18px; }
.empty-row { padding: 35px; color: var(--ink-soft); text-align: center; }
.list-manager-panel { margin-bottom: 22px; }
.subtle-count { color: var(--ink-soft); font-size: 11px; }
.mailing-list-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 0 22px 22px; }
.mailing-list-card { min-height: 88px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--sage-pale); }
.mailing-list-card strong, .mailing-list-card small { display: block; }
.mailing-list-card strong { font: 500 16px Georgia, serif; }
.mailing-list-card small { margin-top: 7px; color: var(--ink-soft); font-size: 10px; }
.membership-chips { display: grid; gap: 5px; min-width: 220px; }
.membership-chip { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 5px 6px 5px 9px; border-radius: 9px; background: #f4f6f1; color: var(--ink-soft); font-size: 10px; }
.membership-chip .badge { flex: 0 0 auto; }
.unassigned-chip { display: inline-block; padding: 7px 9px; border-radius: 9px; background: #f1eee7; color: var(--ink-soft); font-size: 10px; }

.timeline { padding: 14px 24px 25px; }
.timeline-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: start; padding: 17px 0; border-top: 1px solid #edf0ea; }
.timeline-item:first-child { border-top: 0; }
.timeline-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--sage-pale); color: var(--forest); font-weight: 800; }
.timeline strong, .timeline small { display: block; }
.timeline strong { font-size: 13px; }
.timeline small { margin-top: 4px; color: var(--ink-soft); font-size: 11px; }
.timeline time { color: #8b9591; font-size: 10px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.settings-card { padding-bottom: 22px; }
.settings-card label { display: block; margin: 13px 22px; color: var(--ink-soft); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.settings-card label input { display: block; width: 100%; margin-top: 6px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fafbf8; color: var(--ink); font-size: 12px; text-transform: none; }
.settings-card > small { display: block; margin: 13px 22px 0; color: #88918e; font-size: 10px; line-height: 1.5; }
.muted-card { background: #faf9f5; }
.inline-note { margin: 18px 22px 0; padding: 12px; border-radius: 9px; background: #f1eee7; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.switch-row { display: flex !important; align-items: center; justify-content: space-between; text-transform: none !important; }
.switch-row strong, .switch-row small { display: block; }
.switch-row input { width: auto !important; }

.editor-view { margin: -18px -10px 0; }
.editor-topline { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 15px; }
.editor-actions { display: flex; gap: 8px; align-items: center; }
.save-state { color: var(--ink-soft); font-size: 10px; }
.editor-meta { display: grid; grid-template-columns: 1.05fr 1.4fr 1.2fr; gap: 12px; padding: 15px; border: 1px solid var(--border); border-radius: 13px 13px 0 0; background: var(--paper); }
.editor-meta label span { display: block; margin-bottom: 6px; color: #79837f; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.editor-meta input { width: 100%; border: 0; border-bottom: 1px solid #dfe3dc; padding: 5px 1px 8px; outline: none; color: var(--ink); background: transparent; }
.editor-meta input:focus { border-color: var(--forest); }
.campaign-audience-panel { display: grid; grid-template-columns: 1fr auto; gap: 22px; align-items: center; padding: 14px 16px; border-inline: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fbfcf9; }
.field-label { display: block; margin-bottom: 8px; color: #79837f; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.campaign-list-options { display: flex; gap: 8px; flex-wrap: wrap; }
.list-choice { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border: 1px solid #dce2da; border-radius: 9px; background: white; }
.list-choice input { accent-color: var(--forest); }
.list-choice strong, .list-choice small { display: block; }
.list-choice strong { font-size: 11px; }
.list-choice small { margin-top: 2px; color: var(--ink-soft); font-size: 9px; }
.recipient-count { min-width: 170px; text-align: right; }
.recipient-count strong { font: 500 24px Georgia, serif; color: var(--forest); }
.recipient-count span, .recipient-count small { display: block; color: var(--ink-soft); font-size: 10px; }
.recipient-count small { margin-top: 2px; }
.layout-strip { min-height: 52px; display: flex; gap: 7px; align-items: center; padding: 10px 14px; border-inline: 1px solid var(--border); background: #f5f6f2; overflow-x: auto; }
.layout-strip > span { margin-right: 4px; color: var(--ink-soft); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.layout-strip button { white-space: nowrap; border: 1px solid #d8ded7; border-radius: 999px; padding: 7px 10px; background: white; color: var(--forest); font-size: 10px; font-weight: 700; }
.layout-strip button:hover { border-color: var(--forest); }
#saved-layout-buttons { display: contents; }
.editor-frame { height: calc(100vh - 280px); min-height: 570px; overflow: hidden; border: 1px solid var(--border); border-radius: 0 0 13px 13px; background: white; box-shadow: var(--shadow); }
#gjs { height: 100%; }

/* GrapesJS theme */
.gjs-one-bg { background-color: #2a4e45; }
.gjs-two-color { color: #d8e2dd; }
.gjs-three-bg { background-color: #d9c99e; color: #263e37; }
.gjs-four-color, .gjs-four-color-h:hover { color: #d9c99e; }
.gjs-block { min-height: 72px; width: 45%; border-radius: 8px; box-shadow: none; border: 1px solid rgba(255,255,255,.12); }
.gjs-block-label { font-size: 10px; }
.gjs-pn-panel { border-color: rgba(255,255,255,.08); }

.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(26,42,37,.55); backdrop-filter: blur(5px); z-index: 100; }
.modal-backdrop[hidden] { display: none; }
.modal { position: relative; width: min(650px, 96vw); max-height: 90vh; overflow: auto; padding: 28px; border-radius: 18px; background: var(--paper); box-shadow: 0 35px 100px rgba(23,45,38,.3); }
.modal-large { width: min(1020px, 96vw); }
.modal-close { position: absolute; top: 13px; right: 15px; border: 0; background: transparent; color: var(--ink-soft); font-size: 25px; }
.modal h2 { margin: 0 0 6px; font: 500 25px Georgia, serif; }
.modal p { color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.modal-form { display: grid; gap: 14px; margin-top: 20px; }
.modal-form label { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.modal-form input, .modal-form select { display: block; width: 100%; margin-top: 6px; padding: 11px; border: 1px solid var(--border); border-radius: 9px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.preview-shell { margin-top: 18px; padding: 18px; border-radius: 12px; background: #e7e9e5; }
.preview-shell iframe { width: 100%; min-height: 560px; border: 0; border-radius: 7px; background: white; }
.summary-box { margin-top: 16px; padding: 14px; border-radius: 10px; background: var(--sage-pale); font-size: 11px; line-height: 1.65; }
.membership-grid { display: grid; gap: 9px; margin: 20px 0; }
.membership-choice { display: flex; gap: 11px; align-items: center; padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: #fafbf8; }
.membership-choice input { accent-color: var(--forest); }
.membership-choice strong, .membership-choice small { display: block; }
.membership-choice strong { font-size: 12px; }
.membership-choice small { margin-top: 3px; color: var(--ink-soft); font-size: 10px; }
.compact-notice { margin: 16px 0 0; padding: 12px; }
.form-error { min-height: 18px; margin-top: 7px; color: #9b4e45; font-size: 11px; }
.toast-region { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 8px; z-index: 120; }
.toast { min-width: 260px; max-width: 370px; padding: 13px 15px; border-radius: 11px; background: #203e36; color: white; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .24s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1080px) {
  :root { --sidebar: 210px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .mailing-list-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .main { grid-column: 1; }
  .topbar { padding: 0 16px; }
  .content { padding: 26px 16px 60px; }
  .heading-with-action { align-items: flex-start; flex-direction: column; }
  .metric-grid, .settings-grid, .editor-meta { grid-template-columns: 1fr; }
  .mailing-list-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar-filters, .heading-actions { flex-wrap: wrap; }
  .campaign-audience-panel { grid-template-columns: 1fr; }
  .recipient-count { text-align: left; }
  .search-field { min-width: 100%; }
  .editor-actions { flex-wrap: wrap; justify-content: flex-end; }
  table { min-width: 680px; }
  .table-panel { overflow-x: auto; }
}
