/* Marketing Command Center — brand-neutral UI.
   The company accent is injected at runtime as --accent; nothing here is company specific. */

:root {
  --accent: #4F7CFF;
  --brand: #4F7CFF;
  --bg-1: #0d0f13;
  --bg-2: #14171d;
  --bg-3: #1b1f27;
  --line: #262b34;
  --text-1: #eef1f6;
  --text-2: #aab2c0;
  --text-3: #6f7887;
  --ok: #35c07f;
  --warn: #e5a53a;
  --err: #ef4e5a;
  --c1: #4F7CFF; --c2: #8C5BF6; --c3: #E45C9E; --c4: #F0803C;
  --c5: #E5C13A; --c6: #35C07F; --c7: #2FB6C4; --c8: #EF4E5A;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.28);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
[data-theme="light"] {
  --bg-1: #f6f7fa; --bg-2: #ffffff; --bg-3: #f0f2f7;
  --line: #e2e6ee; --text-1: #131720; --text-2: #545d6d; --text-3: #8c95a5;
  --shadow: 0 10px 30px rgba(20,25,40,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg-1); color: var(--text-1); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

#app { display: grid; grid-template-columns: 258px 1fr; min-height: 100vh; }
/* Collapsed, the grid must become a single column. Leaving two columns with the first at
   zero width put the main area into that empty column and everything vanished. */
#app.collapsed { grid-template-columns: 1fr; }
#app.collapsed #sidebar { display: none; }

/* ---------- sidebar ---------- */
#sidebar { background: var(--bg-2); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brandmark { display: flex; align-items: center; gap: 11px; padding: 4px 8px 14px; }
.brandmark-badge { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .3px; }
.brandmark-title { font-weight: 650; font-size: 14px; line-height: 1.2; }
.brandmark-sub { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .09em; }
.nav-section { margin-top: 14px; }
.nav-section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); padding: 4px 10px 6px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: transparent; color: var(--text-2); border-radius: 9px; cursor: pointer; font-size: 13px; font-family: inherit; text-align: left; }
.nav-item:hover { background: var(--bg-3); color: var(--text-1); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text-1); font-weight: 600; }
.ni-ico { display: inline-flex; opacity: .85; }
.ni-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-3); padding: 10px; border-top: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); }

