html, body {
  margin: 0;
  padding: 0;
  font-family: 'Rubik', sans-serif;
  background-color: #EEF0F4;
  color: #432000;
}

* { -webkit-tap-highlight-color: transparent; }

.container {
  max-width: 420px;
  margin: 20px auto;
  padding: 0 12px;
}

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

h1 { margin: 0; font-weight: 500; }
h2 { margin: 0 0 8px; font-weight: 500; }

.status { font-size: 12px; opacity: 0.75; }

.card {
  background: #FFFDF8;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}

.hidden { display: none !important; }

.muted { opacity: .7; font-size: 13px; }

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

input {
  flex: 1;
  color: #432000;
  background-color: #DCE1EB;
  border: 0;
  padding: 12px;
  border-radius: 10px;
  font-size: 16px;
  text-align: left;
}

button {
  color: #FDFDFD;
  background-color: #AC485A;
  border: 0;
  padding: 12px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
}

button:hover { background-color: #432000; }

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.tab {
  background: #DCE1EB;
  color: #432000;
}

.tab.active {
  background: #AC485A;
  color: #fff;
}

hr { border: 0; border-top: 1px solid rgba(0,0,0,.08); margin: 14px 0; }

.codebox {
  margin-top: 10px;
  background: #EEF0F4;
  border-radius: 10px;
  padding: 10px;
}

.code { font-family: ui-monospace, Menlo, Monaco, monospace; font-size: 18px; margin: 6px 0; }

/* Super list */
.super-top { display: flex; gap: 10px; }
.super-top input { text-align: center; font-size: 18px; }
.super-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.super-item {
  font-size: 18px;
  background-color: #FFFDF8;
  padding: 12px;
  border-radius: 10px;
  flex-grow: 1;
  text-align: center;
  box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.15);
  user-select: none;
}
.super-item.done {
  opacity: .55;
  text-decoration: line-through;
}

.fx-label {
  font-size: 13px;
  opacity: 0.75;
  margin-bottom: 4px;
}

/* Gastos */
.gastos-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.gastos-month {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gastos-nav {
  background: #DCE1EB;
  color: #432000;
  padding: 6px 10px;
  border-radius: 10px;
}

.gastos-month-label {
  font-size: 13px;
  opacity: .8;
  min-width: 120px;
  text-align: center;
}

.gastos-form select {
  width: 100%;
  color: #432000;
  background-color: #DCE1EB;
  border: 0;
  padding: 12px;
  border-radius: 10px;
  font-size: 16px;
}

.g-warning {
  margin-top: 10px;
  background: #EEF0F4;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.gastos-totals {
  display: grid;
  gap: 12px;
}

.g-total-value {
  font-size: 26px;
  font-weight: 500;
  margin-top: 4px;
}

.g-cat-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid rgba(0,0,0,.06);
}

.gastos-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.gastos-item {
  background: #FFFDF8;
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0px 1px 4px rgba(0,0,0,0.12);
}

.g-line1, .g-line2 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.g-note {
  font-weight: 500;
}

.g-meta {
  opacity: .75;
  font-size: 13px;
}

.g-toast {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #EEF0F4;
  color: #432000;
  text-align: center;
  font-size: 14px;
}

/* Vencimientos - tabla */
.v-table-wrap {
  overflow-x: auto;
}

.v-table {
  width: 100%;
  border-collapse: collapse;
  background: #FFFDF8;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0px 1px 4px rgba(0,0,0,0.12);
}

.v-table thead th {
  text-align: left;
  font-size: 12px;
  opacity: 0.75;
  padding: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  white-space: nowrap;
}

.v-table tbody td {
  padding: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  vertical-align: top;
  font-size: 13px;
}

.v-table tbody tr:last-child td {
  border-bottom: 0;
}

.v-table tbody tr.done {
  opacity: 0.55;
  text-decoration: line-through;
}

.v-empty {
  text-align: center;
  padding: 14px !important;
  opacity: 0.75;
}

.v-concept { min-width: 120px; font-weight: 500; }
.v-date { min-width: 120px; }
.v-days { width: 50px; text-align: right; }
.v-amount { min-width: 90px; text-align: right; white-space: nowrap; }
.v-note { min-width: 140px; opacity: 0.85; }

@media (max-width: 420px) {
  .v-table thead th, .v-table tbody td {
    padding: 8px;
    font-size: 12px;
  }
  .v-concept { min-width: 110px; }
  .v-note { min-width: 120px; }
}

.g-subamt {
  font-size: 12px;
  white-space: nowrap;
}
/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: #FFFDF8;
  border-radius: 14px;
  box-shadow: 0px 8px 30px rgba(0,0,0,0.25);
  padding: 14px;
}

