/* ============================================================
   Lijo CRM — design system
   Brand: purple #9B6BAD · gold #B1994E · navy #203E71 · Poppins
   ============================================================ */

:root {
  --purple: #9B6BAD;
  --purple-strong: #7d5090;
  --purple-soft: rgba(155, 107, 173, 0.12);
  --gold: #B1994E;
  --gold-soft: rgba(177, 153, 78, 0.14);
  --navy: #203E71;

  --bg: #f7f6f9;
  --surface: #ffffff;
  --surface-2: #f1eff4;
  --surface-3: #e9e6ef;
  --border: #e3e0e9;
  --border-strong: #cfcad9;
  --text: #23202b;
  --text-2: #5f5a6b;
  /* --text-3 carries small labels and hints. It was #918b9e, which sits at about
     3.3:1 on white and was unreadable at 10.8px. This clears 4.5:1. */
  --text-3: #7b7489;
  --accent: var(--purple);
  --accent-contrast: #ffffff;

  --green: #3d9a6b; --green-soft: rgba(61,154,107,.13);
  --red: #cb5449;   --red-soft: rgba(203,84,73,.12);
  --amber: #c08a2d; --amber-soft: rgba(192,138,45,.14);
  --blue: #4a6fa5;  --blue-soft: rgba(74,111,165,.13);

  --shadow-1: 0 1px 2px rgba(32, 25, 45, .06), 0 1px 6px rgba(32, 25, 45, .05);
  --shadow-2: 0 4px 14px rgba(32, 25, 45, .10), 0 2px 4px rgba(32, 25, 45, .06);
  --shadow-3: 0 14px 44px rgba(32, 25, 45, .18);

  --r-sm: 7px; --r-md: 11px; --r-lg: 16px;
  --font: 'Poppins', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Consolas, monospace;
  --sidebar-w: 232px;
}

[data-theme="dark"] {
  --bg: #16131c;
  --surface: #1e1a26;
  --surface-2: #262130;
  --surface-3: #2f2939;
  --border: #322c3e;
  --border-strong: #453d54;
  --text: #efecf4;
  --text-2: #b5aec4;
  --text-3: #948da8;
  --purple-soft: rgba(155, 107, 173, 0.20);
  --gold-soft: rgba(177, 153, 78, 0.20);
  --green-soft: rgba(61,154,107,.20);
  --red-soft: rgba(203,84,73,.20);
  --amber-soft: rgba(192,138,45,.20);
  --blue-soft: rgba(74,111,165,.20);
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 14px rgba(0,0,0,.45);
  --shadow-3: 0 14px 44px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
/* form controls never inherit the browser's default monospace/serif stack */
input, textarea, select, button { font-family: var(--font); font-size: 13px; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--purple-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
[data-theme="dark"] a { color: #c9a3da; }

::selection { background: var(--purple-soft); }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; border-radius: 4px; }

/* ---------------------------------------------------------- layout ---- */

#app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 14px 10px 10px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 16px; user-select: none;
}
/* standalone: used in the sidebar brand, the user chip, and the settings user list */
.logo {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px;
  background: linear-gradient(135deg, var(--purple) 10%, var(--navy) 100%);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; letter-spacing: .5px;
  box-shadow: var(--shadow-1);
}
.logo.sm { width: 26px; height: 26px; font-size: 11px; border-radius: 8px; }
.brand .name { font-weight: 600; font-size: 14.5px; letter-spacing: .2px; }
.brand .name small { display: block; font-weight: 400; font-size: 10.5px; color: var(--text-3); letter-spacing: 1.2px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); padding: 14px 10px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer; border: none; background: none;
  font-family: inherit; font-size: 13px; text-align: left; width: 100%;
}
.nav-item svg { width: 16px; height: 16px; flex: 0 0 auto; opacity: .75; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--purple-soft); color: var(--purple-strong); font-weight: 500; }
[data-theme="dark"] .nav-item.active { color: #d4b3e3; }
.nav-item .count {
  margin-left: auto; font-size: 11px; background: var(--surface-3);
  border-radius: 20px; padding: 1px 8px; color: var(--text-2);
}
.nav-item.active .count { background: var(--purple); color: #fff; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 8px; display: flex; align-items: center; gap: 8px; }
.userchip { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); flex: 1; }
.userchip:hover { background: var(--surface-2); cursor: pointer; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 54px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar h1 { font-size: 15.5px; font-weight: 600; margin: 0; letter-spacing: .1px; }
.topbar .spacer { flex: 1; }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 6px 12px; min-width: 240px;
  color: var(--text-3); cursor: pointer; font-size: 12.5px;
}
.searchbox:hover { border-color: var(--border-strong); }
.searchbox kbd {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; color: var(--text-3);
}

.content { flex: 1; overflow-y: auto; padding: 22px 24px 60px; }
.content.full { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
/* #view sits between .content and the board, so the height and width limits have
   to pass THROUGH it; without this the kanban grows past the viewport and its
   horizontal scrollbar never appears */
.content.full > #view {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; min-width: 0; overflow: hidden;
}

/* --------------------------------------------------------- buttons ---- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  padding: 7px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-strong); border-color: var(--purple-strong); }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 4px 10px; font-size: 11.5px; }
.btn svg { width: 14px; height: 14px; }
.btn:disabled { opacity: .5; cursor: default; }

.iconbtn {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: var(--r-sm); border: none; background: transparent;
  color: var(--text-2); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn svg { width: 15px; height: 15px; }

/* Any control smaller than 28px gets an invisible 28px+ hit area around it, so
   a small dot on screen is still an easy thing to hit with a mouse. */
.hit-pad { position: relative; }
.hit-pad::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; }