/* ---------- topbar ---------- */
#main { display: flex; flex-direction: column; min-width: 0; }
#topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--bg-2); position: sticky; top: 0; z-index: 20; }
.spacer { flex: 1; }
.brand-switch { display: flex; align-items: center; gap: 8px; }
.brand-switch label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }
.icon-btn { position: relative; background: transparent; border: 1px solid var(--line); color: var(--text-2); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--text-1); background: var(--bg-3); }
.badge { position: absolute; top: -6px; right: -6px; background: var(--err); color: #fff; font-size: 10px; border-radius: 9px; padding: 1px 5px; }

/* ---------- layout ---------- */
#view { padding: 24px 26px 60px; max-width: 1360px; width: 100%; }
.page-head { margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 680; letter-spacing: -.01em; }
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 5px; max-width: 78ch; }
.hero { background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 22%, var(--bg-2)), var(--bg-2) 62%); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.hero-title { font-size: 21px; font-weight: 680; }
.hero-sub { color: var(--text-2); margin-top: 6px; font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 26px 0 18px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .cols-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { #app { grid-template-columns: 1fr; } #sidebar { display: none; } .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.muted { color: var(--text-2); }
.hint { color: var(--text-3); font-size: 12px; line-height: 1.55; }
.empty { padding: 46px; text-align: center; color: var(--text-3); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- cards ---------- */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.metric { position: relative; overflow: hidden; }
.metric::after { content: ''; position: absolute; inset: auto auto 0 0; height: 3px; width: 100%; background: var(--mc, var(--accent)); opacity: .85; }
.metric-ico { color: var(--mc, var(--accent)); }
.stat-num { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat-label { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.tile:hover { transform: translateY(-2px); border-color: var(--tc, var(--accent)); }
.tile-ico { color: var(--tc, var(--accent)); margin-bottom: 10px; }
.tile-title { font-weight: 620; font-size: 14px; }
.tile-hint { color: var(--text-3); font-size: 12px; margin-top: 4px; min-height: 32px; }

/* ---------- rows & tables ---------- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg-2); cursor: pointer; margin-bottom: 9px; }
.row:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.r-title { font-weight: 600; font-size: 13.5px; }
.r-meta { color: var(--text-3); font-size: 12px; margin-top: 3px; }
.task-table { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tt-row { display: grid; grid-template-columns: 2.4fr 1fr 1fr 1.2fr .6fr .8fr; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; background: var(--bg-2); }
.tt-row:last-child { border-bottom: 0; }
.tt-row:hover { background: var(--bg-3); }
.tt-head { background: var(--bg-3); color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; cursor: default; }
.tt-head:hover { background: var(--bg-3); }
.tt-cell { font-size: 12.5px; color: var(--text-2); }
@media (max-width: 900px) { .tt-row { grid-template-columns: 2fr 1fr 1fr; } .tt-row > :nth-child(n+4) { display: none; } .tt-head > :nth-child(n+4) { display: none; } }

/* ---------- pills / tags ---------- */
.pill { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); text-transform: capitalize; white-space: nowrap; }
.pill.running, .pill.queued { border-color: color-mix(in srgb, var(--c1) 55%, transparent); color: var(--c1); }
.pill.completed { border-color: color-mix(in srgb, var(--ok) 55%, transparent); color: var(--ok); }
.pill.failed { border-color: color-mix(in srgb, var(--err) 55%, transparent); color: var(--err); }
.pill.archived, .pill.cancelled { color: var(--text-3); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 550; }
input, select, textarea, .input {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text-1);
  border-radius: 9px; padding: 9px 11px; font-size: 13px; font-family: inherit; width: 100%;
}
textarea { min-height: 86px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; min-height: 260px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type="color"] { padding: 3px; height: 36px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 10px 16px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text-1); }
.btn.ghost:hover { background: var(--bg-3); }
.btn.danger { background: var(--err); }
.btn.sm { padding: 7px 12px; font-size: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--text-2); padding: 8px 14px; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 200px; }
.dropzone { border: 1.5px dashed var(--line); border-radius: 11px; padding: 22px; text-align: center; color: var(--text-3); cursor: pointer; font-size: 12.5px; }
.dropzone.drag { border-color: var(--accent); color: var(--text-1); }
.file-chip { display: inline-flex; gap: 8px; align-items: center; background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; margin: 6px 6px 0 0; }

/* ---------- task detail ---------- */
.statusbar { height: 5px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.statusbar .bar { height: 100%; width: 38%; background: var(--accent); border-radius: 999px; animation: slide 1.7s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -38%; } 100% { margin-left: 100%; } }
.spin { width: 15px; height: 15px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-done { display: flex; gap: 12px; align-items: center; }
.status-ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.status-ico.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.status-ico.err { background: color-mix(in srgb, var(--err) 20%, transparent); color: var(--err); }
.feed-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed-ico { width: 18px; color: var(--text-3); }
.feed-step { font-size: 12.5px; }
.feed-detail { color: var(--text-3); font-size: 11.5px; white-space: pre-wrap; }
.feed-time { color: var(--text-3); font-size: 11px; }
.log { background: var(--bg-3); border: 1px solid var(--line); border-radius: 9px; padding: 12px; font-size: 11.5px; white-space: pre-wrap; overflow-x: auto; max-height: 320px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- library ---------- */
.lib-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.lib-thumb { aspect-ratio: 4/3; background: var(--bg-3); display: grid; place-items: center; overflow: hidden; }
.lib-thumb img, .lib-thumb video { width: 100%; height: 100%; object-fit: contain; }
.lib-thumb .ph { font-size: 30px; }
.lib-meta { padding: 10px 12px; }
.lib-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-sub { color: var(--text-3); font-size: 11px; margin-top: 3px; }
.lib-actions { display: flex; gap: 8px; padding: 0 12px 12px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(4,6,10,.62); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); width: min(820px, 100%); max-height: 88vh; overflow-y: auto; padding: 22px; }
.modal-title { font-size: 17px; font-weight: 650; margin-bottom: 14px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 11px 14px; min-width: 240px; box-shadow: var(--shadow); }
.toast.ok { border-left-color: var(--ok); } .toast.err { border-left-color: var(--err); }
.toast-title { font-weight: 620; font-size: 13px; }
.toast-msg { color: var(--text-2); font-size: 12px; margin-top: 3px; }

/* ---------- setup wizard ---------- */
.wizard { max-width: 760px; margin: 40px auto; }
.wizard-steps { display: flex; gap: 8px; margin-bottom: 22px; }
.wizard-steps span { flex: 1; height: 4px; border-radius: 999px; background: var(--line); }
.wizard-steps span.on { background: var(--accent); }
.swatch { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); display: inline-block; }

/* ---------- wizard step labels ---------- */
.wizard-labels { display: flex; gap: 6px; margin: -14px 0 20px; flex-wrap: wrap; }
.wizard-label { background: transparent; border: 0; color: var(--text-3); font-size: 11.5px; font-family: inherit; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.wizard-label:hover { color: var(--text-1); background: var(--bg-3); }
.wizard-label.on { color: var(--accent); font-weight: 600; }
.wizard .toolbar { margin-bottom: 0; }

/* ---------- server-stopped banner ---------- */
.offline-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 12px 18px; background: var(--err); color: #fff; font-size: 13px;
}
.offline-bar .btn { background: rgba(255,255,255,.18); }

/* ---------- rendered markdown (playbook pages) ---------- */
.md { font-size: 13px; line-height: 1.62; color: var(--text-2); }
.md .md-h { color: var(--text-1); margin: 16px 0 6px; font-size: 14px; font-weight: 650; }
.md h3.md-h { font-size: 16px; }
.md .md-p { margin: 8px 0; }
.md .md-list { margin: 8px 0 8px 18px; padding: 0; }
.md .md-list li { margin: 4px 0; }
.md .md-quote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--bg-3); border-radius: 0 8px 8px 0; }
.md code { background: var(--bg-3); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.md strong { color: var(--text-1); }
.md-table { overflow-x: auto; margin: 10px 0; }
.md-table table { border-collapse: collapse; width: 100%; }
.md-table td { border: 1px solid var(--line); padding: 6px 10px; font-size: 12.5px; vertical-align: top; }

/* ---------- brand identity applied to the dashboard ---------- */
:root { --font-display: var(--font); --font-body: var(--font); --brand-strip: var(--accent); }
body { font-family: var(--font-body, var(--font)); }
.page-title, .hero-title, .stat-num, .brandmark-title, .modal-title, .tile-title { font-family: var(--font-display, var(--font)); }
#brandStrip { height: 3px; background: var(--brand-strip); opacity: 0; transition: opacity .2s; }
body.branded #brandStrip { opacity: 1; }
.brandmark-badge.has-logo { background: transparent; width: auto; min-width: 34px; max-width: 132px; height: 34px; border-radius: 0; }
.brandmark-badge.has-logo img { max-width: 132px; max-height: 34px; object-fit: contain; display: block; }
.font-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); margin-bottom: 8px; }
.font-preview { font-size: 19px; line-height: 1.2; }

