/* Callsistance CRM
 *
 * Colors are tokens on :root and redefined for dark. A person's color
 * (--c, set inline) is identity -- Jake blue, Logan orange -- and never
 * changes with the theme. Green and red mean good and bad and nothing else.
 */

:root {
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --ink: #142033;
  --muted: #64748B;
  --line: #E2E8F0;
  --brand: #1D3A5F;
  --brand-ink: #FFFFFF;
  --accent: #2563EB;
  --ok: #15803D;
  --warn: #B45309;
  --danger: #B91C1C;
  --ok-bg: #DCFCE7;
  --warn-bg: #FEF3C7;
  --danger-bg: #FEE2E2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 8px rgba(15, 23, 42, .04);
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1420; --surface: #161E2D; --surface-2: #1B2537; --ink: #E5EAF2;
    --muted: #93A1B8; --line: #283349; --brand: #5B8BD0; --brand-ink: #0E1420;
    --accent: #60A5FA; --ok: #4ADE80; --warn: #FBBF24; --danger: #F87171;
    --ok-bg: #14301F; --warn-bg: #3A2C0B; --danger-bg: #3B1515;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1420; --surface: #161E2D; --surface-2: #1B2537; --ink: #E5EAF2;
  --muted: #93A1B8; --line: #283349; --brand: #5B8BD0; --brand-ink: #0E1420;
  --accent: #60A5FA; --ok: #4ADE80; --warn: #FBBF24; --danger: #F87171;
  --ok-bg: #14301F; --warn-bg: #3A2C0B; --danger-bg: #3B1515;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.danger, h3.sub.danger { color: var(--danger); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.inline { display: inline; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.empty { color: var(--muted); padding: 8px 0; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--brand); color: var(--brand-ink); font-weight: 800;
}
.brand.big { justify-content: center; font-size: 20px; margin-bottom: 18px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--brand); }
.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 700; font-size: 13px;
}
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px;
  width: 32px; height: 32px; display: inline-grid; place-items: center; cursor: pointer; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.linkish.muted { color: var(--muted); }
.linkish.danger { color: var(--danger); }

/* ---- layout ---- */
.page { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
.wide-page { max-width: none; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }
.page-head .actions { display: flex; gap: 8px; margin-left: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > * { min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; margin-right: auto; }
.signin { width: 100%; max-width: 400px; }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.warn-card { border-color: var(--warn); background: var(--warn-bg); }
.warn-card ul { margin: 6px 0; }

/* ---- flash ---- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* ---- buttons & forms ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.1); }
.btn-sm { padding: 5px 11px; font-size: 14px; }
.wide { width: 100%; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; font-size: 15px;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"], input[type="radio"] { display: inline; width: auto; margin: 0; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > label { flex: 1 1 140px; }
.form-row > label.grow { flex: 3 1 240px; }
.form-row > label.narrow { flex: 0 1 90px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 14px; }
.search { display: flex; gap: 8px; flex: 1 1 360px; }
.search input { margin: 0; flex: 1; }
.search select { margin: 0; width: auto; }

/* ---- segmented control ---- */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg a { padding: 5px 11px; border-radius: 7px; color: var(--muted); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.on { background: var(--brand); color: var(--brand-ink); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.dot.hollow { background: transparent; border: 2px solid var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700;
  padding: 1px 8px; border-radius: 99px; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
}
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stage { font-size: 13px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }

/* ---- tasks & lists ---- */
.tasks, .list, .feed, .timeline { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task-title { font-weight: 600; }
.task-meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.task.overdue .task-meta { color: var(--danger); }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.check {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); background: var(--surface);
  color: transparent; cursor: pointer; font-size: 13px; line-height: 1; padding: 0; margin-top: 1px;
}
.check:hover { border-color: var(--ok); color: var(--ok); }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.list li:last-child { border-bottom: 0; }
.list li .muted { font-size: 13px; flex: 1 1 200px; }
.feed li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { margin-right: 4px; }
.feed-note, .tl-note { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: pre-wrap; }

/* ---- race ---- */
.race { display: grid; gap: 10px; margin: 6px 0 14px; }
.lane { display: grid; grid-template-columns: 90px 1fr 120px; gap: 12px; align-items: center; }
.lane-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.lane-pts { text-align: right; font-size: 14px; }
.lane-pts b { font-size: 18px; }
.track {
  position: relative; height: 34px; border-radius: 8px; background:
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--line) calc(10% - 1px) 10%),
    var(--surface-2);
  border: 1px solid var(--line); overflow: visible;
}
.track-fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--c) 22%, transparent); border-radius: 7px 0 0 7px; transition: width .8s ease; }
.car { position: absolute; top: 50%; width: 46px; transform: translateY(-55%); transition: left .8s ease; }
.car svg { display: block; width: 46px; height: 22px; }
.finish {
  position: absolute; right: -1px; top: -4px; bottom: -4px; width: 8px; border-radius: 2px;
  background: repeating-conic-gradient(var(--ink) 0 25%, var(--surface) 0 50%) 0 0 / 8px 8px;
}
.leader { font-weight: 700; color: var(--c); }
.race-card.big .track { height: 46px; }
.mini-metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.mm-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.mm-row { display: flex; align-items: center; gap: 5px; font-size: 14px; }
.bar { display: block; flex: 1; height: 5px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; min-width: 30px; }
.bar > span { display: block; height: 100%; background: var(--c); }
td .bar { margin-top: 4px; }

