/* Calculadora CFE — tokens y componentes.
   Los colores vienen del diseño en design/Calculadora CFE.dc.html. */

:root {
  --page: #101120;
  --surface: #161826;
  --card: #232532;

  --text: #e9e9ed;
  --text-soft: #c9cad6;
  --text-muted: #9a9cb0;
  --text-dim: #8a8c9e;

  --accent: #9184d9;
  --accent-soft: #a49bd6;
  --accent-light: #b3a9e6;
  --accent-bright: #c6bff0;
  --accent-a10: rgba(145, 132, 217, 0.10);
  --accent-a12: rgba(145, 132, 217, 0.12);
  --accent-a14: rgba(145, 132, 217, 0.14);
  --accent-a28: rgba(145, 132, 217, 0.28);
  --accent-a40: rgba(145, 132, 217, 0.40);
  --accent-a55: rgba(145, 132, 217, 0.55);

  --danger: #dda3a3;
  --danger-bg: rgba(201, 139, 139, 0.08);
  --danger-border: rgba(201, 139, 139, 0.32);
  --danger-line: rgba(200, 150, 150, 0.42);
  --danger-text: #c99a9a;

  --good: #a3ddb4;
  --good-bg: rgba(120, 190, 140, 0.07);
  --good-border: rgba(120, 190, 140, 0.28);

  --line: rgba(233, 233, 237, 0.10);
  --line-soft: rgba(233, 233, 237, 0.08);
  --line-strong: rgba(233, 233, 237, 0.18);
  --line-input: rgba(233, 233, 237, 0.14);

  --r-card: 8px;
  --r-input: 6px;
}

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--page);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

input, button, select { font-family: inherit; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }
::selection { background: rgba(145, 132, 217, 0.32); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.tnum { font-variant-numeric: tabular-nums; }

/* --- marco -------------------------------------------------------------- */

.stage {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--page);
}

.app {
  width: 390px;
  min-height: 100vh;
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 0 1px rgba(233, 233, 237, 0.07);
}

@media (max-width: 420px) {
  .app { width: 100%; }
}

/* --- encabezado --------------------------------------------------------- */

