/* Admin console — Direction 1: pure monochrome, light.
   All values are taken verbatim from the design-token sheet
   (docs: admin_design_tokens.md). Near-black (#1c1917) is the only non-grey;
   the single sanctioned use of colour is status pills + the matching banners.
   Tokens live on :root so a dark set could later be swapped via the same names. */

:root {
  /* Neutrals — warm-cool neutral grey */
  --bg-page:        #fafaf9;
  --bg-surface:     #ffffff;
  --bg-subtle:      #f5f5f4;
  --bg-hover:       #f0f0ef;

  --border:         #e7e5e4;
  --border-strong:  #d6d3d1;

  --text-primary:   #1c1917;
  --text-secondary: #57534e;
  --text-tertiary:  #a8a29e;

  /* Primary action — the one filled/dark element per page */
  --action-bg:       #1c1917;
  --action-text:     #ffffff;
  --action-bg-hover: #292524;

  /* Focus ring — near-black at ~35%, monochrome */
  --focus-ring: rgba(28, 25, 23, 0.35);

  /* Status pills — the ONLY colour in the UI */
  --pill-ok-bg:     #ecfdf5;  --pill-ok-text:     #065f46;
  --pill-active-bg: #f5f5f4;  --pill-active-text: #44403c;
  --pill-off-bg:    #fafaf9;  --pill-off-text:    #a8a29e;
  --pill-err-bg:    #fef2f2;  --pill-err-text:    #991b1b;
  --pill-warn-bg:   #fffbeb;  --pill-warn-text:   #92400e;

  /* Banners — match the pill families (one coherent semantic palette) */
  --banner-ok-bg:   #ecfdf5;  --banner-ok-border:   #a7f3d0;  --banner-ok-text:   #065f46;
  --banner-warn-bg: #fffbeb;  --banner-warn-border: #fde68a;  --banner-warn-text: #92400e;

  /* Typography */
  --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* Shape */
  --radius-md: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-page);
}

/* Type scale — two weights only (400 / 500), sentence case in the markup */
h1 { font-size: 17px; font-weight: 500; margin: 0 0 1rem; }
h2 { font-size: 14px; font-weight: 500; margin: 0 0 0.5rem; }
h3 { font-size: 13px; font-weight: 500; margin: 0 0 0.5rem; }

a { color: var(--text-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Visible monochrome keyboard focus on every interactive element */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.topbar .brand { font-weight: 500; font-size: 14px; }
.topbar .logout { color: var(--text-secondary); font-size: 12px; text-decoration: none; }
.topbar .logout:hover { color: var(--text-primary); text-decoration: none; }

/* Layout: side nav + content */
.layout { display: flex; min-height: calc(100vh - 50px); }
.sidenav { width: 220px; background: var(--bg-subtle); border-right: 1px solid var(--border); padding: 8px 0; }
.sidenav ul { list-style: none; margin: 0 0 4px; padding: 0; }
.sidenav a {
  display: block;
  padding: 8px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-left: 2px solid transparent;
}
.sidenav a:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.sidenav a.active {
  background: var(--bg-surface);
  border-left: 2px solid var(--text-primary);
  border-radius: 0;          /* no rounded corner on a single-sided border */
  color: var(--text-primary);
  font-weight: 500;
}
.navgroup-heading {
  padding: 16px 20px 6px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;     /* the one sanctioned uppercase — eyebrow */
  letter-spacing: 0.07em;
  color: var(--text-tertiary);
}
.content { flex: 1; padding: 28px 32px; background: var(--bg-page); }

/* Data table — white surface, hairline rows, subtle header */
table.data {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table.data th, table.data td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
table.data th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-hover); }

/* Status pills — the only colour in the UI. Each = soft fill + same-family text. */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.pill-ok     { background: var(--pill-ok-bg);     color: var(--pill-ok-text); }
.pill-active { background: var(--pill-active-bg); color: var(--pill-active-text); border: 1px solid var(--border); }
.pill-off    { background: var(--pill-off-bg);    color: var(--pill-off-text); }
.pill-err    { background: var(--pill-err-bg);    color: var(--pill-err-text); }
.pill-warn   { background: var(--pill-warn-bg);   color: var(--pill-warn-text); }

/* Missing-value flag — a warn pill */
.flag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-md);
  background: var(--pill-warn-bg);
  color: var(--pill-warn-text);
  font-size: 11px;
  font-weight: 500;
}

/* Keyword chips — neutral grey, not coloured */
.chip {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 2px 9px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 11px;
}

/* Buttons — SECONDARY/outline by default (quiet) */
button,
.action-btn,
.download-btn {
  display: inline-block;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  padding: 8px 16px;
  min-height: 34px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
button:hover,
.action-btn:hover,
.download-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
  color: var(--text-primary);
  text-decoration: none;
}
button:active,
.action-btn:active,
.download-btn:active { transform: scale(0.98); }

/* PRIMARY action — the one filled/dark element per page */
.btn-primary {
  background: var(--action-bg);
  color: var(--action-text);
  border-color: var(--action-bg);
}
.btn-primary:hover {
  background: var(--action-bg-hover);
  border-color: var(--action-bg-hover);
  color: var(--action-text);
}

/* Inputs */
input[type="text"],
input[type="password"],
input[type="search"],
input[type="file"],
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 7px 11px;
}
input[type="text"],
input[type="password"],
input[type="search"],
select { min-height: 34px; }
input::placeholder { color: var(--text-tertiary); }

