/* ============================================================
   Dover Group CRM — design system
   Naming: BEM (block__element--modifier)
   ============================================================ */

/* Chrome/Firefox "scroll anchoring": after jumping to an anchor, the browser
   watches for later layout shifts (e.g. the Libre Franklin webfont swapping
   in above the fold) and silently re-scrolls to compensate, which reads as
   the page bouncing back toward the top. scroll-margin-top already lands
   anchors in the right spot, so we don't want this "correction" at all. */
html {
  overflow-anchor: none;
}

:root {
  color-scheme: light;

  /* Brand */
  --brand-ink:      #270089;   /* primary deep indigo */
  --brand-ink-deep: #1b0061;   /* darker shade for gradients/hover */
  --brand-violet:   #5b2fd6;   /* mid-tone for gradients */
  --brand-lavender: #aaa1ee;   /* light accent */
  --brand-mist:     #ece9fb;   /* tint for hovers / soft fills */
  --brand-haze:     #f6f5fd;   /* page background tint */

  /* Neutrals (subtly violet-tinted) */
  --ink:       #17131f;   /* primary text */
  --ink-soft:  #575070;   /* secondary text */
  --ink-faint: #8b86a0;   /* muted labels */
  --line:      #e7e4f2;   /* borders / dividers */
  --surface:   #ffffff;
  --bg:        var(--brand-haze);

  /* Status */
  --danger:    #c0284d;
  --danger-bg: #fdecef;
  --danger-line: rgba(192, 40, 77, 0.2);
  --success:   #1f8a5b;
  --notice-bg: #fff4d6;
  --notice-ink:#7a5a00;
  --notice-line: rgba(122, 90, 0, 0.15);

  /* Component surfaces (flip in dark mode) */
  --nav-bg:           rgba(255, 255, 255, 0.86);
  --nav-logout-hover: #ded8f7;
  --logo-filter:      none;

  /* Form */
  --radius:     12px;
  --radius-sm:  8px;
  --shadow-sm:  0 1px 2px rgba(23, 19, 31, 0.06), 0 1px 3px rgba(23, 19, 31, 0.05);
  --shadow-md:  0 6px 20px rgba(39, 0, 137, 0.08);
  --shadow-brand: 0 8px 24px rgba(39, 0, 137, 0.28);
  --ring: 0 0 0 3px rgba(90, 47, 214, 0.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Libre Franklin", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Thin brand accent line across the very top of every page */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-lavender), var(--brand-violet) 45%, var(--brand-ink));
  z-index: 60;
}

h1, h2, h3 {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 { font-size: 1.8rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.2rem; margin: 0 0 1rem; }
h3 { font-size: 1rem; margin: 0 0 0.6rem; }

a { color: var(--brand-ink); }

/* ---------- Navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.35rem 1.4rem;
  flex-wrap: wrap;
  padding: 0.7rem 1.75rem;
  background: var(--nav-bg);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__brand {
  display: flex;
  align-items: center;
  margin-right: auto;
  padding-right: 1rem;
}
.nav__logo { height: 38px; display: block; filter: var(--logo-filter); }
.nav__link {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.nav__link:hover {
  color: var(--brand-ink);
  background: var(--brand-mist);
}

/* "More" dropdown, grouping less-frequently-used nav links */
.nav__dropdown { position: relative; }
.nav__dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
.nav__dropdown-caret { width: 14px; height: 14px; transition: transform 0.15s ease; }
.nav__dropdown--open .nav__dropdown-caret { transform: rotate(180deg); }
.nav__dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.4rem;
  min-width: 160px;
  flex-direction: column;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(20, 10, 60, 0.14);
  padding: 0.35rem;
  z-index: 60;
}
.nav__dropdown--open .nav__dropdown-menu { display: flex; }
.nav__dropdown-link {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.nav__dropdown-link:hover {
  color: var(--brand-ink);
  background: var(--brand-mist);
}
@media (max-width: 1300px) {
  .nav__dropdown-toggle { width: 100%; justify-content: space-between; padding: 0.6rem 0.7rem; font-size: 1rem; }
  .nav__dropdown-menu { position: static; box-shadow: none; border: none; margin-top: 0; padding-left: 1rem; }
}

.nav__logout-form { display: contents; }
.nav__logout {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand-mist);
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  transition: background-color 0.15s ease;
}
.nav__logout:hover { background: var(--nav-logout-hover); }
.nav__user { opacity: 0.7; font-weight: 500; }

/* Collapsible menu (links + logout) — inline on desktop, dropdown on mobile */
.nav__menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.nav__search input[type="search"] {
  width: 200px;
  max-width: 100%;
  margin-top: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
  border-radius: 999px;
}
@media (max-width: 1300px) {
  .nav__search input[type="search"] { width: 100%; }
}

/* Icon buttons in the bar (theme toggle + hamburger) */
.nav__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.nav__icon-btn:hover { color: var(--brand-ink); background: var(--brand-mist); border-color: transparent; }
.nav__icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.nav__icon-btn svg { width: 20px; height: 20px; }

/* Sun/moon swap driven by the current theme.
   Selectors are scoped (.nav__theme …) so they outweigh `.nav__icon-btn svg`. */
.nav__theme .nav__theme-icon--moon { display: block; }
.nav__theme .nav__theme-icon--sun  { display: none; }
:root[data-theme="dark"] .nav__theme .nav__theme-icon--moon { display: none; }
:root[data-theme="dark"] .nav__theme .nav__theme-icon--sun  { display: block; }

.nav__toggle { display: none; }               /* shown only on mobile */
.nav__toggle .nav__toggle-open  { display: block; }
.nav__toggle .nav__toggle-close { display: none; }
.nav--open .nav__toggle .nav__toggle-open  { display: none; }
.nav--open .nav__toggle .nav__toggle-close { display: block; }

@media (max-width: 1300px) {
  .nav__toggle { display: inline-flex; order: 2; }
  .nav__theme { order: 1; }
  .nav__menu {
    order: 3;
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding-top: 0.6rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--line);
  }
  .nav--open .nav__menu { display: flex; }
  .nav__link { padding: 0.6rem 0.7rem; font-size: 1rem; }
  .nav__logout-form { display: block; margin-top: 0.3rem; }
  .nav__logout { width: 100%; border-radius: 10px; padding: 0.6rem; }
}