/* --------------------------------------------- segmented view toggle ---- */

/* Two views of the same data (List / Calendar) are never two buttons and never
   purple: one bordered group, the active side filled light grey. */
.segmented {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); overflow: hidden;
}
.segmented button {
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  padding: 6px 14px; border: none; background: transparent;
  color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button:hover { background: var(--surface-2); color: var(--text); }
.segmented button.on { background: var(--surface-3); color: var(--text); font-weight: 600; }

/* --------------------------------------------------- clickable rows ---- */

/* A row marked rowlink opens a record. Pointer, hover fill, and a chevron that
   fades in at the right edge. Nothing else in the app hovers without doing
   something, so hover always means a click will land. */
.rowlink { cursor: pointer; position: relative; }
.rowlink:hover { background: var(--surface-2); }
.rowlink::after {
  content: ''; position: absolute; right: 13px; top: 50%;
  width: 6px; height: 6px; margin-top: -4px; pointer-events: none;
  border-right: 1.6px solid var(--text-3); border-top: 1.6px solid var(--text-3);
  transform: rotate(45deg); opacity: 0; transition: opacity .12s;
}
.rowlink:hover::after { opacity: 1; }
.checkline.rowlink, .promise-row.rowlink, .tl-item.rowlink { padding-right: 30px; }

/* A table row cannot host the chevron itself, so the last cell carries it. */
table.data tbody tr.rowlink td:last-child { position: relative; padding-right: 28px; }
table.data tbody tr.rowlink td:last-child::after {
  content: ''; position: absolute; right: 11px; top: 50%;
  width: 6px; height: 6px; margin-top: -4px; pointer-events: none;
  border-right: 1.6px solid var(--text-3); border-top: 1.6px solid var(--text-3);
  transform: rotate(45deg); opacity: 0; transition: opacity .12s;
}
table.data tbody tr.rowlink:hover td:last-child::after { opacity: 1; }

/* ------------------------------------------------------- filter bar ---- */

/* Add filter, Show archived, Save view and Views were four bare words. They are
   one bordered group of quiet buttons now, so they read as controls. */
.filterbar {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); padding: 2px;
}
.filterbar .btn {
  border-color: transparent; background: transparent; color: var(--text-2);
  padding: 5px 10px; font-size: 12px; gap: 5px;
}
.filterbar .btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.filterbar .btn.on {
  background: var(--surface-3); border-color: var(--border-strong); color: var(--text);
  font-weight: 600;
}
.filterbar .sep { width: 1px; align-self: stretch; background: var(--border); margin: 3px 3px; }

