* {
  box-sizing: border-box;
}

:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #687685;
  --line: #d9e0e7;
  --soft: #eef3f6;
  --primary: #16745f;
  --primary-dark: #0f5a49;
  --danger: #b83333;
  --shadow: 0 16px 42px rgba(20, 35, 52, .12);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: #93a4b1;
}

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(245, 247, 249, .9), rgba(245, 247, 249, .9)),
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(22, 116, 95, .08) 34px 35px);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.muted,
.panel-title span,
.stat-control span,
.stat span {
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  outline: none;
}

input {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 230px;
  padding: 14px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 116, 95, .12);
}

.error {
  min-height: 22px;
  color: var(--danger);
}

.app {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.top-actions,
.input-actions,
.range-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20, 35, 52, .06);
  padding: 16px;
}

.input-panel {
  display: grid;
  gap: 12px;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: 160px 160px 150px repeat(5, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.comparison-panel {
  margin-top: 14px;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.compare-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 8px;
}

.compare-card span,
.compare-card em {
  color: var(--muted);
  font-style: normal;
}

.compare-card strong {
  font-size: 19px;
  line-height: 1.28;
}

.compare-card em.positive {
  color: var(--primary);
}

.compare-card em.negative {
  color: var(--danger);
}

.year-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat,
.stat-control,
.range-actions {
  min-height: 78px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.range-actions {
  align-content: center;
  align-items: center;
}

.stat strong {
  font-size: 24px;
  line-height: 1.1;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1060px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 7px;
  text-align: center;
  vertical-align: middle;
}

th:last-child,
td:last-child {
  border-right: 0;
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--soft);
  font-weight: 700;
}

td input {
  height: 34px;
  border-color: transparent;
  background: transparent;
  text-align: center;
}

td input:focus {
  border-color: var(--primary);
  background: #fff;
}

.owner {
  min-width: 260px;
}

.money,
.number {
  width: 96px;
}

td input[type="date"] {
  min-width: 140px;
}

.total-cell {
  font-weight: 700;
  white-space: nowrap;
}

.delete {
  color: var(--danger);
}

.row-actions {
  min-width: 150px;
}

.row-actions button {
  min-height: 32px;
  margin: 2px;
  padding: 0 9px;
}

.pending-delete {
  background: #fff7f0;
}

.confirm-delete {
  border-color: var(--danger);
}

.confirm-delete:disabled {
  color: var(--muted);
  border-color: var(--line);
  cursor: wait;
}

.cancel-delete {
  color: var(--muted);
}

.add-row {
  margin-top: 12px;
}

.save-state,
.parse-state {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 43, .38);
}

.modal-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head button {
  width: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 920px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .comparison-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 14px;
  }

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

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