/* ---------- Layout ---------- */
.main {
  max-width: 1120px;
  margin: 2.25rem auto;
  padding: 0 1.75rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  /* Wide content (e.g. tables) scrolls horizontally instead of bursting the
     card on small screens. Tables ignore overflow themselves, so it lives here. */
  overflow-x: auto;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* ---------- C.H.R.I.S. (Conversation Handling and Relationship Intelligence
   System) - the duplicate-check hint (see initSimilarRecordsCheck in base.html)
   and its nav mention. Speech-bubble mark, reused at both sizes. ---------- */
.chris-mark {
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-lavender), var(--brand-violet));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chris-mark svg { display: block; }

.nav__chris {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.65rem 0.28rem 0.4rem;
  border-radius: 999px;
  background: var(--brand-mist);
  border: 1px solid var(--brand-lavender);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand-ink);
  text-decoration: none;
  white-space: nowrap;
}
.nav__chris .chris-mark { width: 18px; height: 18px; }
.nav__chris .chris-mark svg { width: 10px; height: 10px; }
.nav__chris:hover { border-color: var(--brand-violet); background: var(--brand-haze); }

.chris-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--brand-mist);
  border: 1px solid var(--brand-lavender);
  margin-top: 0.5rem;
}
.chris-card .chris-mark { width: 26px; height: 26px; }
.chris-card .chris-mark svg { width: 14px; height: 14px; }
.chris-card__label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-ink);
  margin-bottom: 0.15rem;
}
.chris-card__label span {
  font-weight: 400;
  color: var(--ink-faint);
  font-size: 0.72rem;
}
.chris-card__match {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.4rem;
  padding: 0.5rem 0.65rem;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.chris-card__match a { color: var(--brand-ink); font-weight: 600; text-decoration: none; }
.chris-card__match a:hover { text-decoration: underline; }

.create-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.create-hub-card {
  display: block;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.create-hub-card:hover {
  border-color: var(--brand-lavender);
  transform: translateY(-2px);
}
.create-hub-card__title {
  font-weight: 700;
  color: var(--brand-ink);
  margin-bottom: 0.3rem;
}
.create-hub-card__desc {
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* ---------- Saved filters ---------- */
.saved-filters {
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.saved-filters__item { white-space: nowrap; }
.saved-filters__delete-form { display: inline; }
.saved-filters__delete {
  border: none;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 0.1rem;
  font-size: 0.9em;
  line-height: 1;
}
.saved-filters__delete:hover { color: var(--brand-violet); }
.saved-filters__save-form {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 1rem;
}
.saved-filters__save-form input[type="text"] {
  max-width: 200px;
}

/* ---------- Record picker (merge-duplicates tool) ---------- */
.record-picker__results {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.4rem;
}
.record-picker__result {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink);
}
.record-picker__result:hover { border-color: var(--brand-lavender); background: var(--brand-haze); }
.record-picker__empty { color: var(--ink-faint); font-size: 0.85rem; margin-top: 0.4rem; }
.record-picker__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--brand-mist);
  border: 1px solid var(--brand-lavender);
  font-size: 0.88rem;
  color: var(--brand-ink);
}
.record-picker__chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--brand-ink);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

