/* Unfold AI CRM v2 — clean tool UI. Brand tokens: ink #10120F, paper #FBFAF6, coral #FC6641, lime #C7F000 (sparingly). */
* { box-sizing: border-box; }
:root {
  --ink: #10120F;
  --paper: #FBFAF6;
  --coral: #FC6641;
  --lime: #C7F000;
  --line: #E4E1D8;
  --muted: #6B6A64;
  --colbg: #F1EFE7;
}
body {
  margin: 0;
  font-family: Archivo, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--ink); color: var(--paper);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; padding: 4px 8px 2px; }
.brand em { font-family: Newsreader, Georgia, serif; font-style: italic; font-weight: 400; color: var(--coral); }
.brand-sub { font-size: 12px; color: #A9A79E; padding: 0 8px 16px; }
.side-head { display: flex; align-items: center; gap: 10px; }
.side-mark { width: 27px; height: 30px; flex-shrink: 0; margin-left: 8px; }
.nav-btn {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--paper);
  font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.nav-btn:hover { background: #26241F; }
.nav-btn.active { background: var(--coral); color: #fff; font-weight: 600; }
.side-sep { height: 1px; background: #33312B; margin: 14px 0; }
.side-btn {
  background: #26241F; color: var(--paper); border: 1px solid #3A382F;
  font: inherit; font-size: 13px; padding: 9px 12px; border-radius: 8px; cursor: pointer; text-align: left;
}
.side-btn:hover { background: #33312B; }
.side-note { font-size: 11px; color: #A9A79E; padding: 8px; line-height: 1.5; }
.cross-link { margin-top: auto; text-decoration: none; display: block; }

/* Main */
main { flex: 1; padding: 28px 32px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.5px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.lede { color: var(--muted); margin: 0 0 20px; }
.badge {
  display: inline-block; background: #FFF3D6; border: 1px solid #E8C87A;
  color: #6B4E00; font-size: 13px; padding: 8px 12px; border-radius: 8px; margin-bottom: 20px;
}

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat-num { display: block; font-size: 28px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 13px; }

/* Niche tabs (Pipeline only) */
.niche-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.niche-tab {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; cursor: pointer;
}
.niche-tab:hover { border-color: var(--coral); }
.niche-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.niche-empty { color: var(--muted); font-size: 15px; padding: 24px; text-align: center; background: var(--colbg); border-radius: 12px; }

/* Kanban */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.column { flex: 0 0 264px; background: var(--colbg); border-radius: 12px; padding: 10px; min-height: 200px; }
.column.over { outline: 2px dashed var(--coral); }
.col-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; padding: 4px 6px 10px; }
.col-count { background: var(--ink); color: #fff; border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.col-body { display: flex; flex-direction: column; gap: 10px; }
.col-empty { color: var(--muted); font-size: 13px; padding: 12px; text-align: center; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; cursor: grab;
}
.card:hover { border-color: var(--coral); }
.card.dragging { opacity: 0.5; }
.card-practice { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.card-value { font-weight: 800; font-size: 14px; margin-top: 8px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { background: #EFEDE4; border-radius: 20px; padding: 2px 9px; font-size: 11px; }
.tag.score { background: var(--lime); color: var(--ink); font-weight: 600; }
.tag.source { background: #E4E9FF; color: #2B3A67; }
.tag.draft { background: #FFF3D6; color: #6B4E00; font-weight: 600; }

/* Contacts / Follow-ups / Outreach tables */
.search { width: 100%; max-width: 420px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: var(--colbg); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #FFF6F1; }
.status-overdue { color: #B3261E; font-weight: 700; }
.status-today { color: #8A5A00; font-weight: 700; }
.status-upcoming { color: var(--muted); }
.badge-not-sent { background: #EFEDE4; color: var(--muted); }
.badge-sent { background: #FFE9E2; color: #8A2B12; font-weight: 600; }
.badge-replied { background: var(--lime); color: var(--ink); font-weight: 600; }

/* Flows (SVG) */
.flow-wrap { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; overflow-x: auto; margin-bottom: 8px; }
.flow-wrap svg { display: block; min-width: 720px; }
.flow-node { cursor: pointer; }
.flow-node rect { fill: #fff; stroke: var(--ink); stroke-width: 1.5; rx: 10; }
.flow-node.selected rect { fill: var(--coral); stroke: var(--coral); }
.flow-node.selected text { fill: #fff; }
.flow-node text { font-family: Archivo, sans-serif; font-size: 12.5px; font-weight: 600; fill: var(--ink); }
.flow-node .sub { font-size: 11px; font-weight: 400; fill: var(--muted); }
.flow-node.selected .sub { fill: #FFE9E2; }
.flow-arrow { stroke: var(--coral); stroke-width: 2; fill: none; }
.node-detail { background: var(--colbg); border-radius: 10px; padding: 14px 16px; margin: 0 0 28px; font-size: 14px; }
.node-detail p { margin: 6px 0 0; color: var(--muted); }

/* Ads & pages */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.ad-card, .page-card, .template-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.ad-card.visual { padding: 0; overflow: hidden; }
.ad-card.visual .ad-headline, .ad-card.visual .ad-visual, .ad-card.visual .ad-cta, .ad-card.visual .ad-foot { padding-left: 16px; padding-right: 16px; }
.ad-card.visual .ad-headline { padding-top: 14px; }
.ad-card.visual .ad-foot { padding-bottom: 16px; }
.ad-img { display: block; width: 100%; height: auto; }
.ad-headline { font-family: Newsreader, Georgia, serif; font-style: italic; font-size: 21px; line-height: 1.25; }
.ad-visual { color: var(--muted); font-size: 13px; margin-top: 8px; line-height: 1.5; }
.ad-cta { margin-top: 10px; font-size: 13px; font-weight: 600; }
.ad-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 12px; color: var(--muted); }
.page-card.preview { padding: 0; overflow: hidden; }
.page-card.preview .page-path, .page-card.preview .page-name, .page-card.preview .page-note, .page-card.preview .page-open { padding-left: 16px; padding-right: 16px; }
.page-card.preview .page-path { padding-top: 14px; }
.page-card.preview .page-open { display: inline-block; padding-bottom: 16px; }
.page-frame { display: block; width: 100%; height: 420px; border: 0; border-bottom: 1px solid var(--line); background: #fff; }
.page-path { font-weight: 700; font-size: 15px; }
.page-name { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-note { font-size: 13px; margin-top: 8px; line-height: 1.5; }
.page-open { font-size: 13px; font-weight: 600; color: var(--coral); text-decoration: none; margin-top: 10px; }
.page-open:hover { text-decoration: underline; }

/* Templates (Outreach view) */
.template-name { font-weight: 700; font-size: 15px; }
.template-sub { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.template-body { font-size: 13px; line-height: 1.6; white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 12px 0; }
.template-copy { margin-top: 2px; }

/* Detail drawer */
.drawer {
  width: 0; overflow: hidden; flex-shrink: 0;
  background: #fff; border-left: 1px solid var(--line);
  transition: width 0.2s ease;
}
.drawer.open { width: 400px; }
.drawer-inner { width: 400px; padding: 24px; height: 100vh; position: sticky; top: 0; overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.drawer-head h2 { margin: 0; font-size: 20px; }
#drawer-close { background: none; border: 0; font-size: 22px; cursor: pointer; line-height: 1; }
.drawer-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.drawer-row { font-size: 14px; margin-top: 12px; line-height: 1.5; }
.drawer-row strong { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
#drawer-stage, #drawer-source, #drawer-email-status, #drawer-text-status {
  width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin-top: 4px;
}
#drawer-email-date, #drawer-text-date, #td-loom-input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; margin-top: 4px;
}

/* Teardown block */
.teardown { border-top: 1px solid var(--line); margin-top: 20px; }
.td-findings { margin: 8px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.6; }
.td-findings li { margin-bottom: 6px; }
.td-script {
  font-size: 13px; line-height: 1.65; white-space: pre-wrap;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 8px;
}
.loom-btn { display: inline-block; text-decoration: none; text-align: center; }
.loom-save { margin-top: 8px; }
#td-loom-link { margin-top: 8px; font-size: 13px; word-break: break-all; }
#td-loom-link a { color: var(--coral); font-weight: 600; }

/* Outreach send block */
.send-note { color: var(--muted); font-size: 13px; line-height: 1.5; }
.send-btn { display: inline-block; text-decoration: none; text-align: center; margin-right: 8px; margin-top: 8px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.msg { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.msg-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.msg-type { font-weight: 700; color: var(--coral); text-transform: uppercase; letter-spacing: 0.5px; }
.msg-date { color: var(--muted); }
.msg-note { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg-flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.flag { font-size: 11px; border-radius: 20px; padding: 2px 9px; background: #EFEDE4; }
.flag.yes { background: var(--lime); font-weight: 600; }
.flag.follow { background: #FFE9E2; color: #8A2B12; }
.timeline-empty { color: var(--muted); font-size: 14px; }

/* Touchpoint form */
.touch-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.touch-form input, .touch-form select, .touch-form textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px;
}
.touch-form textarea { min-height: 70px; resize: vertical; }
.check-row { display: flex; gap: 16px; font-size: 14px; }
.check-row label { display: flex; align-items: center; gap: 6px; }
.check-row input { width: auto; }
.btn {
  background: var(--coral); color: #fff; border: 0; border-radius: 8px;
  font: inherit; font-weight: 600; padding: 11px 16px; cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }

#offline-banner { background: #B3261E; color: #fff; padding: 10px 16px; text-align: center; font-size: 14px; }
#offline-banner[hidden] { display: none; }
#offline-banner button { margin-left: 12px; background: #fff; color: #B3261E; border: 0; border-radius: 4px; padding: 4px 12px; cursor: pointer; font: inherit; font-size: 14px; }
#key-prompt { position: fixed; inset: 0; background: rgba(16,18,15,.85); display: flex; align-items: center; justify-content: center; z-index: 100; }
#key-prompt[hidden] { display: none; }
.key-card { background: #FBFAF6; color: #10120F; padding: 28px; border-radius: 8px; max-width: 380px; width: calc(100% - 48px); }
.key-card input { width: 100%; padding: 10px; margin: 12px 0; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font: inherit; }
.key-card button { background: #FC6641; color: #fff; border: 0; border-radius: 4px; padding: 10px 18px; cursor: pointer; font: inherit; font-weight: 600; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .drawer.open { width: 100%; }
  .drawer-inner { width: 100%; height: auto; position: static; }
  main { padding: 20px 16px; }
}
