/* UpFront Admin — single-file design tokens + components.
   Desktop-first, dense, fast. Brand-swap surface = the :root tokens block. */

:root {
  /* Direction 1 — Workshop steel + signal yellow.
     Brand-swap touches only this block + lib/email-templates/_layout.js. */
  --c-ink:          #1a1d1f;   /* charcoal — primary */
  --c-steel:        #2a2d2f;   /* darker charcoal — topbar / accents */
  --c-mist:         #6a6a6a;   /* steel grey — muted text */
  --c-rule:         #d6d4cc;   /* off-white border */
  --c-paper:        #ffffff;
  --c-sand:         #f4f3ee;   /* off-white surface */
  --c-sand-deep:    #ebe9e2;
  --c-yellow:       #FFD400;   /* hi-vis signal yellow */
  --c-yellow-deep:  #D9B400;
  --c-yellow-soft:  #FFE45C;
  --c-success:      #1f7a4a;
  --c-success-bg:   #e6f4ec;
  --c-warning-bg:   #fff8cc;
  --c-warning-deep: #806800;
  --c-danger:       #b3261e;
  --c-danger-bg:    #fbe6e4;

  /* Legacy alias retained so existing rules referencing --c-amber keep working
     until the chip palette is rewritten. */
  --c-amber:        var(--c-yellow);
  --c-amber-deep:   var(--c-yellow-deep);

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --s-1:  4px;
  --s-2:  8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  --shadow-1: 0 1px 2px rgba(26,29,31,0.08), 0 1px 3px rgba(26,29,31,0.06);
  --shadow-2: 0 4px 8px rgba(26,29,31,0.10), 0 1px 3px rgba(26,29,31,0.06);

  --font: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Cascadia Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--c-ink);
  background: var(--c-sand);
}
body.auth { display: grid; place-items: center; min-height: 100vh; }
a { color: var(--c-steel); }
a:hover { color: var(--c-ink); }
button { font-family: inherit; font-size: inherit; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-3) var(--s-5);
  background: var(--c-ink); color: #fff;
  border-bottom: 1px solid var(--c-steel);
}
.topbar__brand {
  display: flex; align-items: baseline; gap: var(--s-3);
  text-decoration: none; color: var(--c-sand);
}
.wordmark {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-family: var(--font);
  line-height: 1;
}
.wordmark__chevron {
  color: var(--c-yellow);
  font-size: 13px;
  font-weight: 800;
  transform: translateY(0.04em);
}
.wordmark__upfront {
  color: var(--c-sand);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.wordmark__hire {
  color: var(--c-yellow);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  margin-left: 3px;
}
.brand-tag {
  font-weight: 500; font-size: 10px; color: #b8b8b0;
  letter-spacing: 0.18em; text-transform: uppercase;
  padding-left: var(--s-3);
  border-left: 1px solid #3a3d3f;
}
.topbar__nav { display: flex; gap: var(--s-1); flex: 1; margin-left: var(--s-4); }
.topbar__nav-item {
  color: #cdd5dd; text-decoration: none;
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  font-size: 13px;
}
.topbar__nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.topbar__nav-item--active { background: var(--c-steel); color: #fff; }
.topbar__user { display: flex; align-items: center; gap: var(--s-3); }
.topbar__name { color: #cdd5dd; font-size: 13px; }

/* Buttons inside the topbar inherit a dark background — recolour any ghost
   variants so the text isn't ink-on-ink. */
.topbar .btn,
.topbar .btn--ghost {
  color: #fff;
  background: transparent;
  border-color: rgba(255,255,255,0.25);
}
.topbar .btn:hover,
.topbar .btn--ghost:hover { border-color: rgba(255,255,255,0.6); }

/* main */
.page {
  max-width: 1280px;
  margin: var(--s-5) auto;
  padding: 0 var(--s-5);
}
.page-title { margin: 0 0 var(--s-3); font-size: 24px; }
.page-head {
  display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.back-link {
  text-decoration: none; color: var(--c-mist); font-size: 13px;
}

/* cards / panels */
.card, .panel {
  background: var(--c-paper);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
}
.card { margin-bottom: var(--s-4); }
.card--narrow { max-width: 560px; }
.card--empty { color: var(--c-mist); }
.card__title, .panel__title { margin: 0 0 var(--s-3); font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-mist); font-weight: 700; }

/* dashboard metrics */
.grid { display: grid; gap: var(--s-4); }
.grid--metrics { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: var(--s-5); }
.metric {
  display: flex; flex-direction: column; gap: var(--s-1);
  background: var(--c-paper);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  text-decoration: none; color: var(--c-ink);
  transition: transform 100ms ease, box-shadow 100ms ease;
}
.metric:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.metric__count { font-size: 32px; font-weight: 700; }
.metric__label { font-weight: 600; }
.metric__hint  { color: var(--c-mist); font-size: 12px; }

/* layout helpers */
.layout-2col {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: minmax(280px, 1fr) 2fr;
}
.layout-2col--builder { grid-template-columns: minmax(280px, 1fr) 3fr; }
@media (max-width: 900px) { .layout-2col { grid-template-columns: 1fr; } }

/* lists */
.list-card {
  list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--c-rule); border-radius: var(--r-lg); background: var(--c-paper);
  overflow: hidden;
}
.list-card__item {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--c-rule);
}
.list-card__item:last-child { border-bottom: 0; }
.list-card__main { flex: 1; min-width: 0; }
.list-card__title { margin: 0 0 var(--s-1); font-size: 16px; }
.list-card__meta  { margin: 0; color: var(--c-mist); font-size: 13px; }
.list-card__note  { margin: var(--s-1) 0 0; font-size: 12px; }
.list-card__actions { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* chips & filter chips */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip-link {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--c-paper); color: var(--c-ink);
  border: 1px solid var(--c-rule); border-radius: 999px;
  text-decoration: none; font-size: 13px;
}
.chip-link:hover { border-color: var(--c-mist); }
.chip-link--active { background: var(--c-ink); color: #fff; border-color: var(--c-ink); }
.chip-link__count {
  background: rgba(0,0,0,0.06); padding: 0 var(--s-2);
  border-radius: 999px; font-weight: 600; font-size: 12px;
}
.chip-link--active .chip-link__count { background: rgba(255,255,255,0.18); }

.chip { display: inline-flex; align-items: center; padding: 2px var(--s-2);
  border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--c-sand); color: var(--c-ink); border: 1px solid var(--c-rule); }
.chip--submitted, .chip--quoted { background: var(--c-warning-bg); color: var(--c-warning-deep); border-color: transparent; }
.chip--accepted, .chip--awaiting_payment { background: #e0ecff; color: #1d4a8b; border-color: transparent; }
.chip--paid, .chip--fulfilled, .chip--verified { background: var(--c-success-bg); color: var(--c-success); border-color: transparent; }
.chip--cancelled, .chip--rejected, .chip--expired, .chip--refunded { background: var(--c-danger-bg); color: var(--c-danger); border-color: transparent; }
.chip--pending { background: var(--c-sand-deep); color: var(--c-mist); }

.role-chip { padding: 1px 8px; border-radius: 4px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.role-chip--reviewer   { background: var(--c-sand);    color: var(--c-mist); }
.role-chip--manager    { background: #e0ecff;          color: #1d4a8b; }
.role-chip--superadmin { background: var(--c-yellow);  color: var(--c-ink); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2); padding: 8px var(--s-4);
  background: var(--c-paper); color: var(--c-ink);
  border: 1px solid var(--c-rule); border-radius: var(--r-md);
  text-decoration: none; font-weight: 600; font-size: 13px;
  cursor: pointer;
  transition: background 80ms ease, border-color 80ms ease;
}
.btn:hover { border-color: var(--c-mist); }
.btn--primary { background: var(--c-ink); color: #fff; border-color: var(--c-ink); }
.btn--primary:hover { background: var(--c-steel); border-color: var(--c-steel); }
.btn--ghost   { background: transparent; }
.btn--danger  { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn--danger:hover { background: #931e18; border-color: #931e18; }
.btn--block   { width: 100%; }
.btn--sm      { padding: 5px 10px; font-size: 12px; }

.action-row { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-4); }
.action-details { background: var(--c-sand); padding: var(--s-3); border-radius: var(--r-md); }
.action-details summary { cursor: pointer; list-style: none; }
.action-details summary::-webkit-details-marker { display: none; }
.action-details[open] summary { margin-bottom: var(--s-3); }

/* forms */
.form-stack { display: flex; flex-direction: column; gap: var(--s-3); }
.form-stack--inline { flex-direction: row; flex-wrap: wrap; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field--narrow { max-width: 200px; }
.field__label {
  font-size: 12px; font-weight: 600; color: var(--c-mist);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="search"], .field select, .field textarea,
input[type="search"], select, textarea, input[type="number"], input[type="email"], input[type="text"], input[type="password"] {
  font: inherit; padding: 8px var(--s-3);
  background: #fff; color: var(--c-ink);
  border: 1px solid var(--c-rule); border-radius: var(--r-md);
  outline: none;
}
.field textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--c-steel);
  box-shadow: 0 0 0 3px rgba(13,27,42,0.08);
}

.search-form {
  display: inline-flex; gap: var(--s-2); align-items: center; margin-left: auto;
}
.search-form input[type="search"], .search-form select { min-width: 140px; }

.field-error { color: var(--c-danger); font-size: 12px; }

.inline-form { display: inline-block; }

/* auth card */
.auth-card {
  width: 360px; padding: var(--s-7) var(--s-5);
  background: var(--c-paper); border: 1px solid var(--c-rule);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}
.auth-title { margin: 0 0 var(--s-2); font-size: 24px; }

/* flash */
.flash-stack { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.flash {
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md); font-size: 13px;
  border: 1px solid transparent;
}
.flash--success { background: var(--c-success-bg); color: var(--c-success); border-color: rgba(31,122,74,0.2); }
.flash--info    { background: #e0ecff; color: #1d4a8b; }
.flash--error   { background: var(--c-danger-bg); color: var(--c-danger); border-color: rgba(179,38,30,0.2); }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--c-paper); border: 1px solid var(--c-rule); border-radius: var(--r-lg); overflow: hidden; }
.table th, .table td { padding: var(--s-3) var(--s-4); text-align: left; border-bottom: 1px solid var(--c-rule); }
.table thead { background: var(--c-sand); }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-mist); font-weight: 700; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table--audit td { vertical-align: top; }
.row--disabled { opacity: 0.55; }
.actions { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; }

.pagination { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) 0; justify-content: center; }

/* kv list */
.kv { display: grid; grid-template-columns: 110px 1fr; column-gap: var(--s-3); row-gap: var(--s-2); margin: 0; }
.kv dt { color: var(--c-mist); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.kv dd { margin: 0; }

.bare-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s-2); }

