* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --soft: #e5e7eb;
  --line: rgba(17, 24, 39, 0.08);
  --green: #16a34a;
  --amber: #d97706;
  --orange: #ea580c;
  --red: #dc2626;
  --blue: #2563eb;
  --shadow: 0 16px 32px rgba(15, 23, 42, 0.10);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.08);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #f8fbff 0%, #eef3f8 48%, #f6f7fb 100%);
  color: var(--ink);
}

.app {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 20px 32px;
}

.hero {
  display: flex;
  min-height: 152px;
  margin-bottom: 16px;
  padding: 16px;
  flex-direction: column;
  justify-content: center;
  border-radius: 24px;
  color: #ffffff;
  background:
    linear-gradient(135deg, #12313f 0%, #1f6f68 48%, #53b89c 100%);
  box-shadow: 0 24px 32px rgba(31, 111, 104, 0.24);
}

.eyebrow {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.82);
}

h1 {
  margin: 8px 0 4px;
  text-align: center;
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}

.hero-status {
  margin: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.hero-meta {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.hero-meta p {
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.72);
}

.balance-card,
.current-balance-card,
.settings-card,
.tips-card {
  width: 100%;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.balance-card,
.current-balance-card {
  padding: 20px;
  border-radius: 20px;
}

.section-heading {
  margin-bottom: 12px;
}

h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.balance-line {
  display: grid;
  grid-template-columns: 24px 1fr 24px;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.balance-icon {
  font-size: 24px;
  line-height: 1;
}

.balance-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b 0%, #93c5fd 50%, #34d399 100%);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.16);
}

.balance-midpoint {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(255, 255, 255, 0.64);
  transform: translateX(-50%);
}

.balance-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  border: 4px solid #ffffff;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.24);
  transform: translate(-50%, -50%);
  transition: left 0.6s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}

.balance-marker.saving {
  background: var(--green);
}

.balance-marker.on-track {
  background: var(--green);
}

.balance-marker.fast {
  background: var(--orange);
}

.balance-marker.danger {
  background: var(--red);
}

.balance-status {
  display: inline-flex;
  min-height: 36px;
  margin: 0;
  padding: 0 16px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.10);
  color: #14532d;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.balance-status:not(.neutral)::first-letter {
  font-size: 24px;
  line-height: 1;
}

.balance-status.fast {
  background: rgba(234, 88, 12, 0.10);
  color: #9a3412;
}

.balance-status.saving,
.balance-status.on-track {
  background: rgba(22, 163, 74, 0.10);
  color: #14532d;
}

.balance-status.danger {
  background: rgba(220, 38, 38, 0.10);
  color: #991b1b;
}

.checkin-input-wrapper {
  display: block;
  margin-bottom: 0;
}

input {
  width: 100%;
  border: 1px solid var(--soft);
  outline: none;
  background: var(--surface-strong);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input:focus {
  border-color: rgba(37, 99, 235, 0.56);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.current-balance-card input {
  height: 60px;
  padding: 0 16px;
  border: 2px solid #D8DEE7;
  border-radius: 16px;
  background: #ffffff;
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.90);
  text-align: center;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.current-balance-card input:focus {
  border-color: #16a34a;
  box-shadow:
    0 0 0 4px rgba(22, 163, 74, 0.14),
    0 14px 28px rgba(15, 23, 42, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.current-balance-card input:hover {
  border-color: #C4CCD8;
}

button {
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #12313f 0%, #1f6f68 100%);
  color: #ffffff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 16px 24px rgba(31, 111, 104, 0.20);
}

button:active {
  transform: scale(0.99);
}

.checkin-feedback {
  min-height: 16px;
  margin-top: 4px;
}

.checkin-success {
  display: flex;
  min-height: 16px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.checkin-success.show {
  animation: successPulse 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.checkin-success.show::before {
  content: "✓";
  display: inline-block;
  font-weight: 900;
  animation: checkmark 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes successPulse {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes checkmark {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-45deg);
  }

  70% {
    transform: scale(1.15) rotate(5deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.settings-card,
.tips-card {
  overflow: hidden;
  border-radius: 18px;
}

.settings-card summary,
.tips-card summary {
  display: flex;
  height: 56px;
  padding: 20px;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.settings-card summary::-webkit-details-marker,
.tips-card summary::-webkit-details-marker {
  display: none;
}

.settings-card summary::after,
.tips-card summary::after {
  content: "⌄";
  font-size: 18px;
  font-weight: 800;
  color: var(--muted);
}

.settings-card[open] summary::after,
.tips-card[open] summary::after {
  content: "⌃";
}

.settings-card label {
  display: block;
  padding: 0 20px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.settings-card label:first-of-type {
  margin-top: 8px;
}

.field-label-row {
  display: flex;
  min-height: 32px;
  margin-bottom: 8px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label-row span {
  color: var(--ink);
}

.info-button {
  display: inline-flex;
  width: 32px;
  height: 32px;
  padding: 0;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.06);
  box-shadow: none;
  color: var(--muted);
  font-size: 14px;
  position: relative;
}

.tooltip {
  position: absolute;
  top: 40px;
  right: 0;
  width: min(240px, 72vw);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  white-space: normal;
  z-index: 2;
}

.info-button.open .tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.settings-card input {
  height: 56px;
  padding: 0 16px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 700;
}

.summary-row {
  display: flex;
  min-height: 56px;
  margin: 8px 20px 16px;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 16px;
  background: rgba(17, 24, 39, 0.04);
  font-size: 14px;
  font-weight: 700;
}

.summary-row strong {
  font-size: 16px;
}

.autosave-status {
  margin: 0 20px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.autosave-status.saved {
  color: var(--green);
}

.autosave-status.warning {
  color: var(--orange);
}

.tips-content {
  padding: 0 20px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.55;
}

.tips-content ol {
  margin: 16px 0 0;
  padding-left: 20px;
}

.tips-content li {
  margin-bottom: 16px;
}

.tips-content ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.tips-motto {
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

@media (min-width: 431px) {
  .app {
    padding-top: 24px;
  }
}
