:root {
  --ink: #1b2a4a;
  --paper: #f7f5f2;
  --accent: #c8532b;
  --line: #d8d2c8;
  --muted: #5c5f6e;
  --error: #a02020;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

h1 { font-size: 1.75rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.intro { color: var(--muted); margin-top: 0; }

form {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1.25rem;
}

.fields {
  display: grid;
  grid-template-columns: 1fr 110px 130px auto;
  gap: 0.75rem;
  align-items: end;
}

label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }

input {
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}

input:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

button {
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { background: #a8431f; }

.form-error { color: var(--error); font-size: 0.9rem; margin: 0.6rem 0 0; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.remove-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--error);
  font-size: 0.85rem;
  padding: 0.25rem 0.6rem;
}
.remove-btn:hover { background: #f6e8e8; }

.empty-note { color: var(--muted); font-style: italic; }

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
}
.total-label { font-size: 1.1rem; }
.total-value { font-size: 1.75rem; font-variant-numeric: tabular-nums; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .fields { grid-template-columns: 1fr 1fr; }
  .f-desc { grid-column: 1 / -1; }
  .add-btn { grid-column: 1 / -1; }
  th:nth-child(2), td:nth-child(2) { min-width: 0; }
  th, td { padding: 0.5rem 0.4rem; font-size: 0.85rem; }
}