.muted { color: var(--c-mist); }
.small { font-size: 12px; }
.mono  { font-family: var(--font-mono); }
.mt-16 { margin-top: var(--s-4); }
.mt-24 { margin-top: var(--s-5); }

/* doc preview */
.doc-card { margin: 0 0 var(--s-4); padding: var(--s-3); background: var(--c-sand); border-radius: var(--r-md); }
.doc-card__caption { font-size: 13px; color: var(--c-mist); margin-bottom: var(--s-2); }
.doc-card__caption strong { color: var(--c-ink); }
.doc-card__img { max-width: 100%; border-radius: var(--r-md); border: 1px solid var(--c-rule); display: block; }

/* quote builder */
.lines { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.lines legend { font-weight: 600; padding-bottom: var(--s-2); }
.line {
  display: grid;
  grid-template-columns: 1.2fr 70px 110px 70px 1fr;
  gap: var(--s-3);
  align-items: end;
  padding: var(--s-3);
  background: var(--c-sand);
  border-radius: var(--r-md);
}
.line__name { font-weight: 600; }
.line__field { display: flex; flex-direction: column; }
.line__field span { font-size: 11px; color: var(--c-mist); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.line__total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.extras { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); margin-top: var(--s-4); }
@media (max-width: 800px) { .extras { grid-template-columns: 1fr 1fr; } }

.totals { margin-top: var(--s-4); padding: var(--s-4); border: 1px solid var(--c-rule); border-radius: var(--r-md); background: var(--c-sand); }
.totals__row { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals__row--big { border-top: 1px solid var(--c-rule); margin-top: var(--s-2); padding-top: var(--s-3); font-weight: 700; font-size: 16px; }

/* notes & footer */
.note { background: var(--c-sand); padding: var(--s-3); border-radius: var(--r-md); }
.note__body { margin: 0 0 var(--s-1); white-space: pre-wrap; }
.note__meta { margin: 0; font-size: 12px; }

.footer { padding: var(--s-5); text-align: center; color: var(--c-mist); font-size: 12px; }
.footer__sep { padding: 0 var(--s-2); }
.footer a { color: var(--c-mist); }

.json { background: #fff; padding: var(--s-3); border-radius: var(--r-md); font-size: 12px; max-width: 480px; overflow-x: auto; }
