:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1b1e24;
  --muted: #6b7280;
  --border: #e3e5e9;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --today: #f59e0b;
  --ok: #16a34a;
  --warn: #dc2626;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1d2026;
    --text: #eef0f3;
    --muted: #9aa1ac;
    --border: #2c3038;
    --accent: #60a5fa;
    --accent-soft: #1e3a5f;
    --today: #fbbf24;
    --ok: #4ade80;
    --warn: #f87171;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 3rem;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(320px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  text-align: center;
}

.login-card input, .login-card button {
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.login-card button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.error { color: var(--warn); font-size: 0.9rem; }

header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

header.app-header h1 { font-size: 1.1rem; margin: 0; }
header.app-header a { color: var(--muted); text-decoration: none; font-size: 0.85rem; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.mes-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mes-nav button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  width: 2.4rem;
  height: 2.4rem;
  cursor: pointer;
  color: var(--text);
}

.mes-nav h2 { margin: 0; text-transform: capitalize; font-size: 1.05rem; }

.calendario {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 0.8rem;
}

.dow {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  padding-bottom: 0.2rem;
}

.dia-celda {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.85rem;
  position: relative;
  gap: 2px;
}

.dia-celda.vacio { visibility: hidden; cursor: default; }
.dia-celda.hoy { border-color: var(--today); }
.dia-celda.con-datos { background: var(--accent-soft); font-weight: 600; }
.dia-celda.seleccionado { outline: 2px solid var(--accent); }
.dia-celda .horas-badge { font-size: 0.6rem; color: var(--accent); }

.dia-form { display: flex; flex-direction: column; gap: 0.6rem; }
.fila-doble { display: flex; gap: 0.6rem; }
.fila-doble > div { flex: 1; }

label { font-size: 0.8rem; color: var(--muted); display: block; margin-bottom: 0.2rem; }

input[type="time"], input[type="number"], input[type="text"], input[type="date"] {
  width: 100%;
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.checkbox-fila { display: flex; align-items: center; gap: 0.4rem; }
.checkbox-fila label { margin: 0; }

.botones { display: flex; gap: 0.6rem; margin-top: 0.3rem; }

button.primario, button.peligro, button.secundario {
  flex: 1;
  padding: 0.65rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

button.primario { background: var(--accent); color: white; }
button.peligro { background: transparent; color: var(--warn); border: 1px solid var(--warn); }
button.secundario { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.resultado-dia {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
}

.resultado-dia .linea { display: flex; justify-content: space-between; padding: 0.15rem 0; }
.resultado-dia .linea.total { font-weight: 700; border-top: 1px solid var(--border); margin-top: 0.3rem; padding-top: 0.4rem; }
.aviso-minimo { color: var(--today); font-size: 0.78rem; margin-top: 0.3rem; }

.resumen-mes .linea { display: flex; justify-content: space-between; padding: 0.25rem 0; font-size: 0.92rem; }
.resumen-mes .linea.sub { color: var(--muted); font-size: 0.85rem; padding-left: 0.6rem; }
.resumen-mes .linea.total { font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--border); margin-top: 0.4rem; padding-top: 0.5rem; }

.comparativa {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--border);
}

.comparativa .diff-ok { color: var(--ok); }
.comparativa .diff-mal { color: var(--warn); }

.historial-mes {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0;
  cursor: pointer;
}

.historial-mes:last-child { border-bottom: none; }

.historial-mes .cabecera {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.historial-mes .detalle { display: none; margin-top: 0.5rem; font-size: 0.85rem; }
.historial-mes.abierto .detalle { display: block; }

h3 { margin: 0 0 0.6rem 0; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.oculto { display: none !important; }

.tarifa-info { font-size: 0.75rem; color: var(--muted); margin-top: 0.4rem; }

.eur { color: var(--muted); font-size: 0.85em; font-weight: 400; }
