/* Pure Michigan Epoxy CRM on ABC Business. Tokens are the ABC Business app's (BUSINESS-APP-SPEC §1.9). */
:root {
  --bg: #f8fafc; --surface: #ffffff; --ink: #0f172a; --muted: #475569; --line: #e2e8f0;
  --blue: #2563eb; --red: #ea4335; --yellow: #f6a700; --green: #16a34a;
  --blue-soft: #e8efff; --red-soft: #fdecea; --yellow-soft: #fff4d6; --green-soft: #e7f6ec; --grey-soft: #eef2f6;
  --red-ink: #b42318; --green-ink: #12733a; --blue-ink: #1d4ed8; --warn-ink: #8a5a00;
  --page: #e9eef5; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
  --btn: #2563eb; --link: #2563eb; --red-fill: #c5221f; --green-fill: #15803d;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --ink: #e5e7eb; --muted: #94a3b8; --line: #1f2a44;
    --blue: #3b82f6; --red: #f87171; --green: #22c55e;
    --blue-soft: #14254a; --red-soft: #3a1a1f; --yellow-soft: #3a2e10; --green-soft: #0f2e1d; --grey-soft: #18223a;
    --red-ink: #fca5a5; --green-ink: #86efac; --blue-ink: #93c5fd; --warn-ink: #f6a700;
    --page: #060a14; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35); --link: #60a5fa;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: 17px/1.45 -apple-system, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
a { color: var(--link); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 20px; line-height: 1.25; }
h3 { font-size: 17px; }
.muted { color: var(--muted); } .small { font-size: 15px; } .tiny { font-size: 13px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 8px; }

/* ---------- shell ---------- */
.appbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; height: 58px; padding: 0 10px 0 6px; background: var(--bg); border-bottom: 1px solid var(--line); }
.appbar .title { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--grey-soft); }
.icon-btn svg { width: 24px; height: 24px; }
.wordmark { height: 20px; width: auto; display: block; }
.brandbox { display: flex; flex-direction: column; gap: 4px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.brandbox .biz { font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.brandbox .biz small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }

.drawer { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 300px; max-width: 86vw; background: var(--surface); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .18s ease; overflow-y: auto; display: flex; flex-direction: column; }
.drawer.open { transform: none; box-shadow: var(--shadow); }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(15,23,42,.38); }
.nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a, .nav button { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 12px; border-radius: 12px; color: var(--ink); font-weight: 600; border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.nav a:hover, .nav button:hover { background: var(--grey-soft); }
.nav a[aria-current="page"] { background: var(--blue-soft); color: var(--blue-ink); }
.nav svg { width: 22px; height: 22px; flex: none; }
.nav .count { margin-left: auto; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--red-fill); color: #fff; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.nav-foot { padding: 12px 18px 18px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }

main { padding: 16px 16px 120px; max-width: 1180px; margin: 0 auto; }
@media (min-width: 960px) {
  .drawer { transform: none; box-shadow: none; }
  .scrim, #menuBtn { display: none !important; }
  .shell { margin-left: 300px; }
  .appbar { padding-left: 22px; }
  main { padding: 22px 28px 80px; }
}

/* ---------- pieces ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; flex: 1; }
.grid { display: grid; gap: 14px; }
.grid > *, .stack > * { min-width: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); align-items: start; }
.grid.lead { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.kpi b { display: block; font-size: 26px; line-height: 1.15; letter-spacing: -.01em; }
.kpi span { font-size: 14px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--grey-soft); }
.btn.primary { background: var(--btn); border-color: var(--btn); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.green { background: var(--green-fill); border-color: var(--green-fill); color: #fff; }
.btn.danger { color: var(--red-ink); }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 15px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn svg { width: 20px; height: 20px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { font-size: 13px; opacity: .7; }

.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--grey-soft); color: var(--muted); white-space: nowrap; }
.pill.blue { background: var(--blue-soft); color: var(--blue-ink); }
.pill.green { background: var(--green-soft); color: var(--green-ink); }
.pill.red { background: var(--red-soft); color: var(--red-ink); }
.pill.yellow { background: var(--yellow-soft); color: var(--warn-ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex: none; }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 4px; border-top: 1px solid var(--line); color: var(--ink); cursor: pointer; }
.item:first-child { border-top: 0; }
.item:hover { background: var(--grey-soft); border-radius: 12px; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .r { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; color: #fff; }
.empty { padding: 18px 4px; color: var(--muted); }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--yellow-soft); color: var(--warn-ink); font-size: 15px; font-weight: 600; }
.banner.blue { background: var(--blue-soft); color: var(--blue-ink); }
.banner.red { background: var(--red-soft); color: var(--red-ink); }
.banner.green { background: var(--green-soft); color: var(--green-ink); }

/* ---------- board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: var(--grey-soft); border-radius: 16px; padding: 10px; min-height: 120px; }
.col.over { outline: 2px dashed var(--blue); }
.col h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; padding: 4px 6px 10px; }
.col h3 .n { margin-left: auto; color: var(--muted); font-weight: 600; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; }
.tile .t { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.tile .s { font-size: 14px; color: var(--muted); }
.tile.dragging { opacity: .5; }

/* ---------- forms ---------- */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 600; color: var(--muted); }
input.in, select.in, textarea.in { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font-size: 17px; font-weight: 400; }
textarea.in { min-height: 96px; resize: vertical; }
input.in:focus, select.in:focus, textarea.in:focus { outline: 2px solid var(--blue); border-color: transparent; }
.fgrid { display: grid; gap: 12px; }
@media (min-width: 620px) { .fgrid.two { grid-template-columns: 1fr 1fr; } }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { width: 24px; height: 24px; margin-top: 1px; flex: none; accent-color: var(--blue); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 46px; border: 0; background: var(--surface); font-weight: 700; cursor: pointer; border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #8b95a5; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--green-fill); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- stage picker ---------- */
.stages { display: flex; gap: 6px; flex-wrap: wrap; }
.stages button { min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; font-weight: 600; cursor: pointer; }
.stages button[aria-pressed="true"] { background: var(--btn); color: #fff; border-color: var(--btn); }
.stages button.lost[aria-pressed="true"] { background: var(--red-fill); border-color: var(--red-fill); }

/* ---------- texts ---------- */
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; padding: 4px 2px 8px; }
.bubble { max-width: 82%; padding: 9px 13px; border-radius: 18px; font-size: 16px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { align-self: flex-start; background: var(--grey-soft); border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: var(--btn); color: #fff; border-bottom-right-radius: 6px; }
.bubble.out.sched { background: transparent; color: var(--ink); border: 1.5px dashed var(--line); }
.bubble.out.bad { background: var(--red-soft); color: var(--red-ink); }
.bubble.out.notsent { background: var(--yellow-soft); color: var(--warn-ink); }
.meta { font-size: 12px; color: var(--muted); margin-top: -3px; }
.meta.r { align-self: flex-end; text-align: right; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.composer textarea { min-height: 48px; max-height: 160px; }

.timeline { display: flex; flex-direction: column; }
.ev { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.ev:first-child { border-top: 0; }
.ev .when { color: var(--muted); font-size: 13px; flex: none; width: 92px; }
.ev .what { flex: 1; white-space: pre-wrap; }
.ev .who { color: var(--muted); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow); max-width: 92vw; }
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 18px 18px 26px; }
@media (min-width: 620px) { .sheet-back { align-items: center; } .sheet { border-radius: 22px; } }
.money { font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; word-break: break-word; }
code.copy { display: block; padding: 10px 12px; border-radius: 10px; background: var(--grey-soft); font-size: 13px; word-break: break-all; cursor: copy; }
.skeleton { height: 64px; border-radius: 12px; background: var(--grey-soft); margin-bottom: 8px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
