:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  --ink: #18252d;
  --muted: #62717a;
  --line: #d4dde2;
  --panel: #ffffff;
  --brand: #153b4f;
  --brand-strong: #0d2b3a;
  --accent: #d6a528;
  --soft: #edf3f6;
  --danger: #b42318;
  --ok: #16794c;
  --pending: #8a5a00;
  --bg: #f3f6f8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body.signed-in #loginPanel {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

#vehicleInput {
  text-transform: uppercase;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--brand-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-command,
.back-command {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-command:hover,
.back-command:hover {
  background: var(--soft);
}

.icon-command {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: transparent;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--brand);
  color: #fff;
}

.brand-block,
.header-actions,
.toolbar,
.page-heading,
.wizard-heading,
.section-heading,
.preview-toolbar,
.submit-bar,
.dialog-heading,
.dialog-actions,
.wizard-navigation {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
}

.brand-mark {
  width: 72px;
  height: 46px;
  object-fit: contain;
}

.app-header h1,
.page-heading h2,
.wizard-heading h2,
.section-heading h3,
.dialog-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 22px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.75;
}

.header-actions {
  gap: 10px;
}

.status-pill,
.record-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, 0.42);
}

.status-pill.online {
  background: var(--ok);
}

.status-pill.offline {
  background: var(--danger);
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.toolbar {
  justify-content: flex-end;
  gap: 10px;
  min-height: 38px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
}

.login-panel {
  display: grid;
  max-width: 520px;
  margin: 50px auto;
  gap: 4px;
}

.page-heading,
.wizard-heading,
.section-heading,
.preview-toolbar,
.submit-bar {
  justify-content: space-between;
  gap: 14px;
}

.page-heading,
.wizard-heading {
  margin-bottom: 16px;
}

.wizard-heading {
  align-items: flex-start;
}

.section-heading {
  margin-bottom: 18px;
}

.compact-heading {
  margin-top: 22px;
}

.supporting-copy,
.field-hint {
  color: var(--muted);
}

.supporting-copy {
  margin: -8px 0 18px;
}

.field-hint {
  font-size: 12px;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 15px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  font-weight: 400;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(21, 59, 79, 0.14);
  border-color: var(--brand);
}

input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  height: 20px;
  accent-color: var(--brand);
}

textarea {
  resize: vertical;
}

fieldset {
  min-width: 0;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
}

legend {
  padding: 0 7px;
  font-weight: 700;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.step {
  min-height: 52px;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--muted);
}

.step:last-child {
  border-right: 0;
}

.step span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  margin-right: 5px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.step.active {
  background: var(--brand);
  color: #fff;
}

.step.complete {
  background: var(--soft);
  color: var(--brand);
}

.wizard-step {
  min-height: 470px;
}

.wizard-navigation {
  position: sticky;
  z-index: 10;
  bottom: 0;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.96);
}

.date-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.date-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.team-grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.team-grid {
  display: grid;
  min-width: 720px;
}

.team-row,
.team-header {
  display: grid;
  grid-template-columns: 180px repeat(var(--date-count, 1), minmax(112px, 1fr));
}

