/* ===============================================================
   APPLICATION STYLES
   ---------------------------------------------------------------
   Design tokens are at the top. Change a color or a font once here
   and it changes everywhere, including the client report.
   Report and print rules live in css/report.css.
   =============================================================== */

/* ===============================================================
   DESIGN TOKENS
   =============================================================== */
:root {
  /* Surface and ink */
  --paper:       #EDEFEB;
  --surface:     #FFFFFF;
  --surface-alt: #F6F8F4;
  --ink:         #16211F;
  --ink-2:       #4A5654;
  --ink-3:       #7D8785;
  --line:        #D8DDD8;
  --line-strong: #B9C1BB;

  /* Accents */
  --pine:        #234E43;
  --pine-deep:   #163830;
  --pine-soft:   #E4EDE8;
  --brass:       #A8875A;
  --brass-soft:  #F3ECE0;

  /* Rating colors, used by score displays in app and report */
  --rate-strong:     #234E43;
  --rate-solid:      #8A6D3B;
  --rate-developing: #A9701F;
  --rate-attention:  #8C3B2E;

  /* Type */
  --display: "Spectral", Georgia, "Times New Roman", serif;
  --body:    "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --mono:    "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  /* Space and shape */
  --radius:    4px;
  --radius-lg: 8px;
  --shadow:    0 1px 2px rgba(22, 33, 31, .05), 0 8px 24px rgba(22, 33, 31, .05);
  --maxw:      1160px;
}

/* ===============================================================
   BASE
   =============================================================== */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--display);
  color: var(--ink);
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
}
h1 { font-size: 2rem; letter-spacing: -.01em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 .9em; }

a { color: var(--pine); }

