:root {
  color-scheme: light;
  --ink: #141414;
  --muted: #5a5f68;
  --paper-width: min(96vw, 1400px);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: #e7eaee;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #1f2937;
  border-radius: 6px;
  padding: 0 14px;
  color: #fff;
  background: #1f2937;
  cursor: pointer;
}

button:hover {
  background: #111827;
}

.timesheet-app {
  width: 100%;
  padding: 18px;
}

.toolbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--paper-width);
  margin: 0 auto 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.toolbar p,
.toolbar h1 {
  margin: 0;
}

.toolbar p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.toolbar h1 {
  font-size: 22px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mobile-entry {
  display: none;
  max-width: var(--paper-width);
  margin: 0 auto 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
}

.mobile-day-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.mobile-day-tabs button,
.mobile-actions button {
  min-height: 44px;
  padding: 0 10px;
}

.mobile-day-tabs button {
  border-color: #d1d5db;
  color: #111827;
  background: #fff;
}

.mobile-day-tabs button.active {
  color: #fff;
  background: #1f2937;
}

.mobile-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mobile-form-grid label {
  display: grid;
  gap: 5px;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.mobile-form-grid input {
  min-height: 46px;
  width: 100%;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  padding: 0 11px;
  color: #111827;
  background: #fff;
  font-size: 17px;
  font-weight: 700;
}

.mobile-form-grid input[readonly] {
  color: #374151;
  background: #f3f4f6;
}

.mobile-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mobile-check {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  gap: 8px;
  font-weight: 700;
  background: #fff;
}

.mobile-check input {
  width: 20px;
  height: 20px;
}

.free-text-input {
  min-height: 38px;
  width: min(38vw, 220px);
  border: 1px solid #9ca3af;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

.signature-dialog {
  width: min(92vw, 680px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.32);
}

.signature-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.signature-panel {
  padding: 16px;
  background: #fff;
}

.signature-panel-head,
.signature-panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.signature-panel h2 {
  margin: 0;
  font-size: 20px;
}

.signature-panel select {
  min-height: 38px;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

.modal-signature-pad {
  display: block;
  width: 100%;
  height: 220px;
  margin: 14px 0;
  border: 2px solid #111827;
  border-radius: 6px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

.sheet-wrap {
  width: 100%;
  overflow: auto;
}

.sheet {
  position: relative;
  width: var(--paper-width);
  aspect-ratio: 2336 / 1648;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
}

.sheet-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  user-select: none;
}

.free-text-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.free-text-item {
  position: absolute;
  min-width: 28px;
  min-height: 20px;
  border: 1px dashed transparent;
  padding: 1px 4px;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.55);
  font-size: clamp(10px, 1vw, 17px);
  font-weight: 700;
  line-height: 1.2;
  white-space: pre;
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}

.free-text-item:focus,
.free-text-item:hover {
  border-color: #2563eb;
  outline: 0;
}

.free-signature-item {
  position: absolute;
  width: 16%;
  height: 4.2%;
  border: 1px dashed transparent;
  background: transparent;
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}

.free-signature-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
  pointer-events: none;
}

.free-signature-item:focus,
.free-signature-item:hover,
.free-signature-item.selected {
  border-color: #2563eb;
  outline: 0;
}

.field,
.cell-input {
  position: absolute;
  z-index: 1;
  border: 0;
  padding: 0 0.25%;
  color: #0f172a;
  background: transparent;
  font-size: clamp(10px, 1vw, 17px);
  font-weight: 700;
  outline: 1px solid transparent;
}

.field:focus,
.cell-input:focus {
  background: rgba(255, 255, 255, 0.72);
  outline-color: #2563eb;
}

.name-field {
  left: 10.2%;
  top: 19.7%;
  width: 24.8%;
  height: 2.9%;
}

.week-field {
  top: 27.75%;
  height: 2.75%;
  text-align: center;
}

.week-1 {
  left: 13.3%;
  width: 5.5%;
}

.week-2 {
  left: 19.2%;
  width: 7.2%;
}

.week-3 {
  left: 26.8%;
  width: 7.1%;
}

.rt-field {
  left: 56.8%;
  top: 34.1%;
  width: 9.1%;
  height: 2.9%;
  text-align: center;
}

.client-info-field {
  left: 66.2%;
  top: 34.1%;
  width: 30.3%;
  height: 2.9%;
}

.driver-signature {
  position: absolute;
  z-index: 1;
  left: 31.2%;
  top: 91.85%;
  width: 34.2%;
  height: 4.5%;
  object-fit: contain;
  object-position: left center;
  pointer-events: none;
}

.declaration-date-field {
  left: 72.0%;
  top: 95.1%;
  width: 12.5%;
  height: 2.2%;
}

.cell-input {
  height: 3.05%;
}

.date-cell {
  left: 4.6%;
  width: 4.5%;
  text-align: center;
}

.start-cell {
  left: 9.45%;
  width: 8.0%;
  text-align: center;
}

.break-from-cell {
  left: 17.75%;
  width: 5.35%;
  text-align: center;
}

.break-to-cell {
  left: 23.4%;
  width: 5.25%;
  text-align: center;
}

.finish-cell {
  left: 29.0%;
  width: 8.25%;
  text-align: center;
}

.work-cell {
  left: 37.55%;
  width: 8.1%;
}

.tick-cell {
  display: grid;
  place-items: center;
  padding: 0;
  color: #111;
  background: transparent;
  font-size: clamp(18px, 2vw, 34px);
  font-weight: 900;
}

.digi-cell {
  font-size: clamp(12px, 1.2vw, 20px);
}

.digi-cell {
  left: 46.0%;
  width: 3.8%;
}

.ana-cell {
  left: 50.15%;
  width: 6.35%;
}

.poa-cell {
  left: 56.85%;
  width: 4.0%;
}

.hours-cell {
  left: 61.1%;
  width: 5.0%;
  text-align: center;
}

.client-cell {
  left: 66.55%;
  width: 15.25%;
}

.print-cell {
  left: 82.25%;
  width: 14.25%;
}

.signature-pad {
  position: absolute;
  z-index: 2;
  left: 82.25%;
  width: 14.25%;
  height: 3.05%;
  background: transparent;
  cursor: crosshair;
  touch-action: none;
}

.signature-pad:focus {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.tick-input {
  position: absolute;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

@media (max-width: 760px) {
  .timesheet-app {
    padding: 10px;
  }

  .toolbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .mobile-entry {
    display: block;
  }

  .toolbar-actions button {
    flex: 1;
  }

  .free-text-input {
    width: 100%;
  }

  .sheet {
    width: 1120px;
  }

  .mobile-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

@media print {
  body {
    background: #fff;
  }

  .timesheet-app {
    padding: 0;
  }

  .toolbar {
    display: none;
  }

  .sheet-wrap {
    overflow: visible;
  }

  .sheet {
    width: 100vw;
    box-shadow: none;
  }

  .field,
  .cell-input,
  .free-text-item,
  .free-signature-item {
    background: transparent;
    border-color: transparent;
    outline: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
