:root {
  --ink: #111214; --ink-2: #1a1d20; --paper: #f4f4f1; --white: #fff;
  --muted: #687078; --line: #dfe2e4; --teal: #08766e; --teal-dark: #075c56;
  --red: #b83d39; --green: #17835f; --shadow: 0 12px 32px rgb(18 22 26 / 10%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 14px; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #44bdb5; outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 .35rem; color: var(--teal); font-size: .72rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.brand-mark { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 900; letter-spacing: -.08em; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 8px; font-size: .76rem; }
.login-screen { display: grid; min-height: 100vh; grid-template-columns: minmax(360px,1.08fr) minmax(420px,.92fr); background:#090b0d; }
.login-showcase { position:relative; display:flex; min-height:100vh; flex-direction:column; justify-content:center; overflow:hidden; padding:clamp(3rem,8vw,8rem); color:#fff; background:linear-gradient(110deg,rgba(5,7,9,.98),rgba(5,7,9,.76)),url('/assets/images/hero-photo.webp') center/cover; }
.login-showcase::after { position:absolute; right:-9rem; bottom:-9rem; width:25rem; height:25rem; border:1px solid rgb(109 197 190 / 24%); border-radius:50%; content:""; box-shadow:0 0 0 4rem rgb(8 118 110 / 7%),0 0 0 8rem rgb(8 118 110 / 5%); }
.login-showcase > * { position:relative; z-index:1; }
.login-showcase > img { width:190px; height:auto; margin-bottom:3.5rem; filter:brightness(1.45); }
.login-showcase h2 { max-width:720px; margin:.5rem 0 1.5rem; font-size:clamp(3rem,6vw,6.8rem); line-height:.84; letter-spacing:-.055em; }
.login-showcase h2 span { color:#aeb8c8; }
.login-showcase > p:last-of-type { max-width:650px; margin:0; color:#c8cccf; font-size:1.05rem; line-height:1.7; }
.login-feature-grid { display:grid; max-width:650px; grid-template-columns:repeat(2,1fr); gap:1px; margin-top:3rem; background:rgb(255 255 255 / 18%); }
.login-feature-grid span { background:rgb(8 11 13 / 72%); padding:1rem; color:#dce0e2; font-size:.76rem; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.login-form-panel { display:grid; min-height:100vh; place-items:center; padding:clamp(1.5rem,5vw,5rem); background:linear-gradient(145deg,#f8f8f5,#e9ece8); }
.login-card { width:min(100%,460px); border:1px solid var(--line); background:#fff; padding:clamp(2rem,5vw,3.25rem); box-shadow:0 24px 70px rgb(0 0 0 / 14%); }
.login-logo { width:145px; height:auto; margin-bottom:2rem; filter:invert(1); }
.login-card h1 { margin:.65rem 0 .65rem; font-size:2.35rem; letter-spacing:-.05em; }
.login-card label, .field { display: grid; gap: .4rem; margin-top: 1rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #cbd0d3; border-radius: 5px; background: #fff; padding: .72rem .8rem; color: var(--ink); }
textarea { min-height: 9rem; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.5; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 5px; padding: .6rem 1rem; color: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.button.primary { background: var(--teal); color: #fff; }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { border-color: #cbd0d3; background: #fff; }
.button.danger { border-color: #edc2c0; background: #fff4f4; color: var(--red); }
.button.ghost { border-color: rgb(255 255 255 / 25%); color: #fff; }
.login-card .button { width: 100%; margin-top: 1.25rem; }
.login-card input { min-height:48px; background:#fafbfa; }
.login-card input:focus { border-color:var(--teal); background:#fff; }
.form-message { min-height: 1.4rem; margin: .75rem 0 0; color: var(--red); }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 1rem; background: var(--ink); padding: .65rem 1.25rem; color: #fff; }
.portal-brand, .topbar-actions { display: flex; align-items: center; gap: .8rem; color: inherit; text-decoration: none; }
.topbar-actions { font-size: .82rem; }
.link-button { border: 0; background: transparent; color: #fff; cursor: pointer; text-decoration: underline; }
.workspace { display: grid; min-height: calc(100vh - 58px); grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { border-right: 1px solid var(--line); background: #fff; padding: 1rem .75rem; }
.sidebar nav { position: sticky; top: 74px; display: grid; gap: .25rem; }
.nav-item { display: flex; width: 100%; align-items: center; justify-content: space-between; border: 0; border-radius: 5px; background: transparent; padding: .72rem .8rem; color: #4d545b; text-align: left; cursor: pointer; }
.nav-item:hover { background: #f0f3f2; }
.nav-item.active { background: #e4f1ef; color: var(--teal-dark); font-weight: 800; }
.badge { min-width: 1.6rem; border-radius: 999px; background: #e1e5e6; padding: .15rem .4rem; font-size: .68rem; text-align: center; }
.main-panel { min-width: 0; padding: clamp(1rem, 3vw, 2.25rem); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; font-size: 1.65rem; letter-spacing: -.035em; }
.page-header p { margin: .35rem 0 0; color: var(--muted); }
.header-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stat-card, .panel { border: 1px solid var(--line); background: #fff; box-shadow: 0 3px 12px rgb(20 30 35 / 4%); }
.stat-card { padding: 1.3rem; }
.stat-card span { color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; }
.stat-card strong { display: block; margin-top: .35rem; font-size: 2rem; }
.stat-card small { display: block; margin-top: .35rem; color: var(--muted); }
.panel { margin-top: 1.25rem; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding: 1rem 1.15rem; }
.panel-header h2 { margin: 0; font-size: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .55rem; }
.filters input, .filters select { width: auto; min-width: 12rem; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid #eceeef; padding: .78rem 1rem; text-align: left; vertical-align: top; white-space: nowrap; }
th { background: #fafbfb; color: #596168; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; }
td.wrap-cell { max-width: 27rem; white-space: normal; }
tbody tr:hover { background: #fbfcfc; }
.status { display: inline-flex; align-items: center; gap: .4rem; font-size: .77rem; font-weight: 700; text-transform: capitalize; }
.status::before { width: 7px; height: 7px; border-radius: 50%; background: #9ba1a5; content: ""; }
.status.published::before, .status.completed::before, .status.sent::before { background: var(--green); }
.status.unread::before, .status.draft::before, .status.pending::before { background: #dc8616; }
.status.failed::before { background: var(--red); }
.status.active::before { background: var(--green); }
.status.invited::before { background: #dc8616; }
.status.disabled::before { background: var(--red); }
.row-actions { display: flex; gap: .35rem; }
.icon-button { border: 1px solid #d5d9db; border-radius: 4px; background: #fff; padding: .35rem .55rem; cursor: pointer; }
.empty-state { padding: 3rem 1.5rem; color: var(--muted); text-align: center; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; padding: 1.25rem; }
.settings-grid .wide { grid-column: 1 / -1; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; padding: 1.15rem; }
.media-card { min-width: 0; border: 1px solid var(--line); background: #fff; }
.media-preview { display: grid; height: 145px; place-items: center; overflow: hidden; background: #eef0f0; color: var(--muted); }
.media-preview img { width: 100%; height: 100%; object-fit: cover; }
.media-meta { padding: .75rem; }
.media-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta code { display: block; margin-top: .35rem; overflow: hidden; color: var(--teal-dark); font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.menu-list { display: grid; gap: .6rem; padding: 1.15rem; }
.menu-row { display: grid; grid-template-columns: 2rem 1fr 1.5fr auto auto; gap: .55rem; align-items: center; border: 1px solid var(--line); background: #fff; padding: .65rem; }
.drag-handle { color: #9aa0a4; text-align: center; }
.loading { padding: 3rem; color: var(--muted); text-align: center; }
.toast { position: fixed; z-index: 50; right: 1rem; bottom: 1rem; max-width: 25rem; transform: translateY(150%); border-radius: 5px; background: var(--ink); padding: .85rem 1rem; color: #fff; box-shadow: var(--shadow); transition: transform .2s ease; }
.toast.show { transform: translateY(0); }
dialog { width: min(94vw, 900px); max-height: 92vh; border: 0; padding: 0; box-shadow: 0 25px 70px rgb(0 0 0 / 30%); }
dialog::backdrop { background: rgb(0 0 0 / 50%); }
.dialog-shell { display: grid; max-height: 92vh; grid-template-rows: auto minmax(0, 1fr) auto; }
.dialog-header, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; }
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; }
.dialog-body { overflow: auto; padding: 1.25rem; }
.dialog-actions { border-top: 1px solid var(--line); background: #fafafa; }
.dialog-actions > div { display: flex; gap: .5rem; }
.close-button { border: 0; background: transparent; font-size: 1.5rem; cursor: pointer; }

.submission-tabs { display: flex; gap: 1.25rem; overflow-x: auto; border-bottom: 1px solid var(--line); padding: 0 1.15rem; }
.submission-tabs button { border: 0; border-bottom: 3px solid transparent; background: transparent; padding: .9rem .15rem .7rem; color: var(--muted); cursor: pointer; text-transform: capitalize; }
.submission-tabs button.active { border-color: var(--teal); color: var(--ink); font-weight: 800; }
.lead-detail-dialog { width: min(96vw, 1500px); }
.lead-detail-body { display: grid; min-height: 70vh; grid-template-columns: minmax(0, 2fr) minmax(300px, .9fr); overflow: auto; }
.lead-detail-body > section, .lead-detail-body > aside { padding: 1.5rem; }
.lead-detail-body > aside { border-left: 1px solid var(--line); background: #fafafa; }
.lead-detail-body h3 { margin: 0 0 .8rem; }
.lead-detail-body aside h3:not(:first-child) { margin-top: 2rem; }
.lead-detail-body aside .button { margin-top: .75rem; }
.detail-table { border: 1px solid var(--line); background: #fff; }
.detail-table > div { display: grid; grid-template-columns: minmax(150px,.65fr) minmax(0,1.35fr); gap: 1rem; border-bottom: 1px solid var(--line); padding: .85rem 1rem; }
.detail-table > div:last-child { border-bottom: 0; }
.detail-table span { color: var(--muted); }
.detail-table strong { min-width: 0; overflow-wrap: anywhere; font-weight: 650; white-space: pre-line; }
.detail-table.compact > div { padding: .65rem .8rem; font-size: .8rem; }

.main-panel.builder-mode { height: calc(100vh - 58px); padding: 0; overflow: hidden; }
.builder-toolbar { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); background: #fff; padding: .65rem 1rem; }
.builder-toolbar > div { display: flex; align-items: center; gap: .55rem; }
.page-builder { display: grid; height: calc(100vh - 122px); grid-template-columns: 220px minmax(420px,1fr) 290px; }
.block-library, .block-settings { overflow-y: auto; background: #fff; padding: 1rem; }
.block-library { border-right: 1px solid var(--line); }
.block-settings { border-left: 1px solid var(--line); }
.block-library h2 { margin: 0; font-size: 1rem; }
.block-library-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; margin-top: 1rem; }
.block-library-grid button { display: grid; min-height: 76px; place-items: center; gap: .3rem; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: #4d545b; font-size: .72rem; cursor: grab; }
.block-library-grid button:hover { border-color: var(--teal); color: var(--teal-dark); background: #f2fbfa; }
.block-library-grid button span { color: var(--teal); font-size: 1.1rem; font-weight: 900; }
.builder-stage { display: grid; min-width: 0; grid-template-rows: auto minmax(0,1fr); background: #dfe3e4; padding: 1rem; }
.builder-stage-bar { display: flex; align-items: center; justify-content: space-between; background: #fff; padding: .7rem .9rem; font-size: .78rem; }
.builder-stage-bar span { color: var(--muted); }
#builder-frame { width: 100%; height: 100%; border: 0; background: #fff; box-shadow: 0 4px 16px rgb(20 30 35 / 12%); }
.builder-placeholder { color: var(--muted); line-height: 1.6; }
.builder-settings-head { display: grid; gap: .15rem; border-bottom: 1px solid var(--line); padding-bottom: .85rem; }
.builder-settings-fields { padding-bottom: 1rem; }
.builder-settings-fields textarea { min-height: 8rem; font-size: .78rem; }
.inline-edit-callout, .inline-edit-card { margin: 1rem 0; border: 1px solid #b9dcd9; background: #f1fbfa; padding: .85rem; }
.inline-edit-callout { display: grid; gap: .3rem; }
.inline-edit-callout span { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.inline-edit-card > strong { display: block; }
.inline-edit-card > p { margin: .45rem 0; font-size: .78rem; line-height: 1.45; }
.advanced-html { border-top: 1px solid var(--line); padding-top: .8rem; }
.advanced-html summary { color: var(--muted); font-size: .78rem; font-weight: 750; cursor: pointer; }
.color-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: .3rem; margin-top: .65rem; }
.swatch { aspect-ratio: 1; min-width: 0; border: 1px solid #abb0b3; border-radius: 3px; cursor: pointer; }
.swatch-white { background: #fff; }.swatch-ink { background: #090a0c; }.swatch-charcoal { background: #303338; }.swatch-gray { background: #777b80; }
.swatch-teal { background: #08766e; }.swatch-blue { background: #2563eb; }.swatch-gold { background: #c38308; }.swatch-red { background: #c43d32; }
.builder-wide { width: 100%; margin-top: .8rem; }
.builder-block-actions { display: flex; flex-wrap: wrap; gap: .4rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.danger-text { color: var(--red); }
.revision-list { display: grid; gap: .65rem; }
.revision-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border: 1px solid var(--line); padding: .85rem; }
.media-choice { padding: 0; color: inherit; text-align: left; cursor: pointer; }
.media-choice:hover { border-color: var(--teal); }

@media (max-width: 900px) {
  .login-screen { grid-template-columns:1fr; background:var(--paper); }
  .login-showcase { display:none; }
  .login-form-panel { min-height:100vh; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 15; top: 58px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: .5rem; }
  .sidebar nav { position: static; display: flex; width: max-content; }
  .nav-item { width: auto; white-space: nowrap; }
  .page-builder { grid-template-columns: 170px minmax(360px,1fr) 250px; overflow-x: auto; }
  .builder-toolbar { overflow-x: auto; }
  .lead-detail-body { grid-template-columns: 1fr; }
  .lead-detail-body > aside { border-top: 1px solid var(--line); border-left: 0; }
}
@media (max-width: 620px) {
  .topbar-actions #account-name, .topbar .button { display: none; }
  .main-panel { padding: 1rem; }
  .page-header { display: grid; }
  .stat-grid, .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .wide { grid-column: auto; }
  .menu-row { grid-template-columns: 1.5rem 1fr auto; }
  .menu-row .menu-url { grid-column: 2 / -1; }
  .detail-table > div { grid-template-columns: 1fr; gap: .25rem; }
}

@media print {
  body > * { visibility: hidden; }
  #editor-dialog, #editor-dialog * { visibility: visible; }
  #editor-dialog { position: absolute; inset: 0; width: 100%; max-height: none; box-shadow: none; }
  .close-button, [data-print-entry], [data-save-entry-notes] { display: none !important; }
}
.global-block-note { display: grid; gap: .5rem; margin-top: 1rem; padding: 1rem; background: #e2f3f1; color: #075f59; font-size: .85rem; }
