/* Mayfield design system ("Console"). Tokens first, then layout, then components. */

:root {
  --bg: #f7f8fa;
  --surface: #fff;
  --subtle: #fafbfc;
  --ink: #14161b;
  --muted: #646b7a;
  --faint: #9aa1b0;
  --line: #e6e8ee;
  --side: #101218;
  --side-ink: #c9cdd8;
  --side-line: #222633;
  --accent: #4553d6;
  --accent-strong: #3a47c4;
  --accent-soft: #eceefc;
  --green: #16794c;
  --green-soft: #e2f4ea;
  --green-solid: #2a9d68;
  --amber: #9a6200;
  --amber-soft: #fdf0d5;
  --amber-solid: #e0a526;
  --blue: #1f62b8;
  --blue-soft: #e3eefb;
  --blue-solid: #3b82d6;
  --violet: #6d3fc4;
  --violet-soft: #efe8fb;
  --violet-solid: #8b5cf6;
  --red: #b3362b;
  --red-soft: #fbe6e3;
  --grey-solid: #c9ced9;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 22, 27, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---- Shell ---------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  background: var(--side);
  color: var(--side-ink);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  color: #fff;
  font-weight: 600;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, #6f7bf0, var(--accent));
  display: grid;
  place-items: center;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 1px;
}

.nav-label {
  font-size: 11px;
  color: #6c7283;
  padding: 0 8px 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 7px;
}

.nav a:hover {
  background: #1a1d26;
  color: #fff;
}

.nav a[aria-current="page"] {
  background: var(--side-line);
  color: #fff;
}

.nav .icon {
  opacity: 0.8;
}

.badge {
  margin-left: auto;
  font: 500 11px var(--mono);
  background: #2a2f3f;
  padding: 1px 6px;
  border-radius: 5px;
}

.badge.hot {
  background: var(--accent);
  color: #fff;
}

.me {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 8px 2px;
  border-top: 1px solid var(--side-line);
  font-size: 12.5px;
  min-width: 0;
}

.me div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me small {
  display: block;
  color: #6c7283;
  font-size: 12px;
}

.me-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2a2f3f;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: #fff;
  flex: none;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 57px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
}

.crumb {
  color: var(--muted);
  margin-right: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crumb a:hover {
  color: var(--ink);
}

.crumb b {
  color: var(--ink);
  font-weight: 600;
}

main {
  padding: 24px 28px 64px;
  max-width: 1280px;
}

.page-head {
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-head p {
  color: var(--muted);
  margin-top: 2px;
}

/* ---- Buttons and inputs ----------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(69, 83, 214, 0.35);
}

.btn:hover {
  background: var(--accent-strong);
}

.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn.ghost:hover {
  background: var(--subtle);
}

/* For card headers and other tight spots. */
.btn.small {
  padding: 4px 10px;
  font-size: 12.5px;
}

.input,
.select {
  font: inherit;
  color: var(--ink);
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.input:focus,
.select:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.input::placeholder {
  color: var(--faint);
}

/* Dropdown lists drawn in the app's style instead of the operating system's grey menu.
   Chrome and Edge support this; other browsers keep their usual dropdown. */
@supports (appearance: base-select) {
  .select,
  .select::picker(select) {
    appearance: base-select;
  }

  .select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
  }

  /* A thin chevron, matching the line icons used elsewhere. */
  .select::picker-icon {
    content: "";
    width: 12px;
    height: 12px;
    margin-left: auto;
    background: var(--faint);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
      center / contain no-repeat;
    transition: rotate 0.15s;
  }

  .column-filter.is-set .select::picker-icon {
    background: var(--accent);
  }

  .select:open::picker-icon {
    rotate: 180deg;
  }

  .select::picker(select) {
    margin-top: 4px;
    padding: 4px;
    min-width: max(anchor-size(width), 160px);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(16, 18, 24, 0.14);
    opacity: 0;
    translate: 0 -4px;
    transition:
      opacity 0.12s,
      translate 0.12s,
      overlay 0.12s allow-discrete,
      display 0.12s allow-discrete;
  }

  .select:open::picker(select) {
    opacity: 1;
    translate: 0;
  }

  @starting-style {
    .select:open::picker(select) {
      opacity: 0;
      translate: 0 -4px;
    }
  }

  .select option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 400;
    color: var(--ink);
    cursor: pointer;
  }

  .select option:hover,
  .select option:focus-visible {
    background: var(--subtle);
    outline: none;
  }

  .select option:checked {
    color: var(--accent);
    font-weight: 500;
    background: var(--accent-soft);
  }

  .select option::checkmark {
    order: 1;
    margin-left: auto;
    color: var(--accent);
  }

  /* "Any" reads as a reset, so set it apart from the real values. */
  .select option[value=""] {
    color: var(--muted);
  }
}

/* ---- Cards, stats, pipeline ------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.card-head a {
  font-weight: 500;
  color: var(--accent);
  font-size: 12.5px;
}

.card-head a:hover {
  text-decoration: underline;
}

.card-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* A card title that opens the full page. Overrides the small accent .card-head link. */
.card-head a.card-title-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -4px -8px;
  padding: 4px 8px;
  border-radius: 7px;
  color: var(--ink);
  font-size: inherit;
  font-weight: 600;
}

