/* ==========================================================================
   SFSPac Assessment Portal -- shared shell
   Palette and type deliberately mirror the two assessment forms so the portal
   and the paperwork read as one product.
   ========================================================================== */

:root {
  --navy: #1a2e44;
  --navy-soft: #24405e;
  --teal: #2a6e6e;
  --teal-dark: #1f5555;
  --teal-light: #e8f4f4;
  --gold: #c8922a;
  --gold-light: #fdf4e3;
  --gray-dark: #3a3a3a;
  --gray-mid: #6b6b6b;
  --gray-light: #f4f5f6;
  --border: #ccd4da;
  --border-soft: #e3e8ec;
  --white: #ffffff;
  --page: #e8ecef;
  --red: #b03a2e;
  --red-light: #fbeceb;
  --green: #2f7d4f;
  --green-light: #eaf5ee;

  --radius: 6px;
  --shadow: 0 4px 30px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 1px 3px rgba(26, 46, 68, 0.09);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--gray-dark);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: 'Lora', Georgia, serif; color: var(--navy); font-weight: 700; }

a { color: var(--teal); }
a:hover { color: var(--teal-dark); }

/* ---------------------------------------------------------------- top bar */

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar::after {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--teal) 0%, var(--gold) 100%);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-shrink: 0; }
.brand img { height: 34px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: 'Lora', serif; font-size: 15px; font-weight: 700; color: var(--navy); }
.brand-sub {
  font-size: 9.5px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--teal); font-weight: 600;
}

.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a {
  padding: 7px 13px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-mid);
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { background: var(--gray-light); color: var(--navy); }
.nav a.active { background: var(--teal-light); color: var(--teal-dark); font-weight: 600; }
.nav .who {
  font-size: 12.5px; color: var(--gray-mid); padding-left: 12px;
  margin-left: 6px; border-left: 1px solid var(--border); white-space: nowrap;
}
.nav-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
  background: var(--gold); color: #fff; border-radius: 9px;
  font-size: 11px; font-weight: 700; text-align: center; line-height: 18px;
}

/* ------------------------------------------------------------------ layout */

.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.page-narrow { max-width: 720px; }

.page-head { margin-bottom: 22px; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 25px; letter-spacing: -0.3px; }
.page-head .sub { font-size: 13.5px; color: var(--gray-mid); margin-top: 2px; }
.page-head .spacer { margin-left: auto; }

.card {
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15.5px; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }

/* ------------------------------------------------------- new-assessment tiles */

.start-tile {
  display: block;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.start-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(26, 46, 68, 0.13); color: inherit; }
.start-tile.gold { border-left-color: var(--gold); }
.start-tile .eyebrow {
  font-family: 'Lora', serif; font-size: 9.5px; font-weight: 600;
  letter-spacing: 2.5px; text-transform: uppercase; color: var(--teal); margin-bottom: 5px;
}
.start-tile.gold .eyebrow { color: var(--gold); }
.start-tile h3 { font-size: 17px; margin-bottom: 5px; }
.start-tile p { font-size: 13px; color: var(--gray-mid); }
.start-tile .go { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--teal); }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--teal-dark); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover:not(:disabled) { background: var(--navy-soft); color: #fff; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover:not(:disabled) { background: #ad7d20; color: #fff; }
.btn-ghost { background: var(--white); color: var(--gray-dark); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-light); color: var(--navy); }
.btn-danger { background: var(--white); color: var(--red); border-color: #e6c4c0; }
.btn-danger:hover:not(:disabled) { background: var(--red-light); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 15px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--gray-mid); margin-bottom: 5px;
}
.field .hint { font-size: 12px; color: var(--gray-mid); margin-top: 5px; text-transform: none; letter-spacing: 0; font-weight: 400; }
input[type='text'], input[type='email'], input[type='password'], input[type='tel'],
input[type='date'], input[type='search'], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit; font-size: 14px; color: var(--gray-dark);
  background: var(--white);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(42, 110, 110, 0.13);
}
select { cursor: pointer; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 10px 14px;
  background: var(--gray-light);
  border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--gray-mid); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfc; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .primary-cell { font-weight: 600; color: var(--navy); }
table.data .muted { color: var(--gray-mid); font-size: 12.5px; }

.year-heading {
  font-family: 'Lora', serif; font-size: 13px; font-weight: 700;
  letter-spacing: 1.5px; color: var(--navy);
  background: var(--teal-light);
  padding: 7px 14px; border-bottom: 1px solid var(--border);
}

