:root {
  --brand: #002D62;
  --sidebar-bg: #001a3d;
  --sidebar-w: 240px;
  --sidebar-rail: 64px;
  --teal: #14b8a6;
  --teal-deep: #0f766e;
  --bg: #f4f7f8;
  --paper: #ffffff;
  --paper-2: #f7fafb;
  --ink: #0b1f3a;
  --navy: #0b1f3a;
  --muted: #3d5166;
  --line: #d7e2e8;
  --seal: #9f1239;
  --shadow: 0 10px 30px rgba(11, 31, 58, 0.06);
  --radius: 16px;
  --sans: "Avenir Next", "Segoe UI", "WenQuanYi Micro Hei", "Droid Sans Fallback",
    "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
a { color: var(--teal-deep); }

/* ===== App shell ===== */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: #fff;
  z-index: 20;
}
.sidebar-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 12px 10px;
}
.logo-frame {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.logo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-text { min-width: 0; }
.brand-eyebrow {
  margin: 0;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-name {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}
.workspace-label {
  margin: 0 12px 10px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.04);
}

.mod-nav {
  flex: 1;
  overflow: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mod-nav-label {
  margin: 8px 10px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  font-weight: 700;
}
.mod {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px 8px 12px;
  border-radius: 8px;
  text-align: left;
  color: rgba(255, 255, 255, 0.72);
  position: relative;
  transition: background 0.12s ease, color 0.12s ease;
}
.mod::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: transparent;
}
.mod:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.mod.on {
  background: rgba(20, 184, 166, 0.18);
  color: #fff;
  font-weight: 650;
}
.mod.on::before { background: var(--teal); }
.mod-icon {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: 0.85;
  display: grid;
  place-items: center;
}
.mod-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mod-label { flex: 1; min-width: 0; font-size: 14px; }

.sidebar-foot {
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.foot-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  border: 1px solid transparent;
  height: auto;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
}
.pill.live {
  color: #99f6e4;
  background: rgba(20, 184, 166, 0.15);
  border-color: rgba(153, 246, 228, 0.25);
}
.pill.mock {
  color: #fed7aa;
  background: rgba(154, 52, 18, 0.25);
  border-color: rgba(254, 215, 170, 0.25);
}
.pill.quiet {
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}
.pill.warn {
  color: #fed7aa;
  background: rgba(154, 52, 18, 0.25);
  border-color: rgba(254, 215, 170, 0.25);
}
.plan-expired { color: #fecdd3; border-color: rgba(254, 205, 211, 0.35); background: rgba(159, 18, 57, 0.25); }

.account-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal-deep), var(--brand));
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex: none;
}
.account-meta { min-width: 0; flex: 1; }
.account-meta strong {
  display: block;
  font-size: 12px;
  font-weight: 650;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-meta .pill { margin-top: 4px; }
.session-box[hidden], .auth-form[hidden] { display: none !important; }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-form input {
  height: 34px;
  width: 100%;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.auth-form input::placeholder { color: rgba(255, 255, 255, 0.45); }
.auth-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ghost-side {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  height: 28px;
}
.ghost-side:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar-foot .primary {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
}
#auth-status { margin: 0; color: rgba(255, 255, 255, 0.65); font-size: 12px; }
#auth-status.error { color: #fecdd3; }
.sidebar-home { margin: 0; font-size: 11px; }
.sidebar-home a { color: rgba(255, 255, 255, 0.55); text-decoration: none; }
.sidebar-home a:hover { color: #fff; }

/* ===== Main ===== */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}
.channel-header {
  flex: none;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.channel-title { min-width: 0; display: flex; align-items: center; gap: 10px; }
.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  align-items: center;
  justify-content: center;
}
.menu-btn:hover { background: #f0fdfa; border-color: #99f6e4; }
.channel-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.01em;
}
.channel-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.channel-tools .pill.live {
  color: var(--teal-deep);
  background: #f0fdfa;
  border-color: #99f6e4;
}
.channel-tools .pill.quiet {
  color: var(--muted);
  background: #f7fafb;
  border-color: var(--line);
}
.channel-tools .pill.warn {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fed7aa;
}
.channel-tools a.tiny { text-decoration: none; }

.content {
  flex: 1;
  overflow: auto;
  padding: 18px;
}

.tiny, .ghost, .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 12px;
  height: 32px;
  font-size: 13px;
  font-weight: 650;
}
.tiny, .ghost {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}
.tiny:hover, .ghost:hover {
  background: #f0fdfa;
  border-color: #99f6e4;
}
.primary {
  color: #fff;
  border: 0;
  background: linear-gradient(135deg, var(--teal-deep), var(--ink));
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.22);
}
.primary:hover:not(:disabled) { filter: brightness(1.05); }
.primary:disabled { background: #cbd5e1; color: #64748b; filter: none; box-shadow: none; }

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 58, 0.4);
  z-index: 15;
}