.modal-title {
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 10px;
}

.modal-body {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

button.secondary {
  background: #DCE1EB;
  color: #432000;
}


/* =========================
   Dark Modern Theme (C)
   ========================= */

:root {
  /* neutrals */
  --bg: #0b1220;
  --surface: #101a2e;
  --surface-2: #0f172a;
  --border: rgba(255,255,255,0.10);
  --text: #e5e7eb;
  --muted: rgba(229,231,235,0.70);

  /* accent (elige 1) */
  --accent: #22c55e;        /* green mint */
  --accent-2: #60a5fa;      /* soft blue */

  /* states */
  --danger: #ef4444;
  --warning: #f59e0b;

  /* radius & shadow */
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 12px;

  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-soft: 0 6px 18px rgba(0,0,0,0.25);

  /* focus ring */
  --ring: 0 0 0 3px rgba(34,197,94,0.25);
}

html, body {
  background: var(--bg) !important;
  color: var(--text) !important;
}

.hidden { display: none !important; }

.muted { color: var(--muted) !important; }

/* Container / layout (no rompe tu layout actual) */
.container,
.view {
  max-width: 720px; /* en desktop queda más aire; en móvil no afecta */
  margin: 18px auto;
  padding: 0 14px;
}

/* “Card” look para secciones (si ya usas algo tipo .card, esto ayuda) */
.card, .panel, .box,
.v-form, .g-form, .fx-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
}

/* Headers */
h1, h2 {
  color: var(--text);
  letter-spacing: 0.2px;
}
h2 { margin: 14px 0 10px; }

/* Inputs */
input, select, textarea {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  outline: none !important;
}

input::placeholder, textarea::placeholder {
  color: rgba(229,231,235,0.45) !important;
}

input:focus, select:focus, textarea:focus {
  box-shadow: var(--ring) !important;
  border-color: rgba(34,197,94,0.45) !important;
}

/* Buttons (base) */
button {
  background: rgba(255,255,255,0.08) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: none !important;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}

button:hover {
  background: rgba(255,255,255,0.12) !important;
  border-color: rgba(255,255,255,0.16) !important;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

/* Primario / “Agregar”, “Guardar”, etc.
   Si ya tenés clases tipo .primary / .btn-primary, listo.
   Si no, podés agregar class="primary" a esos botones.
*/
button.primary, .btn-primary {
  background: rgba(34,197,94,0.20) !important;
  border-color: rgba(34,197,94,0.45) !important;
}

button.primary:hover, .btn-primary:hover {
  background: rgba(34,197,94,0.28) !important;
}

button.secondary {
  background: rgba(96,165,250,0.15) !important;
  border-color: rgba(96,165,250,0.35) !important;
}

/* Pills / chips (items del super / tags) */
ul li, .chip, .pill {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--r-md) !important;
  box-shadow: none !important;
}

ul li:hover, .chip:hover, .pill:hover {
  background: rgba(255,255,255,0.06) !important;
}

/* Tabs */
.tabs {
  background: transparent;
  padding: 10px 0;
  gap: 10px;
}

.tabs .tab {
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 999px !important;
  padding: 12px 14px !important;
  font-size: 15px !important;
}

/* soporta .active o .is-active, según tu JS */
.tabs .tab.active,
.tabs .tab.is-active {
  background: rgba(34,197,94,0.22) !important;
  border-color: rgba(34,197,94,0.55) !important;
}

/* Divisores */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

/* Toast */
.g-toast {
  position: fixed;
  bottom: 90px;              /* arriba de las tabs */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(34, 197, 94, 0.22);
  color: var(--text);
  border: 1px solid rgba(34, 197, 94, 0.55);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 1000;
  backdrop-filter: blur(6px);
}

/* =========================
   Vencimientos – tabla (dark fix)
   ========================= */

.v-table-wrap {
  background: transparent;
}

.v-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface) !important;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.v-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.v-table tbody td {
  color: var(--text);
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.v-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Hover suave */
.v-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
  cursor: pointer;
}

/* Estado done */
.v-table tbody tr.done {
  opacity: 0.55;
  text-decoration: line-through;
}

/* Columnas */
.v-date {
  white-space: nowrap;
  color: var(--muted);
}

.v-concept {
  font-weight: 500;
}