/* A live filter condition. Same height as every other pill. */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; border-radius: 20px; padding: 4px 8px 4px 11px;
  background: var(--purple-soft); color: var(--purple-strong);
  cursor: pointer; border: 1px solid transparent; white-space: nowrap;
}
.chip:hover { border-color: var(--purple); }
.chip .x { display: inline-flex; opacity: .65; }
.chip:hover .x { opacity: 1; }
[data-theme="dark"] .chip { color: #d4b3e3; }

/* ----------------------------------------------------------- cards ---- */

.cards { display: grid; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.card .card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px;
}
.card .card-head .spacer { flex: 1; }
.card .card-body { padding: 14px 16px; }
.card .card-body.flush { padding: 0; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 16px; box-shadow: var(--shadow-1); cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.stat:hover { border-color: var(--purple); box-shadow: var(--shadow-2); }
/* The import wizard's four counters are read-outs, not links. */
.stat.static { cursor: default; }
.stat.static:hover { border-color: var(--border); box-shadow: var(--shadow-1); }
.stat .k { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .8px; }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 3px; }
.stat .v small { font-size: 12px; color: var(--text-2); font-weight: 400; margin-left: 6px; }
.stat.warn .v { color: var(--red); }

/* ----------------------------------------------------------- pills ---- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; border-radius: 20px; padding: 2px 9px;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.purple { background: var(--purple-soft); color: var(--purple-strong); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
[data-theme="dark"] .pill.purple { color: #d4b3e3; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
/* Same vertical padding as every other pill, so a row of mixed pills has one
   height rather than two. */
.pill.arch {
  background: var(--surface-3); color: var(--text-3);
  font-size: 10px; padding: 2px 8px; letter-spacing: .3px; font-weight: 500;
}
.namecell { display: inline-flex; align-items: center; gap: 7px; }

/* --------------------------------------------------------- archived ---- */

/* Archived rows stay readable but visibly out of the working set. */
tr.archived-row td, .checkline.archived-row, .promise-row.archived-row { opacity: .6; }
tr.archived-row:hover td { opacity: .85; }
.archbanner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px;
  border: 1px solid var(--border-strong); border-left: 3px solid var(--text-3);
  border-radius: var(--r-sm); background: var(--surface-2);
  font-size: 12.5px; color: var(--text-2);
}
.archbanner .spacer { flex: 1; }

/* ---------------------------------------------------- empty field rows -- */

.fieldmore {
  appearance: none; border: none; background: none; width: 100%; text-align: left;
  padding: 9px 16px; border-bottom: 1px solid var(--border);
  font-family: var(--font); font-size: 11.8px; color: var(--text-3); cursor: pointer;
}
.fieldmore:hover { background: var(--surface-2); color: var(--text-2); }
.fieldlist .fieldmore:last-child { border-bottom: none; }

/* ----------------------------------------------------------- table ---- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); }
table.data { width: 100%; border-collapse: collapse; font-size: 12.8px; }
table.data th {
  text-align: left; font-size: 10.8px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-3); font-weight: 500;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); position: sticky; top: 0; white-space: nowrap;
}
table.data td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
/* Only rows that actually open something react to the mouse. A table used for
   reading (the stage list, the import preview) stays flat. */
