:root {
  --bg: #f6f5f2;
  --card: #fff;
  --ink: #1d1d1b;
  --muted: #6d6a64;
  --line: #e4e1da;
  --accent: #b4405a;
  --accent-ink: #fff;
  --blue: #2f6db3;
  --teal: #1f8a7a;
  --green: #2e8b3e;
  --amber: #b77b0c;
  --violet: #6a4bb3;
  --red: #c0392b;
  --radius: 10px;
  font-family: ui-sans-serif, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); display: flex; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.warn { color: var(--amber); }
.red-t { color: var(--red); }
.violet-t { color: var(--violet); }

.side { width: 220px; background: #1d1d1b; color: #eee; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: -.02em; }
.brand span { color: #e48aa0; font-weight: 400; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #ddd; padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.side nav a.on, .side nav a:hover { background: #33322f; text-decoration: none; color: #fff; }
.count { background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 8px; font-size: 11px; }
.cap { margin-top: auto; background: #2a2926; border-radius: 8px; padding: 10px; }
.cap-label { font-size: 11px; color: #aaa; }
.cap-val { font-size: 20px; font-weight: 700; }
.cap-val small { color: #aaa; font-weight: 400; }
.bar { height: 5px; background: #444; border-radius: 9px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #e48aa0; }
.link { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0; font: inherit; }

main { flex: 1; padding: 28px 32px; max-width: 1400px; }
.flash { background: #eaf6ec; border: 1px solid #bfe3c6; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.head-row h1 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

.btn { background: #fff; border: 1px solid var(--line); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #bbb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--red); border-color: #e9c3be; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { padding: 10px 20px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: wait; }

input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
textarea { resize: vertical; line-height: 1.45; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12px; margin-bottom: 10px; color: #444; }
label.check { flex-direction: row; align-items: center; font-weight: 400; gap: 6px; }
label.check input { width: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #eee; color: #555; vertical-align: middle; }
.badge.blue { background: #e3edf8; color: var(--blue); }
.badge.teal { background: #def2ef; color: var(--teal); }
.badge.green { background: #e1f3e4; color: var(--green); }
.badge.amber { background: #fbefd9; color: var(--amber); }
.badge.violet { background: #ece6f8; color: var(--violet); }
.badge.red { background: #f8e2df; color: var(--red); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: #f0eee9; font-size: 12px; }
.tag.wp { background: #e3edf8; color: #21759b; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi span { color: var(--muted); font-size: 12px; }
.kpi b { font-size: 26px; }
.pipeline { display: flex; gap: 8px; flex-wrap: wrap; }
.stage { flex: 1; min-width: 100px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; color: var(--ink); }
.stage b { font-size: 22px; }
.stage:hover { text-decoration: none; border-color: #bbb; }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 5px 0; border-bottom: 1px solid #f1efea; }
.feed time { color: var(--muted); font-size: 12px; margin-right: 6px; }

.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid #f1efea; vertical-align: top; }
.tbl.offers input, .tbl.offers textarea { font-size: 12px; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.filters input { max-width: 300px; }
.filters select { max-width: 180px; }
.pager { display: flex; gap: 16px; justify-content: center; padding: 16px; }

.draft header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.draft h2 { margin-bottom: 4px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 12px; }
.links { display: flex; gap: 12px; font-size: 12px; margin-top: 4px; }
.draft-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; }
.audit .summary { font-style: italic; color: var(--muted); margin-top: 0; }
.audit ol { padding-left: 18px; margin: 0 0 10px; }
.audit li { margin-bottom: 8px; }
.editor textarea[name=body] { min-height: 240px; }
.sig { margin: -4px 0 0; }
.exclude { position: relative; }
.exclude summary { list-style: none; }
.exclude-box { position: absolute; right: 0; bottom: 40px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; width: 300px; box-shadow: 0 6px 20px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.draft.done { opacity: .35; pointer-events: none; transition: opacity .3s; }
.draft.done::after { content: attr(data-done); display: block; text-align: center; font-weight: 700; padding-top: 8px; }

.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.msg.in { background: #f7f5ff; border-color: #e1dbf5; }
.msg .meta { font-size: 12px; color: var(--muted); }
.subj { font-weight: 600; margin-top: 4px; }
pre { white-space: pre-wrap; font-family: inherit; margin: 8px 0 0; line-height: 1.45; }
.inmsg.unread { border-left: 4px solid var(--accent); }
.inmsg.auto { opacity: .6; }
.days { display: flex; gap: 12px; margin: 6px 0; }
.settings label input[type=number] { max-width: 160px; }

body.login { align-items: center; justify-content: center; }
.login-box { background: #fff; padding: 28px; border-radius: 12px; border: 1px solid var(--line); width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-box .brand { color: var(--ink); }
.err { color: var(--red); margin: 0; }

@media (max-width: 1000px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .cap { margin-top: 0; }
  main { padding: 16px; }
  .grid2, .draft-grid, .grid3, .kpis { grid-template-columns: 1fr; }
}
