:root {
  --bg-main: #f7f4ec;
  --bg-panel: #fffdfa;
  --text-main: #19212b;
  --text-soft: #5f6773;
  --line: #e7dcc8;
  --accent: #0d8a86;
  --accent-2: #ef7a35;
  --personal: #5c67ff;
  --belu: #0f9d8e;
  --criollo: #d44f20;
  --digital: #3f78ff;
  --efectivo: #cb4e37;
  --danger: #b42929;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-soft: 0 14px 35px rgba(36, 33, 27, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at 10% 10%, #fce0cf 0%, transparent 40%),
    radial-gradient(circle at 90% 15%, #d6f3f1 0%, transparent 45%), var(--bg-main);
  position: relative;
}

.bg-orb {
  position: fixed;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  z-index: -1;
  filter: blur(20px);
  opacity: 0.4;
}

.bg-orb-a {
  right: -90px;
  top: 80px;
  background: #f7ab7f;
}

.bg-orb-b {
  left: -110px;
  bottom: 140px;
  background: #8ce4dd;
}

.app-shell {
  width: min(1080px, 100% - 2rem);
  margin: 1.2rem auto 6rem;
  display: grid;
  gap: 1rem;
  animation: reveal 420ms ease-out;
}

.app-header {
  padding: 1rem 0 0.2rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.77rem;
}

h1 {
  margin: 0.35rem 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  line-height: 1.12;
}

.subtitle {
  margin: 0;
  color: var(--text-soft);
  max-width: 65ch;
}

h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
}

.panel {
  background: linear-gradient(150deg, #fffefc, #fff9f1 75%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
}

.summary-card {
  border: 1px solid #ecdfcc;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.8rem;
  min-height: 96px;
}

.summary-card strong {
  display: block;
  font-size: 1.05rem;
  margin-top: 0.25rem;
}

.summary-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.backup-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.backup-note {
  margin: 0.65rem 0 0;
  color: var(--text-soft);
  font-size: 0.85rem;
}

.filter-btn {
  border: 1px solid #dbcdb7;
  border-radius: 999px;
  background: #fff;
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.filter-btn:hover {
  transform: translateY(-1px);
  border-color: #c4b59d;
}

.filter-btn.active {
  background: var(--text-main);
  color: #fff;
  border-color: var(--text-main);
}

.expenses-panel {
  min-height: 220px;
}

.status-area {
  min-height: 56px;
  display: grid;
  align-items: center;
}

.status-box {
  border: 1px dashed #d7c9b4;
  border-radius: var(--radius-md);
  padding: 0.9rem;
  text-align: center;
  background: #fff;
}

.status-box p {
  margin: 0.2rem 0;
  color: var(--text-soft);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 4px solid #ebddc8;
  border-top-color: var(--accent);
  margin: 0 auto;
  animation: spin 1s linear infinite;
}

.expenses-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.expense-item {
  background: #fff;
  border: 1px solid #ebdec9;
  border-radius: var(--radius-md);
  padding: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  animation: fade-in-up 240ms ease both;
}

.expense-left {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  min-width: 0;
}

.category-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 0.4rem;
  flex-shrink: 0;
}

.expense-description {
  margin: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.expense-meta {
  margin: 0.25rem 0 0;
  color: var(--text-soft);
  font-size: 0.83rem;
}

.expense-right {
  text-align: right;
}

.expense-amount {
  margin: 0;
  font-weight: 800;
}

.delete-btn {
  margin-top: 0.35rem;
  border: 1px solid #efc7c0;
  background: #fff3f1;
  color: var(--danger);
  border-radius: 8px;
  padding: 0.34rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 60px;
  height: 60px;
  border-radius: 999px;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #0a6968);
  box-shadow: 0 14px 26px rgba(5, 91, 90, 0.4);
  cursor: pointer;
}

.expense-dialog {
  width: min(560px, calc(100% - 2rem));
  border: 1px solid #cfbfa8;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: 0 20px 60px rgba(24, 26, 30, 0.25);
}

.expense-dialog::backdrop {
  background: rgba(25, 20, 15, 0.46);
}

#expenseForm {
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
}

#expenseForm header h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.35rem;
}

#expenseForm header p {
  margin: 0.2rem 0 0.3rem;
  color: var(--text-soft);
}

label {
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select {
  border: 1px solid #d5c5ad;
  border-radius: 10px;
  padding: 0.68rem;
  font: inherit;
  background: #fff;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(13, 138, 134, 0.2);
  outline-offset: 1px;
}

#descriptionCounter {
  color: var(--text-soft);
  justify-self: end;
}

.form-error {
  color: var(--danger);
  min-height: 1.2em;
  margin: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.3rem;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.62rem 0.95rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: #ede3d2;
  color: #273141;
}

[data-color="personal"] {
  color: var(--personal);
}

[data-color="belu"] {
  color: var(--belu);
}

[data-color="el_chino_criollo"] {
  color: var(--criollo);
}

[data-color="digital"] {
  color: var(--digital);
}

[data-color="efectivo"] {
  color: var(--efectivo);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 1rem);
    margin-top: 0.8rem;
  }

  .panel {
    padding: 0.82rem;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .expense-right {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .backup-row .btn {
    flex: 1 1 150px;
  }
}
