/* Trauma Training Feedback — dashboard styles.
 *
 * The dashboard used to carry every rule as an inline style attribute, which is
 * why the responsive rules in index.html all needed !important to win. Moving
 * the repeated chrome here — layout, cards, tables, chips, buttons — means the
 * media queries are ordinary CSS again.
 *
 * The palette lives in custom properties so a colour is stated once. Genuinely
 * dynamic values (a bar's width, a polygon's points) stay inline, because they
 * are data rather than design. */

/* PT Sans, served from this app rather than a CDN (DESIGN.md F10). Two files,
 * 400 and 700 — the only weights the dashboard uses — and the latin subset
 * only, because the UI is English. Glyphs outside it (✓, △, ⚠) fall through to
 * the system font, which is where they already came from.
 *
 * `font-display: swap` renders in Arial immediately and repaints when the font
 * arrives, so a slow font never blocks the dashboard. The licence ships beside
 * the files in frontend/fonts/OFL.txt — PT Sans is SIL OFL 1.1, which requires
 * it to travel with the font. */
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/pt-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/pt-sans-700.woff2') format('woff2');
}

:root {
  --ink: #220901;
  --ink-mid: #3a2d24;
  --ink-soft: #6f5f54;
  --ink-faint: #a8998e;
  --ink-ghost: #c0b3a6;

  --accent: #941b0c;
  --accent-bright: #bc3908;
  --accent-deep: #621708;
  --gold: #f6aa1c;

  --page: #f2ece4;
  --surface: #fff;
  --surface-warm: #fbf5ec;
  --line: #ece1d3;
  --line-soft: #f4ede3;

  --strength: #4b7f52;
  --strength-deep: #2f6b45;
  --development: #bc3908;
  --concern: #941b0c;
  --neutral: #a39b91;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow-modal: 0 24px 70px rgba(34, 9, 1, 0.3);
}

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

body {
  font-family: 'PT Sans', Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
}

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(34, 9, 1, 0.2); border-radius: 5px; }

@keyframes fbspin { to { transform: rotate(360deg); } }
@keyframes fbfade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

#app { display: flex; min-height: 100vh; width: 100%; }

/* ---------------------------------------------------------------- layout -- */
.fb-main {
  flex: 1;
  min-width: 0;
  padding: 34px 40px 60px;
  max-width: 1240px;
}
.fb-page { animation: fbfade .25s ease; }

.fb-eyebrow {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--accent-bright);
  font-weight: 700;
  text-transform: uppercase;
}
.fb-page h1 { margin: 4px 0; font-size: 34px; color: var(--ink); }
.fb-sub { color: var(--ink-soft); font-size: 15px; }

