:root {
  --ground: #edf0ef;
  --surface: #ffffff;
  --ink: #1c2528;
  --muted: #5a676b;
  --line: #cbd3d2;
  --teal: #1f4e52;
  --teal-dark: #163a3d;
  --gold: #b8892b;
  --error: #a63d2f;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  line-height: 1.45;
}

.top {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem 0.5rem;
  max-width: 1180px;
  margin: 0 auto;
}

h1, h2 {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.3rem; margin-bottom: 0.9rem; }

.mode {
  margin: 0;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  font-size: 0.85rem;
  color: #7a5a14;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.25rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 3rem;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.grid { display: grid; gap: 0.9rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.item-grid .wide { grid-column: span 3; }
.item-grid .field:not(.wide):not(.narrow) { grid-column: span 3; }
.item-grid .narrow { grid-column: span 2; }

.field { position: relative; margin-bottom: 0.2rem; }

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}

input, select, textarea {
  width: 100%;
  min-height: 48px; /* comfortable touch target on a tablet */
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 88px; resize: vertical; }

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

.hint { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); }

.results {
  position: absolute;
  z-index: 5;
  left: 0; right: 0;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28, 37, 40, 0.14);
  overflow: hidden;
}
.results li button {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 0.6rem 0.8rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.results li:last-child button { border-bottom: 0; }
.results li button:hover { background: var(--ground); }
.results .meta { display: block; font-size: 0.85rem; color: var(--muted); }

.item {
  margin: 0 0 1rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
}
.item-title { padding: 0 0.4rem; font-weight: 600; }

button {
  min-height: 48px;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.primary {
  width: 100%;
  border: 0;
  background: var(--teal);
  color: #fff;
}
.primary:hover { background: var(--teal-dark); }
.primary:disabled { background: var(--muted); cursor: progress; }
.secondary {
  border: 1.5px solid var(--teal);
  background: #fff;
  color: var(--teal);
}
.link {
  min-height: 40px;
  padding: 0.2rem 0.4rem;
  border: 0;
  background: none;
  color: var(--error);
  font-weight: 500;
  text-decoration: underline;
}

.summary {
  position: sticky;
  top: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.summary dl { margin: 0 0 1.1rem; }
.summary dl div {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-variant-numeric: tabular-nums; }
.summary .balance { border-bottom: 0; font-weight: 600; font-size: 1.15rem; }
.summary .balance dt { color: var(--ink); }

.status { margin: 0.8rem 0 0; font-size: 0.95rem; }
.status.ok { color: var(--teal); }

.errors {
  padding: 0.8rem 1rem;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: #fbefec;
  color: #6f241a;
}
.errors ul { margin: 0.3rem 0 0 1.1rem; padding: 0; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .summary { position: static; order: -1; }
  .grid.two, .item-grid { grid-template-columns: 1fr; }
  .item-grid .wide, .item-grid .field:not(.wide):not(.narrow), .item-grid .narrow { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
