:root {
  color-scheme: light;
  --ink: #1f2a2b;
  --muted: #657475;
  --line: #d9e1df;
  --paper: #f7faf8;
  --panel: #ffffff;
  --daily: #2f6f73;
  --social: #8a5a44;
  --clothes: #6c6aa8;
  --emotion: #b06a72;
  --danger: #b04444;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
}

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

.login-card {
  width: min(100%, 420px);
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(47, 111, 115, .16);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(32, 67, 70, .16);
  padding: 24px;
}

.login-card h1 {
  margin: 4px 0 20px;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 13px;
}

.sync-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
}
.sync-panel p { flex-basis: 100%; overflow-wrap: anywhere; color: var(--muted); }
.sync-panel a { color: var(--daily); }
.undo-last { width: 100%; margin-top: 8px; }
button:disabled { opacity: .5; cursor: not-allowed; }

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.icon-button,
.plain-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  min-height: 40px;
  padding: 0 12px;
}

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

.budget-card {
  min-width: 0;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 13px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.budget-card span,
.budget-card small {
  color: var(--muted);
}

.budget-card strong {
  font-size: 29px;
  line-height: 1.1;
}

.budget-card.daily strong {
  color: var(--daily);
}

.budget-card.social strong {
  color: var(--social);
}

.budget-card.clothes strong {
  color: var(--clothes);
}

.budget-card.emotion strong {
  color: var(--emotion);
}

.budget-card.over strong {
  color: var(--danger);
}

.entry-panel,
.records-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  margin-bottom: 14px;
}

.amount-field,
.note-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.amount-field input,
.note-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.amount-field input {
  font-size: 25px;
}

.amount-field input:focus,
.note-field input:focus {
  border-color: var(--daily);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.14);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.category {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 8px;
}

.category.is-active {
  border-color: var(--daily);
  background: #e8f2f0;
  color: #17474a;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  margin-top: 12px;
  background: var(--daily);
  color: white;
  font-weight: 700;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.records {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.record {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.record:first-child {
  border-top: 0;
  padding-top: 0;
}

.record-title {
  font-weight: 700;
}

.record > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

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

.empty {
  color: var(--muted);
  line-height: 1.5;
  padding: 10px 0 4px;
}

@media (max-width: 430px) {
  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .budget-card strong {
    font-size: 24px;
  }
}
