/* Contracts, Preferences, the library file, and the printed sheets (run-out and driver job
 * sheets). Built on coach.css: its colours (var(--rf-…), var(--co-accent)) so both looks work. */

/* --- shared ------------------------------------------------------------------------------------- */

.pl-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 24px 32px; text-align: center; color: var(--rf-dim); }
.pl-empty p { margin: 0; max-width: 520px; line-height: 1.5; }
.pl-prefs > .co-page-head { position: sticky; top: -18px; z-index: 5; margin: -18px -24px 16px; padding: 18px 24px 14px; background: var(--rf-bg); box-shadow: 0 1px 0 var(--rf-line); }
.pl-note { margin: 0; font-size: 12px; line-height: 1.45; }
.pl-sub { margin-top: 4px; padding-top: 14px; box-shadow: inset 0 1px 0 var(--rf-line); }
.pl-sub .sec-h { margin: 0; }

/* --- a contract: its itinerary and running days ----------------------------------------------- */

.pl-leg { display: grid; grid-template-columns: 150px 1fr 128px; gap: 6px; }
.pl-leg > input:nth-of-type(3) { grid-column: 1 / -1; }
.pl-leg .est { grid-column: 1 / -1; font-size: 11.5px; color: var(--rf-dim); }

.pl-days { display: flex; flex-direction: column; gap: 16px; }
.pl-count { font-size: 13px; color: var(--rf-dim); }
.pl-count b { font-size: 20px; font-weight: 700; color: var(--co-accent-text); margin-right: 4px; font-variant-numeric: tabular-nums; }
.pl-daysbar { gap: 12px; flex-wrap: wrap; padding: 10px 0 0; box-shadow: inset 0 1px 0 var(--rf-line); }
.pl-key { width: 14px; height: 14px; border-radius: 4px; display: inline-block; box-shadow: inset 0 0 0 1.3px var(--sr-edge); }
.pl-key.on { background: var(--co-accent-deep); box-shadow: none; }
.pl-key.hol { box-shadow: inset 0 -3px 0 var(--rf-warn), inset 0 0 0 1.3px var(--sr-edge); }
.pl-key.sch { background: rgba(var(--sr-action-rgb), 0.18); }
.pl-key.hand { position: relative; }
.pl-key.hand::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--rf-text); }
.pl-cal { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px 22px; }
.pl-cal .days button { position: relative; }
.pl-cal .days button.sch:not(.on) { background: rgba(var(--sr-action-rgb), 0.14); }
.pl-cal .days button.out:not(.on) { opacity: 0.35; }
.pl-cal .days button.hand::after { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pl-cal .days button.on.hol { box-shadow: inset 0 -3px 0 var(--rf-warn); }

/* --- preferences -------------------------------------------------------------------------------- */

.pl-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.pl-sec { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pl-sec.wide { grid-column: 1 / -1; }
.pl-sec > header { display: flex; align-items: center; gap: 12px; }
.pl-sec > header .badge { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; color: var(--co-accent-text); background: rgba(var(--co-accent-rgb), 0.12); }
.pl-sec > header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.pl-sec > header p { margin: 3px 0 0; font-size: 12px; color: var(--rf-dim); }
.pl-unit { display: flex; align-items: center; gap: 8px; }
.pl-unit .input { flex: 1; min-width: 0; }
.pl-unit > span { flex: none; min-width: 52px; font-size: 12px; font-weight: 600; color: var(--rf-dim); }
.pl-rows { display: flex; flex-direction: column; }
.pl-row { display: flex; align-items: center; gap: 16px; padding: 11px 0; box-shadow: inset 0 -1px 0 var(--rf-line); }
.pl-row:first-child { padding-top: 0; }
.pl-row:last-child { box-shadow: none; padding-bottom: 0; }
.pl-row > div:first-child { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pl-row b { font-size: 13px; font-weight: 600; }
.pl-row small { font-size: 12px; color: var(--rf-dim); line-height: 1.4; }
.pl-look { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; justify-content: flex-end; }
.pl-list { display: flex; flex-direction: column; gap: 8px; }
.pl-li { display: flex; align-items: center; gap: 8px; }
.pl-li .input { flex: 1; min-width: 0; }
.pl-li.add { margin-top: 4px; flex-wrap: wrap; }
.pl-li.add .input[type="date"] { flex: 0 1 170px; }
.pl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 11px; border-radius: 15px; font-size: 12px; font-weight: 600; background: var(--sr-soft); color: var(--rf-text); white-space: nowrap; }
.pl-chip small { font-weight: 500; color: var(--rf-dim); font-size: 11px; }
.pl-chip button { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--rf-dim); }
.pl-chip button:hover { color: var(--rf-err); background: rgba(240, 72, 72, 0.14); }
.pl-sh { display: grid; grid-template-columns: 170px 170px 1fr 38px; gap: 8px; align-items: center; }
.pl-sh .field > span:empty { display: none; }
.pl-sh.head span { font-size: 11.5px; font-weight: 600; color: var(--rf-dim); }

/* --- the library file -------------------------------------------------------------------------- */

.pl-kpis { padding: 0 0 16px; }
.pl-file { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 14px; margin-bottom: 14px; border-radius: 10px; background: var(--rf-field); box-shadow: inset 0 0 0 1px var(--sr-edge); }
.pl-file > svg { color: var(--co-accent-text); }
.pl-file b { display: block; font-size: 13px; }
.pl-file small { display: block; margin-top: 2px; font-size: 12px; color: var(--rf-dim); }
.pl-warn { display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.45; color: var(--rf-text); background: rgba(255, 166, 38, 0.12); }
.pl-warn svg { color: var(--rf-warn); margin-top: 1px; }

@media (max-width: 1100px) {
  .pl-cols { grid-template-columns: minmax(0, 1fr); }
  .pl-sh { grid-template-columns: 1fr 1fr; }
}

/* --- designing a sheet: the sheet, and the panel beside it ------------------------------------- */

.ex-tpl { width: 230px; }
.ex-work { display: flex; gap: 18px; align-items: flex-start; }
.ex-sheets { flex: 1; min-width: 0; }
.sd { position: sticky; top: 0; flex: none; width: 340px; max-height: calc(100vh - 150px); display: flex; flex-direction: column; border-radius: 10px; background: var(--rf-card); border: 1px solid var(--rf-line); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }
.sd-top { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--rf-line); font-size: 14px; }
.sd-scroll { overflow: auto; padding: 4px 16px 16px; }
.sd-tpl { display: flex; flex-direction: column; gap: 10px; padding: 12px 0 14px; border-bottom: 1px solid var(--rf-line); }
.sd-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sd-note { margin: 0; font-size: 12px; }
.sd-part { border-bottom: 1px solid var(--rf-line); }
.sd-part > summary { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; cursor: pointer; font-weight: 700; font-size: 13px; list-style: none; }
.sd-part > summary::-webkit-details-marker { display: none; }
.sd-part[open] > summary .hub-icon { transform: rotate(180deg); }
.sd-body { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; }
.sd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sd input[type='range'] { width: 100%; accent-color: var(--co-accent); }
.sd-logo { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 8px; border-radius: 8px; border: 1px dashed var(--rf-line); }
.sd-logo img { max-height: 40px; max-width: 160px; background: #fff; border-radius: 4px; padding: 2px; }
.sd-colour { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.sd-colour input { width: 34px; height: 26px; padding: 0; border: 1px solid var(--rf-line); border-radius: 6px; background: none; cursor: pointer; }
.sd-colour span { flex: 1; }
.sd-colour code { font-size: 11.5px; color: var(--rf-faint); }
.sd-cols { display: flex; flex-direction: column; gap: 4px; }
.sd-col { display: flex; align-items: center; gap: 6px; }
.sd-col .input { flex: 1; min-width: 0; height: 30px; padding: 4px 8px; font-size: 12.5px; }
.sd-col input[type='checkbox'] { accent-color: var(--co-accent); width: 16px; height: 16px; }
.sd-col.off .input { opacity: 0.55; }

/* --- the sheets (paper on screen, and in print) ------------------------------------------------- */

.ex-controls .ex-date { width: 160px; }
.ex-who { width: 220px; }
.ex-table td:nth-child(2) small { white-space: nowrap; }
.paper {
  --rf-text: #071433; --rf-dim: #4a5677; --rf-faint: #7d869c; --rf-line: rgba(7, 20, 51, 0.12);
  max-width: 1120px; margin: 0 auto 22px; padding: 28px 34px 22px; border-radius: 6px;
  background: #fff; color: #071433; box-shadow: 0 6px 30px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(7, 20, 51, 0.08);
  font-size: 12.5px; line-height: 1.4;
}
.paper .co-wordmark b { color: var(--ex-ink, #071433); }
.ex-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 2.5px solid var(--ex-ink, #071433); }
.ex-brand { display: flex; flex-direction: column; gap: 7px; }
.ex-brand > span { font-size: 14px; font-weight: 700; }
.ex-brand > small { font-size: 11.5px; color: var(--rf-dim); white-space: pre-wrap; }
.ex-logo { display: block; width: auto; max-width: 320px; object-fit: contain; object-position: left center; }
.ex-notice { margin: -6px 0 14px; text-align: center; font-style: italic; font-size: 12.5px; }
.ex-title { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.ex-title h2 { margin: 0; font-size: 19px; font-weight: 700; color: var(--ex-ink, #071433); }
.ex-title b { font-size: 13.5px; color: var(--ex-accent, var(--co-accent-deep)); }
.ex-title span { font-size: 12px; color: var(--rf-dim); }
.ex-none { margin: 20px 0; color: var(--rf-dim); font-size: 13px; }
.ex-flag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; color: #b3261e; background: #fde8e7; border: 1px solid #b3261e; white-space: nowrap; }

.ex-table { width: 100%; border-collapse: collapse; }
.ex-table th { text-align: left; padding: 7px 8px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ex-ink, var(--rf-dim)); border-bottom: 1.5px solid var(--ex-ink, #071433); white-space: nowrap; }
.ex-table td { padding: 8px; vertical-align: top; border-bottom: 1px solid var(--rf-line); }
.paper.stripes .ex-table tr:nth-child(even) td { background: color-mix(in srgb, var(--ex-band, #eef1f8) 60%, #fff); }
.ex-table tr.flag td { background: #fff6f5; }
.ex-table td small { display: block; color: var(--rf-dim); font-size: 11px; margin-top: 1px; }
.ex-table .t, .ex-legs .t { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ex-table .n { text-align: right; font-variant-numeric: tabular-nums; }
.ex-table th.n { text-align: right; }
.ex-table .notes { max-width: 260px; font-size: 11.5px; color: var(--rf-dim); }
.ex-sub { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; font-size: 12px; }
.ex-sub b { width: 100%; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--rf-dim); }
.ex-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--rf-line); font-size: 10.5px; color: var(--rf-faint); }

.ex-foot .co-made { margin-left: auto; }
.co-made { display: inline-flex; align-items: center; gap: 4px; font-family: "Montserrat", Arial, sans-serif; font-size: 8.5px; color: #333; white-space: nowrap; }
.co-made b { font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; }
.co-made i { font-style: normal; font-weight: 800; letter-spacing: 0.02em; color: #f20d78; text-transform: uppercase; }

.ex-job { margin-bottom: 16px; border: 1px solid rgba(7, 20, 51, 0.18); border-radius: 6px; overflow: hidden; break-inside: avoid; page-break-inside: avoid; }
.ex-job-head { display: flex; align-items: center; gap: 12px; padding: 9px 12px; background: var(--ex-band, #eef1f8); border-bottom: 1px solid rgba(7, 20, 51, 0.14); font-size: 13.5px; }
.ex-time { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ex-type { font-size: 11px; font-weight: 700; color: var(--ex-accent, var(--co-accent-deep)); white-space: nowrap; }
.ex-trip .ex-job-head { background: color-mix(in srgb, var(--ex-band, #eef1f8) 50%, #fff); }
.ex-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 18px; padding: 10px 12px; }
.ex-facts:empty { display: none; }
.ex-facts i, .ex-notes i { display: block; font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--rf-faint); }
.ex-legs { width: 100%; border-collapse: collapse; border-top: 1px solid var(--rf-line); }
.ex-legs td { padding: 6px 12px; vertical-align: top; border-bottom: 1px solid var(--rf-line); }
.ex-legs tr:last-child td { border-bottom: 0; }
.ex-legs .t { width: 78px; }
.ex-legs .k { width: 120px; color: var(--rf-dim); }
.ex-legs small { display: block; color: var(--rf-dim); font-size: 11px; }
.ex-legs .notes { color: var(--rf-dim); font-size: 11.5px; }
.ex-notes { padding: 9px 12px; border-top: 1px solid var(--rf-line); background: #fffaf0; white-space: pre-wrap; }

@media print {
  html, body, #app { height: auto !important; background: #fff !important; color: #000 !important; }
  .co { position: static !important; display: block !important; overflow: visible !important; background: #fff !important; }
  .co-main { display: block !important; }
  .co-rail, .co-title, .ex-controls, .sd, .co-toasts, .co-menu, .co-scrim, .co-status { display: none !important; }
  .co-page { overflow: visible !important; padding: 0 !important; }
  .paper { max-width: none; margin: 0; padding: 0; border-radius: 0; box-shadow: none; color: #000; --rf-text: #000; --rf-dim: #333; --rf-faint: #555; --rf-line: #bbb; }
  .paper .co-wordmark b, .ex-head { color: #000; }
  .ex-driver { break-after: page; page-break-after: always; }
  .ex-driver.together { break-after: auto; page-break-after: auto; margin-bottom: 10mm; }
  .ex-driver:last-child { break-after: auto; page-break-after: auto; }
  .ex-work { display: block !important; }
  .ex-sheets { overflow: visible !important; }
  .ex-table tr { break-inside: avoid; page-break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
