/* Check Sheets pages (Pages/CheckSheets). Ported from C:\Checksheets\mockup\checksheet-mockup.html.
   Everything is prefixed cs- so it can't affect other K-Track pages. OUT is blue, IN is red (as agreed). */
/* Colours live on :root (not .cs-page) because DxPopup dialogs are drawn outside .cs-page */
:root {
    --cs-brand: #184d9a; --cs-brand-soft: #e8eef8; --cs-line: #d9dee5; --cs-text: #1f2933; --cs-muted: #6b7785;
    --cs-ok: #1a7f37; --cs-bad: #c62828; --cs-out: #184d9a; --cs-in: #d32f2f; --cs-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.cs-page {
    color: var(--cs-text); font-size: 15px; line-height: 1.4; max-width: 1280px; margin: 0 auto; padding: 0 4px 40px;
}
.cs-page button { font: inherit; cursor: pointer; }
.cs-page input, .cs-page select, .cs-page textarea { font: inherit; color: inherit; }

/* top bar */
.cs-topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-radius: 8px; box-shadow: var(--cs-shadow); margin-bottom: 16px; }
.cs-topbar .cs-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
.cs-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--cs-brand); }
.cs-badge { background: var(--cs-brand-soft); color: var(--cs-brand); font-weight: 600; padding: 4px 10px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
.cs-badge.final { background: #e6f4ea; color: #14532d; }
.cs-badge.draft { background: #fff4d6; color: #7a5b00; }
.cs-badge.unsaved { background: #fdecea; color: var(--cs-in); }
.cs-badge.saved { background: #e6f4ea; color: var(--cs-ok); }
.cs-spacer { flex: 1; }
.cs-btn { border: 1px solid var(--cs-line); background: #fff; border-radius: 6px; padding: 8px 14px; min-height: 40px; white-space: nowrap; font: inherit; cursor: pointer; }
.cs-btn:hover:not(:disabled) { background: #f1f4f8; }
.cs-btn:disabled { opacity: .55; cursor: not-allowed; }
.cs-btn.primary { background: var(--cs-brand); border-color: var(--cs-brand); color: #fff; }
.cs-btn.primary:hover:not(:disabled) { background: #123b75; }
.cs-btn.final { background: var(--cs-ok); border-color: var(--cs-ok); color: #fff; }
.cs-btn.final:hover:not(:disabled) { background: #14622b; }
.cs-btn.danger { color: var(--cs-bad); border-color: #f0b4b4; }
.cs-btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.cs-progress { font-size: 13px; color: var(--cs-muted); white-space: nowrap; }
.cs-progress b.o { color: var(--cs-out); } .cs-progress b.i { color: var(--cs-in); }

.cs-tabs { display: flex; gap: 4px; padding: 0 16px; overflow-x: auto; border-top: 1px solid #edf0f4; }
.cs-tab { border: 0; background: none; padding: 12px 18px; border-bottom: 3px solid transparent; color: var(--cs-muted); font-weight: 600; white-space: nowrap; }
.cs-tab.on { color: var(--cs-brand); border-bottom-color: var(--cs-brand); }
.cs-tab small { font-weight: 400; margin-left: 4px; }
.cs-tab:disabled { opacity: .45; cursor: not-allowed; }

.cs-card { background: #fff; border-radius: 8px; box-shadow: var(--cs-shadow); padding: 16px 18px; margin-bottom: 16px; }
.cs-card h2 { margin: 0 0 10px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--cs-brand); font-weight: 700; }
.cs-card h2 .cs-hint { text-transform: none; letter-spacing: 0; color: var(--cs-muted); font-weight: 400; margin-left: 8px; }
.cs-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .cs-grid2 { grid-template-columns: 1fr; } }

.cs-banner { border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; }
.cs-banner.final { background: #e6f4ea; border: 1px solid var(--cs-ok); color: #14532d; font-weight: 600; }
.cs-banner.hist { background: #fff4d6; border: 1px solid #e0c36a; color: #7a5b00; font-size: 13px; }
.cs-banner.warn { background: #fff8e1; border: 1px solid #f0d27a; color: #6b5200; font-size: 14px; }
.cs-banner.error { background: #fdecea; border: 1px solid #f0b4b4; color: #8a1c1c; font-size: 14px; }
.cs-banner.ok { background: #e6f4ea; border: 1px solid #9fd3ad; color: #14532d; font-size: 14px; }
.cs-banner ul { margin: 4px 0 0; padding-left: 18px; }
.cs-hist { margin: 6px 0 0; padding-left: 18px; font-weight: 400; font-size: 13px; }
.cs-hist li { margin: 2px 0; }

/* layout picker */
.cs-picker h1 { margin: 6px 0 4px; font-size: 24px; }
.cs-picker p { color: var(--cs-muted); margin: 0 0 18px; }
.cs-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cs-pick { background: #fff; border: 2px solid transparent; border-radius: 8px; box-shadow: var(--cs-shadow); padding: 14px; text-align: left; }
.cs-pick:hover, .cs-pick:focus-visible { border-color: var(--cs-brand); outline: none; }
.cs-pick .thumb { height: 150px; display: flex; align-items: center; justify-content: center; border-radius: 6px; overflow: hidden; margin-bottom: 10px; }
.cs-pick .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cs-pick .code { display: inline-block; background: var(--cs-brand); color: #fff; font-weight: 700; border-radius: 4px; padding: 1px 8px; margin-right: 8px; }
.cs-pick .name { font-weight: 700; font-size: 17px; }
.cs-pick .sub { color: var(--cs-muted); font-size: 13px; margin-top: 4px; }

/* fields */
.cs-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px; }
.cs-fields .wide { grid-column: 1 / -1; }
label.cs-f { display: block; font-size: 12px; font-weight: 600; color: var(--cs-muted); text-transform: uppercase; letter-spacing: .03em; margin: 0; }
label.cs-f input, label.cs-f select, label.cs-f textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--cs-line); border-radius: 6px; background: #fff; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 15px; }
label.cs-f input:focus, label.cs-f select:focus, label.cs-f textarea:focus { outline: 2px solid var(--cs-brand); border-color: transparent; }
label.cs-f input[readonly], label.cs-f input:disabled, label.cs-f textarea:disabled, label.cs-f select:disabled { background: #f1f4f8; color: var(--cs-muted); }
label.cs-f.bad input, label.cs-f.bad textarea, label.cs-f.bad select { border-color: var(--cs-bad); background: #fff7f7; }
label.cs-f .cs-hint { display: block; margin-top: 3px; font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--cs-muted); }
/* Remarks: 7 lines of 70 characters, like the paper. A fixed-width font makes the box wrap exactly where the line counter
   (CheckSheetUi.RemarksLines) does, so anything allowed fits the box with no scroll bar. */
label.cs-f textarea.cs-remarks { font-family: Consolas, "Courier New", ui-monospace, monospace; font-size: 14px; line-height: 1.45; width: calc(70ch + 22px); max-width: 100%; resize: none; overflow-x: hidden; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
label.cs-f .cs-remarks-count { display: block; margin-top: 3px; font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--cs-muted); }
label.cs-f .cs-remarks-count.over { color: var(--cs-bad); font-weight: 600; }
label.cs-f .cs-err { display: block; color: var(--cs-bad); text-transform: none; letter-spacing: 0; font-weight: 500; margin-top: 3px; }
.cs-sheetno { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.cs-sheetno .pre { font-weight: 800; font-size: 20px; color: var(--cs-text); }
.cs-sheetno input { max-width: 170px; margin: 0 !important; }
.cs-subhead { font-size: 12px; font-weight: 700; margin: 4px 0 8px; }
.cs-subhead.o { color: var(--cs-out); } .cs-subhead.i { color: var(--cs-in); }
.cs-legend { font-size: 13px; color: var(--cs-muted); margin: 0 0 10px; }

/* checklist */
.cs-cl-head, .cs-cl-row { display: grid; grid-template-columns: 1fr 64px 64px; align-items: center; gap: 6px; }
.cs-cl-head { font-size: 12px; font-weight: 700; padding: 0 0 4px; border-bottom: 2px solid var(--cs-line); }
.cs-cl-head .o { color: var(--cs-out); text-align: center; } .cs-cl-head .i { color: var(--cs-in); text-align: center; }
.cs-cl-row { padding: 3px 0; border-bottom: 1px solid #edf0f4; }
.cs-cl-row .lbl { font-size: 14.5px; }
.cs-tg { width: 100%; min-height: 40px; border: 1.5px solid var(--cs-line); border-radius: 6px; background: #fff; font-size: 20px; font-weight: 700; line-height: 1; }
.cs-tg.tick { background: #e6f4ea; border-color: var(--cs-ok); color: var(--cs-ok); }
.cs-tg.cross { background: #fdecea; border-color: var(--cs-bad); color: var(--cs-bad); }
.cs-tg.in-col:not(.tick):not(.cross) { border-color: #f3c3c3; }
.cs-tg:disabled { cursor: not-allowed; opacity: .8; }

.cs-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-seg button { flex: 1; min-width: 44px; min-height: 40px; border: 1.5px solid var(--cs-line); background: #fff; border-radius: 6px; font-weight: 600; }
.cs-seg.o button.on { background: var(--cs-out); color: #fff; border-color: var(--cs-out); }
.cs-seg.i button.on { background: var(--cs-in); color: #fff; border-color: var(--cs-in); }
.cs-seg button:disabled { cursor: not-allowed; }

table.cs-tyres { width: 100%; border-collapse: collapse; }
table.cs-tyres th { text-align: left; font-size: 12px; color: var(--cs-muted); padding: 0 6px 4px; }
table.cs-tyres td { padding: 3px 4px; }
table.cs-tyres td:first-child { font-weight: 700; white-space: nowrap; padding-right: 10px; }
table.cs-tyres input { width: 100%; min-width: 70px; padding: 8px; border: 1px solid var(--cs-line); border-radius: 6px; }
table.cs-tyres input:disabled { background: #f1f4f8; }
.cs-tyre-wrap { overflow-x: auto; }

/* damage diagram */
.cs-dmg-wrap { position: relative; display: inline-block; max-width: 100%; border: 1px dashed var(--cs-line); border-radius: 6px; background: #fff; cursor: crosshair; }
.cs-dmg-wrap.locked { cursor: default; }
.cs-dmg-wrap img { display: block; max-width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.cs-mark { position: absolute; transform: translate(-50%, -50%); min-width: 26px; height: 26px; padding: 0 4px; border-radius: 13px; color: #fff; font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: grab; touch-action: none; user-select: none; }
.cs-mark:active { cursor: grabbing; }
.cs-mark.o { background: var(--cs-out); } .cs-mark.i { background: var(--cs-in); }
.cs-dmg-wrap.locked .cs-mark { cursor: default; }
.cs-pop { position: absolute; z-index: 5; background: #fff; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.28); padding: 8px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 250px; }
.cs-pop button { min-height: 44px; border: 1px solid var(--cs-line); background: #fff; border-radius: 6px; font-weight: 700; }
.cs-pop button small { display: block; font-weight: 400; font-size: 10px; color: var(--cs-muted); }
.cs-pop button:hover { background: var(--cs-brand-soft); }
.cs-pop .x { grid-column: 1 / -1; min-height: 32px; color: var(--cs-muted); font-weight: 400; }
.cs-legend-tbl { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 4px 12px; font-size: 13px; margin: 10px 0; }
.cs-legend-tbl b { display: inline-block; min-width: 26px; }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-chip { background: #eef1f5; border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.cs-chip.o { background: var(--cs-brand-soft); color: var(--cs-out); } .cs-chip.i { background: #fdecea; color: var(--cs-in); }
.cs-phase-seg { max-width: 300px; margin-bottom: 10px; }
.cs-phase-seg button.on.o { background: var(--cs-out); color: #fff; border-color: var(--cs-out); }
.cs-phase-seg button.on.i { background: var(--cs-in); color: #fff; border-color: var(--cs-in); }
.cs-yn { display: flex; gap: 8px; }
.cs-yn button { min-width: 72px; }
.cs-yn button.on { background: var(--cs-brand); color: #fff; border-color: var(--cs-brand); }
.cs-check { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; }
.cs-check input { width: 20px; height: 20px; }

/* attachments */
.cs-drop { position: relative; display: block; cursor: pointer; border: 2px dashed #aab4c2; border-radius: 8px; padding: 22px; text-align: center; color: var(--cs-muted); background: #fbfcfd; }
.cs-drop:hover { border-color: var(--cs-brand); background: var(--cs-brand-soft); }
.cs-drop.full { opacity: .5; pointer-events: none; }
.cs-drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cs-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.cs-file { border: 1px solid var(--cs-line); border-radius: 8px; overflow: hidden; background: #fff; }
.cs-file .pv { height: 140px; background: #eef1f5; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--cs-muted); cursor: pointer; }
.cs-file .pv img { width: 100%; height: 100%; object-fit: cover; }
.cs-file .pv .ext { font-size: 22px; letter-spacing: .04em; }
.cs-file .bd { padding: 8px; display: grid; gap: 6px; }
.cs-file .nm { font-size: 12px; color: var(--cs-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-file select, .cs-file input { width: 100%; padding: 6px 8px; border: 1px solid var(--cs-line); border-radius: 6px; font-size: 13px; }
.cs-file .acts { display: flex; gap: 6px; }
.cs-file .acts .cs-btn { flex: 1; }
.cs-counter { font-weight: 700; } .cs-counter.full { color: var(--cs-bad); }
.cs-nav { display: flex; justify-content: space-between; margin: 8px 0 24px; gap: 8px; }

/* dialogs (inside DxPopup) */
.cs-dlg ul { margin: 0 0 6px; padding-left: 18px; }
.cs-dlg li { margin: 3px 0; }
.cs-dlg li.warn { color: #7a5b00; }
.cs-dlg li.bad { color: var(--cs-in); font-weight: 600; }
.cs-dlg label { display: flex; gap: 10px; align-items: center; min-height: 40px; }
.cs-dlg input[type=checkbox] { width: 20px; height: 20px; }
.cs-dlg textarea { width: 100%; padding: 8px; border: 1px solid #d9dee5; border-radius: 6px; }
.cs-dlg .cs-err { color: #d32f2f; font-size: 13px; min-height: 18px; }

/* list page */
.cs-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; align-items: end; }
.cs-filters .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* filters changed since the last search: the list is stale until Search is pressed */
.cs-btn.primary.pending { background: #d97706; border-color: #d97706; animation: cs-pulse 1.6s ease-in-out infinite; }
.cs-btn.primary.pending:hover:not(:disabled) { background: #b45309; }
@keyframes cs-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, .55); } 50% { box-shadow: 0 0 0 7px rgba(217, 119, 6, 0); } }
@media (prefers-reduced-motion: reduce) { .cs-btn.primary.pending { animation: none; } }
.cs-status { display: inline-block; font-weight: 600; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.cs-status.Draft { background: #fff4d6; color: #7a5b00; }
.cs-status.Finalized { background: #e6f4ea; color: #14532d; }
.cs-pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }

@media (max-width: 600px) { .cs-topbar .cs-row, .cs-tabs { padding-left: 10px; padding-right: 10px; } .cs-card { padding: 12px; } }

/* ---------- print dialog (the PDF itself is made on the server) ---------- */
.cs-dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.cs-muted { color: var(--cs-muted); }
.cs-att-fields { display: contents; }   /* only groups a file's controls so they can be redrawn together */
