/*
 * Aspecto del panel (la forma), el mismo lenguaje que el panel de finanzas: fondo
 * oscuro con brillo violeta, una tarjeta degradada arriba con las cifras grandes, tarjetas
 * redondeadas y botones en píldora.
 *
 * Va en su propia hoja, cargada después de `styles.css`, y no toca columnas, filtros ni
 * lógica: solo cómo se ve. Quitar el <link> de index.html devuelve el panel de siempre.
 */

/* --- Colores --- */

:root {
  --bg: #f4f2ff;
  --surface: #ffffff;
  --surface-2: #f8f6ff;
  --border: #e4e0f7;
  --text: #1d1840;
  --muted: #6b6790;
  --accent: #6d4aff;
  --accent-2: #22c7e8;
  --row-line: transparent;
  --row-hover: #f0ecff;
  --row-bg: #faf9ff;
  --stale-bg: #fff3e8;
  --stale-border: #f97316;
  --stale-text: #c2410c;
  --chip-new-bg: #e6efff;
  --chip-new-text: #2f5fd0;
  --chip-doing-bg: #fff0e3;
  --chip-doing-text: #c2540a;
  --chip-done-bg: #dcf7f1;
  --chip-done-text: #0f7a68;
  --radio: 22px;
  --sombra: 0 1px 2px rgba(40, 20, 120, 0.05), 0 18px 40px -24px rgba(60, 30, 160, 0.35);
  --brillo-1: rgba(124, 77, 255, 0.14);
  --brillo-2: rgba(34, 199, 232, 0.1);

  /* Lo que pone cada paleta de color (tema-oceano.css) sale de aquí. */
  --hero-fondo:
    radial-gradient(30rem 18rem at 85% 110%, rgba(34, 199, 232, 0.55), transparent 70%),
    linear-gradient(120deg, #6a3df5 0%, #8a3cf0 38%, #5a3fd8 68%, #2b7fc0 100%);
  --hero-sombra: 0 30px 60px -30px rgba(106, 61, 245, 0.7);
  --hero-texto: #fff;
  --hero-suave: rgba(255, 255, 255, 0.82);
  --ficha-fondo: linear-gradient(180deg, #1f1b52, #171442);
  --ficha-texto: #fff;
  --ficha-rotulo: #c8c3f2;
  --anillo-centro: #1c1849;
  --anillo: #5eead4;
  --anillo-pista: rgba(255, 255, 255, 0.12);
  --boton: linear-gradient(90deg, #7c5cff, #22c7e8);
  --boton-sombra: rgba(124, 92, 255, 0.9);
  --marca: linear-gradient(180deg, #8b6cff, #22c7e8);
  --titulo-fuente: Outfit, Inter, system-ui, sans-serif;
  --tarjeta-radio: 28px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0c0a1d;
    --surface: #17143a;
    --surface-2: #1d1a48;
    --border: rgba(255, 255, 255, 0.07);
    --text: #f2f0ff;
    --muted: #a7a3cf;
    --accent: #a48bff;
    --row-hover: rgba(255, 255, 255, 0.06);
    --row-bg: rgba(255, 255, 255, 0.035);
    --stale-bg: rgba(249, 115, 22, 0.12);
    --stale-border: #fb923c;
    --stale-text: #fdba74;
    --chip-new-bg: rgba(59, 130, 246, 0.18);
    --chip-new-text: #93c5fd;
    --chip-doing-bg: rgba(249, 115, 22, 0.18);
    --chip-doing-text: #fdba74;
    --chip-done-bg: rgba(45, 212, 191, 0.16);
    --chip-done-text: #5eead4;
    --sombra: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 48px -28px rgba(0, 0, 0, 0.8);
    --brillo-1: rgba(124, 77, 255, 0.28);
    --brillo-2: rgba(20, 150, 170, 0.18);
  }
}

:root[data-theme='dark'] {
  --bg: #0c0a1d;
  --surface: #17143a;
  --surface-2: #1d1a48;
  --border: rgba(255, 255, 255, 0.07);
  --text: #f2f0ff;
  --muted: #a7a3cf;
  --accent: #a48bff;
  --row-hover: rgba(255, 255, 255, 0.06);
  --row-bg: rgba(255, 255, 255, 0.035);
  --stale-bg: rgba(249, 115, 22, 0.12);
  --stale-border: #fb923c;
  --stale-text: #fdba74;
  --chip-new-bg: rgba(59, 130, 246, 0.18);
  --chip-new-text: #93c5fd;
  --chip-doing-bg: rgba(249, 115, 22, 0.18);
  --chip-doing-text: #fdba74;
  --chip-done-bg: rgba(45, 212, 191, 0.16);
  --chip-done-text: #5eead4;
  --sombra: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 48px -28px rgba(0, 0, 0, 0.8);
  --brillo-1: rgba(124, 77, 255, 0.28);
  --brillo-2: rgba(20, 150, 170, 0.18);
}

/* --- Fondo y tipografía --- */

body {
  min-height: 100vh;
  padding: 2rem clamp(1rem, 3vw, 2.5rem);
  background:
    radial-gradient(60rem 40rem at 30% -10%, var(--brillo-1), transparent 70%),
    radial-gradient(50rem 40rem at 100% 60%, var(--brillo-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

h1,
h2,
.stat-value,
.hero-ring-value,
.days {
  font-family: var(--titulo-fuente);
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-mark {
  width: 12px;
  height: 30px;
  border-radius: 6px;
  background: var(--marca);
}

/* --- La tarjeta de arriba --- */

.hero {
  flex: 1 0 100%;
  padding: 1.4rem 1.6rem 1.3rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--tarjeta-radio);
  background: var(--hero-fondo);
  box-shadow: var(--hero-sombra);
  color: var(--hero-texto);
}

.hero-kicker {
  margin: 0 0 0.9rem;
  color: var(--hero-suave);
  font-size: 0.9rem;
  font-weight: 500;
}

.hero-kicker::first-letter {
  text-transform: uppercase;
}

.hero-body {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.hero-main {
  flex: 1;
  min-width: 0;
}

.hero .stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.hero .stat {
  justify-content: space-between;
  gap: 0.35rem;
  padding: 1rem 1.1rem 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: var(--ficha-fondo);
  box-shadow: 0 14px 28px -18px rgba(10, 5, 40, 0.9);
}

/* El rótulo arriba y la cifra debajo, como en finanzas: se lee primero qué es. */
.hero .stat-label {
  order: -1;
  color: var(--ficha-rotulo);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.hero .stat-value {
  color: var(--ficha-texto);
  font-size: 2.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.hero .stat-alerta {
  border-color: rgba(251, 146, 60, 0.45);
}

.hero .stat-alerta .stat-value {
  background: linear-gradient(90deg, #fdba74, #fb7185);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.hero .stat-filtrado .stat-value {
  background: linear-gradient(90deg, #5eead4, #67e8f9);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.hero-insights {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
  color: var(--hero-texto);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
}

.hero-insights li + li {
  margin-top: 0.35rem;
}

/* El anillo: cuánto de lo que se ve está terminado. */
.hero-ring {
  --avance: 0;
  position: relative;
  display: grid;
  flex: none;
  place-content: center;
  width: 9.5rem;
  height: 9.5rem;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--anillo-centro) 76%, transparent 77%),
    conic-gradient(var(--anillo) calc(var(--avance) * 1%), var(--anillo-pista) 0);
  box-shadow: 0 18px 36px -18px rgba(10, 5, 40, 0.9);
  text-align: center;
}

.hero-ring-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.hero-ring-value {
  color: var(--ficha-texto);
}

.hero-ring-label {
  color: var(--ficha-rotulo);
  font-size: 0.78rem;
}

/* La barra por categoría, con su leyenda: «a dónde se va lo que entra». */
.hero-bar {
  display: flex;
  gap: 3px;
  height: 12px;
  margin-top: 1.2rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--anillo-pista);
}

.hero-bar > span {
  border-radius: 3px;
}

.hero-bar-new {
  background: #3b82f6;
}

.hero-bar-indeterminate {
  background: #f97316;
}

.hero-bar-done {
  background: #2dd4bf;
}

.hero-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.2rem;
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--hero-texto);
  font-size: 0.85rem;
  font-weight: 500;
}

.hero-legend li {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.hero-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* --- Tarjetas --- */

.topbar-actions,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radio);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--sombra);
  backdrop-filter: blur(8px);
}

.topbar-actions {
  padding: 1rem 1.1rem;
}

.panel {
  padding: 1.2rem 1.3rem;
}

/* --- Controles: píldoras --- */

.search,
select,
input[type='text'],
input:not([type]),
input[type='date'],
.multi-toggle {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.search {
  min-width: 16rem;
  padding-left: 1rem;
}

select,
input:not([type]),
input[type='date'] {
  padding-left: 0.85rem;
}

button,
.link-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

button:hover,
.link-button:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
}

/* Las acciones principales, con el degradado del botón «Analizar» de finanzas. */
button[type='submit'],
.link-button.primary {
  border: none;
  background: var(--boton);
  box-shadow: 0 10px 22px -12px var(--boton-sombra);
  color: #fff;
}

button[type='submit']:hover,
.link-button.primary:hover {
  filter: brightness(1.08);
}

.tema {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.15rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.tema button {
  padding: 0.25rem 0.6rem;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: normal;
}

.tema button[aria-pressed='true'] {
  background: var(--boton);
  color: #fff;
}

.multi-menu {
  border-radius: 18px;
  background: var(--surface);
}

/* --- La tabla, como la lista de gastos: cada TK es una tarjeta --- */

.tabla-panel {
  border-collapse: separate;
  border-spacing: 0 8px;
}

.tabla-panel th,
.tabla-panel td {
  border-bottom: none;
}

thead th {
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: none;
  color: var(--muted);
}

.tabla-panel tbody td,
tbody tr:nth-child(even) td {
  background: var(--row-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.tabla-panel tbody td:first-child {
  border-left: 1px solid var(--border);
  border-radius: 18px 0 0 18px;
}

.tabla-panel tbody td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 18px 18px 0;
}

.tabla-panel tbody tr:hover td {
  background: var(--row-hover);
}

/* La fila parada ya no lleva solo la raya: la tarjeta entera se tiñe un poco. */
.tabla-panel tr.stale td {
  background: var(--stale-bg);
  border-color: color-mix(in srgb, var(--stale-border) 35%, transparent);
}

.tabla-panel tr.stale td:first-child {
  box-shadow: inset 4px 0 0 var(--stale-border);
}

.key a {
  color: var(--accent);
  font-family: var(--titulo-fuente);
  font-size: 1.02rem;
  font-weight: 700;
}

td.summary {
  font-weight: 600;
}

.estado-chip,
.priority {
  border-radius: 999px;
}

/* Los días, en la misma cápsula que los importes de finanzas. */
.days {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.days-alerta {
  background: linear-gradient(90deg, #fb923c, #f43f5e);
  color: #fff;
}

.note-button {
  border-radius: 14px;
}

/* --- Ventanas --- */

dialog,
.note-dialog {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
}

.note-dialog::backdrop {
  background: rgba(8, 5, 25, 0.65);
  backdrop-filter: blur(4px);
}

/* --- Pantallas estrechas --- */

@media (max-width: 720px) {
  .hero-body {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .hero-ring {
    align-self: center;
    width: 6.5rem;
    height: 6.5rem;
  }

  .hero-ring-value {
    font-size: 1.5rem;
  }

  .hero {
    padding: 1.1rem 1rem;
    border-radius: 22px;
  }

  /* Las tres fichas en una fila: apiladas, ocupaban la pantalla entera antes de la lista. */
  .hero .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .hero .stat {
    padding: 0.7rem 0.65rem;
    border-radius: 16px;
  }

  .hero .stat-label {
    font-size: 0.6rem;
    letter-spacing: 0.05em;
  }

  .hero .stat-value {
    font-size: 1.7rem;
  }

  .hero-insights {
    font-size: 0.88rem;
  }

  h1 {
    font-size: 1.5rem;
  }
}
