:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --text: #16201d;
  --muted: #68736f;
  --line: #dbe4e0;
  --primary: #176b5d;
  --primary-dark: #0f4d43;
  --income: #1f7a4d;
  --expense: #b1423d;
  --warn: #c93c3c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: #10231f;
  color: white;
  display: flex;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 28px;
}

.brand {
  color: white;
  font-size: 20px;
  font-weight: 700;
}

.userbar,
.actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.page {
  margin: 0 auto;
  max-width: 1280px;
  padding: 24px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  background: #e9f5f1;
  border: 1px solid #b6dcd0;
  border-radius: 8px;
  padding: 10px 12px;
}

.message.error {
  background: #fff0ee;
  border-color: #f1b7b1;
}

.login-panel,
.entry-panel,
.filter-panel,
.summary-panel,
.records-panel,
.table-wrap,
.side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(20, 38, 34, 0.06);
}

.login-panel {
  margin: 80px auto;
  max-width: 420px;
  padding: 30px;
}

h1,
h2 {
  margin: 0 0 16px;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 16px;
  margin-top: 18px;
}

.stack,
.entry-form,
.filter-form {
  display: grid;
  gap: 14px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 6px;
}

.check-field {
  align-items: center;
  color: var(--text);
  display: flex;
  gap: 10px;
  min-height: 42px;
}

.check-field input {
  min-height: auto;
  width: auto;
}

.choice-field {
  align-content: start;
}

.other-input {
  display: none;
}

.other-input.is-visible {
  display: block;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 42px;
  padding: 9px 10px;
  width: 100%;
}

button,
.button {
  align-items: center;
  background: var(--primary);
  border: 0;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
}

.secondary,
.ghost {
  background: #e9efed;
  color: var(--text);
}

.ghost {
  min-height: 34px;
}

.secondary:hover,
.ghost:hover {
  background: #dce6e2;
}

.danger {
  background: var(--warn);
  margin-top: 16px;
}

.summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 24px;
}

.income {
  color: var(--income);
}

.expense {
  color: var(--expense);
}

.entry-panel,
.filter-panel {
  margin-bottom: 18px;
  padding: 20px;
}

.narrow {
  max-width: 860px;
}

.entry-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wide {
  grid-column: span 2;
}

.full-row {
  grid-column: 1 / -1;
}

.form-submit {
  align-self: end;
}

.form-submit button {
  min-width: 160px;
}

.filter-form {
  align-items: end;
  grid-template-columns: 2fr repeat(6, minmax(120px, 1fr)) auto auto auto;
}

.summary-panel {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 18px;
}

.records-panel {
  padding: 18px;
}

.table-wrap {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef4f2;
  color: #3d4a46;
  font-size: 13px;
}

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

.pill {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
}

.pill.income {
  background: #e1f4eb;
}

.pill.expense {
  background: #fae7e4;
}

.pill.confirmed {
  background: #e8eee9;
  color: #405047;
}

.pill.pending {
  background: #fff3d6;
  color: #8a5a00;
}

.table-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.table-actions form {
  margin: 0;
}

.table-actions .danger {
  margin-top: 0;
}

.small {
  font-size: 13px;
  line-height: 1;
  min-height: 32px;
  padding: 6px 10px;
}

.action-link {
  align-items: center;
  display: inline-flex;
  font-size: 13px;
  line-height: 1;
  min-height: 32px;
  padding: 6px 2px;
}

.empty,
.muted {
  color: var(--muted);
}

.side {
  align-self: start;
  padding: 18px;
}

.rowline {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 0;
}

.rowline span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rowline b {
  white-space: nowrap;
}

@media (max-width: 980px) {
  .summary-grid,
  .entry-form,
  .filter-form,
  .summary-panel {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .page {
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
  }
}