button { font-family: inherit; font-size: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 2px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ===============================================================
   TOP BAR
   =============================================================== */
.topbar {
  background: var(--pine-deep);
  color: #EAF0EC;
  border-bottom: 3px solid var(--brass);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand-lockup { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand-name {
  font-family: var(--display);
  font-size: 1.05rem;
  color: #FFFFFF;
  letter-spacing: .01em;
  white-space: nowrap;
}
.brand-tool {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #9FB6AA;
  border-left: 1px solid #3D6357;
  padding-left: 12px;
  white-space: nowrap;
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ===============================================================
   BUTTONS
   =============================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 15px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.2;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  text-decoration: none;
}
.btn:hover { border-color: var(--pine); color: var(--pine); }
.btn-primary { background: var(--pine); border-color: var(--pine); color: #FFFFFF; }
.btn-primary:hover { background: var(--pine-deep); border-color: var(--pine-deep); color: #FFFFFF; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(35, 78, 67, .07); color: var(--pine); border-color: transparent; }
.btn-onDark { background: transparent; border-color: #47695D; color: #E7EFE9; }
.btn-onDark:hover { background: #2C5A4D; border-color: #6B8A7E; color: #FFFFFF; }
.btn-danger { border-color: #DFC7C2; color: var(--rate-attention); }
.btn-danger:hover { background: #F8EFED; border-color: var(--rate-attention); color: var(--rate-attention); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-icon { padding: 5px 9px; font-size: .8rem; min-width: 30px; justify-content: center; }

/* ===============================================================
   LAYOUT
   =============================================================== */
.view { max-width: var(--maxw); margin: 0 auto; padding: 32px 24px 80px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.page-head h1 { margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

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

/* ===============================================================
   FORM FIELDS
   =============================================================== */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.field label {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.field input,
.field select,
.field textarea {
  font-family: var(--body);
  font-size: .95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 11px;
  width: 100%;
}
.field textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--pine);
  outline: none;
  box-shadow: 0 0 0 3px var(--pine-soft);
}
.field-hint { font-size: .78rem; color: var(--ink-3); }
.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.field-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }

.search-input {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--body);
  font-size: .9rem;
  min-width: 260px;
  background: var(--surface);
}

/* ===============================================================
   DASHBOARD
   =============================================================== */
.assessment-list { display: flex; flex-direction: column; gap: 10px; }

.assessment-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 14px 18px;
  transition: border-color .12s ease, transform .12s ease;
}
.assessment-row:hover { border-left-color: var(--brass); }
.assessment-row .biz { font-family: var(--display); font-size: 1.08rem; color: var(--ink); }
.assessment-row .owner { font-size: .84rem; color: var(--ink-3); }
.row-score { font-family: var(--mono); font-size: 1.05rem; color: var(--ink); text-align: right; }
.row-score small { display: block; font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.row-date { font-size: .8rem; color: var(--ink-3); text-align: right; min-width: 118px; }

.status-pill {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 100px;
  border: 1px solid var(--line-strong);
  color: var(--ink-3);
  white-space: nowrap;
}
.status-draft     { background: var(--surface-alt); }
.status-review    { background: var(--brass-soft); border-color: #E0CFB2; color: #7A5F30; }
.status-delivered { background: var(--pine-soft); border-color: #BCD4C8; color: var(--pine); }

.empty-state {
  text-align: center;
  padding: 60px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
}
.empty-state h3 { margin-bottom: 6px; }

/* ===============================================================
   WORKSPACE SHELL
   =============================================================== */
.ws-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.ws-header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 24px 0;
}
.ws-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.ws-title-row h1 { font-size: 1.6rem; }
.ws-meta { font-size: .84rem; color: var(--ink-3); margin-top: 4px; }
.ws-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.tabs { display: flex; gap: 2px; margin-top: 18px; overflow-x: auto; }
.tab {
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-size: .86rem;
  color: var(--ink-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--pine); }
.tab.active { color: var(--pine); border-bottom-color: var(--pine); font-weight: 600; }
.tab .tab-num { font-family: var(--mono); font-size: .7rem; color: var(--ink-3); margin-right: 6px; }
.tab.active .tab-num { color: var(--brass); }
.tab .tab-count { font-family: var(--mono); font-size: .68rem; color: var(--ink-3); margin-left: 6px; }

/* Progress strip under the tabs */
.progress-strip { background: var(--surface); border-bottom: 1px solid var(--line); }
.progress-strip-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.progress-track { flex: 1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--pine); transition: width .25s ease; }
.progress-label { font-family: var(--mono); font-size: .7rem; color: var(--ink-3); letter-spacing: .08em; white-space: nowrap; }

/* ===============================================================
   ASSESSMENT QUESTIONS
   =============================================================== */
.section-intro {
  display: flex;
  gap: 18px;
  align-items: baseline;
  margin-bottom: 20px;
}
.section-number {
  font-family: var(--mono);
  font-size: 1.5rem;
  color: var(--brass);
  line-height: 1;
}

.q-item {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 22px;
  align-items: start;
}
.q-item:last-of-type { border-bottom: none; }
.q-item.is-flagged { background: linear-gradient(90deg, rgba(140,59,46,.045), transparent 55%); }
.q-text { color: var(--ink); font-size: .97rem; }
.q-help { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.q-critical {
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--rate-attention);
  border: 1px solid #E2CCC7;
  background: #FAF2F0;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: 2px;
  white-space: nowrap;
}
.q-controls { display: flex; align-items: center; gap: 8px; }

/* Segmented answer control */
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  border: none;
  background: var(--surface);
  padding: 7px 12px;
  font-size: .78rem;
  color: var(--ink-2);
  border-right: 1px solid var(--line);
  white-space: nowrap;
  transition: background .1s ease, color .1s ease;
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { background: var(--surface-alt); }
.segmented button[data-answer="yes"].active      { background: var(--pine); color: #FFF; }
.segmented button[data-answer="progress"].active { background: var(--rate-developing); color: #FFF; }
.segmented button[data-answer="no"].active       { background: var(--rate-attention); color: #FFF; }
.segmented button[data-answer="na"].active       { background: var(--ink-3); color: #FFF; }

.note-toggle { border: none; background: none; color: var(--ink-3); font-size: .78rem; padding: 4px 6px; }
.note-toggle:hover { color: var(--pine); }
.note-toggle.has-note { color: var(--brass); }
.q-note { grid-column: 1 / -1; }
.q-note textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--body);
  font-size: .88rem;
  min-height: 62px;
  background: var(--surface-alt);
  resize: vertical;
}

/* ===============================================================
   SCORE DISPLAYS  (the datum chart)
   =============================================================== */
.score-headline { display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.score-number {
  font-family: var(--display);
  font-size: 4.2rem;
  line-height: .9;
  color: var(--ink);
  font-weight: 500;
}
.score-number sup { font-size: 1.4rem; color: var(--ink-3); font-weight: 400; top: -1.6em; }
.score-rating { font-family: var(--display); font-size: 1.35rem; color: var(--ink); }
.score-blurb { font-size: .88rem; color: var(--ink-2); max-width: 46ch; }

.datum { margin-top: 8px; }
.datum-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr 3.4rem;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.datum-row:last-child { border-bottom: none; }
.datum-num { font-family: var(--mono); font-size: .72rem; color: var(--brass); }
.datum-label { font-size: .9rem; color: var(--ink); }
.datum-sub { font-size: .75rem; color: var(--ink-3); }
.datum-bar {
  position: relative;
  height: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.datum-bar span {
  display: block;
  height: 100%;
  background: var(--pine);
  transition: width .3s ease;
}
.datum-bar::after {
  /* measurement ticks at 25 / 50 / 75 */
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--line-strong) calc(25% - 1px) 25%, transparent 25%),
                    linear-gradient(90deg, transparent 0 calc(50% - 1px), var(--line-strong) calc(50% - 1px) 50%, transparent 50%),
                    linear-gradient(90deg, transparent 0 calc(75% - 1px), var(--line-strong) calc(75% - 1px) 75%, transparent 75%);
  pointer-events: none;
}
.datum-value { font-family: var(--mono); font-size: .95rem; color: var(--ink); text-align: right; }

.rate-strong     .datum-bar span, .fill-strong     { background: var(--rate-strong); }
.rate-solid      .datum-bar span, .fill-solid      { background: var(--rate-solid); }
.rate-developing .datum-bar span, .fill-developing { background: var(--rate-developing); }
.rate-attention  .datum-bar span, .fill-attention  { background: var(--rate-attention); }

.text-strong     { color: var(--rate-strong); }
.text-solid      { color: var(--rate-solid); }
.text-developing { color: var(--rate-developing); }
.text-attention  { color: var(--rate-attention); }

/* ===============================================================
   ALERTS
   =============================================================== */
.alert-block {
  border: 1px solid #E2CCC7;
  border-left: 3px solid var(--rate-attention);
  background: #FBF5F3;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.alert-block h3 { color: var(--rate-attention); font-size: 1rem; margin-bottom: 8px; }
.alert-block ul { margin: 0; padding-left: 18px; }
.alert-block li { margin-bottom: 4px; font-size: .9rem; color: var(--ink-2); }
.alert-block .watch { color: var(--ink-3); }

/* ===============================================================
   RECOMMENDATIONS
   =============================================================== */
.priority-group { margin-bottom: 26px; }
.priority-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 6px;
  margin-bottom: 4px;
}
.priority-head h3 { font-size: 1.05rem; }
.priority-head .count { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); margin-left: auto; }
.priority-note { font-size: .78rem; color: var(--ink-3); margin: 6px 0 12px; }

.rec-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.rec-marker { font-family: var(--mono); font-size: .7rem; color: var(--brass); padding-top: 8px; }
.rec-item textarea {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  padding: 7px 9px;
  font-family: var(--body);
  font-size: .93rem;
  line-height: 1.5;
  color: var(--ink);
  resize: vertical;
  min-height: 44px;
}
.rec-item textarea:hover { border-color: var(--line); background: var(--surface-alt); }
.rec-item textarea:focus { border-color: var(--pine); background: var(--surface); outline: none; }
.rec-tools { display: flex; gap: 3px; align-items: center; padding-top: 4px; }
.rec-source {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
}
.rec-move select {
  font-family: var(--body);
  font-size: .75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 4px 6px;
  background: var(--surface);
  color: var(--ink-2);
}

/* ===============================================================
   SERVICES
   =============================================================== */
.service-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.service-item input[type="checkbox"] { width: 17px; height: 17px; margin-top: 3px; accent-color: var(--pine); }
.service-name { color: var(--ink); font-size: .95rem; font-weight: 600; }
.service-blurb { font-size: .84rem; color: var(--ink-3); }
.service-kind {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brass);
  margin-left: 8px;
}

/* ===============================================================
   MISC
   =============================================================== */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #FFF;
  padding: 10px 18px;
  border-radius: 100px;
  font-size: .85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(22, 33, 31, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 560px; width: 100%;
  max-height: 88vh; overflow-y: auto;
  padding: 26px 28px;
  box-shadow: 0 20px 60px rgba(22,33,31,.28);
}
.modal h2 { margin-bottom: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.helper-note {
  background: var(--brass-soft);
  border: 1px solid #E5D9C2;
  border-radius: var(--radius);
  padding: 12px 15px;
  font-size: .85rem;
  color: #6E5A34;
  margin-bottom: 18px;
}

/* ===============================================================
   RESPONSIVE
   =============================================================== */
@media (max-width: 860px) {
  .grid-2, .grid-3, .field-grid, .field-grid-2 { grid-template-columns: 1fr; }
  .q-item { grid-template-columns: 1fr; }
  .assessment-row { grid-template-columns: 1fr auto; row-gap: 8px; }
  .row-date { text-align: left; }
  .score-number { font-size: 3.2rem; }
  .view { padding: 24px 16px 60px; }
  .topbar-inner, .ws-header-inner, .progress-strip-inner { padding-left: 16px; padding-right: 16px; }
  .brand-tool { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