.team-header {
  position: sticky;
  top: 0;
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

.team-cell {
  min-height: 72px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.team-cell:last-child {
  border-right: 0;
}

.employee-name {
  display: grid;
  align-content: center;
  gap: 5px;
  font-weight: 700;
}

.employee-name small {
  color: var(--muted);
  font-weight: 400;
}

.remove-worker {
  width: fit-content;
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.employee-day {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 6px;
  align-items: center;
}

.employee-day input[type="number"] {
  min-height: 34px;
  padding: 5px;
}

.overtime-label {
  grid-column: 2;
  font-size: 11px;
  color: var(--muted);
}

.paid-hours {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
}

.record-list,
.worksheet-list {
  display: grid;
  gap: 10px;
}

.blade-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.blade-chip {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.blade-chip button {
  min-height: 36px;
  border-radius: 0;
}

.blade-chip-label {
  background: #fff;
  color: var(--ink);
}

.blade-chip-label:hover {
  background: var(--soft);
}

.blade-chip-remove {
  width: 38px;
  padding: 0;
  background: var(--brand);
  font-size: 20px;
}

.work-day-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: var(--soft);
  text-align: center;
}

.work-complete-toggle {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fff;
}

.completion-note {
  margin-top: 10px;
}

.next-day-command {
  width: 100%;
  margin-top: 10px;
}

.day-photo-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fff;
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-command {
  display: inline-grid;
  min-height: 42px;
  margin: 0;
  place-items: center;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.file-command input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.photo-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--soft);
  font-size: 12px;
}

.record-card,
.worksheet-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
  background: #fff;
}

.record-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.record-card h4,
.worksheet-card h3 {
  margin: 0 0 5px;
}

.record-card p,
.worksheet-card p {
  margin: 4px 0;
}

.record-actions {
  display: flex;
  gap: 6px;
}

.record-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.delay-note {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  color: var(--pending);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.plant-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.plant-column {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.plant-column h4 {
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.plant-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
}

.plant-row input[type="text"] {
  grid-column: 2 / -1;
  min-height: 36px;
  padding: 5px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.signature-wrap {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

#signatureCanvas {
  display: block;
  width: 100%;
  height: 170px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  touch-action: none;
}

.signature-wrap button {
  margin-top: 9px;
}

.signature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.signature-actions button {
  margin-top: 0;
}

.saved-signature-preview {
  display: block;
  width: min(260px, 100%);
  max-height: 78px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  object-fit: contain;
}

.preview-toolbar {
  margin-top: 24px;
}

.sheet-preview {
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 16px;
  background: #dfe5e8;
}

.a4-sheet {
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  padding: 30px;
  background: #fff;
  color: #111;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  font-family: Arial, sans-serif;
}

.sheet-brand {
  display: grid;
  grid-template-columns: 120px 1fr 145px;
  gap: 16px;
  align-items: center;
  text-align: center;
}

.sheet-brand .sheet-logo {
  width: 118px;
  height: 78px;
  object-fit: contain;
}

.sheet-brand h2 {
  margin: 0;
  font-size: 28px;
}

.sheet-brand h3 {
  margin: 4px 0 0;
  font-size: 23px;
}

.sheet-number {
  border-bottom: 1px solid #111;
  padding: 7px;
  text-align: left;
}

.sheet-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 20px 0 12px;
}

.sheet-field {
  min-height: 31px;
  border-bottom: 1px solid #111;
  padding: 7px 5px;
  font-size: 12px;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid #111;
  padding: 5px;
  vertical-align: top;
}

.sheet-table th {
  background: #e8e8e8;
}

.sheet-table .sheet-work-header th {
  background: #e8e8e8;
  font-size: 9px;
  font-weight: 800;
}

.sheet-table .sheet-day-row td {
  padding: 0;
  background: #cfd5d8;
}

.sheet-day-band {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
}

.sheet-day-band span:last-child {
  max-width: 420px;
  text-align: right;
  font-weight: 700;
  white-space: normal;
}

.sheet-table .sheet-delay-row td {
  background: #fff7df;
  font-size: 9px;
}

.sheet-section-title {
  margin: 12px 0 0;
  border: 1px solid #111;
  padding: 6px;
  background: #d9d9d9;
  font-size: 12px;
  font-weight: 700;
}

.sheet-signature {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 18px;
  margin-top: 28px;
}

.sheet-signature > div {
  min-height: 62px;
  border-bottom: 1px solid #111;
  font-size: 11px;
}

.sheet-signature-value {
  margin-top: 14px;
}

.sheet-signature img {
  width: 100%;
  max-height: 52px;
  object-fit: contain;
}

.sheet-footer {
  margin-top: 22px;
  font-size: 10px;
  text-align: center;
}

.submit-bar {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

dialog {
  width: min(720px, calc(100% - 24px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fff;
}

dialog::backdrop {
  background: rgba(13, 43, 58, 0.58);
}

dialog form {
  padding: 20px;
}

.dialog-heading {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.dialog-close {
  border-color: var(--line);
  color: var(--ink);
}

.dialog-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.dynamic-fields {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.dynamic-fields label {
  grid-column: span 6;
  margin: 0;
}

.dynamic-fields .measurement-field {
  grid-column: span 4;
}

.dynamic-fields .high-level-field,
.dynamic-fields .location-field {
  grid-column: 1 / -1;
}

.high-level-field {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--soft);
}

.record-status.draft {
  background: #e8eef1;
  color: var(--ink);
}

.record-status.pending-sync,
.record-status.sync-failed {
  background: #fff1c9;
  color: var(--pending);
}

.record-status.synced {
  background: #dcf5e7;
  color: var(--ok);
}

@media (max-width: 720px) {
  .app-header {
    position: static;
  }

  .brand-mark {
    width: 62px;
    height: 40px;
  }

  .app-header h1 {
    font-size: 19px;
  }

  .shell {
    padding: 10px;
  }

  .toolbar {
    justify-content: space-between;
  }

  .two-column,
  .dynamic-fields {
    grid-template-columns: 1fr;
  }

  .dynamic-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dynamic-fields label {
    grid-column: 1 / -1;
  }

  .dynamic-fields .measurement-field {
    grid-column: span 1;
    font-size: 12px;
  }

  .dynamic-fields .high-level-field,
  .dynamic-fields .location-field {
    grid-column: 1 / -1;
  }

  .step {
    padding: 0 5px;
    font-size: 0;
  }

  .step span {
    margin: 0;
    font-size: 12px;
  }

  .wizard-heading {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .wizard-heading > .secondary-command {
    grid-column: 1 / -1;
  }

  .page-heading,
  .section-heading,
  .preview-toolbar,
  .submit-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .wizard-step {
    min-height: 0;
    padding: 15px;
  }

  .date-selector {
    grid-template-columns: 1fr;
  }

  .plant-row {
    grid-template-columns: 22px 1fr;
  }

  .plant-row input[type="text"] {
    grid-column: 2 / -1;
  }

  .plant-grid {
    grid-template-columns: 1fr;
  }

  .work-day-bar {
    grid-template-columns: auto 1fr;
  }

  .work-day-bar > div {
    grid-column: 2;
    grid-row: auto;
  }

  .a4-sheet {
    transform-origin: top left;
  }
}