/* ---------- Keyboard shortcuts help ---------- */
.shortcuts-help {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.shortcuts-help[hidden] {
  display: none;
}
.shortcuts-help__panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.2rem 1.4rem;
  width: 320px;
  max-width: calc(100vw - 2rem);
}
.shortcuts-help__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  color: var(--brand-ink);
}
.shortcuts-help__close {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
}
.shortcuts-help__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.9rem;
}
.shortcuts-help__list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.shortcuts-help__list span {
  min-width: 3.4rem;
  display: inline-flex;
  gap: 0.25rem;
}
kbd {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
  background: var(--brand-mist);
  border: 1px solid var(--brand-lavender);
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--brand-ink);
}

/* ---------- Quick add ---------- */
.quick-add__button {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  border: none;
  background: var(--brand-ink);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 90;
}
.quick-add__button:hover {
  background: var(--brand-ink-deep);
}
.quick-add {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 5.5rem 1.5rem 1.5rem;
  z-index: 100;
}
.quick-add[hidden] {
  display: none;
}
.quick-add__panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.2rem 1.4rem;
  width: 260px;
  max-width: calc(100vw - 2rem);
}
.quick-add__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  color: var(--brand-ink);
}
.quick-add__close {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
}
.quick-add__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.quick-add__list a {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.quick-add__list a:hover {
  background: var(--brand-mist);
}

/* ---------- User guide table of contents ---------- */
/* Each entry's link text already starts with its own number ("1. The dashboard"),
   so a bullet marker in front of it would just repeat that number visually. */
.toc-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* .nav is position: sticky, so without this, a TOC anchor link scrolls its target's
   top edge to y=0 - directly behind the sticky nav, which then covers the section
   heading. Applied to every anchor-target card, not just the guide, since any page
   could grow an in-page anchor link later. */
.card[id] {
  scroll-margin-top: 80px;
}

/* ---------- Bulk actions bar ---------- */
.bulk-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  background: var(--brand-mist);
  border: 1px solid var(--brand-lavender);
  font-size: 0.88rem;
  color: var(--brand-ink);
}
.bulk-actions-bar[hidden] {
  display: none;
}
.bulk-actions-bar__form {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.bulk-checkbox-cell {
  width: 1.6rem;
}

/* ---------- Stats ---------- */
.stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.stats__card {
  position: relative;
  overflow: hidden;
  flex: 1 1 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
}
.stats__card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--brand-lavender), var(--brand-ink));
}
.stats__value {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--brand-ink);
}
.stats__label {
  margin-top: 0.35rem;
  color: var(--ink-faint);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Tables ---------- */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}
