/* Daily Observation Reports and Evaluations & Assessments (module: dor). Class prefix: dr-.
   Colors come from the shared tokens only, so light and dark themes both work. */

.dr-page { min-width: 0; }
.dr-page [hidden], .dr-form [hidden] { display: none !important; }
.dr-print-head { display: none; }

/* ---------- list pages ---------- */
.dr-strip {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px;
  background: var(--surface); border: 1px solid var(--gold); border-left-width: 6px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.dr-strip-n {
  flex: none; min-width: 56px; height: 56px; padding: 0 10px; display: grid; place-items: center; border-radius: 12px;
  background: var(--gold); color: var(--navy); font-family: var(--font-head); font-size: 32px; font-weight: 600; line-height: 1;
}
.dr-strip-body { flex: 1; min-width: 0; }
.dr-strip-body h2 { font-size: 18px; }
.dr-strip-body p { color: var(--muted); margin-top: 2px; }
.dr-strip.calm { border-color: var(--line); border-left-width: 1px; box-shadow: none; }
.dr-strip.calm .dr-strip-n { background: var(--surface-2); color: var(--muted); }

/* The filter bar is a grid: the search box on a row of its own, then the selects in equal columns (a select is never squeezed until its
   text is cut off). The Mine chip, when there is one, takes the last column. Two columns on a narrow laptop, one on a phone. */
.toolbar.dr-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: center; }
.toolbar.dr-bar.dr-bar-chip { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
.toolbar.dr-bar .search { grid-column: 1 / -1; min-width: 0; }
.toolbar.dr-bar .select { width: 100%; min-width: 0; }
@media (max-width: 1200px) {
  .toolbar.dr-bar, .toolbar.dr-bar.dr-bar-chip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar.dr-bar .chip { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 520px) {
  .toolbar.dr-bar, .toolbar.dr-bar.dr-bar-chip { grid-template-columns: minmax(0, 1fr); }
}

/* Tables. The columns are few enough to show Status at laptop widths; text wraps before the table ever scrolls. */
.dr-tbl td { padding-top: 9px; padding-bottom: 9px; }
/* A status pill in a table stays on one line (styles.css), which takes a few more pixels of the evaluation list's seven columns. At a
   laptop's narrower page the cells give a little of their side padding back, so Status stays on screen with no scroll. */
@media (min-width: 721px) and (max-width: 1100px) {
  .dr-tbl th, .dr-tbl td { padding-left: 6px; padding-right: 6px; }
  .dr-tbl th:first-child, .dr-tbl td:first-child { padding-left: 12px; }
  .dr-tbl th:last-child, .dr-tbl td:last-child { padding-right: 12px; }
}
.dr-st { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dr-top td { vertical-align: top; }
.dr-top th:nth-child(2), .dr-top td:nth-child(2) { min-width: 132px; } /* the recruit and the type under it keep a readable width beside two long texts */
/* A long note: wraps (a long unbroken word breaks), and past a few lines it is cut with a Show more button under it (clipText) */
.dr-clip { display: block; min-width: 160px; white-space: normal; overflow-wrap: anywhere; }
.dr-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.dr-cliprow { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.dr-toggle { padding: 2px 0; border: 0; background: none; color: var(--text); font-size: 13px; font-weight: 600; text-decoration: underline; cursor: pointer; }
.dr-toggle:hover { text-decoration-thickness: 2px; }

.dr-over li { flex-wrap: wrap; }
.dr-over .grow { min-width: 200px; }
.dr-quiet { padding: 16px 20px; color: var(--muted); }
.dr-more { padding: 10px 20px 14px; border-top: 1px solid var(--line); }
.dr-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding-top: 12px; }

/* The page head: the title block takes the free room, so the buttons stay on the right however long the line under the title is */
.dr-page .page-head > :first-child { flex: 1 1 320px; min-width: 0; }
.dr-sub-pills { display: inline-flex; flex-wrap: wrap; gap: 6px; vertical-align: middle; }
/* the recruit and the date stay together: when the whole line does not fit beside the pills, it drops under them as one piece */
.dr-sub-text { display: inline-block; vertical-align: middle; }
/* tabs: the full names, and short ones for a phone */
.dr-t-short { display: none; }

/* ---------- forms ---------- */
.dr-form .textarea { min-height: 120px; }
.dr-slot { min-width: 0; }
/* The first card of a form: the recruit and the officer share the first row, and the three small fields (.dr-third) share the second,
   so no field sits alone in a half-empty row. Two columns on a narrow laptop (the last field then spans both), one on a tablet. */
.form-grid.dr-fg6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dr-fg6 > * { grid-column: span 3; }
.dr-fg6 > .dr-third { grid-column: span 2; }
@media (max-width: 1100px) {
  .form-grid.dr-fg6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dr-fg6 > *, .dr-fg6 > .dr-third { grid-column: auto; }
  .dr-fg6 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 900px) { .form-grid.dr-fg6 { grid-template-columns: minmax(0, 1fr); } }
.dr-static {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 42px; padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font-weight: 600;
}
.dr-scale { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); }
.dr-scale > span { display: inline-flex; align-items: center; gap: 6px; }
@media (hover: none) { .dr-tip { display: none; } }

.dr-rates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dr-rates > :last-child:nth-child(odd) { grid-column: 1 / -1; } /* an odd one out takes the whole row, not half of it */
.dr-rate { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.dr-rate:focus-within { border-color: var(--field-line); }
.dr-rate.dr-bad { border-color: var(--bad); }
.dr-rate .rating-input { flex-wrap: nowrap; gap: 6px; }
.dr-rate .rate { flex: 1 1 0; min-width: 0; width: auto; height: 44px; }

.dr-group { display: flex; flex-direction: column; gap: 8px; }
.dr-group .label { font-weight: 600; font-size: 14px; }
.dr-group .err { font-size: 13px; color: var(--bad-fg); font-weight: 600; }
.dr-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
/* Three choices sit in one row, five in two rows of three and two (never four and one); a narrow screen stacks them. */
.dr-choices.dr-n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dr-choices.dr-n5 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dr-choices.dr-n5 > :nth-child(-n+3) { grid-column: span 2; }
.dr-choices.dr-n5 > :nth-child(n+4) { grid-column: span 3; }
@media (max-width: 900px) {
  .dr-choices.dr-n5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dr-choices.dr-n5 > * { grid-column: auto; }
  .dr-choices.dr-n5 > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) { .dr-choices.dr-n3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .dr-choices.dr-n5 { grid-template-columns: minmax(0, 1fr); } }
.dr-choice { position: relative; display: block; cursor: pointer; }
.dr-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.dr-choice span {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 9px 14px; border: 1px solid var(--field-line); border-radius: 10px;
  background: var(--field-bg); font-weight: 600; font-size: 14px;
}
.dr-choice span::before { content: ''; flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--field-line); background: var(--field-bg); }
.dr-choice:hover span { border-color: var(--text); }
.dr-choice input:checked + span { background: var(--btn-dark); color: var(--btn-dark-fg); border-color: var(--btn-dark); }
.dr-choice input:checked + span::before { border-color: var(--gold); background: var(--gold); box-shadow: inset 0 0 0 3px var(--btn-dark); }
.dr-choice input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Ask the Supervisor for help or report a concern (FTA and FTO). Two short choices stay side by side, and the note says who is told. */
.dr-concern .dr-choices { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.dr-route { font-size: 13px; color: var(--muted); }

.dr-needs > label, .dr-needs > .label { color: var(--bad-fg); }
.dr-needs .textarea { border-color: var(--bad); }
/* keep a focused control clear of the sticky action bar */
.dr-form input, .dr-form select, .dr-form textarea, .dr-form .rate, .dr-form .dr-choice { scroll-margin-bottom: 120px; }

.dr-actions {
  position: sticky; bottom: 12px; z-index: 6; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.dr-actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dr-live { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; font-weight: 600; }
.dr-live-text { color: var(--muted); font-weight: 400; font-size: 13px; }

/* ---------- detail pages ---------- */
.dr-rows { list-style: none; margin: 0; padding: 0; }
.dr-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.dr-rows li:first-child { padding-top: 0; }
.dr-rows li:last-child { border-bottom: 0; padding-bottom: 0; }
.dr-rows .t { font-weight: 600; }
.dr-rows .h { font-size: 13px; color: var(--muted); }
.dr-rows .v { display: flex; align-items: center; gap: 10px; }
.dr-avg-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
/* stands where Approve and Return would be, for the person who wrote or signed the report */
.dr-why { display: inline-flex; align-items: center; gap: 8px; max-width: 360px; font-size: 13px; color: var(--muted); }
.dr-why svg { flex: none; }
/* a saved draft that is not complete: the waiting Sign and submit button and its reason stay together, and the reason drops under the button when the row is narrow */
.dr-submit { display: inline-flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; max-width: 100%; }
@media (min-width: 901px) { .dr-kv-s { grid-template-columns: minmax(84px, 116px) minmax(0, 1fr); gap: 10px 14px; } }
.dr-sec + .dr-sec { margin-top: 18px; }
.dr-grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.dr-grid2 .dr-sec + .dr-sec { margin-top: 0; }
.dr-sec h3 { font-size: 12px; font-family: var(--font-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.dr-text { white-space: pre-wrap; word-break: break-word; }
.dr-bars .hbar { grid-template-columns: minmax(110px, 200px) minmax(0, 1fr) 36px; }
.dr-bars .hbar .fill.bad { background: var(--bad); }
.dr-rec { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }

/* ---------- small screens ---------- */
.dr-headx { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 12px; min-width: 0; }
.dr-head-wrap { flex-wrap: wrap; row-gap: 8px; }
.dr-headx .small { white-space: nowrap; }
@media (max-width: 760px) {
  .dr-rates { grid-template-columns: minmax(0, 1fr); }
  .dr-strip { flex-wrap: wrap; }
  .dr-strip .btn { width: 100%; }
  .dr-actions { bottom: 8px; padding: 10px 12px; }
  .dr-actions .btn { flex: 1 1 120px; }
  .dr-actions .spacer, .dr-actions .dr-cancel { display: none; }
  .dr-live { flex: 1 1 100%; }
  .dr-bars .hbar { grid-template-columns: minmax(90px, 120px) minmax(0, 1fr) 32px; }
  /* touch targets: the Mine chip, Export CSV, the list's Show more and the link back are 44px tall on a phone */
  .dr-bar .chip, .dr-headx .btn, .dr-pager .btn, .dr-page .crumb { min-height: 44px; }
  .dr-headx .btn { min-width: 44px; }
  .dr-toggle { padding: 12px 0; }
}
/* an overdue row: the title takes the whole line, and the pill and button sit under it, the same in every row */
@media (max-width: 640px) { .dr-over .grow { flex: 1 1 100%; min-width: 0; } }
@media (max-width: 520px) {
  .dr-xlabel { display: none; }
  .dr-rows li { grid-template-columns: minmax(0, 1fr); }
  /* the pills of a report's status sit on a line of their own, so the recruit and date under them never split */
  .dr-sub-pills { display: flex; margin-bottom: 6px; }
  /* tabs: short names, side by side */
  .dr-t-long { display: none; }
  .dr-t-short { display: inline; }
  .dr-page .tabs a { flex: 1; text-align: center; padding-left: 8px; padding-right: 8px; }
}

/* A phone (and a small tablet, where the evaluation list's seven columns no longer fit) has no room for columns: every row of a list
   becomes a small card, each value under the name of its column. The first cell (the report and its date) is the card's title. */
@media screen and (max-width: 720px) {
  .table.dr-stack, .table.dr-stack tbody, .table.dr-stack tr, .table.dr-stack td { display: block; width: 100%; }
  .table.dr-stack thead { display: none; }
  .table.dr-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.dr-stack tbody tr:last-child { border-bottom: 0; }
  .table.dr-stack td, .table.dr-stack td:first-child, .table.dr-stack td:last-child {
    display: flex; align-items: flex-start; gap: 12px; min-width: 0; padding: 5px 0; border: 0; white-space: normal;
  }
  .table.dr-stack td::before {
    content: attr(data-label); flex: none; width: 124px; padding-top: 2px; color: var(--muted); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .table.dr-stack td[data-label=""]::before, .table.dr-stack td:first-child::before { display: none; }
  .table.dr-stack td:first-child { margin-bottom: 4px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); font-size: 16px; }
  .table.dr-stack td > * { min-width: 0; }
  .table.dr-stack .pill { white-space: normal; }
  .dr-clip { min-width: 0; }
}

@media (forced-colors: active) {
  .dr-choice input:checked + span, .dr-rate .rate[aria-checked="true"] { border: 3px solid Highlight; }
  .dr-strip-n { border: 1px solid CanvasText; }
}

/* ---------- print: a clean document for Export PDF (always light, chrome hidden) ---------- */
@media print {
  .dr-clamp { display: block; overflow: visible; } /* paper shows a whole note, and has no button to open it */
  .dr-toggle { display: none; }
  .dr-print-head { display: block; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid #000; }
  .dr-print-org { font-size: 10pt; letter-spacing: 0.1em; text-transform: uppercase; }
  .dr-print-title { font-size: 18pt; font-weight: 700; margin-top: 2px; }
  .dr-print-meta { font-size: 9pt; color: #444; margin-top: 2px; }
  .dr-doc {
    --surface: #fff; --surface-2: #f0f0f0; --hover: #f0f0f0; --text: #000; --muted: #444; --line: #bbb; --fill: #222; --on-fill: #fff;
    --good: #1f5a38; --good-fg: #1f5a38; --good-bg: #dcefe3; --bad: #8f2a20; --bad-fg: #8f2a20; --bad-bg: #f6ddd9;
    --warn: #6b4f08; --warn-bg: #f7e8c4; --info: #1e3a5f; --info-bg: #dce4f0; --exam: #3b3a78; --exam-bg: #e4e3f4;
    color: #000;
  }
  .dr-doc, .dr-doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .dr-doc { font-size: 10pt; }
  .dr-doc .page-head h1 { display: none; }
  .dr-doc .page-head { margin-bottom: 8px; }
  .dr-doc .grid.split { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 12px; align-items: start; }
  .dr-doc .stack { gap: 10px; }
  .dr-doc .card { border: 1px solid #999; border-radius: 6px; box-shadow: none; break-inside: avoid; }
  .dr-doc .card-head { padding: 8px 12px; }
  .dr-doc .card-head h2 { font-size: 12pt; }
  .dr-doc .card-body { padding: 10px 12px; }
  .dr-doc .kv, .dr-doc .dr-kv-s { grid-template-columns: 112px minmax(0, 1fr); gap: 5px 10px; }
  .dr-doc .kv dt, .dr-doc .kv dd { line-height: 1.3; }
  .dr-doc .dr-rows li { padding: 6px 0; }
  .dr-doc .hbar, .dr-doc .dr-bars .hbar { grid-template-columns: 190px minmax(0, 1fr) 24px; gap: 8px; padding: 1px 0; font-size: 9.5pt; }
  .dr-doc .hbar .track { height: 10px; }
  .dr-doc .dr-grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
  .dr-doc .dr-grid2 .dr-sec + .dr-sec { margin-top: 0; }
  .dr-doc .dr-sec + .dr-sec { margin-top: 10px; }
  .dr-doc .timeline li { padding-bottom: 10px; }
  .dr-doc .notice { padding: 8px 12px; }
  .dr-doc .hbar .fill { background: #222; }
  .dr-doc .hbar .fill.good { background: #1f5a38; }
  .dr-doc .hbar .fill.gold { background: #d9a441; }
  .dr-doc .hbar .fill.bad { background: #8f2a20; }
}