/* ---------- the epitaph ----------
   A small stone at the foot of every page. Subtle by design: noticed on the second
   visit, read on the third. */
#epitaph {
  margin: 8px auto 30px;
  padding: 18px 26px 0;
  max-width: 62ch;
  text-align: center;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  opacity: .68;                     /* legible when looked at, invisible when not */
  transition: opacity .35s ease, color .35s ease;
  cursor: default;
  user-select: none;
}
#epitaph:hover { opacity: 1; color: var(--text-2); }
.epitaph-quote {
  margin: 0;
  font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  font-style: italic;
  font-size: 12px;
  line-height: 1.75;
  letter-spacing: .01em;
}
.epitaph-date {
  margin: 7px 0 0;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .22em;
}
.epitaph-date span { color: var(--accent); opacity: .75; }

/* ---------- the savings meter, engraved under the epitaph ---------- */
.savings-meter {
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  cursor: pointer;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .2em;
}
.savings-meter .sv-item { display: inline-flex; align-items: baseline; gap: 6px; }
.savings-meter b {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  transition: color .35s ease;
}
.savings-meter:hover b { color: var(--accent); }
.savings-meter i { font-style: normal; opacity: .8; }
.savings-meter .sv-sep { opacity: .4; }

/* ---------- who is signed in, and the way out ---------- */
.account-box { display: flex; align-items: center; gap: 6px; padding: 8px 10px 4px; border-top: 1px solid var(--line); }
.account-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; background: transparent; border: 0; padding: 4px; border-radius: 9px; cursor: pointer; text-align: left; font-family: inherit; color: var(--text-1); }
.account-who:hover { background: var(--bg-3); }
.account-mark { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; }
.account-name { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-org { display: block; font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-out { flex: none; background: transparent; border: 1px solid var(--line); color: var(--text-3); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.account-out:hover { color: var(--err); border-color: var(--err); }
