/* ---------- tokens ---------- */

:root {
  color-scheme: dark;

  --surface-0: #101010;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --linea:     #33332f;

  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #8a8a80;

  --acento:      #c8f000;   /* lima de marca: nunca se usa como color de serie */
  --acento-ink:  #101010;

  /* Paleta categorica, pasos para superficie oscura. Orden fijo:
     1 Gasolina · 2 Comida · 3 Ocio · 4 Suscripciones. Nunca se cicla. */
  --serie-1: #3987e5;
  --serie-2: #d95926;
  --serie-3: #199e70;
  --serie-4: #c98500;

  --radio: 14px;
  --sombra: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .25);
}

:root[data-theme="light"] {
  color-scheme: light;

  --surface-0: #f4f4f1;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --linea:     #dedcd5;

  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #7a7973;

  --acento:      #4d6b00;
  --acento-ink:  #ffffff;

  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --serie-3: #1baf7a;
  --serie-4: #eda100;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.oculto { display: none !important; }

/* ---------- login ---------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login form {
  width: min(100%, 340px);
  background: var(--surface-1);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 28px 24px;
  box-shadow: var(--sombra);
}

.login h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.01em; }
.login p  { margin: 0 0 22px; color: var(--text-muted); font-size: 13px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input, select {
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 16px;
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--linea);
  border-radius: 10px;
  font-size: 16px;   /* 16px evita que iOS haga zoom al enfocar */
  font-family: inherit;
}

input:focus, select:focus {
  outline: 2px solid var(--acento);
  outline-offset: 1px;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
}

.btn-principal {
  width: 100%;
  padding: 12px;
  background: var(--acento);
  color: var(--acento-ink);
  font-weight: 650;
}

.error {
  color: #e66767;
  font-size: 13px;
  margin: 0 0 14px;
  min-height: 1em;
}

/* ---------- estructura ---------- */

.envoltorio {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

header.barra {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.marca {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-right: auto;
}

.punto {
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--acento);
}

.barra select { width: auto; margin: 0; padding: 8px 10px; font-size: 14px; }

.btn-sutil {
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--linea);
  padding: 8px 12px;
  font-size: 14px;
}

nav.pestanas {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--linea);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
  width: fit-content;
}

nav.pestanas button {
  padding: 8px 16px;
  background: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 550;
}

nav.pestanas button[aria-selected="true"] {
  background: var(--surface-0);
  color: var(--text-primary);
}

.rejilla {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 14px;
}

.tarjeta {
  background: var(--surface-1);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 20px;
}

.tarjeta h2 {
  margin: 0 0 16px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- cifra principal ---------- */

.destacada {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--acento) 0%, color-mix(in oklab, var(--acento) 72%, #4a7a00) 100%);
  color: var(--acento-ink);
  border: none;
}

.destacada h2 { color: color-mix(in oklab, var(--acento-ink) 62%, transparent); }

.cifra {
  font-size: clamp(34px, 8vw, 54px);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.desglose-destacada {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-size: 13px;
  font-weight: 550;
  color: color-mix(in oklab, var(--acento-ink) 72%, transparent);
}

.desglose-destacada b {
  display: block;
  font-size: 17px;
  font-weight: 700;
  color: var(--acento-ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- barras por categoria ---------- */

.barras { display: flex; flex-direction: column; gap: 14px; }

.fila-barra { display: block; }

.fila-barra .etiquetas {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.fila-barra .nombre {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

/* El punto de color lleva la identidad; el texto va en tinta, nunca del color de la serie */
.pastilla {
  width: 9px; height: 9px;
  border-radius: 3px;
  flex: none;
}

.fila-barra .valor {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pista {
  height: 9px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.relleno {
  height: 100%;
  border-radius: 0 4px 4px 0;   /* extremo de dato redondeado, anclado a la base */
  min-width: 3px;
  transition: width .35s cubic-bezier(.2, .7, .3, 1);
}

/* ---------- reparto por persona ---------- */

.pila {
  display: flex;
  gap: 2px;              /* separacion de 2px entre segmentos */
  height: 30px;
  margin-bottom: 14px;
}

.pila > div {
  border-radius: 4px;
  min-width: 4px;
}

.leyenda {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
}

.leyenda span { display: flex; align-items: center; gap: 7px; }
.leyenda b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ---------- listados ---------- */

.lista { display: flex; flex-direction: column; }

.mov {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--linea);
}

.mov:last-child { border-bottom: none; }

.mov .concepto { font-weight: 550; }

.mov .meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

.mov .crece { flex: 1; min-width: 0; }
.mov .concepto, .mov .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mov .importe {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.borrar {
  background: none;
  color: var(--text-muted);
  padding: 6px 8px;
  font-size: 16px;
  line-height: 1;
  border-radius: 8px;
}

.borrar:hover { background: var(--surface-2); color: #e66767; }

.insignia {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .03em;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--linea);
}

.insignia.pendiente {
  background: color-mix(in oklab, #c98500 22%, var(--surface-1));
  border-color: color-mix(in oklab, #c98500 45%, var(--surface-1));
  color: #f0c46a;
}

:root[data-theme="light"] .insignia.pendiente { color: #7a5200; }

.vacio {
  color: var(--text-muted);
  font-size: 14px;
  padding: 10px 0;
}

.pie-nota {
  margin-top: 26px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- tooltip ---------- */

#tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--linea);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-primary);
  box-shadow: var(--sombra);
  opacity: 0;
  transition: opacity .12s;
}

#tooltip.visible { opacity: 1; }
#tooltip .t-titulo { font-weight: 650; margin-bottom: 2px; }
#tooltip .t-dato { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Objetivo de puntero mas grande que la propia barra */
.zona-hover { padding: 4px 0; margin: -4px 0; cursor: default; }

/* ---------- formulario de fijos ---------- */

.form-linea {
  display: grid;
  grid-template-columns: 1fr 150px 130px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.form-linea input, .form-linea select { margin-bottom: 0; }
.form-linea button { padding: 11px 16px; }

@media (max-width: 620px) {
  .form-linea { grid-template-columns: 1fr 1fr; }
  .form-linea button { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .marca { width: 100%; margin-right: 0; }
  header.barra { gap: 8px; }
  .barra select { flex: 1; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .relleno { transition: none; }
}
