/* Palette pulled from ajactraining.org: navy header/heading color, bright
   blue accent/links/buttons, and "Avenir Next" typography. Status badges
   below stay their own functional green/amber/gray — those signal SOP
   state, not brand, and shouldn't compete with the accent color. */
:root {
  --ink: #1c2128;
  --ink-soft: #57606a;
  --line: #d0d7de;
  --bg: #f6f8fa;
  --card: #ffffff;
  --navy: #003c81;
  --accent: #008bfe;
  --accent-hover: #0072d1;
  --accent-soft: #e6f3ff;
  --active: #1a7f37;
  --active-soft: #dafbe1;
  --checked-out: #9a6700;
  --checked-out-soft: #fff8c5;
  --retired: #57606a;
  --retired-soft: #eaeef2;
  --radius: 8px;
  --radius-btn: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

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

.topbar {
  background: var(--navy);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar .home-link {
  display: flex;
  align-items: center;
  color: #ffffff;
  padding: 4px;
  border-radius: 6px;
}
.topbar .home-link:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.topbar .brand {
  font-weight: 800;
  font-size: 17px;
  color: #ffffff;
}
.topbar .brand span { color: var(--accent); }

.beta-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 2px 7px;
  border-radius: 999px;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  margin: 0 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f8f8f8;
  color: var(--ink-soft);
}
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  width: 100%;
}
.topbar-search input::placeholder { color: var(--ink-soft); }
.topbar-search:focus-within { border-color: var(--accent); }

.topbar .who {
  font-size: 13px;
  color: #d7e6f7;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar .who strong { color: #ffffff; }
.topbar .who a { color: #ffffff; }
.logout-form { display: inline; margin: 0; }
.logout-form button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 13px;
  color: #ffffff;
  cursor: pointer;
}
.logout-form button:hover { text-decoration: underline; }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px;
}

h1 { font-size: 24px; margin: 0 0 4px; color: var(--navy); font-weight: 800; }
h2 { font-size: 18px; margin: 28px 0 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; color: var(--navy); font-weight: 800; }
.subtitle { color: var(--ink-soft); margin: 0 0 24px; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: #b03434; border-color: #e5b3b3; }
.btn-danger:hover { background: #fff3f3; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: var(--bg); }

.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-th:hover { color: var(--accent); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: var(--active-soft); color: var(--active); }
.badge-checked_out { background: var(--checked-out-soft); color: var(--checked-out); }
.badge-retired { background: var(--retired-soft); color: var(--retired); }

label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
label:first-child { margin-top: 0; }
input[type=text], textarea, input[type=email] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
textarea { min-height: 90px; }
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.field-note { font-size: 12px; color: var(--ink-soft); font-weight: 400; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  font-size: 13px;
}
.meta-grid .label { color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.meta-grid .value { font-weight: 600; margin-top: 2px; }

.notice {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 20px;
}
.notice-warn { background: var(--checked-out-soft); color: #7a5200; border: 1px solid #f0d878; }
.notice-old { background: var(--retired-soft); color: var(--ink-soft); border: 1px solid var(--line); }

.sop-body pre {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
  font-size: 14px;
}

/* Program SOP section bodies (see src/render-helpers.js): each source line
   is its own block. Paragraph lines get real spacing above and below so
   consecutive sentences don't read as one run-on block; bullet lines stay
   tight so a list still reads as a list. */
.section-lines { font-size: 14px; }
.line-para { margin: 10px 0; }
.line-bullet { margin: 2px 0; }
.line-warn { margin: 10px 0; }
.section-lines .line-para:first-child,
.section-lines .line-bullet:first-child,
.section-lines .line-warn:first-child { margin-top: 0; }
.section-lines .line-para:last-child,
.section-lines .line-bullet:last-child,
.section-lines .line-warn:last-child { margin-bottom: 0; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}

.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 16px 0; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; }

/* Repeatable Steps / Contacts editors */
.repeat-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg);
}
.repeat-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.repeat-row-head .step-number { font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.repeat-row .btn-remove-row {
  font-size: 12px;
  padding: 3px 10px;
  color: #b03434;
  border-color: #e5b3b3;
  background: #fff;
}
.repeat-row .btn-remove-row:disabled { opacity: 0.4; cursor: not-allowed; }
.repeat-row label { margin-top: 10px; font-size: 12px; }
.repeat-row label:first-of-type { margin-top: 0; }
.contact-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; align-items: end; }
.contact-row .field label { margin-top: 0; }

/* Top-of-field-aligned row for form headers (SOP ID / Category, Effective
   date / Owner). Unlike .contact-row, this keeps labels aligned along the
   same line even when one field has a hint/error line under it and the
   other doesn't. */
.form-row { display: grid; gap: 12px; align-items: start; }
.form-row .field label { margin-top: 0; }
.form-row select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
.add-row-btn { font-size: 13px; }

/* A program SOP's inline ⚠ warning lines (see src/render-helpers.js) */
.warn-line {
  display: inline-block;
  background: #fff8e1;
  border-left: 3px solid #d9a400;
  color: #7a5200;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  margin: 2px 0;
}

.notice-important {
  background: #fff8e1;
  border: 1px solid #f0d878;
  border-left: 4px solid #d9a400;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 20px;
}

.error-banner {
  background: #fdeded;
  border: 1px solid #e5b3b3;
  color: #8a2c2c;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 20px;
}

.steps-table td { vertical-align: top; white-space: pre-wrap; }
.steps-table td:first-child { white-space: normal; font-weight: 600; width: 50px; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 24px;
}
.login-card {
  background: var(--card);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.login-brand {
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.login-brand span { color: var(--accent); }
.login-brand .beta-badge {
  color: var(--ink-soft);
  background: var(--bg);
  border-color: var(--line);
}
.login-card h1 { font-size: 20px; margin: 0 0 16px; }

/* Explanatory note under a page heading (e.g. the SOP list's AJAC vs.
   non-AJAC process guidance). */
.guidance {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 14px 18px;
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.55;
}
.guidance-title { font-weight: 800; font-size: 16px; color: var(--navy); margin-bottom: 10px; }
.guidance-subtitle { font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.guidance p { margin: 0 0 8px; }
.guidance p:last-child { margin-bottom: 0; }
