:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --panel: #faf9f5;
  --line: #e7e4db;
  --ink: #23211d;
  --muted: #79756c;
  --accent: #2f5545;
  --accent-soft: #e3ede5;
  --warn: #9a6224;
  --warn-soft: #f6eddd;
  --danger: #9b2c2c;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(35,33,29,.04);
  --font-serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, serif;

  /* Sidebar is light cream, matching the reference design — not dark. */
  --side-bg: #f4f2ea;
  --side-ink: #23211d;
  --side-muted: #79756c;
  --side-line: #e4e0d5;
  --side-active-bg: #dfe9e0;
  --side-active-ink: #2f5545;

  /* Activity-trend bars: pale for older weeks, saturated for recent. */
  --bar-pale: #d5ddd0;
  --bar-mid: #9db3a1;
  --bar-deep: #4a6b55;
}


* { box-sizing: border-box; }

/* The `hidden` attribute must beat any author `display` rule below.
   Without this, `.gate{display:grid}` and `.drawer{display:flex}` override the
   UA stylesheet's [hidden]{display:none}, leaving the login screen stuck on
   and the drawer overlay permanently covering the page. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ gate */

.gate {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2.5rem;
  padding: 2rem;
}

.wordmark {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 7vw, 3.25rem);
  font-weight: 400;
  letter-spacing: .22em;
  text-transform: uppercase;
  margin: 0;
  text-indent: .22em;
}
.wordmark.small {
  font-size: .95rem;
  letter-spacing: .18em;
  text-indent: .18em;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  width: min(300px, 85vw);
}

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { min-height: 5rem; resize: vertical; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: .55rem .9rem;
  background: none;
  color: var(--ink);
}
button.primary { background: var(--accent); color: #fff; }
button.ghost { border-color: var(--line); }
button.danger { color: var(--danger); border-color: var(--line); }
button:hover { filter: brightness(1.06); }
button:disabled { opacity: .5; cursor: default; }

.error { color: var(--danger); font-size: .85rem; margin: 0; text-align: center; }

/* ---------------------------------------------------------------- shell */

#app {
  display: flex;
  align-items: stretch;
  min-height: 100dvh;
}

.sidebar {
  flex: 0 0 210px;
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  color: var(--side-ink);
  padding: 1.1rem .9rem;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.sidebar-brand { padding: .3rem .5rem 1.5rem; }
.sidebar .wordmark.small { color: var(--side-ink); }

.tabs { display: flex; flex-direction: column; gap: .1rem; }
.tab {
  color: var(--side-muted);
  text-align: left;
  padding: .5rem .6rem;
  border-radius: var(--radius);
  font-size: .88rem;
}
.tab:hover { background: var(--side-line); color: var(--side-ink); }
.tab.is-active { background: var(--side-active-bg); color: var(--side-active-ink); font-weight: 600; }

.sidebar-signout {
  margin-top: auto;
  color: var(--side-muted);
  border-color: var(--side-line);
}
.sidebar-signout:hover { color: var(--side-ink); }

main#views { flex: 1; min-width: 0; padding: 2rem 2.25rem 4rem; max-width: 1180px; }
.view { display: none; }
.view.is-active { display: block; }

h2 { font-family: var(--font-serif); font-size: 1.1rem; font-weight: 400; margin: 1.75rem 0 .35rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 0 0 .9rem; }

.toolbar { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1; min-width: 180px; }
.toolbar select { width: auto; }

/* ----------------------------------------------------------- day header */

.day-header { margin-bottom: 1.75rem; }
#day-heading {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.9rem;
  margin: 0 0 .4rem;
}
#day-heading::first-letter {
  font-size: 1.5em;
  line-height: .7;
}
.day-summary {
  font-size: .95rem;
  color: var(--muted);
  margin: 0;
  max-width: 62ch;
  border-left: 2px solid var(--accent);
  padding-left: .8rem;
}

/* ------------------------------------------------------- dashboard grid */

.dash-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 2.5rem;
  align-items: start;
}
@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; gap: 1.5rem; } }

/* Small-caps section header with a count on the right — the repeating
   structural motif of the reference dashboard. */
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: .4rem;
  margin: 1.75rem 0 .75rem;
}
.dash-col > .sec-head:first-child { margin-top: 0; }
.sec-head h3 {
  margin: 0;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink);
}
.sec-head .sec-meta { font-size: .75rem; color: var(--muted); white-space: nowrap; }

.sub-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 1rem 0 .4rem;
}

