:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --panel: #ffffff;
  --text: #202522;
  --muted: #6f7772;
  --line: #dedbd2;
  --accent: #16735f;
  --accent-dark: #0f5848;
  --blue: #345d9d;
  --amber: #b8771a;
  --danger: #b3261e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  padding: 0 16px;
}

button:hover,
.icon-button:hover {
  background: var(--accent-dark);
}

.ghost {
  background: #ece9e1;
  color: var(--text);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel,
.panel,
.summary article,
.settlement {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-panel {
  width: min(400px, 100%);
  padding: 28px;
  box-shadow: 0 20px 50px rgba(32, 37, 34, 0.08);
}

.login-form {
  display: grid;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar h1,
.section-head h2,
.login-panel h1 {
  margin: 0;
}

.page {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 28px) 44px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.month-nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  margin-bottom: 14px;
}

.icon-button {
  display: grid;
  place-items: center;
  padding: 0;
}

.date-picker {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 110px 70px;
  gap: 10px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.tabs a {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 750;
}

.tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.summary {
  display: grid;
  grid-template-columns: 1.25fr repeat(3, 1fr);
  gap: 10px;
}

.summary article {
  padding: 16px;
}

.summary span,
.settlement span,
.section-head span,
.payment-name span {
  color: var(--muted);
  font-size: 0.86rem;
}

.summary strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

.main-total strong {
  font-size: 2rem;
}

.settlement {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  padding: 16px;
  border-left: 5px solid var(--amber);
}

.panel {
  margin-top: 12px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.add-panel {
  border-left: 5px solid var(--blue);
}

.add-form {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.8fr 1fr 1fr auto;
  gap: 9px;
  align-items: center;
}

.recap-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 12px;
}

.debt-list,
.compact-list {
  display: grid;
  gap: 8px;
}

.debt-list div,
.compact-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.debt-list span,
.compact-list span,
.excel-table small {
  color: var(--muted);
  font-size: 0.84rem;
}

.payments {
  display: grid;
  gap: 8px;
}

.payment-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.4fr) 120px 130px 150px minmax(130px, 1fr);
  gap: 9px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.payment-name strong,
.payment-name span {
  display: block;
}

.payment-name span {
  margin-top: 2px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.excel-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  background: #fff;
}

.excel-table th,
.excel-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: middle;
}

.excel-table th {
  background: #ede9df;
  color: #3d433f;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.excel-table td:last-child,
.excel-table th:last-child {
  border-right: 0;
}

.excel-table tr:last-child td {
  border-bottom: 0;
}

.excel-table tfoot td {
  background: #f7f3ea;
  font-weight: 800;
}

.excel-table td strong,
.excel-table td small {
  display: block;
}

.selected-row td {
  background: #eef4f2;
}

.year-strip {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.year-strip a {
  display: grid;
  gap: 7px;
  justify-items: center;
  min-width: 0;
  padding: 8px 4px;
  border-radius: 8px;
  color: var(--muted);
}

.year-strip a.active {
  background: #eef4f2;
  color: var(--text);
  font-weight: 800;
}

.year-strip i {
  display: block;
  width: 100%;
  max-width: 18px;
  min-height: 8px;
  border-radius: 999px 999px 2px 2px;
  background: var(--blue);
}

.year-strip strong {
  font-size: 0.72rem;
  white-space: nowrap;
}

.alert {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.alert.error {
  color: var(--danger);
  background: #fff3f1;
}

.alert.success {
  color: var(--accent-dark);
  background: #eef8f4;
}

@media (max-width: 900px) {
  .topbar,
  .settlement,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .summary,
  .add-form,
  .recap-grid,
  .payment-row {
    grid-template-columns: 1fr;
  }

  .date-picker {
    grid-template-columns: 1fr 92px 58px;
  }

  .year-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .debt-list div,
  .compact-list div {
    align-items: flex-start;
    flex-direction: column;
  }
}
