:root {
  --ink: #0a0066;          /* Pepper primary */
  --text: #1a1d2b;         /* body copy */
  --muted: #6b7280;
  --line: #e6e8ee;
  --bg: #ffffff;           /* white-forward */
  --card: #ffffff;
  --brand: #0a0066;
  --brand-2: #07004d;      /* darker hover */
  --accent: #0a0066;
  --good: #16a36a;
  --bad: #d64545;
  --flat: #9aa0ac;
  --pos: #16a36a;
  --neg: #d64545;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 24px; }
h1, h2, h3, h4 { color: var(--ink); }

/* topbar — white with the Pepper logo */
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 0; }
.topbar .wrap { display: flex; align-items: center; gap: 14px; }
.brand-link { display: inline-flex; align-items: center; }
.logo-img { height: 26px; display: block; }
.topbar-tag { color: var(--muted); font-size: 13px; border-left: 1px solid var(--line); padding-left: 14px; }

/* home — two top-aligned cards, no separate hero */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(440px, 540px); gap: 28px; align-items: start; padding: 40px 0 64px; }
.home-left .form { margin: 0; max-width: none; }
.form-head { margin-bottom: 4px; }
.form-head h2 { font-size: 20px; margin: 0 0 5px; }
.form-head p { color: var(--muted); font-size: 14px; margin: 0; }