/* ------------------------------------------------------------------- pills */

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 11px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
}
.pill-draft { background: var(--gold-light); color: #8a6512; }
.pill-submitted { background: var(--green-light); color: var(--green); }
.pill-pending { background: var(--gold-light); color: #8a6512; }
.pill-approved { background: var(--green-light); color: var(--green); }
.pill-rejected { background: var(--red-light); color: var(--red); }
.pill-admin { background: var(--teal-light); color: var(--teal-dark); }
.pill-user { background: var(--gray-light); color: var(--gray-mid); }
.pill-district { background: var(--teal-light); color: var(--teal-dark); }
.pill-haccp { background: var(--gold-light); color: #8a6512; }

/* ------------------------------------------------------------------ notices */

.notice {
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 4px solid var(--teal);
  background: var(--teal-light);
  font-size: 13.5px;
  margin-bottom: 18px;
}
.notice.warn { border-left-color: var(--gold); background: var(--gold-light); color: #5a4010; }
.notice.error { border-left-color: var(--red); background: var(--red-light); color: var(--red); }
.notice.ok { border-left-color: var(--green); background: var(--green-light); color: var(--green); }
.notice strong { display: block; margin-bottom: 2px; }
.notice:empty { display: none; }

.empty {
  padding: 44px 20px; text-align: center; color: var(--gray-mid); font-size: 14px;
}
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--navy); }

.loading { padding: 40px; text-align: center; color: var(--gray-mid); font-size: 13.5px; }

/* ------------------------------------------------------------------- toast */

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--navy); color: #fff;
  padding: 11px 17px; border-radius: var(--radius);
  font-size: 13.5px; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.24);
  max-width: 380px;
  animation: toast-in 0.16s ease;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------- modal */

.overlay {
  position: fixed; inset: 0; background: rgba(26, 46, 68, 0.5);
  display: none; align-items: center; justify-content: center; z-index: 150; padding: 20px;
}
.overlay.active { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius);
  max-width: 460px; width: 100%; padding: 24px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.3);
}
.modal h3 { font-size: 17px; margin-bottom: 9px; }
.modal p { font-size: 13.5px; color: var(--gray-mid); margin-bottom: 18px; }
.modal .btn-row { justify-content: flex-end; }

/* -------------------------------------------------------------- auth screens */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 36px 20px; }
.auth-card {
  background: var(--white); width: 100%; max-width: 430px;
  border-radius: var(--radius); box-shadow: var(--shadow); border-top: 5px solid var(--teal);
  overflow: hidden;
}
.auth-head { padding: 28px 32px 20px; text-align: center; border-bottom: 1px solid var(--border-soft); }
.auth-head img { height: 52px; width: auto; margin-bottom: 14px; }
.auth-head .eyebrow {
  font-family: 'Lora', serif; font-size: 9.5px; font-weight: 600;
  letter-spacing: 3px; text-transform: uppercase; color: var(--teal); margin-bottom: 5px;
}
.auth-head h1 { font-size: 21px; }
.auth-head p { font-size: 13px; color: var(--gray-mid); margin-top: 5px; }
.auth-body { padding: 24px 32px 30px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border-soft); }
.auth-tabs button {
  flex: 1; padding: 13px 8px; background: none; border: none; border-bottom: 3px solid transparent;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--gray-mid); cursor: pointer;
}
.auth-tabs button.active { color: var(--teal-dark); border-bottom-color: var(--teal); }
.auth-foot { text-align: center; font-size: 13px; color: var(--gray-mid); margin-top: 16px; }
.auth-foot a { font-weight: 600; }

.link-btn {
  background: none; border: none; padding: 0; font: inherit; font-size: 13px;
  color: var(--teal); cursor: pointer; text-decoration: underline;
}

/* ------------------------------------------------------------------ filters */

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 150px; padding: 7px 10px; font-size: 13px; }
.filters input[type='search'] { min-width: 220px; }

/* --------------------------------------------------------------- form shell
   Injected above the assessment forms themselves. The forms bring their own
   stylesheet, so everything here is namespaced to avoid collisions. */

.fx-bar {
  position: sticky; top: 0; z-index: 60;
  background: var(--navy); color: #fff;
  padding: 9px 20px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-family: 'Source Sans 3', sans-serif; font-size: 13.5px;
}
.fx-bar a, .fx-bar button { font-family: inherit; }
.fx-back { color: #cfe0e0; text-decoration: none; font-weight: 600; font-size: 13px; }
.fx-back:hover { color: #fff; }
.fx-title { font-family: 'Lora', serif; font-weight: 600; font-size: 14px; }
.fx-meta { font-size: 12px; color: #9db4c4; }
.fx-spacer { margin-left: auto; }
.fx-state { font-size: 12px; color: #9db4c4; min-width: 92px; text-align: right; }
.fx-state.saving { color: var(--gold); }
.fx-state.saved { color: #7fc79c; }
.fx-state.error { color: #f0a49c; }
.fx-bar .btn { padding: 6px 13px; font-size: 12.5px; }
.fx-bar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.32); }
.fx-bar .btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: #fff; }

.fx-banner {
  padding: 10px 20px; font-size: 13px;
  background: var(--gold-light); color: #5a4010; border-bottom: 1px solid #e8d9b4;
}
.fx-banner.readonly { background: var(--teal-light); color: var(--teal-dark); border-bottom-color: #c5e0e0; }
.fx-banner:empty { display: none; }

/* A read-only record still has to look like the filled paper form, so keep the
   controls visible and simply refuse input. */
body.fx-readonly input, body.fx-readonly textarea, body.fx-readonly select {
  pointer-events: none;
  background: #fbfbfc;
}

@media print {
  .topbar, .fx-bar, .fx-banner, .toast-stack, .no-print { display: none !important; }
}

@media (max-width: 720px) {
  .topbar-inner { padding: 10px 16px; gap: 12px; }
  .nav .who { display: none; }
  .page { padding: 20px 16px 48px; }
  .field-row { grid-template-columns: 1fr; }
}
