:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efeb;
  --border: #e4e1db;
  --border-strong: #d3cfc7;
  --text: #1c1b19;
  --muted: #6c6861;
  --faint: #9a958d;
  --accent: #9a5b2e;
  --accent-text: #ffffff;
  --accent-soft: #f6ece3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #157f3c;
  --ok-soft: #e7f5ec;
  --warn: #a15c07;
  --warn-soft: #fdf2e0;
  --shadow: 0 1px 2px rgba(28, 27, 25, .06), 0 1px 1px rgba(28, 27, 25, .04);
  --shadow-lg: 0 12px 40px rgba(28, 27, 25, .16);
  --radius: 10px;
  --s-new: #8a867f;
  --s-contacted: #2563eb;
  --s-meeting: #7c3aed;
  --s-negotiating: #c2780a;
  --s-won: #15803d;
  --s-lost: #c2410c;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #121110;
  --surface: #1b1a18;
  --surface-2: #252320;
  --border: #33302c;
  --border-strong: #46423c;
  --text: #edebe7;
  --muted: #a7a29a;
  --faint: #7a756d;
  --accent: #e0a172;
  --accent-text: #1b1a18;
  --accent-soft: #382a1f;
  --danger: #f28b82;
  --danger-soft: #3a1d1a;
  --ok: #6fd391;
  --ok-soft: #173223;
  --warn: #f3b85b;
  --warn-soft: #3a2c14;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  --s-new: #9d978e;
  --s-contacted: #6f9cf5;
  --s-meeting: #a78bfa;
  --s-negotiating: #eab155;
  --s-won: #5ccf86;
  --s-lost: #f08a5d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Tamil", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  white-space: nowrap; text-decoration: none !important; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.small { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn.call { background: var(--ok-soft); border-color: transparent; color: var(--ok); font-weight: 600; }
.btn svg { width: 16px; height: 16px; flex: none; }

