:root {
  --paper-width: 210mm;
  --paper-height: 297mm;
  --ink: #222;
  --card: rgba(255, 255, 255, 0.9);
  --line: #d8dfeb;
  --accent: #26435f;
  --bg-a: #e1ddd5;
  --bg-b: #f3efe8;
  --font: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 28%),
    linear-gradient(180deg, var(--bg-a) 0%, var(--bg-b) 100%);
}

body {
  padding: 18px;
}

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

button,
select,
input,
textarea {
  border-radius: 12px;
}

button {
  border: 1px solid #193149;
  background: #26435f;
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
}

button.secondary {
  background: #eef3f8;
  color: #203245;
}

button.danger {
  background: #fff4f4;
  border-color: #a23232;
  color: #8d2020;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

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

.toolbar-title h1 {
  font-size: 30px;
  font-weight: 500;
}

.eyebrow {
  color: #526171;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.toolbar-controls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.entry-picker {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.entry-picker select {
  min-width: 320px;
  padding: 10px 12px;
  border: 1px solid #c1ccda;
}

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

.status-message {
  min-height: 18px;
  margin: 0;
  color: #1d5b2f;
  font-size: 13px;
}

.status-message[data-state="error"] {
  color: #8a2323;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 18px;
  align-items: start;
}

.editor-card,
.preview-card {
  background: var(--card);
  border: 1px solid rgba(137, 148, 162, 0.35);
  box-shadow: 0 18px 45px rgba(42, 34, 22, 0.12);
  backdrop-filter: blur(10px);
}

.editor-card {
  border-radius: 24px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.editor-section {
  border: 1px solid #dde5ef;
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.editor-section h2,
.preview-head h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.editor-section label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.editor-section label span,
.section-head p,
.preview-head p {
  color: #637284;
}

.editor-grid {
  display: grid;
  gap: 12px;
}

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

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

.editor-grid .wide {
  grid-column: 1 / -1;
}

.editor-card input,
.editor-card textarea {
  width: 100%;
  border: 1px solid #cfd8e4;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
}

.editor-card textarea {
  resize: vertical;
  min-height: 92px;
}

.editor-card .large-area {
  min-height: 180px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.section-head h2,
.section-head p {
  margin: 0;
}

.employee-editor {
  border: 1px solid #d7dfeb;
  border-radius: 16px;
  overflow: hidden;
}

.employee-editor-head,
.employee-editor-row {
  display: grid;
  grid-template-columns: 1.7fr repeat(4, 0.7fr) 0.7fr;
}

.employee-editor-head {
  background: #f2f6fa;
  font-size: 12px;
  color: #526171;
}

.employee-editor-head span,
.employee-editor-row > * {
  padding: 10px;
  border-right: 1px solid #d7dfeb;
}

.employee-editor-head span:last-child,
.employee-editor-row > *:last-child {
  border-right: 0;
}

.employee-editor-row {
  border-top: 1px solid #d7dfeb;
}

.employee-editor-row input,
.employee-editor-row output {
  border: 0;
  border-radius: 0;
  padding: 10px;
}

.employee-editor-row output {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fbfcfe;
}

.preview-card {
  border-radius: 28px;
  padding: 18px;
}

.preview-head {
  margin-bottom: 12px;
}

.preview-head h2,
.preview-head p {
  margin: 0;
}

.preview-head p {
  margin-top: 6px;
  font-size: 13px;
}

.print-sheet {
  position: relative;
  width: var(--paper-width);
  min-width: var(--paper-width);
  height: var(--paper-height);
  margin: 0 auto;
  background: #fff url("/template.png") center/100% 100% no-repeat;
  box-shadow: 0 18px 50px rgba(24, 18, 12, 0.18);
}

.preview-text,
.preview-area,
.preview-employee-cell {
  position: absolute;
  font-size: 10.8px;
  line-height: 1.2;
  color: #111;
  white-space: pre-wrap;
  overflow: hidden;
}

.preview-text {
  padding: 0;
}

.preview-area {
  padding: 0;
}

.diary-number {
  top: 8.2mm;
  left: 164.5mm;
  width: 28mm;
  height: 5mm;
}

.project-name {
  top: 18.5mm;
  left: 10mm;
  width: 91mm;
  height: 7mm;
}

.project-location {
  top: 31.5mm;
  left: 10mm;
  width: 91mm;
  height: 7mm;
}

.investor {
  top: 44.7mm;
  left: 10mm;
  width: 91mm;
  height: 7mm;
}

.site-manager {
  top: 18.5mm;
  left: 105mm;
  width: 56mm;
  height: 7mm;
}

.date {
  top: 18.5mm;
  left: 168.5mm;
  width: 28mm;
  height: 7mm;
}

.weather-morning {
  top: 34.4mm;
  left: 125mm;
  width: 41mm;
  height: 5mm;
  text-align: center;
}

.weather-morning-temp {
  top: 34.4mm;
  left: 176mm;
  width: 12mm;
  height: 5mm;
  text-align: center;
}

.weather-afternoon {
  top: 40.6mm;
  left: 125mm;
  width: 41mm;
  height: 5mm;
  text-align: center;
}

.weather-afternoon-temp {
  top: 40.6mm;
  left: 176mm;
  width: 12mm;
  height: 5mm;
  text-align: center;
}

.preview-employee-rows {
  position: absolute;
  inset: 0;
}

.preview-employee-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.5mm;
}

.preview-employee-cell.name {
  justify-content: flex-start;
}

.preview-employee-cell.total {
  justify-content: center;
}

.material-notes {
  top: 57.4mm;
  left: 104mm;
  width: 78mm;
  height: 14mm;
}

.material-inbound {
  top: 57.8mm;
  left: 184.2mm;
  width: 6.5mm;
  height: 4.8mm;
  text-align: center;
}

.material-outbound {
  top: 57.8mm;
  left: 193mm;
  width: 6.5mm;
  height: 4.8mm;
  text-align: center;
}

.foreign-transport {
  top: 73.5mm;
  left: 104mm;
  width: 95mm;
  height: 15mm;
}

.mechanisms {
  top: 89.7mm;
  left: 104mm;
  width: 95mm;
  height: 17mm;
}

.daily-description {
  top: 113mm;
  left: 9.5mm;
  width: 190mm;
  height: 136mm;
}

.tests-performed {
  top: 257.5mm;
  left: 9.5mm;
  width: 190mm;
  height: 18mm;
}

.contractor-signature {
  top: 286.5mm;
  left: 61mm;
  width: 46mm;
  height: 5mm;
  text-align: center;
}

.client-signature {
  top: 286.5mm;
  left: 145mm;
  width: 46mm;
  height: 5mm;
  text-align: center;
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-card {
    overflow-x: auto;
  }
}

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

  html,
  body {
    width: 210mm;
    height: 297mm;
    padding: 0;
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .preview-card {
    display: block;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .print-sheet {
    margin: 0;
    box-shadow: none;
  }
}
