:root {
  color-scheme: light;
  font-family: Inter, Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f4f7f6;
  color: #17211d;
  --page-bg: #f4f7f6;
  --surface: #ffffff;
  --surface-strong: #edf6f2;
  --text-muted: #5a6862;
  --line: #d6e0dc;
  --line-strong: #aab9b2;
  --primary: #176b4d;
  --primary-strong: #10543c;
  --primary-soft: #dff4e8;
  --danger: #9d1c1c;
  --danger-soft: #ffe3e3;
  --focus: #bfe8d3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #eaf3ef 0, var(--page-bg) 220px),
    var(--page-bg);
}

a {
  color: inherit;
}

.page {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 18px 12px 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.intro {
  margin: 0 0 24px;
  max-width: 56ch;
  color: var(--text-muted);
  line-height: 1.5;
}

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

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 12px 18px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(23, 107, 77, 0.16);
}

.button:active {
  transform: translateY(1px);
}

.button.secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: #17211d;
  box-shadow: none;
}

.entry-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

label,
.table-label {
  font-weight: 700;
}

.table-label {
  margin: 0 0 6px;
}

.helper-text {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: #17211d;
  font: inherit;
  font-size: 1rem;
}

input:focus {
  border-color: var(--primary);
  outline: 3px solid var(--focus);
}

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(32, 47, 41, 0.08);
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #e7eeeb;
  padding: 8px 6px;
  text-align: left;
}

th {
  background: var(--surface-strong);
  color: #26352f;
  font-size: 0.9rem;
  font-weight: 800;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.m-cell {
  width: 42px;
  font-weight: 700;
  text-align: center;
}

.total-row td {
  background: #eef8f3;
  font-weight: 700;
}

th:first-child,
td:first-child {
  width: 42px;
  text-align: center;
}

th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  width: auto;
}

th:nth-child(4),
td:nth-child(4) {
  width: 68px;
}

td input {
  min-height: 44px;
  padding: 9px 8px;
  text-align: right;
}

.validation-cell,
[data-validation-summary] {
  text-align: center;
}

.validation-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.validation-icon.valid {
  background: var(--primary-soft);
  color: var(--primary);
}

.validation-icon.invalid {
  background: var(--danger-soft);
  color: var(--danger);
}

.message {
  min-height: 28px;
  color: var(--danger);
  font-weight: 700;
  line-height: 1.4;
}

.message.success {
  color: var(--primary);
}

@media (min-width: 680px) {
  .page {
    padding-top: 40px;
  }

  .brand {
    font-size: 2rem;
  }

  th,
  td {
    padding: 10px;
  }

  th:first-child,
  td:first-child {
    width: 72px;
  }

  th:nth-child(4),
  td:nth-child(4) {
    width: 120px;
  }
}

@media (max-width: 520px) {
  .topbar .button {
    min-height: 40px;
    padding: 8px 12px;
  }

  .entry-form > .actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 0 -12px -24px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: rgba(244, 247, 246, 0.96);
  }

  .entry-form > .actions .button {
    width: 100%;
  }
}