.dash-row {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.dash-row:last-child { border-bottom: 0; }
.dash-row:hover { background: var(--panel); }
.dash-row .rl { flex: 1; min-width: 0; }
.dash-row .rt { font-size: .88rem; }
.dash-row .rs { font-size: .76rem; color: var(--muted); }
.dash-row .rr { font-size: .76rem; color: var(--muted); white-space: nowrap; }
.dash-row .rr.alert { color: var(--warn); font-weight: 600; }

/* Flagged rows get a left rule, echoing the reference's callout treatment. */
.dash-row.flagged { border-left: 2px solid var(--warn); padding-left: .6rem; }
.dash-row.starred { border-left: 2px solid var(--accent); padding-left: .6rem; }

/* Active Pipeline rows: name+meta | stage | time in stage. Fixed widths on
   the last two keep the stage badges in a clean vertical line regardless of
   how long the deal names are. */
.dash-row.pipe {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.5rem 5.5rem;
  gap: .6rem;
  align-items: center;
}
.dash-row.pipe .rt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-row.pipe .rs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-row.pipe .stage-col { justify-self: start; }
.dash-row.pipe .rr { text-align: right; }

@media (max-width: 640px) {
  .dash-row.pipe { grid-template-columns: minmax(0, 1fr) auto; }
  .dash-row.pipe .rr { display: none; }
}

.sec-link {
  display: block;
  text-align: right;
  font-size: .76rem;
  color: var(--muted);
  padding: .5rem 0;
  width: 100%;
}
.sec-link:hover { color: var(--accent); }

/* Inline variant, sitting beside a count inside a .sec-head. */
.sec-link-inline {
  font-size: .75rem;
  color: var(--accent);
  padding: 0;
  border: 0;
  background: none;
  font-weight: 600;
}
.sec-link-inline:hover { text-decoration: underline; }

.dash-note { font-size: .8rem; color: var(--muted); font-style: italic; padding: .5rem 0; }

/* ------------------------------------------------------ week / activity */

.week-figures { display: flex; align-items: baseline; gap: 1.5rem; flex-wrap: wrap; padding: .5rem 0; }
.week-fig .n { font-family: var(--font-serif); font-size: 1.6rem; }
.week-fig .l { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.next5 { display: flex; gap: .4rem; padding: .5rem 0; }
.day-cell {
  flex: 1;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .5rem .2rem;
  min-width: 0;
}
.day-cell .dow { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.day-cell .cnt { font-family: var(--font-serif); font-size: 1.15rem; line-height: 1.4; }
.day-cell .dt { font-size: .62rem; color: var(--muted); }
.day-cell.has-1 { background: var(--bar-pale); }
.day-cell.has-2 { background: var(--bar-mid); }
.day-cell.has-3 { background: var(--bar-deep); color: #fff; }
.day-cell.has-3 .dow, .day-cell.has-3 .dt { color: rgba(255,255,255,.75); }

.trend {
  display: flex;
  align-items: flex-end;
  gap: .25rem;
  height: 90px;
  padding: .5rem 0;
}
.trend-bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.trend-bar .bv { font-size: .62rem; color: var(--muted); margin-bottom: .15rem; }
.trend-bar .bb { width: 100%; background: var(--bar-pale); border-radius: 2px 2px 0 0; min-height: 2px; }
.trend-bar.recent .bb { background: var(--bar-mid); }
.trend-bar.newest .bb { background: var(--bar-deep); }
.trend-foot { display: flex; justify-content: space-between; font-size: .65rem; color: var(--muted); }

/* ---------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}
.stat .n { font-family: var(--font-serif); font-size: 1.7rem; font-weight: 400; }
.stat .l { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat.alert .n { color: var(--warn); }

/* Stat tiles that act as filters (Pipeline). */
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--accent); }
.stat.clickable.is-active { background: var(--accent-soft); border-color: var(--accent); }
.stat.clickable.is-active .n { color: var(--accent); }

.filter-bar { margin-bottom: 1rem; }

/* Per-contact interaction history, shown inside the drawer. */
.note-entry {
  border-left: 2px solid var(--line);
  padding: .4rem 0 .4rem .7rem;
  margin-bottom: .6rem;
}
.note-entry-meta {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: .2rem;
}
.note-entry-body { font-size: .85rem; }
.note-entry-sub { font-size: .78rem; color: var(--muted); margin-top: .2rem; }

/* -------------------------------------------------------------- subtabs */
/* Pipeline's Deals / Opportunities / Ventures switcher — a lighter-weight
   sibling to the sidebar tabs, scoped inside one view. */

.subtabs {
  display: flex;
  gap: 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}
.subtab {
  color: var(--muted);
  padding: .5rem 0;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtab.is-active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.subview { display: none; }
.subview.is-active { display: block; }

/* ------------------------------------------------------------------ chips */

.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip {
  font-size: .8rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}
.chip.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

.view-toggle { display: flex; gap: .25rem; margin-bottom: 1.25rem; }
.toggle-btn { font-size: .8rem; color: var(--muted); padding: .35rem .7rem; }
.toggle-btn.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* --------------------------------------------------------------- tables */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
th { font-weight: 600; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { max-width: 30ch; white-space: normal; color: var(--muted); }

.pill {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.mute { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.empty { color: var(--muted); padding: 1.5rem; text-align: center; }

/* ------------------------------------------------- grouped list sections */
/* Shared by Contacts-by-firm, the Deals stage board, and the Opportunities
   stage board — same visual language: a small-caps section label, then
   surface-backed groups of clickable rows. */

.category-heading {
  font-family: var(--font-serif);
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 1.75rem 0 .6rem;
}
.category-heading:first-child { margin-top: 0; }

.firm-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
  overflow: hidden;
}
.firm-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  padding: .55rem .9rem;
  background: var(--accent-soft);
  font-weight: 600;
  font-size: .88rem;
}
.firm-count { font-weight: 400; color: var(--muted); font-size: .78rem; white-space: nowrap; }

.contact-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .9rem;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.contact-row:hover { background: var(--accent-soft); }
.contact-who { flex: 1; min-width: 0; }
.contact-name { font-size: .9rem; }
.contact-title { font-size: .78rem; color: var(--muted); }
.contact-row .pill:first-child { flex-shrink: 0; }
.contact-row .pill:last-child { flex-shrink: 0; }
.contact-row.static { cursor: default; }
.contact-row.static:hover { background: none; }

/* Columnar contact rows: tier · name · title · cadence · warm/cold. */
.contact-row.cols {
  display: grid;
  grid-template-columns: 2.4rem minmax(110px, 1.15fr) minmax(0, 2fr) 6.5rem 4.2rem;
  gap: .6rem;
  align-items: center;
}
.contact-row.cols .c-name { font-size: .9rem; }
.contact-row.cols .c-title {
  font-size: .8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-row.cols .c-cadence { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.contact-row.cols .c-cadence.alert { color: var(--warn); font-weight: 600; }
.contact-row.cols .c-blank { color: var(--line); font-size: .78rem; }

@media (max-width: 760px) {
  .contact-row.cols { grid-template-columns: 2.4rem 1fr 5.5rem; }
  .contact-row.cols .c-title { display: none; }
  .contact-row.cols .c-blank { display: none; }
}

/* --------------------------------------------------------------- notes */

.note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: .75rem;
  cursor: pointer;
}
.note:hover { border-color: var(--accent); }
.note h4 { margin: 0 0 .2rem; font-size: .95rem; font-family: var(--font-serif); font-weight: 400; }
.note .meta { color: var(--muted); font-size: .8rem; margin-bottom: .5rem; }
.note p { margin: 0; font-size: .9rem; }

/* -------------------------------------------------------------- drawer */

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  justify-content: flex-end;
  z-index: 20;
}
.drawer-panel {
  background: var(--bg);
  width: min(460px, 100vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.drawer-head, .drawer-foot {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font-size: 1rem; font-family: var(--font-serif); font-weight: 400; margin-right: auto; }
.drawer-foot { border-bottom: 0; border-top: 1px solid var(--line); margin-top: auto; }
.drawer-foot .primary { margin-left: auto; }
#drawer-form { padding: 1.1rem; overflow-y: auto; flex: 1; }
#drawer-form label { display: block; margin-bottom: .9rem; }
#drawer-form span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }

@media (max-width: 820px) {
  #app { flex-direction: column; }
  .sidebar {
    flex: none;
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: .6rem .9rem;
    gap: 1rem;
    z-index: 5;
  }
  .sidebar-brand { padding: 0; }
  .tabs { flex-direction: row; flex-wrap: wrap; gap: .15rem; margin-right: auto; }
  .sidebar-signout { margin-top: 0; }
  main#views { padding: 1.25rem 1rem 3rem; }
}

@media (max-width: 600px) {
  th, td { padding: .5rem .6rem; }
  td.wrap { display: none; }
}