.v-days {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Empty state */
.v-empty {
  text-align: center;
  color: var(--muted);
  padding: 14px !important;
}

/* Días: colores semánticos */
.v-days {
  font-weight: 600;
}

.v-table tbody tr td.v-days[data-state="overdue"] {
  color: var(--danger);
}

.v-table tbody tr td.v-days[data-state="today"] {
  color: var(--warning);
}

.v-table tbody tr td.v-days[data-state="ok"] {
  color: var(--accent);
}

/* Date picker icon (calendar) visible in dark */
input[type="date"] {
  color-scheme: dark; /* ayuda a que el control nativo use iconos claros */
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.85);
  cursor: pointer;
}
/* Modal (dark) */
.modal-backdrop {
  background: rgba(0,0,0,0.55) !important;
}

.modal {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow) !important;
}

.modal-title {
  color: var(--text) !important;
}

.modal-body {
  color: var(--text) !important;
}

.modal-row span:first-child {
  color: var(--muted) !important;
}

.modal-row span:last-child {
  color: var(--text) !important;
}

/* Ocultar icono nativo de date */
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
}

/* Date field with custom icon */
.date-field {
  position: relative;
}

.date-field input[type="date"] {
  width: 100%;
  padding-right: 44px; /* espacio para el icono */
}

.date-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  opacity: 0.85;
  pointer-events: none; /* el click va al input */
}

/* Date field: no invadir otros elementos */
.date-field {
  position: relative;
  display: block;
  width: 100%;
}

.date-field input[type="date"] {
  width: 100%;
  padding-right: 46px; /* espacio para el icono */
  box-sizing: border-box;
}

.date-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  opacity: 0.9;
  pointer-events: auto; /* ahora SI es clickeable */
  cursor: pointer;
  z-index: 2;
}

.date-icon {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}

/* ===== Theme tokens ===== */

/* Dark (default) */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #101a2e;
  --surface-2: #0f172a;
  --border: rgba(255,255,255,0.10);
  --text: #e5e7eb;
  --muted: rgba(229,231,235,0.70);

  --accent: #22c55e;
  --accent-2: #60a5fa;

  --danger: #ef4444;
  --warning: #f59e0b;

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 12px;

  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-soft: 0 6px 18px rgba(0,0,0,0.25);

  --ring: 0 0 0 3px rgba(34,197,94,0.25);
}

/* Light */
:root[data-theme="light"] {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef2ff; /* muy suave */
  --border: rgba(15,23,42,0.12);
  --text: #0f172a;
  --muted: rgba(15,23,42,0.60);

  --accent: #2563eb;     /* azul */
  --accent-2: #0ea5e9;   /* celeste */

  --danger: #dc2626;
  --warning: #d97706;

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 12px;

  --shadow: 0 10px 30px rgba(15,23,42,0.10);
  --shadow-soft: 0 6px 18px rgba(15,23,42,0.08);

  --ring: 0 0 0 3px rgba(37,99,235,0.22);
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.switch input { display: none; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255,255,255,0.10);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: 0.2s;
}

.slider:before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  border-radius: 999px;
  transition: 0.2s;
  opacity: 0.9;
}

.switch input:checked + .slider {
  background: rgba(37,99,235,0.18);
  border-color: rgba(37,99,235,0.35);
}

.switch input:checked + .slider:before {
  transform: translate(20px, -50%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--accent); /* en dark verde / en light azul */
}

.brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
}

/* Forms: rows that don't overflow */
.v-form .row,
.g-form .row,
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap; /* clave: permite que baje de línea si no entra */
}

.v-form .row > *,
.g-form .row > *,
.row > * {
  min-width: 0;      /* clave: permite encoger en flex */
  max-width: 100%;
}

/* Date field should behave */
.date-field {
  position: relative;
  flex: 1 1 220px;   /* puede crecer/encoger */
  width: 100%;
}

.date-field input[type="date"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-right: 46px; /* espacio para icono */
}

/* En filas con botón al lado, el botón no debe encoger */
.row button {
  flex: 0 0 auto;
}
@media (max-width: 420px) {
  .v-form .row,
  .g-form .row,
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .row button {
    width: 100%;
  }
}
/* Gastos: date + botón en la misma fila sin overlap */
#g-add {
  flex: 0 0 auto;            /* no se achica */
  white-space: nowrap;
}

#view-gastos .row {
  display: flex;
  gap: 10px;
  align-items: center;
}

#view-gastos .row > * {
  min-width: 0;              /* permite que el date se encoja */
}

#view-gastos .date-field {
  flex: 1 1 0;               /* ocupa lo que haya, pero puede encoger */
  width: auto;
  min-width: 0;
}

#view-gastos .date-field input[type="date"] {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 420px) {
  #view-gastos .row {
    flex-wrap: wrap;
  }
  #g-add {
    width: 100%;
  }
}
#view-vencimientos .row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

#view-vencimientos .row > * {
  min-width: 0;
  max-width: 100%;
}

#view-vencimientos .date-field {
  width: 100%;
}