/* ===== Panels / modules (preserved) ===== */
.module { display: block; }
.module[hidden] { display: none !important; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.panel-head, .block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
h2, h3 { margin: 0; font-size: 18px; font-weight: 700; color: var(--navy); }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.fine { font-size: 13px; line-height: 1.55; margin: 8px 0 0; color: var(--muted); }

.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field.grow { flex: 1; min-width: 220px; }
.field.grow select, .field.grow input { width: 100%; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
input, select { height: 42px; padding: 0 12px; }
textarea {
  width: 100%;
  min-height: 280px;
  margin-top: 10px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
}
select { min-width: 140px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.content button {
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
}
.content button.tiny, .channel-tools .tiny {
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
}
.content button.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--navy);
}
.content button.ghost:hover:not(:disabled) { border-color: var(--teal); background: #f0fdfa; }
.content button.primary {
  height: 40px;
  border-radius: 12px;
  padding: 0 14px;
}

.status { min-height: 1.3em; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.status.error { color: var(--seal); }

.disclaimer, .banner {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 14px;
}
.disclaimer {
  background: #f0fdfa;
  color: var(--navy);
  border: 1px solid #99f6e4;
}
.banner.mock { background: #fff7ed; color: #9a3412; }
.banner.live { background: #f0fdfa; color: var(--teal-deep); }

.desk {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(380px, 1.15fr);
  gap: 16px;
  align-items: start;
}
.composer, .output, .wizard, .playbook, .stub, .compliance,
.pack-panel, .content-desk, .social-desk, .leads-desk, .board {
  padding: 16px 18px 18px;
}
.output { min-height: 420px; }
.empty { padding: 8px 4px; }
.preview { margin: 10px 0 0; padding-left: 18px; line-height: 1.7; }
.summary { margin: 0 0 8px; font-size: 22px; font-weight: 700; line-height: 1.35; color: var(--navy); }
.eyebrow {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--navy);
  font-weight: 650;
}

.controls, .wizard-tools, .lead-tools, .play-extra {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-top: 12px;
}
.play-extra { display: block; }
.play-extra .field { margin-bottom: 8px; }

.wizard input, .playbook input, .content-desk input, .content-desk select,
.lead-tools input, .lead-tools select, .leads-desk form input, .social-desk input, .social-desk select {
  width: 100%;
}
.wizard textarea { min-height: 140px; }
.wizard .field, .social-editor .field { margin-top: 10px; }
#sell-card { margin-top: 14px; }
#sell-card textarea, .social-desk textarea, .pack-editor textarea { min-height: 88px; margin-top: 0; }
.file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.content-grid .field:first-child { grid-column: 1 / -1; }
.content-desk .actions, .leads-desk .actions, .social-editor .actions { margin-top: 12px; }
#content-notes, .notes { white-space: pre-wrap; line-height: 1.65; }

.play-steps, .wizard-steps { margin: 12px 0; }
.play-steps { list-style: none; padding: 0; display: grid; gap: 8px; }
.play-step {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.play-step p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.play-step input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal-deep); }
.letter-preview, .letter {
  white-space: pre-wrap;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
}
.letter { margin-top: 10px; }
.letter pre { margin: 0; white-space: pre-wrap; font-family: inherit; }
.letter-head { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.due-list { margin: 8px 0 0; padding-left: 18px; }
.due-list button { height: auto; padding: 0; border: 0; background: transparent; color: var(--teal-deep); text-align: left; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.fact { padding: 10px 12px; border-radius: 12px; background: var(--paper-2); border: 1px solid var(--line); }
.fact.wide { grid-column: 1 / -1; }
.fact span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.fact strong { font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.fact strong.missing { color: #64748b; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 8px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 13px; }
.block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.meta-line { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.meta-line code { font-family: ui-monospace, monospace; font-size: 12px; }
.steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: grid; grid-template-columns: 32px 1fr; gap: 10px; }
.num {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--navy); color: #fff; font-size: 14px;
}
.steps p { margin: 3px 0 0; color: var(--muted); }

.pack-editor summary { cursor: pointer; font-weight: 650; }
.pack-grid { display: grid; gap: 8px; margin-top: 10px; }
.pack-grid label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.pack-grid .ghost { justify-self: start; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  height: 32px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-size: 13px;
}
.filters button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.board-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.board-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.board-item.active { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.row-open { height: auto; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.row-open strong { display: block; }
.row-open span, .lead-row .muted { display: block; margin-top: 2px; font-size: 13px; }
.board-empty { margin: 8px 0 0; }
.lead-row { align-items: start; }
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.lead-actions select { min-width: 88px; height: 36px; }

.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.day-card {
  width: 100%;
  height: auto;
  min-height: 168px;
  padding: 10px;
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.day-card strong { font-size: 14px; color: var(--navy); }
.day-card em {
  align-self: flex-start;
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--teal-deep);
  background: #f0fdfa;
  border-radius: 999px;
  padding: 2px 6px;
}
.day-card p { margin: 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.day-card.on {
  background: #fff;
  border-color: var(--navy);
  box-shadow: inset 0 0 0 1px var(--navy), 0 8px 18px rgba(10, 35, 72, 0.12);
}
.social-editor {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.compliance-card {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.compliance-card h3 { margin-bottom: 8px; }
.compliance-card ul { margin: 0; padding-left: 18px; }

.foot { margin-top: 8px; color: var(--muted); font-size: 13px; }
.foot p { margin: 0; }
.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--navy);
  color: #f8fffe;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.25);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .backdrop { display: block; }
  .menu-btn { display: inline-flex; }
  .desk { grid-template-columns: 1fr; }
  .channel-sub { display: none; }
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  textarea { min-height: 200px; }
}
@media (max-width: 640px) {
  .content { padding: 12px; }
  .facts, .content-grid, .board-item, .week { grid-template-columns: 1fr; }
  .filters { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .mod { transition: none; }
}
