:root {
  --bg: #0f172a;
  --card: #ffffff;
  --muted: #64748b;
  --text: #0f172a;
  --green: #22c55e;
  --green-dark: #16a34a;
  --border: #e2e8f0;
  --soft: #f8fafc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Inter, Arial, sans-serif;
}

body {
  position: relative;
  min-height: 100vh;
  background: #f8fafc;
  color: var(--text);
  padding: 18px;
}

body.modal-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
  touch-action: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: -1;
  height: 340px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(180deg, #0f172a 0%, #111827 100%);
}

.app {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.topbar {
  color: #ffffff;
  padding: 10px 2px 24px;
}

.eyebrow {
  font-size: 13px;
  opacity: 0.75;
  margin-bottom: 8px;
}

.topbar h1 {
  font-size: 28px;
  letter-spacing: -0.7px;
  margin-bottom: 8px;
}

.topbar p {
  font-size: 14px;
  line-height: 1.5;
  color: #cbd5e1;
  max-width: 520px;
}

.summary-card {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #ffffff;
  border-radius: 26px;
  padding: 24px;
  box-shadow: 0 24px 50px rgba(22, 163, 74, 0.28);
  margin-bottom: 18px;
}

.summary-label {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 8px;
}

.summary-total {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -1.4px;
  margin-bottom: 16px;
}

.summary-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  backdrop-filter: blur(8px);
}

.section-card {
  background: var(--card);
  border-radius: 26px;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(226, 232, 240, 0.8);
  margin-bottom: 18px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 19px;
  letter-spacing: -0.4px;
}

.section-header span {
  font-size: 13px;
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.section-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.month-badge {
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.toggle-btn {
  border: none;
  background: #0f172a;
  color: #ffffff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.expense-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.expense-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.expense-item:active {
  transform: scale(0.985);
}

.icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: #ffffff;
  border: 1px solid var(--border);
}

.expense-info h3 {
  font-size: 15px;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.expense-info p {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.3;
}

.expense-value {
  text-align: right;
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
}

.variable-card {
  margin-bottom: 0;
}

.variable-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.variable-item {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

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

.variable-topline h3 {
  font-size: 15px;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.variable-topline p {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.3;
}

.variable-topline span {
  color: #0f172a;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.progress-block {
  margin-bottom: 12px;
}

.progress-percent {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  margin-bottom: 5px;
}

.progress-percent.is-warning {
  color: #ca8a04;
}

.progress-percent.is-danger {
  color: #dc2626;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border-radius: inherit;
}

.progress-fill.is-warning {
  background: linear-gradient(135deg, #ca8a04, #facc15);
}

.progress-fill.is-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
}

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

.variable-usage span {
  color: var(--muted);
  font-size: 12.5px;
}

.variable-usage strong {
  color: #0f172a;
  font-size: 15px;
  white-space: nowrap;
}

.variable-details {
  border-top: 1px solid var(--border);
  margin-bottom: 12px;
  padding-top: 10px;
}

.variable-detail-row {
  display: grid;
  grid-template-columns: 1fr 32px 72px 28px;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.detail-info {
  min-width: 0;
}

.detail-info span {
  color: #334155;
  font-size: 13px;
}

.detail-info small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.detail-info small:first-child {
  margin-top: 0;
}

.empty-detail {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}

.person-badge {
  display: grid;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  place-items: center;
  background: #e2e8f0;
  color: #334155;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.variable-detail-row strong {
  color: #0f172a;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.delete-expense-btn {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: none;
  background: #fee2e2;
  color: #dc2626;
  border-radius: 999px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.delete-expense-btn:hover {
  background: #fecaca;
  color: #b91c1c;
}

.delete-expense-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.detail-toggle-btn {
  display: grid;
  width: 32px;
  height: 24px;
  margin: 0 auto;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.detail-toggle-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.is-hidden {
  display: none;
}

.floating-add-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.28);
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.success-feedback {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.18);
  animation: successBackdropIn 180ms ease-out;
  pointer-events: none;
}

.success-feedback.is-hidden {
  display: none;
}

.success-feedback.is-leaving {
  animation: successBackdropOut 220ms ease-in forwards;
}

.success-feedback > div,
.success-feedback > span {
  grid-area: 1 / 1;
}

.success-check {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  background: #22c55e;
  color: #ffffff;
  border-radius: 999px;
  box-shadow: 0 24px 55px rgba(34, 197, 94, 0.34);
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  transform-origin: center;
  animation: successCheckIn 420ms cubic-bezier(0.2, 1.25, 0.35, 1) both;
}

.success-feedback span {
  align-self: center;
  background: #ffffff;
  color: #166534;
  border-radius: 999px;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.16);
  font-size: 13px;
  font-weight: 800;
  padding: 9px 14px;
  transform: translateY(68px);
  animation: successTextIn 360ms ease-out 120ms both;
}

@keyframes successBackdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes successBackdropOut {
  to {
    opacity: 0;
  }
}

@keyframes successCheckIn {
  0% {
    opacity: 0;
    transform: scale(0.55);
  }
  65% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes successTextIn {
  from {
    opacity: 0;
    transform: translateY(76px);
  }
  to {
    opacity: 1;
    transform: translateY(68px);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.48);
  padding: 18px;
}

.modal-overlay.is-hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 430px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 24px;
  box-shadow: 0 24px 55px rgba(15, 23, 42, 0.24);
  padding: 18px;
}

.modal-header {
  margin-bottom: 16px;
}

.modal-header h2 {
  color: #0f172a;
  font-size: 20px;
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}

.modal-header span {
  color: var(--muted);
  font-size: 13px;
}

.form-field {
  display: block;
  margin-bottom: 12px;
}

.form-field span {
  display: block;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.form-field input,
.form-field select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 15px;
  padding: 12px;
}

.form-field input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.modal-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.modal-btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.modal-btn.secondary {
  background: #e2e8f0;
  color: #334155;
}

.modal-btn.primary {
  background: #0f172a;
  color: #ffffff;
}

@media (min-width: 700px) {
  body {
    padding: 36px;
  }

  .modal-overlay {
    place-items: center;
    padding: 36px;
  }

  .floating-add-btn {
    right: 36px;
    bottom: 36px;
  }

  .topbar h1 {
    font-size: 36px;
  }

  .summary-total {
    font-size: 52px;
  }

  .expense-grid {
    grid-template-columns: 1fr 1fr;
  }

  .section-card {
    padding: 22px;
  }
}