table.data th.num, table.data td.num { text-align: right; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
/* Row actions hide until hover only where the row itself is a link. In a table
   you read rather than click, hiding the one button on it just loses it. */
table.data tbody tr.rowlink td.actions .btn { visibility: hidden; }
table.data tbody tr.rowlink:hover td.actions .btn { visibility: visible; }

/* ---------------------------------------------------------- kanban ---- */

.kanban {
  display: flex; gap: 12px; align-items: stretch;
  overflow-x: scroll; overflow-y: hidden;
  padding: 18px 24px 14px;
  flex: 1 1 auto; min-width: 0; min-height: 0;
}
/* the horizontal scrollbar must be visible and grabbable at all times —
   without it there is no way to reach the stages past the viewport */
.kanban::-webkit-scrollbar { height: 12px; }
.kanban::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 8px; margin: 0 24px; }
.kanban::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--surface-2); }
.kanban::-webkit-scrollbar-thumb:hover { background: var(--purple); }
.kanban::after { content: ''; flex: 0 0 12px; }  /* breathing room past the last column */
.kcol {
  flex: 0 0 264px; display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); scroll-snap-align: start;
  min-height: 180px; align-self: stretch;
}
.kcol-head { padding: 10px 12px 8px; display: flex; align-items: baseline; gap: 8px; }
.kcol-head .t { font-weight: 600; font-size: 12.5px; }
.kcol-head .n { font-size: 11px; color: var(--text-3); }
.kcol-head .sum { margin-left: auto; font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.kcol-body { padding: 4px 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kcol-empty {
  flex: 1; display: grid; place-items: center; min-height: 90px;
  border: 1px dashed var(--border-strong); border-radius: var(--r-sm);
  color: var(--text-3); font-size: 11.5px; margin: 2px;
}
.kcol.dragover { outline: 2px dashed var(--purple); outline-offset: -4px; }

.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; cursor: grab; box-shadow: var(--shadow-1);
  transition: box-shadow .12s, border-color .12s;
}
.kcard:hover { border-color: var(--purple); box-shadow: var(--shadow-2); }
.kcard.dragging { opacity: .45; }
.kcard .t { font-weight: 500; font-size: 12.8px; margin-bottom: 4px; }
.kcard .org { font-size: 11.5px; color: var(--text-2); margin-bottom: 6px; }
.kcard .meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-3); }
.kcard .meta .money { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.kcard .rot { color: var(--red); display: inline-flex; align-items: center; gap: 3px; }
.kcard .nohistory { color: var(--text-3); font-size: 10.5px; }
.kcard .next {
  display: flex; align-items: center; gap: 6px;
  margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--border);
  font-size: 11px; color: var(--text-2);
}
.kcard .next .when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.kcard .next .when.overdue { color: var(--red); font-weight: 600; }
.kcard .next .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .next.none { color: var(--text-3); }
.kcard .next .addnext {
  appearance: none; border: 1px solid var(--border-strong); background: none;
  color: var(--text-3); border-radius: 4px; width: 17px; height: 17px; line-height: 1;
  cursor: pointer; font-size: 12px; padding: 0; margin-left: auto; flex: none;
  position: relative;
}
.kcard .next .addnext::before { content: ''; position: absolute; inset: -6px; }
.kcard .next .addnext:hover { border-color: var(--purple); color: var(--purple); }
.nextstep.overdue { color: var(--red); font-weight: 500; }

.kanban-drop {
  display: flex; gap: 12px; padding: 10px 24px; border-top: 1px solid var(--border);
  background: var(--surface);
}
.dropzone {
  flex: 1; text-align: center; padding: 12px; border-radius: var(--r-md);
  border: 2px dashed var(--border-strong); color: var(--text-3);
  font-weight: 500; font-size: 12.5px; display: none;
}
.kanban-drop.active .dropzone { display: block; }
.dropzone.won.dragover { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.dropzone.lost.dragover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.dropzone.parked.dragover { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); }

/* --------------------------------------------------------- record ---- */

.record-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.record-head .avatar {
  width: 44px; height: 44px; border-radius: var(--r-md);
  background: var(--purple-soft); color: var(--purple-strong);
  display: grid; place-items: center; font-weight: 600; font-size: 17px;
}
[data-theme="dark"] .record-head .avatar { color: #d4b3e3; }
.record-head .titleblock { flex: 1; min-width: 0; }
.pill-edit { display: inline-flex; align-items: center; cursor: pointer; border-radius: 20px; }
.pill-edit:hover .pill { box-shadow: 0 0 0 1.5px var(--purple); }
.pill-edit select {
  font-family: var(--font); font-size: 11.5px; padding: 2px 6px;
  border: 1px solid var(--purple); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
.record-head h2 { margin: 0 0 4px; font-size: 19px; font-weight: 600; }
.record-head .sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-2); font-size: 12.5px; }

.record-grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .record-grid { grid-template-columns: 1fr; } }