input[type=text], input[type=tel], input[type=password], input[type=date], input[type=time], input[type=search], input[type=url], select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); outline: none;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.field > span { padding-left: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip .n { color: var(--faint); font-weight: 500; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--s-new); }
.dot.new { background: var(--s-new); } .dot.contacted { background: var(--s-contacted); } .dot.meeting { background: var(--s-meeting); }
.dot.negotiating { background: var(--s-negotiating); } .dot.won { background: var(--s-won); } .dot.lost { background: var(--s-lost); }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.star { color: var(--faint); background: none; border: 0; cursor: pointer; padding: 2px; line-height: 0; }
.star.on { color: #e3a008; }
.star.on svg { fill: currentColor; }
.star svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------ layout */
/* sidebar on the left, collapsible to icons; the page on the right */
.shell { --side: 232px; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .18s ease; }
.shell.collapsed { --side: 64px; }
.side {
  position: sticky; top: 0; height: 100vh; z-index: 30; overflow: hidden;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px 10px; padding-top: max(12px, env(safe-area-inset-top));
}
.side-brand { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 6px; margin-bottom: 14px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.side-brand img { width: 30px; height: 30px; flex: none; }
.side-x { margin-left: auto; }
.side-nav { display: grid; gap: 2px; }
.side-foot { margin-top: auto; display: grid; gap: 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.nav {
  position: relative; display: flex; align-items: center; gap: 11px; width: 100%; height: 40px; padding: 0 11px;
  border: 0; border-radius: 9px; background: none; cursor: pointer; color: var(--muted); font-weight: 500;
  white-space: nowrap; text-align: left; text-decoration: none !important;
}
.nav svg { width: 20px; height: 20px; flex: none; }
.nav:hover { background: var(--surface-2); color: var(--text); }
.nav[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .lbl { overflow: hidden; text-overflow: ellipsis; }
.nav .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.side-scrim { display: none; }
/* collapsed: icons only; the count sits on the icon */
.shell.collapsed .lbl { display: none; }
.shell.collapsed .side-brand { padding: 0 7px; }
.shell.collapsed .nav { padding: 0; justify-content: center; }
.shell.collapsed .nav .count { position: absolute; top: 3px; right: 5px; min-width: 17px; height: 17px; padding: 0 4px; font-size: 10.5px; margin: 0; }

.content { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 12px; min-height: 61px;
}
.page-title { margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; }
.top .search { flex: 1; max-width: 380px; margin-left: auto; position: relative; }
.top .search input { padding-left: 32px; }
.top .search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--faint); }
.only-sm { display: none !important; }
.menu-btn { position: relative; }
.menu-btn .count { position: absolute; top: 0; right: -2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.menu-btn .count.hidden { display: none; }

.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px 4px; }
.bar .summary { margin-left: auto; color: var(--muted); font-size: 13px; }
main { padding-bottom: 40px; }

/* ------------------------------------------------------------ board */
.board { display: flex; gap: 12px; padding: 10px 16px 24px; overflow-x: auto; align-items: flex-start; min-height: calc(100vh - 130px); scroll-snap-type: x proximity; }
.col { flex: 0 0 286px; background: var(--surface-2); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 150px); scroll-snap-align: start; border: 1px solid transparent; }
.col.drop { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; font-weight: 600; }
.col-head .n { color: var(--muted); font-weight: 500; margin-left: auto; font-size: 13px; }
.col-body { padding: 0 8px 8px; overflow-y: auto; display: grid; gap: 8px; align-content: start; }
.col-empty { color: var(--faint); font-size: 13px; padding: 12px 6px; text-align: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 11px; cursor: pointer; box-shadow: var(--shadow); display: grid; gap: 5px; }
.card:hover { border-color: var(--border-strong); }
.card.dragging { opacity: .45; }
.card-title { display: flex; gap: 6px; align-items: flex-start; font-weight: 600; line-height: 1.3; }
.card-title .name { flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title .star { margin: -1px -2px 0 0; }
.card-meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 6px; flex-wrap: wrap; }
.card-next { font-size: 12.5px; display: flex; gap: 6px; align-items: flex-start; padding: 5px 7px; border-radius: 7px; background: var(--surface-2); }
.card-next.over { background: var(--danger-soft); color: var(--danger); }
.card-next.today { background: var(--warn-soft); color: var(--warn); }
.card-next svg { width: 13px; height: 13px; flex: none; margin-top: 2px; }
.card-next span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-last { font-size: 12px; color: var(--faint); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* ------------------------------------------------------------ follow-ups */
.wrap { max-width: 860px; margin: 0 auto; padding: 8px 16px; }
.group { margin-top: 18px; }
.group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.group h3.over { color: var(--danger); }
.tasklist { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.task { display: flex; gap: 12px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--border); }
.task:first-child { border-top: 0; }
.task .when { width: 92px; flex: none; font-size: 13px; font-weight: 600; }
.task .when.over { color: var(--danger); }
.task .what { flex: 1; min-width: 0; }
.task .what .t { font-weight: 500; }
.task .what .h { font-size: 12.5px; color: var(--muted); }
.task .what .h button { all: unset; cursor: pointer; color: var(--accent); }
.task .what .h button:hover { text-decoration: underline; }
.task.done .t { text-decoration: line-through; color: var(--faint); }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 12px; }

/* ------------------------------------------------------------ list */
.tablewrap { margin: 8px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none; }
th.sorted { color: var(--text); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .stage { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
td.next { max-width: 280px; }

/* ------------------------------------------------------------ drawer */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 51;
  background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slide .16s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.d-head { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 16px 12px; padding-top: max(14px, env(safe-area-inset-top)); display: grid; gap: 10px; }
.d-title { display: flex; gap: 8px; align-items: flex-start; }
.d-title h2 { margin: 0; font-size: 18px; line-height: 1.3; flex: 1; }
.d-sub { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.d-actions select { width: auto; min-width: 150px; font-weight: 600; }
.d-body { overflow-y: auto; padding: 12px 16px 40px; display: grid; gap: 12px; align-content: start; flex: 1; }
.sec { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.sec > h4 { margin: 0; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sec > h4 .n { color: var(--faint); font-weight: 500; }
.sec > h4 .right { margin-left: auto; }
.hint { font-size: 12.5px; color: var(--muted); }
.hint.move { color: var(--accent); font-weight: 500; }
.items { display: grid; gap: 2px; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item .body { flex: 1; min-width: 0; }
.item .meta { font-size: 12px; color: var(--faint); margin-top: 2px; }
.item .x { opacity: .55; }
.item:hover .x { opacity: 1; }
.item .t { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-icon { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--muted); }
.tl-icon svg { width: 14px; height: 14px; }
.tl-icon.call { background: var(--accent-soft); color: var(--accent); }
.tl-icon.stage { background: var(--surface-2); }
.tl-icon.task { background: var(--ok-soft); color: var(--ok); }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.form { display: grid; gap: 8px; }

/* ------------------------------------------------------------ modal, login, toast */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0, 0, 0, .32); padding: 16px; }
.modal .box { width: min(440px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 18px; display: grid; gap: 12px; }
.modal h3 { margin: 0; font-size: 16px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login h1 { margin: 0; font-size: 20px; display: flex; gap: 10px; align-items: center; }
.login h1 img { width: 30px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; opacity: 0; pointer-events: none; transition: .18s; z-index: 90; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------ phones */
@media (max-width: 760px) {
  /* on a phone the sidebar slides in over the page from the menu button, always with words */
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 82vw); height: auto; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); z-index: 70; }
  .shell.side-open .side { transform: none; }
  .shell.side-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .32); z-index: 65; }
  .shell.collapsed .lbl { display: inline; }
  .shell.collapsed .nav { padding: 0 11px; justify-content: flex-start; }
  .shell.collapsed .nav .count { position: static; margin-left: auto; }
  .only-sm { display: inline-flex !important; }
  .top { flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px; min-height: 0; }
  .page-title { font-size: 17px; }
  .top .search { order: 5; flex-basis: 100%; max-width: none; margin: 0; }
  .bar { padding: 10px 12px 2px; }
  .board { padding: 8px 12px 20px; min-height: auto; }
  .col { flex-basis: 84vw; max-height: none; }
  .col-body { overflow: visible; }
  .wrap { padding: 4px 12px; }
  .task { padding: 10px 12px; gap: 10px; }
  .task .when { width: 70px; }
  .tablewrap { margin: 8px 12px; }
  .drawer { width: 100vw; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > :first-child { grid-column: 1 / -1; }
  .hide-sm { display: none; }
}

/* outcome chips are radio buttons */
.chip.radio { position: relative; }
.chip.radio input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chip.radio:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.radio:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-soft); }

/* icons inside headings and text never grow past the text */
.sec > h4 svg, .tl-icon svg, .card-next svg, .chip svg, .menu-pop svg { width: 15px; height: 15px; flex: none; }
.sec > h4 svg { color: var(--muted); }
