/*
 * Colour values appear ONCE, in the two token tiers below.
 *
 *   Tier 1 — base values. The raw palette. Retune the product's colour here.
 *   Tier 2 — semantic tokens. What components actually use.
 *
 * Components may only ever reference tier 2. A hardcoded hex in a component will
 * not flip in dark mode, because dark mode works by re-pointing tier 2 at
 * different tier 1 values.
 *
 * The palette is deliberately neutral: the CRM serves every brand, and each brand
 * record carries its own colour shown as a chip on rows. Chrome in any brand's
 * colour would swallow that brand's marker. Purple and yellow are unclaimed by
 * McCrae Tech (orange), Amalga (blue), Orchestral (green) and Indexity (orange).
 */

:root {
  /* ---- Tier 1: base values ---- */
  --purple-100: #ede8fb;
  --purple-300: #b9a4ee;
  --purple-500: #7c4ddb;
  --purple-600: #6a3cc4;
  --purple-700: #522d99;

  --yellow-200: #fdf0bf;
  --yellow-400: #f2c230;
  --yellow-600: #9a7508;

  --grey-000: #ffffff;
  --grey-050: #fafaf8;
  --grey-100: #f3f4f2;
  --grey-200: #e6e7e3;
  --grey-300: #cdcec9;
  --grey-500: #8b8c86;
  --grey-700: #4a4a46;
  --grey-800: #2b2b29;
  --grey-900: #191919;
  --grey-950: #0f0f0e;

  --red-500: #c4362c;
  --green-600: #2f7a4f;

  /* ---- Tier 2: semantic tokens ---- */
  --color-bg: var(--grey-050);
  --color-surface: var(--grey-000);
  --color-surface-sunken: var(--grey-100);
  --color-border: var(--grey-200);
  --color-border-strong: var(--grey-300);

  --color-text: var(--grey-900);
  --color-text-muted: var(--grey-700);
  --color-text-subtle: var(--grey-500);

  --color-accent: var(--purple-600);
  --color-accent-hover: var(--purple-700);
  --color-accent-subtle: var(--purple-100);
  --color-on-accent: var(--grey-000);

  /* Attention, not decoration: "due today", "going cold". Yellow fails contrast
     at small sizes, so it is a background with dark text on it, never a
     foreground colour. */
  --color-attention-bg: var(--yellow-200);
  --color-attention-text: var(--yellow-600);

  --color-danger: var(--red-500);
  --color-success: var(--green-600);

  --font-body: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-heading: 'Helvetica Neue', Helvetica, Arial, sans-serif;

  --radius: 6px;
  --space: 1rem;
}

html[data-theme='dark'] {
  --color-bg: var(--grey-950);
  --color-surface: var(--grey-900);
  --color-surface-sunken: var(--grey-800);
  --color-border: var(--grey-800);
  --color-border-strong: var(--grey-700);

  --color-text: var(--grey-100);
  --color-text-muted: var(--grey-300);
  --color-text-subtle: var(--grey-500);

  --color-accent: var(--purple-300);
  --color-accent-hover: var(--purple-100);
  --color-accent-subtle: var(--purple-700);
  --color-on-accent: var(--grey-950);

  --color-attention-bg: var(--yellow-600);
  --color-attention-text: var(--yellow-200);
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

h1, h2, h3 { font-family: var(--font-heading); line-height: 1.25; }

a { color: var(--color-accent); }
a:hover { color: var(--color-accent-hover); }

.wrap {
  max-width: 60rem;
  margin: 0 auto;
  padding: calc(var(--space) * 2) var(--space);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space);
}

.muted { color: var(--color-text-muted); }

/* --- Top bar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  padding: 0.75rem var(--space);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.brand { font-weight: 700; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* A form button that reads as a link, so sign-out can be a POST without
   looking like a primary action. */
.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--color-accent);
  cursor: pointer;
  text-decoration: underline;
}

/* --- Auth pages ----------------------------------------------------------- */

.auth {
  max-width: 24rem;
  margin: 0 auto;
}

.auth h1 { margin-bottom: 0.25rem; }

.auth form { display: grid; gap: 0.35rem; }

.auth label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

input[type='email'],
input[type='password'],
input[type='text'] {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

button[type='submit'] {
  margin-top: var(--space);
  padding: 0.6rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--color-on-accent);
  background: var(--color-accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

button[type='submit']:hover { background: var(--color-accent-hover); }

.error,
.notice {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border-strong);
}

.error {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

/* Yellow as a background with dark text on it, never as a foreground colour. */
.notice {
  background: var(--color-attention-bg);
  color: var(--color-attention-text);
  border-color: var(--color-attention-text);
}

.small { font-size: 0.875rem; }

/* --- Board ---------------------------------------------------------------- */

.wrap-wide { max-width: 100rem; }

.board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space);
  flex-wrap: wrap;
}

.board-head h1 { margin-bottom: 0.25rem; }

.progress {
  font-size: 1.1rem;
  color: var(--color-text-muted);
}

.progress strong {
  font-size: 1.6rem;
  color: var(--color-accent);
}

/* Brand is always chip plus label — never colour alone. */
.brand-chip {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.4rem;
  border-radius: 2px;
  background: var(--color-border-strong);
  vertical-align: baseline;
}

.columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
  margin-top: var(--space);
}

.columns.aside {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: calc(var(--space) * 2);
}

.column {
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.6rem;
  min-height: 6rem;
}

.column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
}

.count {
  padding: 0.05rem 0.45rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.contact-card { margin-bottom: 0.6rem; }
.contact-card h3 { margin: 0 0 0.15rem; font-size: 0.95rem; }
.contact-card p { margin: 0.15rem 0; }

.contact-card.is-suppressed {
  border-color: var(--color-danger);
}

.meta { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.contact-card details { margin-top: 0.5rem; }
.contact-card summary { cursor: pointer; color: var(--color-accent); }
.contact-card form { display: grid; gap: 0.2rem; margin-top: 0.4rem; }
.contact-card button[type='submit'] { margin-top: 0.5rem; padding: 0.35rem 0.6rem; }

select,
textarea,
input[type='date'],
input[type='file'] {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
}

textarea { resize: vertical; font-family: ui-monospace, monospace; font-size: 0.85rem; }

ul.plain { list-style: none; padding: 0; }
ul.plain li { margin-bottom: 0.5rem; }

/* Below tablet width the columns stack rather than squeezing to nothing. */
@media (max-width: 900px) {
  .columns,
  .columns.aside {
    grid-template-columns: minmax(0, 1fr);
  }
}