.card-title-link .card-count {
  font: 500 11.5px var(--mono);
  color: var(--muted);
  background: var(--subtle);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 6px;
}

.card-title-link .icon {
  width: 14px;
  height: 14px;
  color: var(--faint);
  transition: translate 0.15s;
}

.card-head a.card-title-link:hover,
.card-head a.card-title-link:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.card-title-link:hover .icon,
.card-title-link:focus-visible .icon {
  color: var(--accent);
  translate: 2px 0;
}

.card-title-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.stack {
  display: grid;
  gap: 12px;
  align-content: start;
}

/* A number that opens a detail view, e.g. a client's required items. */
.count-link {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  font: 500 12.5px var(--mono);
  color: var(--accent);
  white-space: nowrap;
  text-decoration: underline transparent;
  text-underline-offset: 3px;
  transition: background 0.12s, color 0.12s, text-decoration-color 0.12s;
}

.count-link:hover,
.count-link:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-decoration-color: currentColor;
}

.count-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Linked from the clients table; clear the sticky top bar when jumped to. */
#required-items {
  scroll-margin-top: 72px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stat {
  padding: 14px 16px 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 12.5px;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}

.stat-note {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.stat-note.attention {
  color: var(--amber);
}

.stat-note.good {
  color: var(--green);
}

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.grid-main.even {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.pipeline {
  padding: 16px;
}

.pipeline-bar {
  display: flex;
  height: 10px;
  gap: 2px;
  border-radius: 6px;
  overflow: hidden;
  background: #eef0f4;
}

.pipeline-bar i {
  display: block;
  min-width: 4px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 12px 8px;
  margin-top: 14px;
}

.legend div {
  font-size: 12px;
  color: var(--muted);
}

.legend b {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 6px;
}

.s-pending {
  background: var(--grey-solid);
}

.s-requested {
  background: var(--amber-solid);
}

.s-partially_received {
  background: var(--violet-solid);
}

.s-received {
  background: var(--blue-solid);
}

.s-reviewed {
  background: var(--green-solid);
}

.s-waived {
  background: #e3e6ec;
}

/* ---- Tables ----------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  padding: 8px 16px;
  background: var(--subtle);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafbff;
}

tr.is-clickable {
  cursor: pointer;
}

tr.is-muted {
  color: var(--faint);
}

tr.is-muted .who-avatar {
  filter: grayscale(1);
  opacity: 0.6;
}

.cell-strong {
  font-weight: 500;
}

.cell-clip {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.num {
  font: 12.5px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  min-width: 0;
}

.who:hover span:last-child {
  text-decoration: underline;
}

.who-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex: none;
}

.who-avatar.large {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 18px;
}

.meter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.meter-track {
  width: 90px;
  height: 6px;
  background: #eef0f4;
  border-radius: 4px;
  overflow: hidden;
}

.meter-track i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.meter-track i.low {
  background: var(--amber-solid);
}

.meter-track i.full {
  background: var(--green-solid);
}

/* ---- Pills and chips -------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill.grey {
  background: #eef0f4;
  color: var(--muted);
}

.pill.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.pill.green {
  background: var(--green-soft);
  color: var(--green);
}

.pill.violet {
  background: var(--violet-soft);
  color: var(--violet);
}

.pill.red {
  background: var(--red-soft);
  color: var(--red);
}

.filters {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.chip:hover {
  color: var(--ink);
  border-color: #d5d9e2;
}

.chip[aria-current="true"] {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
  font-weight: 500;
}

.filters .search {
  margin-left: auto;
  width: 240px;
  padding: 6px 10px;
}

/* A compact labelled dropdown that filters one table column. */
.column-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.column-filter .select {
  width: auto;
  border: 0;
  padding: 4px 2px;
  font-size: 12.5px;
  background: transparent;
  cursor: pointer;
}

.column-filter .select:focus {
  outline: none;
}

.column-filter:focus-within {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

/* Highlighted while it is narrowing the table, like a selected chip. */
.column-filter.is-set {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.column-filter.is-set .select {
  color: var(--accent);
  font-weight: 500;
}

.clear-filters {
  color: var(--accent);
  font-size: 12.5px;
}

.clear-filters:hover {
  text-decoration: underline;
}

/* A short secondary line under a cell's main text. */
.cell-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

/* Per-row actions at the end of a table, e.g. Edit. */
.col-actions {
  width: 1%;
  text-align: right;
}

.row-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.row-action:hover,
.row-action:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}

.row-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- Activity feed ---------------------------------------------------------- */

.feed {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.feed li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 9px 16px;
  align-items: start;
  cursor: pointer;
}

.feed li:hover {
  background: #fafbff;
}

.feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 6px;
}

.feed-title,
.feed small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed small {
  color: var(--muted);
}

.feed time {
  font: 11.5px var(--mono);
  color: var(--faint);
  white-space: nowrap;
}

/* ---- Empty states ----------------------------------------------------------- */

.empty {
  padding: 44px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
}

.empty b {
  display: block;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 2px;
}

/* ---- Client detail ---------------------------------------------------------- */

.profile {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.profile-action {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* A short message box: a result ("Approved."), a problem, or a state like paused. */
.notice {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--subtle);
  border: 1px solid var(--line);
  font-size: 13px;
}

.notice.good {
  background: var(--green-soft);
  border-color: transparent;
  color: var(--green);
}

.notice.bad {
  background: var(--red-soft);
  border-color: transparent;
  color: var(--red);
}

.notice.paused {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--amber-soft);
  border-color: transparent;
  color: var(--amber);
}

.card-body {
  padding: 14px 16px;
  display: grid;
  gap: 14px;
}

textarea.input {
  resize: vertical;
  min-height: 0;
  line-height: 1.45;
}

.email-body {
  font: 13px/1.5 var(--sans);
}

/* The chase preview: the real email HTML, isolated from the app's styles. */
.email-preview {
  display: block;
  width: 100%;
  height: 460px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f5f7;
}

.note-form {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.note-form .field {
  width: 100%;
}

/* The decision box in the item drawer. */
.decision {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--subtle);
}

.decision-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.decision .hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

kbd {
  font: 500 10.5px var(--mono);
  padding: 0 4px;
  border-radius: 4px;
  border: 1px solid currentColor;
  opacity: 0.6;
}

.assign {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--subtle);
}

.check.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Notes and history, newest first. Typed notes stand out; automatic events are quieter. */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--line);
  display: grid;
  gap: 12px;
}