.panel-reports { padding: 22px; position: sticky; top: 24px; }
.panel-title { font-size: 16px; margin: 0 0 14px; }
.reports-scroll { max-height: 560px; overflow-y: auto; overflow-x: hidden; }
.reports-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.reports-table th { font-size: 11px; }
.reports-table th, .reports-table td { padding: 10px 8px; vertical-align: top; }
.reports-table th:first-child, .reports-table td:first-child { padding-left: 0; }
.reports-table th:nth-child(2), .reports-table td:nth-child(2) { width: 104px; }
.reports-table th:nth-child(3), .reports-table td:nth-child(3) { width: 96px; }
.reports-table th:nth-child(4), .reports-table td:nth-child(4) { width: 78px; }
.rep-name {
  border: 1px solid transparent; background: transparent; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--ink); width: 100%; padding: 5px 7px; border-radius: 6px;
  text-overflow: ellipsis;
}
.rep-name:hover { border-color: var(--line); }
.rep-name:focus { border-color: var(--brand); outline: none; background: #fff; }
.rep-name.saved { border-color: var(--good); }
.rep-period { color: var(--muted); }
.rep-date { color: var(--muted); font-size: 12px; line-height: 1.3; white-space: nowrap; }
.rep-time { display: block; color: var(--flat); font-size: 11px; }
.rep-actions { text-align: right; white-space: nowrap; }
.rep-actions form { display: inline; margin: 0; }
.rep-open { color: var(--brand); font-weight: 600; text-decoration: none; font-size: 12.5px; }
.rep-open:hover { text-decoration: underline; }
.rep-del { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; margin-left: 8px; }
.rep-del:hover { color: var(--bad); }
.empty { color: var(--muted); font-size: 14px; margin: 4px 0; }

@media (max-width: 920px) {
  .home-grid { grid-template-columns: 1fr; }
  .panel-reports { position: static; }
}

/* hero + form (centered) */
.hero { padding: 48px 0 8px; text-align: center; }
.hero h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.5px; }
.lede { color: var(--muted); max-width: 600px; margin: 0 auto; font-size: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; box-shadow: 0 6px 24px rgba(10, 0, 102, 0.06); }
.form { max-width: 520px; margin: 22px auto 64px; display: flex; flex-direction: column; gap: 16px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
select, .search {
  padding: 11px 34px 11px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 15px; color: var(--text); width: 100%;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236b7280' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}
.hint { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }

/* searchable client combobox */
.combo { position: relative; }
.combo .search { width: 100%; }
.combo-panel {
  list-style: none; margin: 6px 0 0; padding: 6px; position: absolute; z-index: 20;
  left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(10, 0, 102, 0.12); max-height: 240px; overflow: auto; display: none;
}
.combo-panel.open { display: block; }
.combo-option { padding: 9px 11px; border-radius: 7px; cursor: pointer; font-size: 15px; color: var(--text); }
.combo-option[hidden] { display: none; }
.combo-option:hover, .combo-option.active { background: #f1f1fa; }
.combo-option[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.combo-sub { color: var(--muted); font-size: 13px; }
.btn {
  background: var(--brand); color: #fff; border: 0; border-radius: 9px;
  padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--brand-2); }
.btn[disabled] { cursor: default; opacity: 0.92; }
.btn.loading { background: var(--brand-2); }
.spinner {
  display: inline-block; width: 15px; height: 15px; margin-right: 9px; vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f1f2f6; }
.note { color: var(--muted); font-size: 13px; margin: 2px 0 0; text-align: center; }
.alert { background: #fdecec; color: #a12; border: 1px solid #f3c2c2; padding: 14px 16px; border-radius: 10px; margin: 18px 0; }

/* action bar */
.actionbar { display: flex; align-items: center; justify-content: space-between; padding: 22px 0 8px; }
.actionbar.sticky {
  position: sticky; top: 0; z-index: 50; background: #fff; padding: 14px 0;
  border-bottom: 1px solid var(--line); box-shadow: 0 4px 14px rgba(10, 0, 102, 0.05);
}

/* edit mode — editable narrative fields */
.editing [data-edit] {
  outline: 1px dashed #b9bce6; background: #fbfbff; border-radius: 6px;
  padding: 3px 6px; transition: outline-color 0.15s;
}
.editing [data-edit]:hover { outline-color: var(--accent); }
.editing [data-edit]:focus { outline: 2px solid var(--accent); background: #fff; }

/* editable highlight cards */
.hl-remove, .hl-add { display: none; }
.editing .highlight { position: relative; padding-right: 34px; }
.editing .hl-title, .editing .hl-detail {
  display: block; outline: 1px dashed #b9bce6; background: #fbfbff; border-radius: 6px; padding: 2px 6px;
}
.editing .hl-detail { margin-top: 5px; }
.editing .hl-title:focus, .editing .hl-detail:focus { outline: 2px solid var(--accent); background: #fff; }
.editing .hl-title:empty::before { content: "Highlight title"; color: var(--flat); }
.editing .hl-detail:empty::before { content: "One sentence with a number"; color: var(--flat); }
.editing .hl-remove {
  display: inline-flex; align-items: center; justify-content: center; position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 6px; cursor: pointer; font-size: 11px;
}
.editing .hl-remove:hover { color: var(--bad); border-color: #f3c2c2; }
.editing .hl-add {
  display: inline-block; margin-top: 12px; background: #fff; border: 1px dashed var(--accent);
  color: var(--accent); padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.editing .hl-add:hover { background: #f3f3fb; }

/* editable recommendations */
.rec-item { position: relative; }
.rec-body { flex: 1; }
.rec-remove, .rec-add { display: none; }
.editing .rec-title, .editing .rec-detail {
  outline: 1px dashed #b9bce6; background: #fbfbff; border-radius: 6px; padding: 3px 6px;
}
.editing .rec-title:focus, .editing .rec-detail:focus { outline: 2px solid var(--accent); background: #fff; }
.editing .rec-title:empty::before { content: "Recommendation title"; color: var(--flat); }
.editing .rec-detail:empty::before { content: "Why, and the expected impact"; color: var(--flat); }
.editing [data-prio-badge] { cursor: pointer; }
.editing .rec-remove {
  display: inline-flex; align-items: center; justify-content: center; align-self: center;
  width: 26px; height: 26px; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 7px; cursor: pointer; font-size: 12px;
}
.editing .rec-remove:hover { color: var(--bad); border-color: #f3c2c2; }
.editing .rec-add {
  display: inline-block; margin-top: 14px; background: #fff; border: 1px dashed var(--accent);
  color: var(--accent); padding: 9px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.editing .rec-add:hover { background: #f3f3fb; }

/* editable text-box groups (executive summary + section overviews) */
.block-add, .block-remove { display: none; }
.editing .ed-block { outline: 1px dashed #b9bce6; background: #fbfbff; border-radius: 6px; padding: 6px 8px; }
.editing .ed-block:focus { outline: 2px solid var(--accent); background: #fff; }
.editing .ed-block:empty::before { content: "Add text…"; color: var(--flat); }
.editing .text-block { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.editing .text-block .ed-block { flex: 1; margin: 0; }
.editing .block-remove {
  display: inline-flex; align-items: center; justify-content: center; align-self: flex-start;
  width: 26px; height: 26px; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 7px; cursor: pointer; font-size: 12px; flex: none;
}
.editing .block-remove:hover { color: var(--bad); border-color: #f3c2c2; }
.editing .block-add {
  display: inline-block; background: #fff; border: 1px dashed var(--accent); color: var(--accent);
  padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.editing .block-add:hover { background: #f3f3fb; }

/* section reordering */
.editing [data-section] { position: relative; outline: 1px dashed #d7d9ee; outline-offset: 8px; border-radius: 4px; }
.section-tools { display: none; }
.editing .section-tools { display: flex; gap: 6px; position: absolute; top: -4px; right: 0; z-index: 5; }
.editing .section-tools button {
  width: 28px; height: 28px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 7px; cursor: pointer; font-size: 11px; line-height: 1; box-shadow: 0 2px 6px rgba(10, 0, 102, 0.08);
}
.editing .section-tools button:hover { background: var(--ink); color: #fff; }

/* Edit with AI */
.ai-edit { display: none; }
.editing .ai-edit {
  display: inline-flex; align-items: center; gap: 4px; flex: none; align-self: flex-start;
  border: 1px solid #c9caf0; background: #fff; color: var(--accent); border-radius: 7px;
  padding: 3px 8px; font-size: 11px; font-weight: 700; cursor: pointer;
  opacity: 0; transition: opacity 0.12s;
}
.editing .text-block:hover .ai-edit,
.editing .rec-item:hover .ai-edit,
.editing .ai-edit:focus { opacity: 1; }
.editing .ai-edit:hover { background: #f3f3fb; }

.ai-pop {
  position: absolute; z-index: 100; width: 300px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 16px 40px rgba(10, 0, 102, 0.18); padding: 12px;
}
.ai-pop[hidden] { display: none; }
.ai-pop-head { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.ai-pop-input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit;
  font-size: 13px; resize: vertical; min-height: 54px;
}
.ai-pop-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.ai-pop-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.ai-pop-status { flex: 1; font-size: 12px; color: var(--muted); }
.ai-pop button { border-radius: 7px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: #fff; }
.ai-pop .ai-send { background: var(--brand); color: #fff; border-color: var(--brand); }
.ai-pop .ai-send:disabled { opacity: 0.6; cursor: default; }
.ai-pop .ai-cancel:hover { background: #f1f2f6; }
.actions { display: flex; gap: 10px; align-items: center; }
.link { color: var(--accent); text-decoration: none; font-weight: 600; }
.draft-tag { font-size: 12px; color: #9a6b00; background: #fff4d6; border: 1px solid #f0dca0; padding: 4px 10px; border-radius: 20px; }
.saved-tag { font-size: 12px; color: var(--muted); padding: 4px 4px; }

/* report */
.report { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 36px; margin-bottom: 60px; box-shadow: 0 8px 30px rgba(10, 0, 102, 0.07); }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 18px; }
.report-head h1 { margin: 0; font-size: 26px; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.period-tag { text-align: right; }
.period-main { font-weight: 700; font-size: 17px; }
.period-sub { color: var(--muted); font-size: 13px; }

.block { padding: 28px 0; border-bottom: 1px solid var(--line); }
.block:last-of-type { border-bottom: 0; }
.block h2 { font-size: 19px; margin: 0 0 16px; letter-spacing: -0.3px; }
.block-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.block-head h2 { margin: 0; }
.tag-ai { font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.4px; }

.summary-block { background: #f6f6fc; margin: 0 -36px; padding: 28px 36px; border-radius: 0; }
.exec { font-size: 16px; max-width: 760px; }
.highlights { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
.highlight { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.highlight strong { display: block; font-size: 13px; color: var(--accent); margin-bottom: 2px; }
.highlight span { font-size: 14px; }

/* metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 14px; }
.metric-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin: 4px 0; }
.metric-prev { font-size: 12px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.badge.good { color: var(--good); background: #e7f6ee; }
.badge.bad { color: var(--bad); background: #fbeaea; }
.badge.flat { color: var(--flat); background: #eef0f3; }

.insight { background: #f5f7fa; border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 16px 0; font-size: 15px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 16px; }
.panel h3 { font-size: 14px; margin: 0 0 12px; }
.panel h4 { font-size: 13px; margin: 0 0 6px; }

/* Fixed-height wrapper so Chart.js (maintainAspectRatio:false) can't grow the
   canvas unbounded. */
.chart-box { position: relative; height: 240px; width: 100%; }
.chart-box canvas { position: absolute; inset: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 12px; }
td { padding: 7px 8px; border-bottom: 1px solid #f1f2f5; }
tr:last-child td { border-bottom: 0; }
.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); font-weight: 600; }
tr.you { background: #f1fff8; }
.you-tag { font-size: 10px; background: var(--brand); color: #fff; padding: 1px 6px; border-radius: 10px; vertical-align: middle; }

.movers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.movers ul { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.movers li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #f1f2f5; }

/* sentiment */
.sbar { display: flex; height: 14px; border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.s-pos { background: var(--good); } .s-neu { background: #c7ccd6; } .s-neg { background: var(--bad); }
.legend { list-style: none; display: flex; gap: 16px; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.d-pos { background: var(--good); } .d-neu { background: #c7ccd6; } .d-neg { background: var(--bad); }

.prompts { list-style: none; padding: 0; margin: 0; }
.prompts li { padding: 8px 0; border-bottom: 1px solid #f1f2f5; display: flex; flex-direction: column; gap: 4px; }
.prompt-q { font-style: italic; font-size: 14px; }
.chip { align-self: flex-start; font-size: 11px; padding: 2px 8px; border-radius: 12px; }
.chip.hit { background: #e7f6ee; color: var(--good); }
.chip.miss { background: #fbeaea; color: var(--bad); }

/* recs */
.recs .rec-list { list-style: none; counter-reset: r; padding: 0; margin: 0; }
.rec-list li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rec-list p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.prio { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; margin-top: 2px; }
.prio-high { background: #fbeaea; color: var(--bad); }
.prio-medium { background: #fff4d6; color: #9a6b00; }
.prio-low { background: #eef0f3; color: var(--muted); }

.report-foot { color: var(--muted); font-size: 12px; padding-top: 24px; text-align: center; }

@media (max-width: 760px) {
  .grid-2, .highlights, .movers { grid-template-columns: 1fr; }
}

/* print */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .report { border: 0; padding: 0; margin: 0; }
  .panel, .metric, .highlight { break-inside: avoid; }
  .block { break-inside: avoid; }
}
