/* base.css */
:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1f2428; --line: #30363d;
  --text: #f0f6fc; --muted: #8b949e; --blue: #58a6ff; --green: #238636; --green2: #2ea043;
  --lime: #deff9a; --red: #f85149; --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding-top: var(--safe-t); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.hidden { display: none !important; }

/* Barra superior / navegación */
.top { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 8px 16px; padding-top: calc(8px + var(--safe-t)); margin-top: calc(-1 * var(--safe-t)); }
/* Estilos para el contenedor del logo y título */
.brand { 
  font-weight: 700; 
  white-space: nowrap; 
  display: flex; 
  align-items: center; 
  gap: 10px; /* Separación entre el icono y el texto */
  cursor: pointer;
}

/* Estilo exacto para que el logo no se vea gigante */
.brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px; /* Opcional: le da bordes ligeramente redondeados */
}

#nav { 
  display: flex; 
  gap: 4px; 
}

/* Comportamiento para PC: Mantiene el menú arriba a la derecha */
@media (min-width: 701px) {
  #nav {
    position: fixed;
    top: calc(8px + var(--safe-t));
    right: 16px;
    z-index: 30;
  }
}

#nav button { background: none; border: 0; border-radius: 8px; padding: 6px 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
#nav button small { font-size: 14px; }
#nav button.active { background: var(--bg); color: var(--text); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + var(--safe-b)); }
h2, h3 { margin: 0 0 10px; }
.muted { color: var(--muted); }

/* Móvil: navegación abajo */
@media (max-width: 700px) {
  .brand { font-size: 15px; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; background: var(--panel); border-top: 1px solid var(--line); justify-content: space-around; padding: 6px 4px calc(6px + var(--safe-b)); z-index: 30; }
  #nav button { flex-direction: column; gap: 0; padding: 4px 8px; flex: 1; }
  #nav button span { font-size: 20px; }
  #nav button small { font-size: 11px; }
  main { padding-bottom: calc(90px + var(--safe-b)); }
}

/* Fix para que los iconos del menú no se aplasten */
#nav button .nav-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0; /* Esto evita que el navegador los haga minúsculos */
  display: block;
}

/* Tamaños para la pantalla de inicio */
.logo-img { 
  width: 36px; height: 36px; 
  vertical-align: middle; margin-right: 8px; 
}
.home-ic { 
  width: 64px; height: 64px; 
  object-fit: contain; margin-bottom: 12px; 
}

/* Estilos para que el calendario dinámico se vea gigante en el inicio */
.cal-icon-dynamic.home-ic {
  width: 64px; height: 64px; 
  border-radius: 10px; 
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.cal-icon-dynamic.home-ic .cal-m { font-size: 14px; padding: 4px 0; }
.cal-icon-dynamic.home-ic .cal-d { font-size: 28px; margin-top: 2px; }
.cal-icon-dynamic.home-ic .cal-y { font-size: 12px; margin-top: 2px; }

/* Para la vista móvil (si los iconos deben ser más grandes) */
@media (max-width: 700px) {
  #nav button .nav-icon {
    width: 28px;
    height: 28px;
  }
}

/* Tarjetas y Botones compartidos */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 26px; font-weight: 800; }
.value.blue { color: var(--blue); }
.value.lime { color: var(--lime); }
.value.tax { color: var(--red); }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green2); }
.btn.blue { background: #3498db; border-color: #3498db; color: #fff; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.small { padding: 8px 12px; }
.icon-btn { background: none; border: 0; font-size: 20px; color: var(--muted); padding: 6px 10px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* Modal y Toast (Formulario) */
.modal { position: fixed; inset: 0; background: rgba(1,4,9,.75); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; max-height: 94vh; overflow-y: auto; padding: 14px 16px calc(18px + var(--safe-b)); display: grid; gap: 10px; }
@media (min-width: 701px) { .modal { align-items: center; } .sheet { border-radius: 16px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 0; }
legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.row-plus { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; }
.plus-list { list-style: none; padding: 0; margin: 8px 0 0; }
.plus-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 4px; background: var(--bg); cursor: pointer; font-size: 14px; }
.actions { display: grid; gap: 8px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 80; max-width: 90%; text-align: center; }

/* Ajustes y Gráficos (Vistas secundarias compartidas) */
.grid-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
label { display: block; font-size: 14px; color: var(--muted); }
label input, label select { margin-top: 4px; color: var(--text); font-size: 16px; }
.list { list-style: none; padding: 0; margin: 8px 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--bg); }
.row-add { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.error { color: var(--red); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 22px; }
.bar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar .fill { width: 100%; max-width: 46px; background: var(--blue); border-radius: 4px 4px 0 0; min-height: 1px; }
.bar .v { font-size: 10px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.bar .k { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bar.zero .fill { background: var(--line); }

/* Icono de calendario dinámico (Corregido) */
.cal-icon-dynamic {
  width: 24px;
  height: 26px; /* Ligeramente rectangular */
  background: #e1edf6;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* Reparte el espacio automáticamente */
  overflow: hidden;
  margin-bottom: 2px;
  padding-bottom: 2px; /* Margen de seguridad inferior */
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  flex-shrink: 0;
}
.cal-icon-dynamic .cal-m {
  background: #4a82b8;
  color: #ffffff;
  font-size: 6px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  padding: 2px 0 1px;
  letter-spacing: 0.5px;
}
.cal-icon-dynamic .cal-d {
  color: #1a4f7c;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  line-height: 1;
  margin: 0;
}
.cal-icon-dynamic .cal-y {
  color: #1a4f7c;
  font-size: 5px;
  font-weight: 700;
  text-align: center;
  line-height: 1;
  margin: 0;
}

/* Ajuste de tamaño para el menú del móvil */
@media (max-width: 700px) {
  .cal-icon-dynamic {
    width: 28px;
    height: 30px;
  }
  .cal-icon-dynamic .cal-m { font-size: 7px; }
  .cal-icon-dynamic .cal-d { font-size: 12px; }
  .cal-icon-dynamic .cal-y { font-size: 5px; }
}

/* Estilos para el calendario gigante de la pantalla de inicio */
.cal-icon-dynamic.home-ic {
  width: 64px; 
  height: 70px; /* Proporción rectangular ampliada */
  border-radius: 10px; 
  padding-bottom: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.cal-icon-dynamic.home-ic .cal-m { font-size: 14px; padding: 6px 0 4px; }
.cal-icon-dynamic.home-ic .cal-d { font-size: 26px; }
.cal-icon-dynamic.home-ic .cal-y { font-size: 11px; }