.timeline li {
  position: relative;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--grey-solid);
  box-shadow: 0 0 0 2px var(--surface);
}

.timeline li.is-note::before {
  background: var(--accent);
}

.timeline li.is-error::before {
  background: var(--red);
}

.timeline li.is-error .timeline-body {
  color: var(--red);
}

.timeline-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.timeline li.is-event .timeline-body {
  color: var(--muted);
}

.profile h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.profile-meta {
  display: flex;
  gap: 6px 14px;
  color: var(--muted);
  flex-wrap: wrap;
  align-items: center;
  margin-top: 2px;
}

.stats.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ---- Drawer ----------------------------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(16, 18, 24, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 5;
}

.drawer {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 440px;
  max-width: calc(100% - 24px);
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(16, 18, 24, 0.25);
  transform: translateX(calc(100% + 24px));
  /* Eases out on opening so it settles gently into place. */
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-open .scrim {
  opacity: 1;
  pointer-events: auto;
}

.drawer-open .drawer {
  transform: none;
}

#drawer-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.drawer-head p {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.icon-btn {
  padding: 4px;
  border-radius: 6px;
  color: var(--muted);
}

.icon-btn:hover {
  background: #eef0f4;
  color: var(--ink);
}

.drawer-content {
  padding: 20px;
  display: grid;
  gap: 16px;
  overflow-y: auto;
  align-content: start;
  flex: 1;
}

.drawer-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.drawer form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.field {
  display: grid;
  gap: 5px;
  align-content: start;
  font-size: 12.5px;
  font-weight: 500;
}

.field .hint {
  font-weight: 400;
  color: var(--muted);
}

.field .error {
  font-weight: 400;
  color: var(--red);
}