/* ---- pipeline board ---- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: stretch; min-height: calc(100vh - 190px); }
.column { flex: 0 0 260px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.column.closed { flex-basis: 220px; opacity: .92; }
.column header { display: flex; justify-content: space-between; padding: 10px 12px; font-weight: 700; font-size: 14px; border-bottom: 1px solid var(--line); }
.column .count { color: var(--muted); font-weight: 600; }
.cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 80px; flex: 1; }
.column.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kcard {
  display: block; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c);
  border-radius: 8px; padding: 9px 10px; color: var(--ink); cursor: grab; box-shadow: var(--shadow);
}
.kcard:hover { text-decoration: none; border-color: var(--accent); border-left-color: var(--c); }
.kcard.dragging { opacity: .4; }
.kc-name { font-weight: 700; }
.kc-sub { font-size: 13px; color: var(--muted); }
.kc-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: 12px; }
.more { padding: 4px; text-align: center; }

/* ---- tables ---- */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.score-table td.num { min-width: 120px; }
.score-table tr.total td { font-size: 17px; background: var(--surface-2); }
.settings-table input { width: 90px; margin: 0; }

/* ---- record page ---- */
.record-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.record-sub { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; color: var(--muted); }
.record-side { display: flex; align-items: center; gap: 10px; }
.stage-select { width: auto; margin: 0; font-weight: 700; }
.stage-track { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.stage-track span { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.stage-track span.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.touch-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.touch { margin: 0; }
.touch input { position: absolute; opacity: 0; pointer-events: none; }
.touch span {
  display: inline-block; padding: 8px 13px; border-radius: 8px; border: 1px solid var(--line);
  color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; background: var(--surface);
}
.touch input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.touch input:focus-visible + span { outline: 2px solid var(--accent); }
.touch.note span { border-style: dashed; color: var(--muted); }
.next-step { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 2px; margin: 4px 0 12px; }
.next-step legend { font-weight: 700; font-size: 13px; padding: 0 4px; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { margin-top: 6px; }
.tl-stage { font-size: 14px; }
.tl-reached > div > b { color: var(--ok); }
.add-task { margin-top: 10px; }
.add-task summary, details summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.notes-view { white-space: pre-wrap; margin-top: 10px; font-size: 14px; }
.archive-form { margin-top: 12px; text-align: right; }

/* ---- calendar ---- */
.cal-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.cal-side h2 { margin-top: 14px; }
.cal-side h2:first-child { margin-top: 0; }
.owner-toggles { margin-bottom: 12px; }
.unscheduled { display: flex; flex-direction: column; gap: 6px; }
.uchip {
  padding: 7px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
  border-left: 4px solid var(--c); cursor: grab; font-size: 14px;
}
.uchip small { display: block; color: var(--muted); }
.cal-card { padding: 12px; min-width: 0; }
#calendar { --fc-border-color: var(--line); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2);
  --fc-today-bg-color: color-mix(in srgb, var(--accent) 9%, transparent); --fc-button-bg-color: var(--surface);
  --fc-button-border-color: var(--line); --fc-button-text-color: var(--ink); --fc-button-hover-bg-color: var(--surface-2);
  --fc-button-hover-border-color: var(--line); --fc-button-active-bg-color: var(--brand); --fc-button-active-border-color: var(--brand);
  --fc-list-event-hover-bg-color: var(--surface-2); font-size: 14px; }
#calendar .fc-toolbar-title { font-size: 18px; }
#calendar .fc-button-active { color: var(--brand-ink); }
#calendar .fc-event { cursor: pointer; }
#calendar .is-done { opacity: .45; text-decoration: line-through; }
#calendar .k-deadline { border-style: dashed !important; }
.dialog { border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.dialog-actions .spacer { flex: 1; }

/* ---- 8-week chart ---- */
.weeks-chart { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; height: 200px; align-items: end; }
.wk { display: flex; flex-direction: column; height: 100%; }
.wk-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 4px; border-bottom: 1px solid var(--line); }
.wk-bar { width: 18px; min-height: 2px; background: var(--c); border-radius: 4px 4px 0 0; position: relative; }
.wk-bar em { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; color: var(--muted); }
.wk-label { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- phones ---- */
@media (max-width: 860px) {
  .grid-2, .cal-layout { grid-template-columns: 1fr; }
  .mini-metrics { grid-template-columns: repeat(2, 1fr); }
  .lane { grid-template-columns: 64px 1fr 80px; gap: 8px; }
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 16px; }
  .nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .brand-text { display: none; }
  .page { padding: 16px 16px 50px; }
  .column { flex-basis: 78vw; }
}

/* The card that follows the pointer while dragging on the board. */
.kcard.ghost { position: fixed; z-index: 100; pointer-events: none; transform: rotate(2deg); box-shadow: 0 12px 30px rgba(0,0,0,.25); cursor: grabbing; }
.kcard { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* ---- suggestions ---- */
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.section-title { margin: 24px 0 12px; font-size: 18px; }
.batch-prompt { font-style: italic; margin: 0 0 6px; }
.batch-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 8px 0 4px; }
.batch-actions select, .sugg-actions select { display: inline-block; width: auto; margin: 0; padding: 4px 8px; font-size: 14px; }
.sugg-list { list-style: none; margin: 0; padding: 0; }
.sugg { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.sugg-main { min-width: 0; flex: 1; }
.sugg-sub { font-size: 14px; }
.sugg-why { font-size: 14px; margin: 4px 0; }
.sugg-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.tag-ok { color: var(--ok); }
.key-card { border-color: var(--ok); }
.copy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.copy-row code, .cowork-prompt pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; word-break: break-all; }
.cowork-prompt pre { white-space: pre-wrap; max-height: 360px; overflow: auto; }
.cowork-prompt { margin: 12px 0; }
@media (max-width: 860px) { .sugg { flex-direction: column; } .sugg-actions { align-items: flex-start; } }
