:root {
  color-scheme: light;
  --ink: #1d2421;
  --muted: #66716c;
  --line: #d9e0dc;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --green: #2f5d50;
  --green-dark: #214237;
  --mint: #e8f2ed;
  --gold: #f4c95d;
  --red: #b44545;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #edf4ef 0%, #fbfcfa 36%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(35, 55, 44, 0.08);
  padding: 24px;
}

.login-panel h1 {
  font-size: 2.6rem;
}

.login-message {
  min-height: 1.4em;
  color: var(--red);
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
}

.topbar p {
  color: var(--muted);
  margin-top: 8px;
}

.summary,
.panel,
.table-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(35, 55, 44, 0.08);
}

.summary {
  padding: 18px;
  margin-bottom: 18px;
}

.family-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

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

input:focus,
select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(47, 93, 80, 0.14);
}

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

.summary-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--paper);
  min-height: 84px;
  display: grid;
  align-content: space-between;
}

.summary-grid span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.summary-grid strong {
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

.balance-card {
  background: #fff8df !important;
  border-color: #ead28a !important;
}

.status {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 750;
}

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

.panel,
.table-panel {
  padding: 16px;
}

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

.entry-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.entry-form button {
  grid-column: 1 / -1;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: white;
  padding: 9px 14px;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--green-dark);
}

.secondary,
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.secondary:hover,
.ghost:hover {
  background: var(--mint);
}

.danger {
  background: transparent;
  color: var(--red);
  border: 1px solid #efc2c2;
  min-height: 34px;
  padding: 5px 9px;
}

.danger:hover {
  background: #fff0f0;
}

.tables {
  display: grid;
  gap: 18px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

td.amount,
th.amount {
  text-align: right;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .family-settings,
  .summary-grid,
  .workspace,
  .entry-form {
    grid-template-columns: 1fr;
  }

  .secondary,
  .ghost,
  .panel-heading button {
    width: 100%;
  }
}