.fieldlist { display: flex; flex-direction: column; }
.field { padding: 8px 16px; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--border); }
.field:last-child { border-bottom: none; }
.field .k { font-size: 10.8px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); }
/* a long URL or email has to wrap inside the panel instead of running off it */
.field .v { min-height: 20px; font-size: 13px; border-radius: 4px; padding: 1px 4px; margin-left: -4px; overflow-wrap: anywhere; }
.field .v.editable:hover { background: var(--surface-2); cursor: text; }
.field .v.empty { color: var(--text-3); font-style: italic; }
.field .v input, .field .v select, .field .v textarea {
  width: 100%; font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--purple); border-radius: 4px; padding: 3px 6px;
}

/* -------------------------------------------------------- timeline ---- */

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: none; }
.tl-icon {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-3); color: var(--text-2);
}
.tl-icon svg { width: 13px; height: 13px; }
.tl-icon.note { background: var(--gold-soft); color: var(--gold); }
.tl-icon.activity { background: var(--blue-soft); color: var(--blue); }
.tl-icon.promise { background: var(--purple-soft); color: var(--purple-strong); }
.tl-icon.audit { background: var(--surface-3); color: var(--text-3); }
.tl-body { flex: 1; min-width: 0; }
.tl-body .head { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.tl-body .head .who { font-weight: 600; }
.tl-body .head .when { color: var(--text-3); font-size: 11.5px; margin-left: auto; white-space: nowrap; }
.tl-body .text { margin-top: 3px; font-size: 12.8px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.tl-body .diff { margin-top: 4px; font-size: 11.5px; color: var(--text-3); font-family: var(--mono); }

/* -------------------------------------------------------- promises ---- */

.promise-row { display: flex; gap: 14px; padding: 11px 16px; border-bottom: 1px solid var(--border); align-items: center; }
.promise-row:last-child { border-bottom: none; }
.promise-row .what { flex: 1; min-width: 0; font-size: 13px; }
.promise-row .what .meta { margin-top: 3px; font-size: 11.5px; color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; }
.promise-row.overdue { border-left: 3px solid var(--red); padding-left: 13px; }
.promise-row .due { font-size: 11.5px; white-space: nowrap; color: var(--text-2); }
.promise-row .due.overdue { color: var(--red); font-weight: 600; }

/* ----------------------------------------------------------- modal ---- */

.overlay {
  position: fixed; inset: 0; background: rgba(20, 15, 30, .45);
  display: grid; place-items: center; z-index: 100; backdrop-filter: blur(2px);
}
.modal {
  width: min(560px, calc(100vw - 40px)); max-height: calc(100vh - 80px);
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border);
}
.modal.wide { width: min(760px, calc(100vw - 40px)); }
.modal-head { display: flex; align-items: center; padding: 16px 20px 12px; font-weight: 600; font-size: 14.5px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.fgroup { display: flex; flex-direction: column; gap: 4px; }
.fgroup label { font-size: 11px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: .6px; }
.fgroup input, .fgroup select, .fgroup textarea {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 8px 10px;
}
.fgroup input:focus, .fgroup select:focus, .fgroup textarea:focus { border-color: var(--purple); outline: none; }
.fgroup textarea { resize: vertical; min-height: 64px; }

.dupewarn {
  margin-top: 10px; border: 1px solid var(--amber); background: var(--amber-soft);
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 12.5px;
}
.dupewarn .title { font-weight: 600; color: var(--amber); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.dupewarn .cand { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.dupewarn .cand .reasons { color: var(--text-3); font-size: 11.5px; }

/* ---------------------------------------------------------- palette ---- */

.palette {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 15, 30, .45); backdrop-filter: blur(2px);
  display: flex; justify-content: center; padding-top: 12vh;
}
.palette-box {
  width: min(600px, calc(100vw - 40px)); max-height: 60vh;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); border: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; height: fit-content;
}
.palette-box input {
  font-family: inherit; font-size: 15px; padding: 16px 18px;
  border: none; outline: none; background: transparent; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.palette-list { overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px;
}
.palette-item.sel, .palette-item:hover { background: var(--purple-soft); }
.palette-item .type { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); width: 64px; flex: 0 0 auto; }
.palette-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item kbd { font-family: var(--mono); font-size: 10px; color: var(--text-3); }
.palette-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ------------------------------------------------------------ misc ---- */

.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: var(--bg); font-size: 12.8px;
  padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-2);
  animation: toastIn .18s ease-out; max-width: 380px;
}
.toast.error { background: var(--red); color: #fff; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty {
  padding: 40px 20px; text-align: center; color: var(--text-3);
}
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .5; }
.empty .hint { font-size: 12px; margin-top: 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  font-family: inherit; font-size: 12.8px; padding: 8px 14px; cursor: pointer;
  border: none; background: none; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--purple-strong); border-bottom-color: var(--purple); font-weight: 600; }
