:root {
  color-scheme: light;
  font-family: Arial, sans-serif;
  --border: #333;
  --muted: #667085;
  --panel: #f6f8fb;
  --header: #c8c8c8;
  --blue: #1f7ae0;
  --red: #c0392b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef2f7;
  color: #222;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

button.danger {
  background: var(--red);
}

.app {
  width: min(1180px, calc(100% - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 40px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.toolbar h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.hidden-file {
  display: none;
}

.save-status {
  min-height: 20px;
  margin: -6px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.save-status.error {
  color: var(--red);
}

.save-status.ok {
  color: #157347;
}

.meta,
.summary {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.meta {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  padding: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.meta label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meta input,
.signature input {
  width: 100%;
  min-height: 34px;
  border: 1px solid #c7cdd8;
  border-radius: 4px;
  padding: 6px 8px;
  background: #fff;
}

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

.summary div {
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  text-align: right;
}

.sheet {
  overflow-x: auto;
  background: #fff;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

th,
td {
  border: 1px solid var(--border);
  padding: 5px;
  vertical-align: top;
}

th {
  background: var(--header);
  text-align: center;
}

td:nth-child(1),
td:nth-child(9) {
  text-align: center;
}

th:nth-child(1) { width: 50px; }
th:nth-child(2) { width: 118px; }
th:nth-child(3) { width: 270px; }
th:nth-child(4) { width: 145px; }
th:nth-child(5) { width: 96px; }
th:nth-child(6),
th:nth-child(7) { width: 130px; }
th:nth-child(8) { width: 170px; }
th:nth-child(9) { width: 52px; }

td input,
td select {
  width: 100%;
  min-height: 32px;
  border: 0;
  background: transparent;
}

td input.money {
  text-align: right;
}

td input:focus,
td select:focus,
.meta input:focus,
.signature input:focus {
  outline: 2px solid #8ec5ff;
  outline-offset: 0;
}

.delete-row {
  width: 34px;
  min-height: 32px;
  padding: 0;
  background: var(--red);
}

.signature {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
}

.signature > div {
  width: 300px;
  text-align: center;
}

.signature strong {
  display: block;
  margin-bottom: 64px;
}

@media (max-width: 820px) {
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
    width: 100%;
  }

  .meta,
  .summary {
    grid-template-columns: 1fr;
  }
}

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

  .app {
    width: 100%;
    padding: 0;
  }

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

  .sheet {
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 12px;
  }
}
