:root {
  color-scheme: light;
  --ink: #18324f;
  --muted: #607086;
  --line: #b7c7d8;
  --blue: #1769aa;
  --pale: #eaf3f8;
  --warn: #fff4d6;
  --warn-line: #d89d1b;
  --error: #9f2531;
  --ok: #26754b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #f2f5f7;
}

button, input, select, textarea { font: inherit; }

button, select {
  border: 1px solid #8fa7bd;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: .58rem .8rem;
}

button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--blue); background: #f4f9fc; }
button:disabled { cursor: not-allowed; opacity: .55; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem max(1.2rem, calc((100vw - 1500px) / 2));
  color: white;
  background: linear-gradient(110deg, #112f50, #1769aa);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.8rem; }
h2 { margin-bottom: .4rem; }
.eyebrow { margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 700; }
.prototype-badge { padding: .65rem .9rem; border: 1px solid #fff8; border-radius: 999px; font-weight: 700; font-size: .78rem; }
.account-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; min-width: 0; max-width: 100%; }
.account-state { margin: 0; font-weight: 700; font-size: 1rem; }
.header-link, #header-sign-out, #header-close-app {
  color: white;
  background: transparent;
  border: 1px solid #ffffffcc;
  border-radius: 999px;
  padding: .45rem .9rem;
  text-decoration: none;
  font-weight: 700;
}
#admin-login #admin-status { grid-column: 1 / -1; }
.sign-in-feedback { width: min(1500px, calc(100% - 2rem)); margin: 1rem auto 0; }
.sign-in-feedback:empty { display: none; }

main { width: min(1500px, calc(100% - 2rem)); margin: 1rem auto 2rem; }
.notice { padding: .85rem 1rem; border: 1px solid; border-radius: 7px; }
.warning { background: var(--warn); border-color: var(--warn-line); color: #6a4b00; }
.neutral { background: #eef5fa; border-color: #aac3d5; }
.error { background: #fff0f1; border-color: #d79ba2; color: var(--error); }
.success { background: #edf8f1; border-color: #a7ceb7; color: var(--ok); }

.steps { display: flex; gap: .5rem; margin: 1rem 0; flex-wrap: wrap; }
.step.active { color: white; background: var(--blue); border-color: var(--blue); }

.panel { padding: 1rem; background: white; border: 1px solid #dce3e8; border-radius: 9px; box-shadow: 0 4px 18px #1b3e5d0c; }
.hidden { display: none !important; }
.office-confirm {
  position: fixed;
  inset: 0;
  margin: auto;
  z-index: 20;
  width: min(36rem, calc(100% - 2rem));
  height: fit-content;
  padding: 1.25rem;
  background: #fff;
  border: 2px solid #1f4e79;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.office-report-tools { margin-top: 1rem; }
.save-state { font-weight: 700; margin: .35rem 0; }
.save-state-busy { color: #1f4e79; }
.save-state-ok { color: #1d6b3a; }
.save-state-error { color: #9b1c1c; }
.saved-change-box {
  margin: .4rem 0 .8rem;
  padding: .7rem;
  border: 2px solid #9b1c1c;
  border-radius: 6px;
  background: #fff6f6;
}
.saved-change-box button { margin-top: .5rem; }
.shared-apply { margin-top: 1rem; }
.shared-apply summary { cursor: pointer; font-weight: 700; }
body.signed-out #admin-first-setup:not(.hidden) { display: grid !important; }
.row-reports { min-width: 16rem; background: #f8fbfc; }
.row-report-tools { display: grid; gap: .35rem; }
.row-report-line { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.report-count { font-weight: 700; }
.fleet-export { margin-top: 1rem; padding: 1rem; border: 1px solid #b7c7d8; border-radius: 7px; background: #f8fbfc; }
.field-gap { color: #9b1c1c; font-size: .85rem; margin: .25rem 0; }
.field-missing { outline: 2px solid #9b1c1c; }
.office-hidden { display: none !important; }
body.signed-out .steps,
body.signed-out #worksheet-section,
body.signed-out #reports-section,
body.signed-out #register-section,
body.signed-out #jobcard-section,
body.signed-out #diagnostics-panel { display: none; }
body.signed-out #admin-section { display: block !important; }
body.signed-out #admin-login:not(.hidden) { display: grid !important; }
body.signed-out #account-state,
body.signed-out #header-sign-out, body.signed-out #header-close-app { display: none !important; }
body:not(.signed-out) #header-sign-in,
body:not(.signed-out) .sign-in-banner,
body:not(.signed-out) #admin-login,
body:not(.signed-out) #admin-first-setup { display: none !important; }
.panel-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.panel-heading > * { min-width: 0; max-width: 100%; }
.panel-heading h2 { margin-bottom: 0; }
.variant-control { min-width: 0; max-width: 100%; }
.variant-control select { width: 100%; max-width: 22rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
label { display: grid; gap: .32rem; font-size: .78rem; font-weight: 650; }
input, textarea {
  min-width: 0;
  border: 1px solid #aebdcc;
  border-radius: 4px;
  padding: .45rem .5rem;
  color: #172b3e;
  background: white;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: .75rem; margin-bottom: 1rem; }
.form-grid > * { min-width: 0; max-width: 100%; }
.draft-manager {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .75rem;
  margin-bottom: .7rem;
  padding: .8rem;
  border: 1px solid #b7c7d8;
  background: #f8fbfc;
}
.draft-manager > label { flex: 1 1 16rem; min-width: 0; max-width: 100%; }
.draft-manager > button { flex: 0 1 auto; max-width: 100%; }
.finish-clear-storage-warning {
  flex: 1 1 22rem;
  margin: 0;
  padding: .55rem .7rem;
  border: 2px solid #b4232f;
  border-radius: 6px;
  color: #8f1723;
  background: #fff0f1;
  font-weight: 700;
}
.draft-manager input,
.draft-manager select {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .74rem; }
th, td { border: 1px solid var(--line); padding: .25rem; vertical-align: top; }
th { min-width: 95px; background: var(--pale); text-align: left; }
th:first-child { min-width: 38px; }
td input, td select { width: 100%; max-width: 100%; min-width: 0; padding: .35rem; overflow: hidden; text-overflow: ellipsis; }
td button { max-width: 100%; min-width: 0; }
td select[data-key="jobCardCategory"] { min-width: 168px; }
td.row-number { text-align: center; font-weight: 700; color: var(--muted); }
.worksheet-table-wrap {
  max-height: 72vh;
  overflow-x: scroll;
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
  border: 1px solid var(--line);
  break-after: page;
}
#worksheet-table { min-width: 2500px; }
#worksheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}
@media print {
  .worksheet-table-wrap { max-height: none; overflow: visible; border: 0; }
  #worksheet-table { min-width: 0; }
  #worksheet-table thead { display: table-header-group; }
}
.hint { color: var(--muted); font-size: .83rem; margin: .7rem 0 0; }
.result-reason { display: block; width: 11rem; min-height: 2.6rem; margin-top: .25rem; }
.checklist-editor { display: grid; gap: .45rem; margin-top: .7rem; }
.checklist-editor label { display: grid; gap: .15rem; }

.attachment-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.attachment-list { display: grid; gap: .6rem; margin-top: .8rem; }
.attachment {
  display: grid;
  grid-template-columns: 1.5fr repeat(4, .7fr) auto;
  gap: .5rem;
  padding: .7rem;
  border: 1px solid #c7d4df;
  border-radius: 6px;
  font-size: .8rem;
}
.attachment-conflict { border-color: #d79ba2; background: #fff7f7; }
.attachment strong { overflow-wrap: anywhere; }
.tag { align-self: start; justify-self: start; max-width: 100%; padding: .15rem .4rem; border-radius: 6px; background: #e8f1f7; font-size: .68rem; font-weight: 700; overflow-wrap: anywhere; }
.row-conflict { background: #fff0f1; }

.real-upload, .correction-review, .batch-review { margin: 1rem 0; padding: 1rem; border: 1px solid #b7c7d8; border-radius: 7px; background: #f8fbfc; }
.real-upload h3, .correction-review h3, .batch-review h3 { margin-bottom: .35rem; }
.real-upload p { color: var(--muted); font-size: .82rem; }
.upload-controls { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .7rem; }
.simulation-tools { margin: 1rem 0; padding: .6rem .8rem; border: 1px dashed #aebdcc; border-radius: 6px; }
.simulation-tools summary { cursor: pointer; font-weight: 700; }
.review-heading { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.review-issues { color: var(--error); font-weight: 700; }
.correction-table { min-width: 850px; }
.correction-table th { width: 180px; min-width: 180px; }
.correction-table td:nth-child(2) { width: 320px; color: var(--muted); }
.correction-table code { white-space: normal; overflow-wrap: anywhere; }
.correction-table input { width: 100%; }
.vehicle-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .8rem; margin: 1rem 0; }
.vehicle-card { padding: .8rem; border: 1px solid #b7c7d8; border-radius: 7px; background: white; }
.vehicle-card p { margin: 0 0 .4rem; font-size: .86rem; }
.vehicle-card-ready { border-color: #8fbea4; background: #f3fbf6; }
.vehicle-card-blocked { border-color: #d7b56a; background: #fff8e8; }
.vehicle-card-selected { outline: 2px solid var(--blue); }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .5rem 0; padding: .5rem; border: 1px dashed #b7c7d8; background: #f8fbfc; font-size: .82rem; }
.generate-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .7rem 0; }
.completion-board { display: grid; gap: 1rem; margin: 1rem 0; }
.completion-card { padding: 1rem; border: 1px solid #b7c7d8; border-radius: 7px; background: #fff; }
.completion-card h3 { margin-bottom: .4rem; }
.completion-card ul { margin: .4rem 0 .8rem 1.1rem; }
.completion-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .7rem; }
#missing-items-list ul, #owner-decisions-list ul { margin: .4rem 0 0 1.1rem; }
.diagnostics { margin: 1.2rem max(1.2rem, calc((100vw - 1500px) / 2)) 1.5rem; padding: .8rem 1rem; border: 1px dashed #aebdcc; border-radius: 6px; background: #f8fbfc; }
.diagnostics summary { cursor: pointer; font-weight: 700; }
.batch-record { display: flex; grid-template-columns: none; gap: .6rem; align-items: start; margin: .45rem 0; padding: .55rem; border: 1px solid #a7ceb7; border-radius: 5px; background: #edf8f1; }
.batch-record input { margin-top: .2rem; }
.batch-record-blocked { border-color: #d79ba2; background: #fff0f1; }
.exception-list, .queue-list { margin: .6rem 0 1rem; font-size: .86rem; }
.exception-item, .queue-item { margin: .35rem 0; padding: .45rem .6rem; border-radius: 5px; }
.exception-item { border: 1px solid #d79ba2; background: #fff0f1; }
.queue-item-matched { border: 1px solid #8fbea4; background: #f3fbf6; }
.queue-item-unmatched, .queue-item-failed { border: 1px solid #d7b56a; background: #fff8e8; }
#bulk-upload-progress { width: 100%; height: .7rem; margin: .4rem 0 .7rem; }

.jobcard {
  width: 210mm;
  max-width: 100%;
  height: 297mm;
  margin: auto;
  padding: 6mm;
  border: 2px solid #557ca0;
  background: white;
  box-shadow: 0 10px 30px #18324f1f;
  overflow: visible;
  font-size: 8.3pt;
}
.jc-head {
  display: grid;
  grid-template-columns: 156px 1fr 190px;
  align-items: stretch;
  min-height: 148px;
  border-top: 3px solid #aeb4ba;
  border-bottom: 4px solid #b5121b;
  background: #f3f4f5;
}
.jc-brand-panel { display: grid; place-items: center; background: #121417; }
.jc-logo { width: 142px; height: 142px; object-fit: contain; }
.jc-title { display: grid; place-content: center; text-align: center; color: #23272b; }
.jc-title h3 { margin: 0; font-size: 1.75em; }
.jc-title p { margin: .2rem 0 0; }
.jc-ref { display: grid; align-content: center; justify-items: end; padding: 8px 10px; color: #b5121b; font-weight: 800; text-align: right; line-height: 1.35; }
.category-key { margin: .6rem 0; padding: .45rem .7rem; background: #fff4d6; border: 1px solid #d89d1b; color: #6a4b00; font-weight: 800; }
.jc-section-title { margin-top: 3px; padding: 2px 4px; background: #dcecf3; color: #1b5685; font-weight: 800; }
.jc-details { display: grid; grid-template-columns: 1.4fr 1fr 1fr; border: 1px solid #86a5bf; }
.jc-details span { min-height: 20px; padding: 2px 3px; border-right: 1px solid #a9bdce; border-bottom: 1px solid #a9bdce; overflow-wrap: anywhere; }
.jc-details span:nth-child(3n) { border-right: 0; }
.jc-expiry { padding: 3px 4px; border: 1px solid #86a5bf; border-top: 0; background: #f8fbfc; }
.jc-expiry-conflict { border-color: #d79ba2; background: #fff0f1; color: var(--error); }
.jc-options { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #86a5bf; border-top: 0; }
.jc-options div { display: grid; gap: 1px; padding: 3px; border-right: 1px solid #a9bdce; }
.jc-options div:last-child { border-right: 0; }
.jc-categories { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid #86a5bf; }
.jc-categories span { display: flex; gap: 4px; align-items: center; justify-content: center; padding: 3px; border-right: 1px solid #a9bdce; text-align: center; }
.jc-categories span:last-child { border-right: 0; }
.outline-box { display: inline-block; flex: 0 0 8px; width: 8px; height: 8px; border: 1px solid currentColor; background: white; position: relative; }
.outline-box.ticked::after { content: ""; position: absolute; left: 1px; top: -1px; width: 3px; height: 6px; border-right: 1.5px solid #b5121b; border-bottom: 1.5px solid #b5121b; transform: rotate(45deg); }
.jc-category-selected { font-weight: 700; }
.jc-alert { margin: 3px 0; padding: 3px 4px; border: 2px solid #d6a129; background: #fff8df; color: #6e4c00; font-weight: 650; }
.jc-table { table-layout: fixed; font-size: 7.2pt; line-height: 1.1; }
.jc-table th, .jc-table td { text-align: center; min-width: 0; height: 17px; padding: 1px 2px; }
.jc-table th:first-child, .jc-table td:first-child { text-align: left; width: 22%; min-width: 100px; }
.jc-table td { overflow-wrap: anywhere; }
.jc-notes { min-height: 25px; padding: 3px; border: 1px solid #86a5bf; border-top: 0; overflow-wrap: anywhere; }
.jc-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-top: 3px; }
.jc-summary div { min-height: 40px; padding: 4px; border: 1px solid #abc0d2; background: #e5f0f6; }
.jc-summary strong { display: block; margin-top: 3px; font-size: 1.2em; }
.jc-decision { margin-top: 3px; padding: 4px; border: 2px solid #c08d20; background: #fff9e8; }
.jc-decision-pass { border-color: #25834a; background: #e7f7ed; color: #176b37; }
.jc-decision-borderline-pass { border-color: #c08d20; background: #fff9e8; color: #8a6100; }
.jc-decision-fail { border-color: #b5121b; background: #fdebed; color: #9b1c1c; }
.jc-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-top: 3px; }
.jc-sign div { min-height: 52px; padding: 4px; border: 1px solid #7d9ab5; }
.release-row, .downloads { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; justify-content: center; margin-top: 1rem; }
.downloads a { color: var(--blue); }

.register-wrap { margin-top: 1rem; border: 1px solid #b7c7d8; }
.register-table { min-width: 1900px; table-layout: fixed; font-size: .64rem; }
.register-table th { min-width: 58px; text-align: center; vertical-align: middle; }
.register-table th:nth-child(2) { width: 160px; }
.register-table th:nth-child(4) { width: 130px; }
.register-table td { min-width: 58px; overflow-wrap: anywhere; }
.register-table tbody tr:nth-child(even) { background: #f8fbfc; }
.register-table td:nth-last-child(-n+6) { background: #fffaf0; }
.register-ref { padding: .2rem .3rem; margin-top: .25rem; border-radius: 3px; color: var(--blue); font-size: .62rem; text-decoration: underline; }
.register-conflict { color: var(--error); background: #fff0f1 !important; font-weight: 700; }

.check-list { display: grid; grid-template-columns: repeat(2, minmax(250px, 1fr)); gap: .6rem; }
.check { padding: .75rem; border: 1px solid #b8cbd9; border-radius: 6px; background: #f8fbfc; }
.check::before { content: "✓"; display: inline-grid; place-items: center; width: 1.2rem; height: 1.2rem; margin-right: .45rem; border-radius: 50%; color: white; background: var(--ok); font-weight: 800; }
.check small { display: block; margin: .35rem 0 0 1.7rem; color: var(--muted); }
.check-fail { border-color: #d79ba2; background: #fff0f1; }
.check-fail::before { content: "×"; background: var(--error); }

footer { padding: 1rem; text-align: center; color: var(--muted); font-size: .76rem; }

@media (max-width: 800px) {
  .topbar, .panel-heading { align-items: stretch; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .attachment { grid-template-columns: 1fr 1fr; }
  .draft-manager { flex-direction: column; align-items: stretch; }
  .check-list { grid-template-columns: 1fr; }
  .jc-options, .jc-categories { grid-template-columns: 1fr 1fr; }
}

@page { size: A4 portrait; margin: 0; }