.field.has-error .input,
.field.has-error .select {
  border-color: var(--red);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

/* A titled group of fields inside a form, e.g. "Chasing". */
.field-group {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field-group legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-group > .hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
}

/* One-click values under an input, e.g. item types the firm already uses. */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.suggestions .chip {
  font-weight: 400;
  cursor: pointer;
}

/* A number input with a unit after it ("7 days"). */
.input-suffix {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.input-suffix .input {
  border: 0;
  outline: 0;
  min-width: 0;
}

.input-suffix span {
  padding-right: 10px;
  color: var(--muted);
  font-weight: 400;
}

.input-suffix:focus-within {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.field.has-error .input-suffix {
  border-color: var(--red);
}

/* A bordered list of checkboxes, one per row. */
.check-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
}

.check + .check {
  border-top: 1px solid var(--line);
}

.check:hover {
  background: var(--subtle);
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.check-label {
  font-weight: 500;
}

.check .pill {
  margin-left: auto;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  cursor: pointer;
}

.switch input {
  appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--grey-solid);
  position: relative;
  transition: background 0.15s;
  cursor: pointer;
  margin: 0;
  flex: none;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.switch input:checked {
  background: var(--accent);
}

.switch input:checked::after {
  transform: translateX(14px);
}

.facts {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.section-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--subtle);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.55;
}

.attachment,
.finding {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
}

.finding + .finding,
.attachment + .attachment {
  margin-top: 8px;
}

.finding-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-weight: 500;
}

.finding p {
  color: var(--muted);
  margin-top: 6px;
}

/* ---- Toast ------------------------------------------------------------------ */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 10;
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16, 18, 24, 0.25);
  animation: toast 4.5s ease forwards;
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  6%,
  88% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}

/* ---- Error page ------------------------------------------------------------- */

.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.error-page .num {
  font-size: 13px;
}

.error-page h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 6px 0;
}

.error-page p {
  color: var(--muted);
  max-width: 44ch;
  margin: 0 auto 16px;
}

/* ---- Sign in ------------------------------------------------------------------ */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  gap: 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.auth-card h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.auth-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--amber-soft);
  color: var(--amber);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-sso,
.auth-submit {
  justify-content: center;
  width: 100%;
  padding: 9px 12px;
}

.ms-logo {
  width: 16px;
  height: 16px;
}

.auth-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.auth-or::before,
.auth-or::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.auth-help {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.auth-firms {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.auth-firms a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 500;
}

.auth-firms a:hover {
  background: var(--subtle);
}

.auth-firms .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.me form {
  margin-left: auto;
  flex: none;
}

.me-signout {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: #6c7283;
}

.me-signout:hover,
.me-signout:focus-visible {
  background: var(--side-line);
  color: #fff;
}

/* ---- Admin panel ---------------------------------------------------------------- */

.admin-sections {
  display: grid;
  gap: 12px;
  max-width: 920px;
}

.card-head h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.admin-form {
  display: grid;
  gap: 14px;
  align-content: start;
}

.card > .admin-form:not(.card-body) {
  padding: 16px;
  max-width: 560px;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-row a {
  color: var(--accent);
  font-size: 12.5px;
}

.admin-steps {
  display: grid;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.admin-steps > div {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.admin-steps .input {
  width: 100%;
}

.admin-days {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-weight: 400;
}

.admin-inline {
  display: flex;
  gap: 6px;
  align-items: center;
}

.admin-add {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.checks {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  width: 100%;
}

.checks li {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.checks li.ok {
  background: var(--green-soft);
  color: var(--green);
}

.checks li.bad {
  background: var(--red-soft);
  color: var(--red);
}

.checks li span {
  color: var(--ink);
  font-size: 12.5px;
}

.cell-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.hint-text {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.mono,
.mono-small {
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.mono-small {
  font-size: 11.5px;
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Small screens ---------------------------------------------------------- */

@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    position: static;
    height: auto;
    gap: 12px;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
  }

  .nav-label,
  .me {
    display: none;
  }

  .top,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .stats,
  .stats.three {
    grid-template-columns: 1fr 1fr;
  }

  .grid-main,
  .grid-main.even {
    grid-template-columns: minmax(0, 1fr);
  }

  .filters .search {
    width: 100%;
    margin-left: 0;
  }

  .hide-small {
    display: none;
  }

  .row-action span {
    display: none;
  }

  .filters .search {
    width: 100%;
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation-duration: 0.01s !important;
  }

  /* No sliding when the system asks for less motion: a short fade instead. */
  .drawer {
    transform: none;
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.15s,
      visibility 0.15s !important;
  }

  .drawer-open .drawer {
    opacity: 1;
    visibility: visible;
  }

  .scrim {
    transition: opacity 0.15s !important;
  }
}

/* Forms inside a drawer's content keep their own grid layout (the .drawer form rule
   above is for forms that make up the whole drawer). */
.drawer form.note-form,
.drawer form.decision,
.drawer form.assign {
  display: grid;
}

/* A muted line of guidance on its own (inside a field, .field .hint applies). */
p.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}
