:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --line: #d9ded5;
  --text: #18201c;
  --muted: #667268;
  --green: #1f7a4d;
  --blue: #2367a6;
  --gold: #a86418;
  --violet: #6f5aa8;
  --shadow: 0 1px 2px rgba(20, 29, 23, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: #fbfcf9;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.status-strip {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid #a5cfb8;
  border-radius: 999px;
  color: #155b39;
  background: #e9f6ef;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

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

.balance-tile,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.balance-tile {
  min-height: 112px;
  padding: 16px;
  border-top: 4px solid var(--green);
}

.balance-tile:nth-child(2) {
  border-top-color: var(--gold);
}

.balance-tile:nth-child(3) {
  border-top-color: var(--blue);
}

.balance-tile:nth-child(4) {
  border-top-color: var(--violet);
}

.balance-name {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.balance-value {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  font-weight: 800;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
  gap: 16px;
}

.panel {
  padding: 18px;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  font-size: 0.95rem;
}

.right {
  text-align: right;
}

.amount-cell {
  font-weight: 800;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#settingsForm {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input {
  min-height: 42px;
  width: 100%;
  border: 1px solid #bec7bf;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

input:focus {
  outline: 3px solid rgba(35, 103, 166, 0.18);
  border-color: var(--blue);
}

.button,
.small-button {
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.button {
  min-height: 42px;
  width: 100%;
  padding: 10px 12px;
}

.small-button {
  min-height: 32px;
  padding: 6px 10px;
  color: #163e68;
  border-color: #b7cbe0;
  background: #edf5fc;
}

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

.button.primary:hover {
  background: #17683f;
}

.button.secondary {
  color: #163e68;
  border-color: #b7cbe0;
  background: #edf5fc;
}

.button.secondary:hover {
  background: #e0eef9;
}

.button.slim {
  width: auto;
  min-width: 104px;
  min-height: 38px;
  padding: 8px 12px;
}

.button.quiet {
  color: var(--text);
  border-color: var(--line);
  background: #f9faf7;
}

.button.quiet:hover,
.small-button:hover {
  background: #eef2ec;
}

.divider {
  height: 1px;
  background: var(--line);
}

.safety-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(24px);
  opacity: 0;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid #b7cbe0;
  border-radius: 8px;
  color: #14395f;
  background: #eef6fd;
  box-shadow: var(--shadow);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 880px) {
  .balance-grid,
  .layout {
    grid-template-columns: 1fr;
  }

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

  .status-strip {
    align-items: flex-start;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    margin-top: 16px;
  }

  .topbar {
    padding: 18px 14px;
  }

  .panel {
    padding: 14px;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .button.slim {
    width: 100%;
  }

  th,
  td {
    padding: 10px 6px;
  }
}