thead th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  background: transparent;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--line);
}
tbody td {
  text-align: left;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
tbody tr { transition: background-color 0.12s ease; }
tbody tr:hover { background: var(--brand-haze); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--brand-ink);
  color: #fff;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.btn:hover {
  background: var(--brand-ink-deep);
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn--sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

/* Reminder row actions (Mark done / Snooze / Dismiss) - each is its own <form>, so
   wrap them as flex items rather than relying on inline-block spacing, which was
   causing them to overlap when they wrapped onto a second line in a narrow column. */
.reminder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Dashboard "View more" toggle under a truncated table (see dashboard.html) */
.dashboard-view-more { margin-top: 0.6rem; }

/* Secondary / ghost variant */
.btn--ghost {
  background: var(--surface);
  color: var(--brand-ink);
  border: 1px solid var(--line);
}
.btn--ghost:hover {
  background: var(--brand-mist);
  box-shadow: var(--shadow-sm);
}

/* ---------- Forms ---------- */
form p { margin: 0 0 1rem; }
label { font-weight: 600; font-size: 0.9rem; color: var(--ink-soft); }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="url"],
input[type="tel"], input[type="search"], select, textarea {
  width: 100%;
  max-width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  padding: 0.55rem 0.7rem;
  margin-top: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-violet);
  box-shadow: var(--ring);
}
textarea { min-height: 6rem; resize: vertical; }
.helptext { display: block; color: var(--ink-faint); font-size: 0.8rem; margin-top: 0.25rem; }

.errorlist {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.messages__item {
  background: var(--notice-bg);
  color: var(--notice-ink);
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-weight: 500;
  border: 1px solid var(--notice-line);
}

/* ---------- Dark mode ----------
   The toggle sets data-theme="dark|light" on <html>; an inline <head> script
   seeds it from the saved choice or the OS preference before first paint. */
:root[data-theme="dark"] {
  color-scheme: dark;
  /* Brand — brightened so it reads as both action-fill and accent text on dark */
  --brand-ink:      #8b6fff;
  --brand-ink-deep: #7857f0;
  --brand-violet:   #a08cff;
  --brand-lavender: #c4b9ff;
  --brand-mist:     #241d3d;
  --brand-haze:     #17131f;

  --ink:       #ece9f5;
  --ink-soft:  #b3adc7;
  --ink-faint: #857f9c;
  --line:      #2a2540;
  --surface:   #1e1a2e;
  --bg:        #131020;

  --danger:      #ff8095;
  --danger-bg:   #3a1420;
  --danger-line: rgba(255, 128, 149, 0.22);
  --success:     #57d19a;
  --notice-bg:   #33280a;
  --notice-ink:  #f0d68a;
  --notice-line: rgba(240, 214, 138, 0.18);

  --nav-bg:           rgba(19, 16, 32, 0.82);
  --nav-logout-hover: #322a52;
  /* Logo text is black on transparent — render it white on dark surfaces */
  --logo-filter:      brightness(0) invert(1);

  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:    0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-brand: 0 8px 24px rgba(139, 111, 255, 0.35);
  --ring:         0 0 0 3px rgba(139, 111, 255, 0.45);
}
:root[data-theme="dark"] .btn { color: #14101f; }
/* .btn--ghost has a dark (not brand-ink-filled) background even in dark mode, so it
   needs its own colors here - otherwise the rule above (same specificity, earlier in
   source order) wins and leaves near-black text on a near-black button. Near-white
   text plus a lighter-than-card fill (brand-ink alone measured ~4.7:1 on --surface,
   technically AA but still hard to read) gives clear separation and ~13:1 contrast. */
:root[data-theme="dark"] .btn--ghost { background: var(--brand-mist); color: var(--ink); }
:root[data-theme="dark"] .btn--ghost:hover { background: var(--line); }

@media (max-width: 640px) {
  .nav { padding: 0.6rem 1rem; }
  .main { margin: 1.5rem auto; padding: 0 1rem; }
  h1 { font-size: 1.5rem; }

  /* Keep table columns at their natural width on phones so the card scrolls
     horizontally (see .card overflow-x) instead of cramming/overflowing. */
  .card table { white-space: nowrap; }
}