.head {
  padding: 22px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.head__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.head__title { font-size: 19px; font-weight: 500; letter-spacing: -0.01em; }

.pill {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  border: 1px solid var(--accent-a40);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.head__meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.track {
  height: 4px;
  border-radius: 999px;
  background: rgba(233, 233, 237, 0.09);
  overflow: hidden;
}

.track__fill { height: 100%; border-radius: 999px; background: var(--accent); }

/* --- cuerpo ------------------------------------------------------------- */

.body {
  flex: 1;
  padding: 0 20px 96px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--sm { gap: 8px; }
.stack--md { gap: 12px; }
.stack--lg { gap: 16px; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.card--accent { border-color: var(--accent-a28); }
.card--flush { padding: 14px 14px 10px; gap: 12px; }

.section-title { font-size: 13px; font-weight: 500; }

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.hint { font-size: 10.5px; color: var(--text-dim); }
.rule { height: 1px; background: var(--line); }

/* --- estimado ----------------------------------------------------------- */

.hero {
  border: 1px solid var(--accent-a28);
  border-radius: var(--r-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: linear-gradient(160deg, var(--accent-a10), rgba(145, 132, 217, 0.02));
}

.hero__label {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-soft);
  font-weight: 600;
}

.hero__amount {
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.hero__sub {
  font-size: 12.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.hero__delta {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.hero__delta b { font-weight: 600; font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.stat {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 11px 12px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat__label {
  font-size: 9.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

.stat__value {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat__unit { font-size: 10px; color: var(--text-dim); }

/* --- gráfica ------------------------------------------------------------ */

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }

.chart__ylabel {
  position: absolute;
  left: 9.4%;
  transform: translate(-100%, -50%);
  font-size: 9px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart__today {
  position: absolute;
  top: 1px;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--text-dim);
  white-space: nowrap;
  background: var(--card);
  padding: 0 3px;
}

.chart__axis {
  display: flex;
  justify-content: space-between;
  padding: 0 0 2px 10.6%;
  font-size: 9.5px;
  color: var(--text-dim);
}

/* --- desglose ----------------------------------------------------------- */

.breakdown { display: flex; flex-direction: column; gap: 8px; }

.breakdown__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.breakdown__label { color: var(--text-soft); }
.breakdown__dots { flex: 1; border-bottom: 1px dotted var(--line-input); height: 1px; }
.breakdown__detail { color: var(--text-dim); font-size: 11px; }
.breakdown__amount { font-weight: 500; min-width: 74px; text-align: right; }

.totals {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.totals__row { display: flex; justify-content: space-between; }
.totals__row span:first-child { color: var(--text-soft); }
.totals__row b { font-weight: 500; }

.totals__row--grand {
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

.totals__row--grand span:first-child { color: var(--text); }

/* --- avisos ------------------------------------------------------------- */

.alert {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 13px 14px;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--card);
}

.alert i { font-size: 17px; margin-top: 1px; }
.alert__text { display: flex; flex-direction: column; gap: 3px; }
.alert__title { font-size: 12.5px; font-weight: 600; }

.alert__body {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  text-wrap: pretty;
}

.alert--good { border-color: var(--good-border); background: var(--good-bg); }
.alert--good i, .alert--good .alert__title { color: var(--good); }

.alert--warn { border-color: var(--danger-border); background: var(--danger-bg); }
.alert--warn i, .alert--warn .alert__title { color: var(--danger); }

.alert--stack { flex-direction: column; gap: 10px; }
.alert--stack .alert__head { display: flex; gap: 11px; align-items: flex-start; }
.alert--stack i { color: var(--accent); }

.budget-input {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 28px;
}

.budget-input span { font-size: 11px; color: var(--text-dim); }
.budget-input span.sym { font-size: 13px; }

/* --- formularios -------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 5px; }
.field--grow { flex: 1; }

.field__label {
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: var(--r-input);
  color: var(--text);
  font-size: 13px;
  padding: 8px 9px;
}

.input--num { font-variant-numeric: tabular-nums; }
.input--right { text-align: right; }
.input--sm { font-size: 12.5px; }
.input--tight { padding: 7px 9px; }

.input:disabled {
  background: rgba(233, 233, 237, 0.04);
  color: var(--text-dim);
}

.pair { display: flex; gap: 8px; }

.btn {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text-soft);
  border-radius: var(--r-card);
  padding: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover { border-color: var(--accent); color: var(--accent-light); }

.btn--primary {
  border-color: var(--accent);
  color: var(--accent-light);
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
}

.btn--primary:hover { background: var(--accent-a12); }
.btn--primary:active { background: rgba(145, 132, 217, 0.22); }

.btn--wide { width: 100%; padding: 11px; font-size: 12.5px; font-weight: 600; }
.btn--grow { flex: 1; }

.btn--danger { color: var(--text-dim); padding: 10px; margin-top: 4px; width: 100%; }
.btn--danger:hover { border-color: #c98b8b; color: var(--danger); }

.btn--icon {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  font-size: 14px;
  line-height: 1;
  display: flex;
}

.btn--icon:hover { color: var(--text); }

/* --- segmentado --------------------------------------------------------- */

.segmented {
  display: flex;
  gap: 6px;
  padding: 3px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

.segmented button {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  border-radius: var(--r-input);
  padding: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent-a14);
  border-color: var(--accent);
  color: var(--accent-bright);
}

/* --- lecturas ----------------------------------------------------------- */

.reading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 11px 12px;
  background: var(--card);
}

.reading--base { background: rgba(233, 233, 237, 0.03); color: var(--text-soft); }
.reading__date { width: 52px; color: var(--text-dim); }
.reading__meter { width: 62px; text-align: right; font-weight: 500; }
.reading__delta { flex: 1; text-align: right; color: var(--text-soft); }
.reading__rate { width: 64px; text-align: right; color: var(--accent-soft); }
.reading__note { flex: 1; text-align: right; color: var(--text-dim); }

.empty {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.45;
  text-wrap: pretty;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-card);
  padding: 16px 14px;
  text-align: center;
}

/* --- histórico ---------------------------------------------------------- */

.hist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 11px 12px;
  background: var(--card);
}

.hist__row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.hist__range { color: var(--text-soft); flex: 1; }
.hist__kwh { font-weight: 600; width: 58px; text-align: right; }
.hist__cost { color: var(--accent-soft); width: 62px; text-align: right; font-weight: 500; }

/* confirmación de borrado en línea: dos toques, sin diálogo que tape la lista */
.hist__confirm { display: flex; gap: 9px; align-items: baseline; }

.btn--link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
}

.btn--link:hover { color: var(--text); }
.btn--link--danger { color: var(--danger); font-weight: 600; }

.hist__track { height: 3px; border-radius: 999px; background: var(--line-soft); }
.hist__fill { height: 100%; border-radius: 999px; background: var(--accent-a55); }

/* --- ajustes ------------------------------------------------------------ */

.bucket-head {
  display: flex;
  gap: 8px;
  font-size: 9.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  padding: 0 2px;
}

.bucket-head span:nth-child(1) { flex: 1.3; }
.bucket-head span:nth-child(2) { width: 74px; text-align: right; }
.bucket-head span:nth-child(3) { width: 82px; text-align: right; }

.bucket { display: flex; gap: 8px; align-items: center; }
.bucket .input:nth-child(1) { flex: 1.3; min-width: 0; }
.bucket .input:nth-child(2) { width: 74px; }
.bucket .input:nth-child(3) { width: 82px; }

.choice {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 11px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.choice__label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.choice__desc { font-size: 11px; color: var(--text-dim); line-height: 1.4; }

.choice[aria-pressed="true"] {
  background: var(--accent-a10);
  border-color: var(--accent);
}

.choice[aria-pressed="true"] .choice__label { color: var(--accent-bright); }

.inline-field { display: flex; align-items: center; gap: 9px; }
.inline-field > span:first-child { font-size: 11.5px; color: var(--text-soft); flex: 1; }
.inline-field > span:last-child { font-size: 12.5px; color: var(--text-dim); }
.inline-field .input { width: 70px; }

.note {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.45;
  text-wrap: pretty;
}

/* --- cuenta ------------------------------------------------------------- */

.account {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.account__head { display: flex; gap: 11px; align-items: flex-start; }
.account__head i { font-size: 17px; margin-top: 1px; color: var(--accent); }

.account__status {
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.account__status.is-error { color: var(--danger); }

/* --- navegación --------------------------------------------------------- */

.tabbar {
  position: sticky;
  bottom: 0;
  background: rgba(22, 24, 38, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(233, 233, 237, 0.09);
  padding: 9px 12px 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.tabbar button {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
  color: var(--text-dim);
  border-radius: var(--r-input);
}

.tabbar button:hover { background: rgba(233, 233, 237, 0.05); }
.tabbar button[aria-selected="true"] { color: var(--accent); }
.tabbar i { font-size: 20px; }
.tabbar span { font-size: 10px; font-weight: 500; letter-spacing: 0.01em; }
