:root {
  --primary: #C8102E;          /* rojo 100 Montaditos */
  --primary-dark: #A00D25;
  --primary-tint: #FBE9EC;     /* rojo muy claro (fondos activos) */
  --accent: #E8A400;           /* dorado */
  --cream: #FFFDF9;            /* fondo sidebar */
  --cream-line: #ECE1D2;       /* líneas cálidas */
  --ink: #241C18;             /* texto principal cálido */
  --sidebar-w: 248px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #F5EEE3;
  color: var(--ink);
}
a { color: var(--primary); }
h1, h2 { color: var(--ink); }

/* =====================================================================
   LOGIN
   ===================================================================== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.login-wrap {
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(200,16,46,.10), transparent 60%),
    #F5EEE3;
}
.card {
  background: #fff; border-radius: 14px; padding: 2.25rem 2.5rem;
  box-shadow: 0 10px 30px rgba(2,6,23,.10); width: 100%; max-width: 460px;
  border-top: 4px solid var(--primary);
}
.card h1 { margin: .25rem 0 .1rem; font-size: 1.4rem; text-align: center; }
.logo { display: block; width: 100%; max-width: 320px; height: auto; margin: 0 auto 1rem; }
.login-mark {
  width: 56px; height: 56px; margin: 0 auto .75rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border-radius: 14px; font-size: 1.7rem;
  box-shadow: 0 4px 10px rgba(200,16,46,.30);
}
.login-sub { margin: 0 0 1.25rem; text-align: center; color: #8a7d6d; font-size: .85rem; font-weight: 600; }
label { display: block; font-size: .85rem; margin: .75rem 0 .25rem; font-weight: 600; }
input[type=email], input[type=password], input[type=text],
input[type=number], input[type=date], input[type=datetime-local], input[type=time], select {
  width: 100%; padding: .65rem .75rem; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 1rem;
}
.btn {
  display: inline-block; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 1rem; font-weight: 600;
  padding: .7rem 1.1rem; width: 100%; margin-top: 1.1rem; text-decoration: none;
  text-align: center;
}
.btn:hover { filter: brightness(.95); }
.btn:disabled { opacity: .35; cursor: not-allowed; filter: none; }
.btn-secondary { background: #64748b; }
.btn-ghost { background: #e2e8f0; color: #0f172a; }
.btn-danger { background: #dc2626; }
.btn-inline { width: auto; margin: 0; padding: .6rem 1rem; }
.btn-sm { width: auto; margin: 0; padding: .4rem .75rem; font-size: .85rem; }
.alert { padding: .65rem .85rem; border-radius: 8px; font-size: .9rem; margin: 0 0 1rem; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-ok    { background: #dcfce7; color: #166534; }

/* =====================================================================
   LAYOUT CON SIDEBAR
   ===================================================================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--cream);
  border-right: 1px solid var(--cream-line);
  position: fixed; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
}
.sidebar .brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--cream-line);
}
.brandmark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  background: var(--primary); color: #fff; font-size: 1.15rem;
  box-shadow: 0 2px 5px rgba(200,16,46,.28);
}
.brand-logo {
  height: 54px; width: auto; max-width: 132px; object-fit: contain; flex: 0 0 auto;
  background: #fff; border-radius: 9px; padding: 4px 7px; border: 1px solid var(--cream-line);
}
/* Marca en vertical (cuando hay logo): logo a todo el ancho + local debajo */
.brand-stacked { flex-direction: column; align-items: stretch; gap: .5rem; }
.brand-stacked .brand-logo {
  width: 100%; max-width: none; height: auto; max-height: 110px; padding: 8px;
  border-radius: 10px;
}
.brand-stacked .brand-text { align-items: center; text-align: center; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 800; font-size: 1.02rem; color: var(--ink); }
.brand-local { font-size: .72rem; font-weight: 600; color: #9a8b78; }
.brand-contact {
  padding: .65rem 1.25rem .9rem; border-top: 1px solid var(--cream-line);
  display: flex; flex-direction: column; gap: .28rem;
  font-size: .74rem; color: #7c6f5f; line-height: 1.3;
}
.brand-contact > div { display: flex; align-items: flex-start; gap: .4rem; }
.brand-contact .bc-ico { flex: 0 0 auto; }
.brand-contact a { color: inherit; text-decoration: none; word-break: break-word; }
.brand-contact a:hover { color: var(--primary); text-decoration: underline; }
/* Contacto bajo la marca (arriba): sin borde superior (la marca ya lo tiene),
   con separador inferior antes del menú. */
.brand-contact.sidebar-only { border-top: 0; border-bottom: 1px solid var(--cream-line); }
/* La versión de página (contacto al final) solo se ve en móvil */
.brand-contact.page-contact { display: none; }
.sidebar .nav { flex: 1; padding: .75rem .6rem; overflow-y: auto; }
.nav-section {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: #b0a08b; padding: 1rem .65rem .35rem;
}
.navlink {
  display: flex; align-items: center; gap: .7rem;
  padding: .65rem .7rem; margin: .12rem 0; border-radius: 8px;
  color: #4b4038; text-decoration: none; font-weight: 600; font-size: .95rem;
  border-left: 3px solid transparent;
}
.navlink .ico { width: 1.25rem; text-align: center; }
.navlink:hover { background: #F3EADB; }
.navlink.active {
  background: var(--primary-tint); color: var(--primary-dark);
  border-left-color: var(--primary);
}
.sidebar-foot {
  padding: .9rem 1.25rem; border-top: 1px solid var(--cream-line);
  font-size: .78rem; color: #a1927e;
}
.sidebar-foot .app-version { font-size: .72rem; font-weight: 700; color: #b9ab98; margin-top: .15rem; letter-spacing: .02em; text-align: center; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.appbar {
  position: sticky; top: 0; z-index: 5;
  background: #fff; border-bottom: 1px solid var(--cream-line);
  box-shadow: inset 0 3px 0 var(--primary);
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.5rem;
}
.appbar h1 { margin: 0; font-size: 1.3rem; }
.appbar-user { display: flex; align-items: center; gap: .75rem; }
.user-chip { color: #6b5d4d; font-size: .9rem; }
.content { padding: 1.5rem; }

/* =====================================================================
   PANELES, TABLAS, FORMULARIOS
   ===================================================================== */
.panel { background: #fff; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.25rem;
         box-shadow: 0 1px 3px rgba(2,6,23,.06); }
.panel h2 { margin-top: 0; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid #e2e8f0; font-size: .92rem; }
th { color: #475569; font-weight: 600; }
.muted { color: #64748b; font-size: .85rem; }
.aviso-doc { display: block; margin-top: .25rem; font-size: .8rem; font-weight: 600; color: #b45309; }
.inactivo { opacity: .55; }
.actions { white-space: nowrap; }
.actions form { display: inline; }
.actions > * { margin-right: .35rem; }

/* Chips de filtro */
.filtros { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  text-decoration: none; font-size: .82rem; font-weight: 600;
  padding: .25rem .65rem; border-radius: 999px;
  background: #f1f5f9; color: #475569;
}
.chip:hover { background: #e2e8f0; }
.chip-on { background: var(--primary); color: #fff; }

/* =====================================================================
   CALENDARIO DE EQUIPO (matriz empleados x días)
   ===================================================================== */
.cal-wrap { overflow-x: auto; }
.cal { border-collapse: collapse; font-size: .72rem; width: 100%; table-layout: fixed; }
.cal th, .cal td { border: 1px solid #e2e8f0; text-align: center; }
.cal thead th { padding: .25rem 0; color: #475569; font-weight: 600; }
.cal th[data-hoy] { background: var(--primary-tint); font-weight: 800; }
.cal th[data-hoy] span { color: var(--primary) !important; font-weight: 800; }
.cal .emp {
  text-align: left; padding: .35rem .6rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
  position: sticky; left: 0; background: #fff; z-index: 1; width: 210px;
}
.cal thead .emp { z-index: 2; }
.cal .wknd { background: #f8fafc; }
.cal .festivo { background: #fde68a; }
.cal td.festivo { background: #fef3c7; }
.cal td.libre { background: #e2e8f0; }
.cal td.cov { text-align: center; font-size: .72rem; font-weight: 700; height: 26px; }
.cal td.cov-under { background: #fee2e2; color: #991b1b; }   /* por debajo del mínimo */
.cal td.cov-ok    { background: #dcfce7; color: #166534; }   /* cubre el mínimo */
.cal td.cov-none  { background: #f1f5f9; color: #94a3b8; }   /* sin objetivo y sin nadie */
.cal .cell { height: 32px; padding: 0; }
.cal .celltxt {
  display: block; font-size: .66rem; font-weight: 700; line-height: 32px;
  color: #334155; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px;
}
.cal td.festivo .celltxt, .cal td.wknd .celltxt, .cal td.libre .celltxt { color: #64748b; font-weight: 600; }
.cal .cell.has { border-radius: 3px; }
/* Colores por tipo de ausencia */
.t-vacaciones      { background: #93c5fd; }
.t-baja_medica     { background: #fca5a5; }
.t-asuntos_propios { background: #c4b5fd; }
.t-permiso         { background: #5eead4; }
.t-otro            { background: #cbd5e1; }
.cell.pend { opacity: .4; }

.cal-legend { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; font-size: .82rem; color: #475569; }
.cal-legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; margin-right: .35rem; }
.cal-legend.cal-legend { align-items: center; }
.legend-edit { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: #475569; }
.legend-edit input[type=color] { width: 24px; height: 24px; padding: 1px; border: 1px solid #cbd5e1; border-radius: 4px; cursor: pointer; }
.cal-nav { display: flex; align-items: center; gap: .6rem; }

/* ---- Cuadrante de turnos ---- */
.cuadrante { width: 100%; border-collapse: collapse; }
.cuadrante th, .cuadrante td { border: 1px solid #e2e8f0; padding: .3rem; text-align: center; vertical-align: middle; }
.cuadrante td { vertical-align: top; text-align: left; }
.cuadrante thead th { font-size: .8rem; color: #475569; }
.cuadrante .emp { text-align: left; white-space: nowrap; min-width: 160px; font-weight: 600; }
.cuadrante .wknd { background: #f8fafc; }
.cuadrante select { width: 100%; padding: .3rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .8rem; }
.turno-chip { display: inline-block; padding: .1rem .45rem; border-radius: 999px; font-size: .75rem; color: #fff; font-weight: 600; }
.turno-libre { color: #64748b; font-size: .78rem; }
.cell-turnos { display: flex; flex-direction: column; gap: .12rem; align-items: flex-start; }
.chk { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; white-space: nowrap; }
.chk input { width: auto; }
.chk .dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
/* Turno en su fila y los puestos DEBAJO (indentados). El hueco de los puestos
   se reserva aunque el turno no esté marcado, para que Mañana/Tarde queden
   alineados entre días (los del último turno se colapsan, no sobra espacio). */
.turno-block { margin-bottom: .3rem; }
.puestos-block { display: flex; flex-direction: column; gap: .1rem; margin: .1rem 0 .25rem 1.35rem; }
.puesto-chk { font-size: .7rem; color: #475569; }
.puesto-chk .dot { width: 8px; height: 8px; }

/* Turnos: filas editables */
.turno-row { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }
.turno-edit { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.turno-edit input[type=text] { flex: 1 1 160px; }
.turno-edit input[type=time] { width: 120px; }
.turno-edit input[type=color] { width: 46px; height: 38px; padding: 2px; }
.turno-edit select { width: auto; padding: .45rem .5rem; }

/* Calendario: celda dividida en bandas HORIZONTALES de turno (una por turno).
   Días consecutivos con el mismo turno se alinean como una línea gruesa. */
.cal .segs { display: flex; flex-direction: column; height: 32px; }
.cal .seg { flex: 1 1 0; }
.cal .seg + .seg { border-top: 1px solid #fff; }

.badge { padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.b-entrada { background:#dcfce7; color:#166534; }
.b-salida  { background:#fee2e2; color:#991b1b; }
.b-pausa   { background:#fef3c7; color:#92400e; }
.b-info    { background:#dbeafe; color:#1e40af; }

/* Fichaje */
.fichar { display: flex; gap: .75rem; flex-wrap: wrap; }
.fichar button { flex: 1 1 160px; padding: 1rem; font-size: 1.05rem; }
.btn-in  { background: #16a34a; }
.btn-out { background: #dc2626; }
.btn-pause { background: #d97706; }

/* Estado de jornada */
.status { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.status-badge { font-size: 1.05rem; font-weight: 700; padding: .4rem .95rem; border-radius: 999px; }
.s-trabajando { background: #dcfce7; color: #166534; }
.s-pausa      { background: #fef3c7; color: #92400e; }
.s-fuera      { background: #e2e8f0; color: #475569; }
.status .desde { color: #64748b; font-size: .9rem; }
.status .worked { margin-left: auto; text-align: right; }
.status .worked b { font-size: 1.5rem; display: block; line-height: 1.1; }

/* Formularios */
.form-row { margin-bottom: .9rem; }
.form-row label { margin-bottom: .3rem; }
.row-2 { display: flex; gap: 1rem; flex-wrap: wrap; }
.row-2 > * { flex: 1 1 180px; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.2rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.check input { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; }
.datos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem 1.5rem; }
.datos-grid > div > span.muted { display: block; font-size: .78rem; margin-bottom: .1rem; }

/* =====================================================================
   RESPONSIVE: sidebar arriba en pantallas pequeñas
   ===================================================================== */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; border-right: 0; border-bottom: 1px solid var(--cream-line); }
  .sidebar .nav { display: flex; flex-wrap: wrap; gap: .25rem; }
  .nav-section { display: none; }
  .navlink { margin: 0; border-left: 0; }
  .navlink.active { border-left: 0; border-bottom: 2px solid var(--primary); border-radius: 6px 6px 0 0; }
  .sidebar-foot { display: none; }
  .main { margin-left: 0; }
  /* En móvil: ocultar el contacto del sidebar y mostrarlo al final de la página */
  .brand-contact.sidebar-only { display: none; }
  .brand-contact.page-contact {
    display: flex; margin: 1.25rem 0 .5rem; padding: 1rem 1.25rem;
    background: #fff; border-radius: 12px; border-top: 0;
    box-shadow: 0 1px 3px rgba(2,6,23,.06);
  }
}