[data-theme="dark"] .tab.active { color: #d4b3e3; }
.tab .count { font-size: 11px; color: var(--text-3); margin-left: 5px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"], .toolbar select {
  font-family: inherit; font-size: 12.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 7px 10px;
}

.checkline { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.checkline:last-child { border-bottom: none; }
.checkline input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--purple); cursor: pointer; }
.checkline .sub { color: var(--text-3); font-size: 11.5px; }
.checkline.done .t { text-decoration: line-through; color: var(--text-3); }
/* Dates line up in their own column instead of butting against whatever text
   happens to end nearest them. */
.checkline .when { margin-left: auto; font-size: 11.5px; color: var(--text-2); white-space: nowrap; min-width: 132px; text-align: right; }
.checkline .when.overdue { color: var(--red); font-weight: 600; }
/* A task row is one line: what it is on the left, its facts and its date on the
   right. It used to stack the meta line under the title and leave a metre of
   empty page between that and the date. */
.checkline .tt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checkline .metaline { flex: 0 0 auto; color: var(--text-3); font-size: 11.5px; }
.checkline .metaline a { color: var(--text-2); }
.checkline.done .tt { text-decoration: line-through; color: var(--text-3); }

/* A heading over one slice of a list. Sentence case with its own count, never
   shouted: "Overdue (131)". */
.listgroup {
  padding: 13px 16px 5px; font-size: 12px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: baseline; gap: 6px;
}
.listgroup .n { font-weight: 400; color: var(--text-3); }
/* a rule above each group after the first, so the slices read as slices */
.card-body.flush > .listgroup:not(:first-child) { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 14px; }