/* Login page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-page); }
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  width: 320px;
  display: flex;
  flex-direction: column;
}
.login-card h1 { font-size: 17px; font-weight: 500; margin: 0 0 18px; text-align: center; }
.login-card label { font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.login-card input { margin-bottom: 16px; }
.login-card button {        /* the page's one primary action */
  padding: 10px;
  background: var(--action-bg);
  color: var(--action-text);
  border-color: var(--action-bg);
}
.login-card button:hover { background: var(--action-bg-hover); border-color: var(--action-bg-hover); color: var(--action-text); }
.login-card .error,
p.error {
  background: var(--banner-warn-bg);
  color: var(--banner-warn-text);
  border: 1px solid var(--banner-warn-border);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  margin: 0 0 16px;
}

@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .sidenav { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}

/* Record detail (browse) */
dl.record { display: grid; grid-template-columns: 210px 1fr; gap: 8px 18px; margin: 0; max-width: 920px; }
dl.record dt { font-weight: 500; color: var(--text-secondary); font-size: 12px; }
dl.record dd { margin: 0; word-break: break-word; font-size: 13px; }
pre.longtext {
  white-space: pre-wrap; word-wrap: break-word;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 14px; margin: 0;
  font-family: var(--font-mono); font-size: 12px; max-width: 760px;
}
.download-btn { margin-top: 18px; }
/* In a data table the download button sits inline in a row — compact, no top margin. */
table.data .download-btn { margin-top: 0; padding: 5px 12px; min-height: 0; }

/* Reports page: separate the two report sections. */
.report-block { margin-bottom: 2rem; }
.report-block h2 { font-size: 14px; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }

/* Paging controls */
.paging { margin-top: 14px; display: flex; gap: 14px; align-items: center; font-size: 13px; }
.paging a { color: var(--text-primary); }
.paging a:hover { text-decoration: underline; }

/* Master-CV search + editing */
.search-form { display: flex; gap: 10px; margin: 4px 0 18px; max-width: 640px; }
.search-form input[type="search"] { flex: 1; }
.profile-edit {
  width: 100%; min-height: 460px; padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5; resize: vertical;
}
.form-actions { display: flex; gap: 16px; align-items: center; margin-top: 14px; }
.form-actions .cancel { color: var(--text-secondary); text-decoration: none; }
.form-actions .cancel:hover { text-decoration: underline; }
.action-btn { margin-top: 18px; }
.diff {
  white-space: pre-wrap; word-wrap: break-word;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px; font-family: var(--font-mono); font-size: 12px; max-height: 440px; overflow: auto;
}
/* Diff add/remove — reuse the sanctioned ok/err families, not invented hues. */
.diff .add { color: var(--pill-ok-text);  background: var(--pill-ok-bg);  display: block; }
.diff .del { color: var(--pill-err-text); background: var(--pill-err-bg); display: block; }

/* Notices / banners */
.notice-warn {
  background: var(--banner-warn-bg); border: 1px solid var(--banner-warn-border);
  color: var(--banner-warn-text); padding: 10px 12px; border-radius: var(--radius-md);
}
.notice-success {
  background: var(--banner-ok-bg); border: 1px solid var(--banner-ok-border);
  color: var(--banner-ok-text); padding: 10px 12px; border-radius: var(--radius-md); margin-bottom: 18px;
}
.notice-success a { color: var(--banner-ok-text); font-weight: 500; text-decoration: underline; }

/* Action panels (upload / tailor / publish / page) */
.upload-box, .tailor-box, .publish-box, .page-box {
  margin-top: 24px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle);
}
.upload-box h2, .tailor-box h2, .publish-box h2, .page-box h2 {
  margin: 0 0 10px; font-size: 14px; font-weight: 500;
}
.upload-box input[type="file"] { margin-top: 6px; }
.tailor-box select { margin-top: 6px; min-width: 280px; max-width: 100%; }

/* Page management state actions — inline forms sit side by side. */
.page-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.page-actions form { display: inline; margin: 0; }
.page-actions button { padding: 5px 12px; min-height: 0; font-size: 12px; }
/* Destructive flip stays monochrome (colour = data only); the confirm() dialog is the guard. */
.page-actions button.danger { color: var(--text-secondary); }

/* Publish confirm preview — the will-publish / dropped / no-availability lists. */
.publish-preview { margin: 14px 0; }
.publish-preview h2 { font-size: 14px; font-weight: 500; margin: 0 0 6px; }
.publish-preview h3 { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin: 12px 0 6px; }
.publish-preview ul { margin: 0; padding-left: 22px; }
.publish-preview li { font-size: 13px; line-height: 1.5; }

/* Busy state for slow write actions (busy.js): button disabled on submit + spinner.
   The spinner uses currentColor, so it is light on the filled primary and dark on
   outline buttons automatically — legible against both. */
button[aria-busy="true"] { opacity: 0.85; cursor: progress; }
.busy-spinner {
  display: inline-block; width: 0.85em; height: 0.85em; margin-right: 7px; vertical-align: -0.1em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: busy-spin 0.6s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }

/* Respect reduced-motion: gate the press-scale and the busy spinner. */
@media (prefers-reduced-motion: reduce) {
  button, .action-btn, .download-btn { transition: none; }
  button:active, .action-btn:active, .download-btn:active { transform: none; }
  .busy-spinner { animation: none; }
}
