* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #22303c;
  background: #f6f7f9;
}
a { color: #1a6b8f; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef1f4; padding: 0 4px; border-radius: 4px; font-size: 0.88em; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: #1b2833; color: #d8e0e7; padding: 1.2rem 1rem;
}
.sidebar h1 { font-size: 1.05rem; margin: 0 0 1.2rem; }
.sidebar h1 a { color: #fff; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { color: #d8e0e7; display: block; padding: 0.35rem 0.5rem; border-radius: 6px; }
.sidebar li a:hover { background: #2b3d4d; text-decoration: none; }
.linklike { background: none; border: none; color: #8fa3b3; cursor: pointer; padding: 0.35rem 0.5rem; font-size: 0.9rem; }
.linklike:hover { color: #fff; }
.inline { display: inline; }

main { flex: 1; padding: 1.6rem 2rem; max-width: 1100px; }
h2 { margin-top: 0; }
.muted { color: #7b8a97; }
.small { font-size: 0.8rem; }
.hint { color: #7b8a97; font-size: 0.85rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.card {
  background: #fff; border: 1px solid #e3e8ed; border-radius: 12px; padding: 1rem 1.2rem;
}
.card header { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.card h3 { margin: 0; }
.pill {
  border-radius: 999px; padding: 0.12rem 0.65rem; font-size: 0.75rem; white-space: nowrap;
}
.pill.ok { background: #e2f3e8; color: #1e6b3a; }
.pill.bad { background: #fdeaea; color: #93312d; }
.pill.warn { background: #fdf3df; color: #8a5b13; }
.banner {
  border-radius: 8px; padding: 0.55rem 0.9rem; font-size: 0.85rem; margin: 0 0 1.1rem;
}
.banner.warn { background: #fdf6e6; border: 1px solid #ecd9a8; color: #6f4a0e; }
.banner code { background: rgba(0, 0, 0, 0.05); padding: 0 0.25rem; border-radius: 4px; }
.confignote {
  display: inline-block; background: #f4f6f8; border: 1px dashed #cfd8df; border-radius: 6px;
  padding: 0.2rem 0.6rem; font-size: 0.78rem; color: #62717e; margin: 0.4rem 0 0;
}
a.pill { text-decoration: none; }
.summary { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.1rem; }
.linkrow a { margin-right: 0.7rem; font-size: 0.85rem; }
.gh ul { margin: 0.3rem 0 0; padding-left: 1.1rem; font-size: 0.82rem; }
.gh code { font-size: 0.78rem; }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat {
  background: #fff; border: 1px solid #e3e8ed; border-radius: 12px; padding: 0.7rem 1.1rem;
  display: flex; flex-direction: column;
}
.stat-num { font-size: 1.3rem; font-weight: 700; }
.stat-sm .stat-num { font-size: 1.05rem; }

.metric-section { margin: 1.5rem 0 0; }
.metric-section h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.funnel-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.25rem 0; font-size: 0.82rem; }
.funnel-label { width: 190px; color: #62717e; text-align: right; }
.funnel-track { flex: 1; }
.funnel-bar { display: block; height: 16px; background: #1a6b8f; border-radius: 4px; min-width: 2px; }
.funnel-count { width: 3rem; font-variant-numeric: tabular-nums; }

.entry-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.8rem 0 1.2rem; }
.entry-form input, .entry-form select {
  padding: 0.4rem 0.55rem; border: 1px solid #ccd5dd; border-radius: 6px; background: #fff;
}
button.primary {
  background: #1a6b8f; color: #fff; border: none; border-radius: 6px;
  padding: 0.45rem 1rem; cursor: pointer;
}
button.primary:hover { background: #15597a; }
.icon-btn { background: none; border: none; color: #a5b2bd; cursor: pointer; font-size: 1rem; }
.icon-btn:hover { color: #a33; }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e3e8ed; border-radius: 10px; overflow: hidden; }
.table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #7b8a97; padding: 0.55rem 0.7rem; border-bottom: 1px solid #e3e8ed;
}
.table td { padding: 0.45rem 0.7rem; border-bottom: 1px solid #eef1f4; }
.table input { border: 1px solid #dde3e9; border-radius: 5px; padding: 0.2rem 0.4rem; }

.filter-row a {
  display: inline-block; padding: 0.25rem 0.8rem; border-radius: 999px; margin-right: 0.3rem;
  background: #fff; border: 1px solid #e3e8ed; font-size: 0.85rem;
}
.filter-row a.active { background: #1a6b8f; color: #fff; border-color: #1a6b8f; }

.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
.kanban-col { background: #eef1f4; border-radius: 12px; padding: 0.8rem; }
.kanban-col h3 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.task { background: #fff; border-radius: 8px; padding: 0.55rem 0.7rem; margin-bottom: 0.55rem; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.task-title { font-size: 0.9rem; }
.task-meta { font-size: 0.75rem; }
.task-actions { margin-top: 0.35rem; display: flex; gap: 0.3rem; }
.task-actions button {
  background: #f2f5f7; border: 1px solid #dbe2e8; border-radius: 6px; cursor: pointer;
  font-size: 0.78rem; padding: 0.3rem 0.6rem; color: #33465a;
}
.task-actions button:hover { background: #e6ecf1; }
.task-actions .icon-btn {
  background: none; border: none; margin-left: auto; color: #8a99a6;
  font-size: 1rem; padding: 0.2rem 0.5rem;
}
.task-actions .icon-btn:hover { color: #a33; }

.doclist { list-style: none; padding: 0; margin: 0.3rem 0 0; }
.doclist li { padding: 0.3rem 0; border-bottom: 1px solid #eef1f4; display: flex; justify-content: space-between; gap: 1rem; }
.doclist li:last-child { border-bottom: none; }

.doc-body { background: #fff; border: 1px solid #e3e8ed; border-radius: 12px; padding: 1.4rem 1.8rem; }
.doc-body table { border-collapse: collapse; }
.doc-body td, .doc-body th { border: 1px solid #e3e8ed; padding: 0.3rem 0.6rem; font-size: 0.88rem; }
.json { background: #1b2833; color: #cde3f2; padding: 1rem; border-radius: 10px; overflow-x: auto; font-size: 0.82rem; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1b2833; }
.login-box {
  background: #fff; border-radius: 12px; padding: 2rem 2.2rem; width: 320px;
  display: flex; flex-direction: column; gap: 0.8rem;
}
.login-box h1 { margin: 0 0 0.4rem; font-size: 1.2rem; text-align: center; }
.login-box input { padding: 0.55rem 0.7rem; border: 1px solid #ccd5dd; border-radius: 8px; font-size: 1rem; }
.login-box input:focus { outline: 2px solid #1a6b8f; outline-offset: 1px; border-color: #1a6b8f; }
.error-box { background: #fdeaea; border: 1px solid #f2c4c4; color: #93312d; border-radius: 8px; padding: 0.5rem 0.9rem; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .kanban { grid-template-columns: 1fr; }
  main { padding: 1rem 0.8rem; }
  /* Wide tables scroll inside their card instead of pushing the page wider
     than the phone and clipping the amount column. (Kept to small screens:
     an overflow ancestor would clip the stacked chart's hover tooltip, which
     only matters where there is a pointer to hover with.) */
  .card, .chart-card { overflow-x: auto; }
  .stat { padding: 0.55rem 0.8rem; }
  .stat-num { font-size: 1.1rem; }
}

/* Dates and other first-column values never wrap mid-string ("2026-08-␤21"). */
.grid-table.wide td:first-child { white-space: nowrap; }

/* ---- cost model ------------------------------------------------------- */
/* Chart colours are set per mark from the model (fixed categorical slots, one
   hue per project) — only the furniture lives here. */
.chart-card { margin-bottom: 1rem; }
.chart-card h3 { margin: 0 0 0.2rem; }
.chart-card .hint { margin: 0 0 0.9rem; }
.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 860px) { .chart-pair { grid-template-columns: 1fr; } }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.5rem; font-size: 0.82rem; }
.legend .key { display: inline-flex; align-items: center; gap: 0.4rem; color: #52514e; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.dash {
  height: 0; border-top: 2px dashed #e34948; border-radius: 0; width: 16px;
}

svg .grid { stroke: #e8ebee; stroke-width: 1; }
svg .axis { font: 11px -apple-system, BlinkMacSystemFont, sans-serif; fill: #7b8a97; }
svg .axis-title { fill: #a3aeb8; }
svg .bar-name { fill: #22303c; font-size: 12px; }
svg .bar-value { fill: #22303c; font-size: 12px; font-weight: 600; }
svg .end-label { fill: #22303c; font-size: 11px; font-weight: 600; }
svg .threshold { stroke: #e34948; stroke-width: 2; stroke-dasharray: 5 4; }
svg .threshold-label { fill: #b03a39; }

.tableview { margin-top: 0.8rem; }
.tableview summary { cursor: pointer; font-size: 0.82rem; color: #1a6b8f; }
.grid-table { border-collapse: collapse; width: 100%; font-size: 0.85rem; margin-top: 0.6rem; }
.grid-table.wide { font-size: 0.86rem; }
.grid-table th {
  text-align: left; font-weight: 600; color: #7b8a97; font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid #e3e8ed; padding: 0.4rem 0.6rem 0.4rem 0; white-space: nowrap;
}
.grid-table td { padding: 0.4rem 0.6rem 0.4rem 0; border-bottom: 1px solid #f0f3f6; vertical-align: top; }
.grid-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid-table .neg { color: #93312d; }
.grid-table tr.total td { font-weight: 700; border-top: 2px solid #e3e8ed; border-bottom: 0; }

/* ---- personal finances ------------------------------------------------ */
.stat-num.neg { color: #93312d; }
.chart-card .grid-table td, .chart-card .grid-table th { padding-right: 0.8rem; }
.entry-form a { font-size: 0.85rem; }
svg .clip-label { fill: #93312d; font-size: 11px; font-weight: 600; paint-order: stroke; stroke: #fff; stroke-width: 3px; }

/* stacked category chart */
.stack-wrap { position: relative; }
#stack-legend .key { background: none; border: 1px solid transparent; border-radius: 999px; padding: 0.1rem 0.55rem 0.1rem 0.35rem; cursor: pointer; font: inherit; font-size: 0.82rem; color: #52514e; }
#stack-legend .key:hover { border-color: #e3e8ed; background: #fff; }
#stack-legend .key.off { opacity: 0.45; text-decoration: line-through; }
#stack-legend .key.off i { background: #d8dde2 !important; }
.seg { cursor: pointer; transition: opacity 0.12s; }
.seg.dim { opacity: 0.45; }
.seg:hover, .seg:focus { stroke: #fff; stroke-width: 2px; outline: none; }
.tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid #e3e8ed; border-radius: 8px; padding: 0.5rem 0.7rem; box-shadow: 0 4px 14px rgba(0,0,0,0.08); font-size: 0.8rem; min-width: 190px; z-index: 2; }
.tip-head { font-weight: 600; color: #22303c; margin-bottom: 0.3rem; }
.tip-row { display: flex; align-items: center; gap: 0.45rem; color: #52514e; padding: 0.08rem 0; }
.tip-row i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tip-row b { color: #22303c; font-variant-numeric: tabular-nums; min-width: 78px; text-align: right; }
.tip-row.strong { color: #22303c; font-weight: 600; }

/* inline category editor on the transactions table */
.cat-edit { border: 1px solid #ccd5dd; border-radius: 5px; padding: 0.15rem 0.3rem; background-color: #fff; font: inherit; font-size: 0.8rem; color: #62717e; width: 138px; }
.cat-edit:hover, .cat-edit:focus { border-color: #9fb2c2; }
/* strip the native look so the chevron shows on iOS Safari too */
select.cat-edit {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 1.3rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2362717e' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 8px 5px;
}
.cat-missing { color: #8a5b13; background-color: #fdf6e6; border-color: #ecd9a8; }

/* ---- Listening Post ---------------------------------------------------- */
.page-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.6rem; }
.page-head h2 { margin: 0; }
.banner.info { background: #e8f2f8; border: 1px solid #bcd7e6; color: #1a4c66; }
.summary .pill { background: #fff; border: 1px solid #e3e8ed; color: #33465a; }
.summary .pill.active { background: #1a6b8f; color: #fff; border-color: #1a6b8f; }
.spacer { flex: 1; }
.who { margin-top: 1rem; display: flex; align-items: center; gap: 0.4rem; }
.btn { display: inline-block; white-space: nowrap; background: #f2f5f7; border: 1px solid #dbe2e8; border-radius: 6px; cursor: pointer;
  font-size: 0.78rem; padding: 0.3rem 0.6rem; color: #33465a; text-decoration: none; font-family: inherit; }
.btn:hover { background: #e6ecf1; text-decoration: none; }
.primary-link { background: #1a6b8f; color: #fff; border-color: #1a6b8f; }
.primary-link:hover { background: #15597a; }

.mention-list { display: flex; flex-direction: column; gap: 0.6rem; }
.mention { background: #fff; border: 1px solid #e3e8ed; border-radius: 10px; padding: 0.7rem 0.9rem; }
.mention.fresh { animation: pop 1.6s ease-out; border-color: #7fb6d1; }
@keyframes pop { from { background: #e6f3fa; } to { background: #fff; } }
.mention header, .mention-detail header, .response header { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; font-size: 0.82rem; }
.mention-title { display: block; font-weight: 600; margin: 0.3rem 0 0.2rem; color: #22303c; }
.excerpt { margin: 0.2rem 0 0.3rem; font-size: 0.86rem; color: #3f4f5e; white-space: pre-line; }
.engagement { font-variant-numeric: tabular-nums; color: #62717e; font-size: 0.8rem; }
.status-dismissed { opacity: 0.55; }
.status-sent { border-left: 4px solid #1e6b3a; }
.status-drafted { border-left: 4px solid #1a6b8f; }
.status-saved { border-left: 4px solid #8a5b13; }
.pill.venture { background: #eef1f4; color: #33465a; }
.pill.plat-reddit { background: #ffe9dd; color: #b5410f; }
.pill.plat-x { background: #e5e7ea; color: #1b2833; }
.pill.plat-instagram { background: #f8e3f0; color: #9b2c72; }
.pill.plat-facebook { background: #e1e9fb; color: #1d47a3; }
.pill.plat-tiktok { background: #e6f7f5; color: #0f6b63; }
.pill.plat-other { background: #eef1f4; color: #4d5c6a; }

.two-col { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } }
.post-text { white-space: pre-wrap; word-break: break-word; font: inherit; background: #f8fafb; border: 1px solid #eef1f4;
  border-radius: 8px; padding: 0.6rem 0.8rem; margin: 0.5rem 0; max-height: 26rem; overflow: auto; }
.post-text.small { font-size: 0.82rem; }
.mention-detail h3 { margin: 0.5rem 0 0.2rem; }
.refile { margin-top: 0.5rem; }
.refile .entry-form { margin: 0.4rem 0 0; }
.response { margin-bottom: 0.8rem; }
textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 0.5rem 0.6rem; border: 1px solid #ccd5dd; border-radius: 6px; }
input.wide, textarea.wide { width: 100%; box-sizing: border-box; }
.composer-foot { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.4rem 0; }
.count { font-size: 0.8rem; color: #7b8a97; font-variant-numeric: tabular-nums; }
.count.over { color: #93312d; font-weight: 700; }
.dispatch { border-top: 1px dashed #e3e8ed; margin-top: 0.4rem; padding-top: 0.4rem; }
.sentform input { border: 1px solid #dde3e9; border-radius: 5px; padding: 0.25rem 0.4rem; font-size: 0.8rem; width: 230px; }
.picker { list-style: none; margin: 0.4rem 0 0.6rem; padding: 0; max-height: 15rem; overflow: auto; border: 1px solid #eef1f4; border-radius: 8px; }
.picker li { padding: 0.4rem 0.7rem; border-bottom: 1px solid #f0f3f6; cursor: pointer; font-size: 0.88rem; }
.picker li:hover { background: #f4f8fb; }
.picker li.picked { background: #e6f3fa; }
.picker li:last-child { border-bottom: none; }
.brand { margin-top: 0.8rem; }
.brand summary { cursor: pointer; }
.stack { display: flex; flex-direction: column; gap: 0.6rem; }
.stack label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: #52514e; }
.stack label.small { flex-direction: row; align-items: center; gap: 0.3rem; }
.stack input, .stack select { padding: 0.4rem 0.55rem; border: 1px solid #ccd5dd; border-radius: 6px; background: #fff; font: inherit; }
.row { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: end; }
.kind-head { margin: 0.8rem 0 0.2rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: #7b8a97; }
.version summary { cursor: pointer; }
.topic { background: #fff; border: 1px solid #e3e8ed; border-radius: 8px; padding: 0.5rem 0.8rem; margin-bottom: 0.5rem; }
.topic summary { cursor: pointer; }
.topic form { margin-top: 0.6rem; }
.entry-form label.small { display: inline-flex; align-items: center; gap: 0.3rem; }
.grid-table td.small a { margin-right: 0.2rem; }