.section-title { font-size: 13px; font-weight: 600; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.section-title .spacer { flex: 1; }

.login-wrap { height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-box {
  width: 340px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-box .brand { padding: 0 0 6px; }

.mergegrid { display: grid; grid-template-columns: 130px 1fr 1fr; gap: 0; font-size: 12.5px; }
.mergegrid > div { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.mergegrid .mk { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.mergegrid .mv { cursor: pointer; border-radius: 4px; }
.mergegrid .mv:hover { background: var(--surface-2); }
.mergegrid .mv.chosen { background: var(--purple-soft); font-weight: 500; }

/* meta lines: separated inline facts under a title (org · $12,000 · by Yitz) */
.metaline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 0; }
.metaline > * { display: inline-flex; align-items: baseline; }
.metaline > * + *::before {
  content: '·'; color: var(--text-3); margin: 0 7px; font-weight: 600;
}

/* custom field designer */
.fieldrow {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.fieldrow:last-child { border-bottom: none; }
.fieldrow .grip { color: var(--text-3); cursor: grab; user-select: none; font-size: 14px; line-height: 1; }
.fieldrow.dragging { opacity: .4; }
.fieldrow.dropbefore { box-shadow: inset 0 2px 0 var(--purple); }
.fieldrow .fname { font-weight: 500; font-size: 13px; }
.fieldrow .fkey { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.fieldrow .spacer { flex: 1; }
.typepick { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.typepick button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer; text-align: left; color: var(--text);
}
.typepick button:hover { border-color: var(--purple); background: var(--purple-soft); }
.typepick button.sel { border-color: var(--purple); background: var(--purple-soft); font-weight: 500; }
.typepick .tt { font-size: 12.5px; }
.typepick .td { font-size: 10.5px; color: var(--text-3); }
.optlist { display: flex; flex-direction: column; gap: 6px; }
.optlist .opt { display: flex; gap: 6px; align-items: center; }
.optlist .opt input { flex: 1; }

.switchrow { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; }
.switchrow input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--purple); margin-top: 1px; cursor: pointer; }
.switchrow .lbl { font-size: 12.5px; }
.switchrow .hint { font-size: 11px; color: var(--text-3); }

.keyreveal {
  font-family: var(--mono); font-size: 12px; background: var(--surface-2);
  border: 1px dashed var(--border-strong); padding: 10px 12px; border-radius: var(--r-sm);
  word-break: break-all; user-select: all;
}

/* --------------------------------------------------------- calendar ---- */

.calgrid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.calhead { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); padding: 4px 6px; }
.calcell {
  min-height: 104px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 5px; display: flex; flex-direction: column; gap: 3px;
  overflow: hidden;
}
.calcell.off { background: transparent; border: none; }
.calcell.today { border-color: var(--purple); box-shadow: inset 0 0 0 1px var(--purple); }
.calday {
  font-size: 11.5px; font-weight: 600; color: var(--text-2); padding: 1px 4px;
  border-radius: 4px; cursor: pointer; align-self: flex-start;
}
.calday:hover { background: var(--purple-soft); }
.calitem {
  font-size: 10.8px; padding: 2px 6px; border-radius: 4px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--surface-2); border-left: 3px solid var(--border-strong);
}
.calitem:hover { background: var(--surface-3); }
.calitem.blue { border-left-color: var(--blue); background: var(--blue-soft); }
.calitem.purple { border-left-color: var(--purple); background: var(--purple-soft); }
.calitem.gold { border-left-color: var(--gold); background: var(--gold-soft); }
.calitem.red { border-left-color: var(--red); background: var(--red-soft); }
.calitem.amber { border-left-color: var(--amber); background: var(--amber-soft); }
.calitem.done { opacity: .45; text-decoration: line-through; }
.calmore { font-size: 10px; color: var(--text-3); padding: 0 6px; }

@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 90; height: 100%; transform: translateX(-100%); transition: transform .18s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-3); }
  .content { padding: 16px 14px 60px; }
  .record-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ---- searchable company combo (round 2) ---- */
.combo { position: relative; }
.combo input { width: 100%; padding-right: 28px; box-sizing: border-box; }
.combo-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-3); cursor: pointer;
  padding: 2px; display: flex; align-items: center;
}
.combo-clear::before { content: ''; position: absolute; inset: -7px; }
.combo-clear:hover { color: var(--text); }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow-2);
  z-index: 60; max-height: 240px; overflow-y: auto;
}
.combo-list .palette-item { padding: 8px 12px; }
.combo-list .palette-item .type { width: auto; margin-left: auto; }

/* ---- tasks list: one done control + a bulk hover zone (round 2) ---- */
.donebtn {
  width: 18px; height: 18px; flex: 0 0 18px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); background: transparent;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; color: #fff; position: relative;
}
/* 18px on screen, 30px to the mouse */
.donebtn::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; }
/* icon() writes display:block inline, which beat `display:none` here and left a
   white tick sitting inside every unchecked circle. Invisible on white, plainly
   wrong in dark mode, where it read as "everything is already done". */
.donebtn svg { opacity: 0; }
.donebtn:hover { border-color: var(--green); }
.donebtn.on { background: var(--green); border: none; }
.donebtn.on svg { opacity: 1; }
.checkline .bulkzone {
  width: 26px; flex: 0 0 26px; display: flex; align-items: center; justify-content: center;
  align-self: stretch; margin-left: -8px;
}
.checkline .bulkzone .bulkcb { opacity: 0; transition: opacity .12s; }
.checkline:hover .bulkzone .bulkcb,
.bulkzone.active .bulkcb,
.checkline .bulkzone .bulkcb:checked { opacity: 1; }

/* ---- timeline note archive: visible on hover only (round 2) ---- */
.tl-item .tl-archive { opacity: 0; margin-left: auto; transition: opacity .12s; }
.tl-item:hover .tl-archive { opacity: 1; }