/* ---------------------------------------------------------------- cards --- */
.fb-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.fb-card + .fb-card { margin-top: 16px; }
.fb-card h2 { margin: 0 0 2px; font-size: 18px; color: var(--ink); }
.fb-card-note { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.fb-card-attention { border-left: 4px solid var(--accent); }

.fb-stack { display: flex; flex-direction: column; gap: 12px; }
.fb-stack-sm { display: flex; flex-direction: column; gap: 8px; }
.fb-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.fb-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.fb-grid-2col { display: grid; grid-template-columns: 1fr 1.25fr; gap: 16px; margin-bottom: 22px; }
.fb-grid-even { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

.fb-metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent-bright);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.fb-metric-label { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.fb-metric-value { font-size: 34px; font-weight: 700; color: var(--accent-deep); line-height: 1.1; }
.fb-metric-value .fb-of { font-size: 18px; color: var(--ink-faint); }
.fb-metric-alert { border-top-color: var(--accent); }
.fb-metric-alert .fb-metric-value { color: var(--accent); }
.fb-metric-gold { border-top-color: var(--gold); }

/* --------------------------------------------------------------- sidebar -- */
.fb-sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: linear-gradient(180deg, #3a1102 0%, var(--ink) 60%);
  color: #f5efe6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.fb-brand { padding: 26px 24px 22px; border-bottom: 1px solid rgba(246, 170, 28, 0.22); }
.fb-brand-eyebrow { font-size: 12px; letter-spacing: 3px; color: var(--gold); font-weight: 700; }
.fb-brand-title { font-size: 25px; font-weight: 700; line-height: 1.15; margin-top: 6px; }
.fb-brand-sub { font-size: 13px; color: #c9bcae; margin-top: 8px; }
.fb-nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.fb-navbtn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; border-left: 3px solid transparent; cursor: pointer;
  padding: 11px 14px; border-radius: 7px;
  font-family: inherit; font-size: 15px; font-weight: 700;
  background: transparent; color: #e8ddce; text-align: left;
  transition: background .15s;
}
.fb-navbtn:hover { background: rgba(246, 170, 28, 0.14); }
.fb-navbtn.fb-active { background: rgba(246, 170, 28, 0.20); color: var(--gold); border-left-color: var(--gold); }
.fb-navbtn span:first-child { flex: 1; }
.fb-badge {
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  padding: 1px 8px; border-radius: 20px;
}
.fb-navbtn.fb-active .fb-badge { background: var(--gold); color: var(--ink); }
.fb-sidebar-foot {
  margin-top: auto; padding: 20px 24px;
  border-top: 1px solid rgba(246, 170, 28, 0.18);
  font-size: 12px; line-height: 1.55; color: #b7a99b;
}

/* --------------------------------------------------------------- top bar -- */
.fb-topbar, .fb-backdrop { display: none; }
.fb-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 45;
  align-items: center; gap: 12px; padding: 10px 14px;
  background: linear-gradient(90deg, #3a1102, var(--ink));
  color: #f5efe6; box-shadow: 0 2px 10px rgba(34, 9, 1, 0.3);
}
.fb-iconbtn {
  background: rgba(246, 170, 28, 0.16); border: none; color: var(--gold);
  border-radius: 7px; cursor: pointer; font-family: inherit;
}
.fb-hamburger { width: 38px; height: 38px; font-size: 19px; }
.fb-account { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #d8ccbe; }
.fb-account a { color: var(--gold); font-weight: 700; }
.fb-account button { padding: 5px 10px; font-size: 12.5px; font-weight: 700; }

/* -------------------------------------------------------------- controls -- */
.fb-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 20px; }
.fb-select {
  font-family: inherit; font-size: 13.5px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
.fb-segmented { display: inline-flex; border-radius: 6px; overflow: hidden; }
.fb-segmented button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 5px 11px; cursor: pointer;
}
.fb-segmented button.fb-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.fb-refresh {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-faint);
}
.fb-btn {
  font-family: inherit; font-size: 14px; font-weight: 700;
  border: none; border-radius: var(--radius-sm); padding: 8px 14px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.fb-btn:hover { filter: brightness(1.08); }
.fb-btn[disabled] { background: var(--ink-ghost); cursor: default; filter: none; }
.fb-btn-quiet { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); }
.fb-btn-quiet:hover { color: var(--accent); border-color: var(--accent); filter: none; }

/* ----------------------------------------------------------------- rows --- */
.fb-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 12px; border: 1px solid #f0e6d8; border-radius: 7px;
  cursor: pointer; transition: background .15s;
}
.fb-row:hover { background: var(--surface-warm); }
.fb-row-main { flex: 1; min-width: 0; }
.fb-row-title { font-weight: 700; font-size: 15px; color: var(--ink); }
.fb-row-title .fb-muted { font-weight: 400; color: var(--ink-faint); font-size: 13px; }
.fb-row-body { font-size: 14px; color: #4a3d34; text-wrap: pretty; }
.fb-row-meta { text-align: right; flex: 0 0 auto; font-size: 13px; color: var(--ink-soft); }
.fb-row-meta small { display: block; font-size: 12px; color: var(--ink-faint); }

.fb-table { overflow-x: auto; }
.fb-table-inner { min-width: 560px; }
.fb-tr, .fb-th {
  display: grid;
  grid-template-columns: 1.6fr .8fr .8fr .8fr 1fr;
  align-items: center;
  padding: 9px 10px;
}
.fb-th {
  font-size: 12px; color: var(--ink-faint); font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--line); padding: 8px 10px;
}
.fb-tr { font-size: 14px; border-bottom: 1px solid var(--line-soft); cursor: pointer; transition: background .15s; }
.fb-tr:hover { background: var(--surface-warm); }
.fb-tr-name { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.fb-center { text-align: center; }
.fb-right { text-align: right; }
.fb-muted { color: var(--ink-soft); }
.fb-faint { color: var(--ink-faint); }
.fb-empty { color: var(--ink-soft); font-size: 14px; }

/* ---------------------------------------------------------------- chips --- */
.fb-chip {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; white-space: nowrap; flex: 0 0 auto;
  color: #fff;
}
.fb-chip-positive { background: var(--strength); }
.fb-chip-developmental { background: var(--development); }
.fb-chip-concern { background: var(--concern); }
.fb-chip-neutral { background: var(--neutral); }
.fb-chip-soft { background: #f0e6da; color: var(--ink-soft); }

.fb-avatar {
  border-radius: 7px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(246, 170, 28, 0.28); color: var(--accent-deep); font-weight: 700;
  background-size: cover; background-position: center top;
  overflow: hidden;
}
.fb-avatar-img { border: 2px solid var(--gold); }

/* ---------------------------------------------------------------- modal --- */
.fb-modal-ov {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(34, 9, 1, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 30px; animation: fbfade .15s ease;
}
.fb-modal {
  background: var(--surface); border-radius: 10px; max-width: 640px; width: 100%;
  max-height: 84vh; overflow: auto; box-shadow: var(--shadow-modal);
}
.fb-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 20px 24px 12px; border-bottom: 1px solid var(--line);
}
.fb-modal-body { padding: 18px 24px 24px; }
.fb-modal-close {
  background: none; border: none; font-size: 22px; color: var(--ink-faint);
  cursor: pointer; font-family: inherit; line-height: 1;
}

/* ------------------------------------------------------------- messages --- */
.fb-note {
  font-size: 13px; color: #8a5a00; background: #fffaf1;
  border: 1px solid #f0dcb4; border-radius: 6px; padding: 10px 12px;
}
.fb-error {
  font-size: 13.5px; color: var(--accent); background: #fdf3f1;
  border: 1px solid #f0d2cb; border-radius: 6px; padding: 10px 12px;
}
.fb-centre-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; color: var(--ink-soft); font-size: 15px;
  padding: 40px; text-align: center;
}
.fb-spinner {
  width: 20px; height: 20px; border: 3px solid #e7dccd;
  border-top-color: var(--accent-bright); border-radius: 50%;
  display: inline-block; animation: fbspin .8s linear infinite;
}

/* ---------------------------------------------------------------- login --- */
.fb-login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 30px; }
.fb-login {
  background: var(--surface); border: 1px solid var(--line);
  border-top: 4px solid var(--accent); border-radius: 10px;
  padding: 28px 30px; max-width: 360px; width: 100%;
  box-shadow: 0 10px 40px rgba(34, 9, 1, 0.12);
}
.fb-login h1 { margin: 6px 0 4px; font-size: 22px; color: var(--ink); }
.fb-login input {
  width: 100%; padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 14px;
}
.fb-login button { width: 100%; padding: 11px; margin-top: 2px; }

/* ---------------------------------------------------------- JMS profile --- */
.fb-jms-layout { display: grid; grid-template-columns: 240px 1fr; gap: 22px; align-items: start; }
.fb-jms-roster {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; position: sticky; top: 20px;
  max-height: calc(100vh - 60px); overflow: auto;
}
.fb-jms-head {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; gap: 22px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.fb-jms-stat { text-align: center; padding: 8px 16px; border-left: 1px solid var(--line); }
.fb-jms-stat-value { font-size: 26px; font-weight: 700; color: var(--accent-deep); }
.fb-jms-stat-label { font-size: 12px; color: var(--ink-soft); }

/* ------------------------------------------------------------ responsive -- */
@media (max-width: 920px) {
  .fb-topbar { display: flex; }
  .fb-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    height: 100dvh; width: min(280px, 84vw); flex: none;
    z-index: 60; transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(34, 9, 1, 0.4);
  }
  .fb-sidebar.fb-open { transform: translateX(0); }
  .fb-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(34, 9, 1, 0.45); z-index: 55; animation: fbfade .15s ease;
  }
  .fb-main { padding: 76px 16px 48px; }
  .fb-page h1 { font-size: 24px; }
  .fb-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .fb-grid-2col, .fb-grid-even, .fb-jms-layout { grid-template-columns: 1fr; }
  .fb-jms-roster { position: static; max-height: 260px; }
  .fb-row { flex-wrap: wrap; }
  .fb-row-main { min-width: 70%; }
  .fb-row-meta { text-align: left; }
  .fb-modal-ov { padding: 12px; }
  .fb-modal { max-height: 92vh; }
  .fb-refresh { margin-left: 0; }
}
