/* Planilla Valverde – estilos (CSS limpio, sin librerías, funciona sin internet) */
:root {
  --bg: #f3f1ec;
  --card: #ffffff;
  --ink: #1d2b2e;
  --muted: #667579;
  --line: #e4e0d6;
  --primary: #0b5d57;
  --primary-dark: #08423e;
  --primary-soft: #e3f1ef;
  --accent: #f2b632;
  --accent-soft: #fff3d1;
  --danger: #b3261e;
  --ok: #1b7f4b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 40, .06), 0 4px 14px rgba(20, 40, 40, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
h1 { font-size: 1.6rem; margin: .1rem 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
a { color: var(--primary); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }
.strong { font-weight: 650; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--primary-dark); color: #fff; padding: .6rem 1.25rem; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-size: 1.1rem; }
.brand b { color: var(--accent); }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--primary-dark); font-weight: 800;
}
.brand-mark.big { width: 56px; height: 56px; font-size: 1.6rem; border-radius: 14px; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a {
  color: #d6ebe8; text-decoration: none; padding: .5rem .9rem; border-radius: 8px; font-weight: 550;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .1); }
.topbar nav a.on { background: rgba(255, 255, 255, .16); color: #fff; }
.topbar nav a.salir { opacity: .75; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.head-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.volver { display: inline-block; font-size: .9rem; text-decoration: none; margin-bottom: .2rem; }
.volver:hover { text-decoration: underline; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .45rem 1rem; border-radius: 10px; border: 1.5px solid #cfcabc;
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: #f6f4ee; border-color: #b9b3a2; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.lg { min-height: 48px; padding: .6rem 1.3rem; font-size: 1.02rem; }
.btn.small { min-height: 30px; padding: .15rem .6rem; font-size: .8rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #efece4; }
.btn.danger { color: var(--danger); }
.btn.pulso { box-shadow: 0 0 0 0 rgba(242, 182, 50, .7); animation: pulso 1.6s infinite; background: #0e7068; }
@keyframes pulso { 70% { box-shadow: 0 0 0 10px rgba(242, 182, 50, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 182, 50, 0); } }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
form.inline { display: inline; }

/* ---------- Tarjetas y tablas ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.3rem; }
.card.vacio { text-align: center; padding: 2.5rem 1rem; }
.stack { display: grid; gap: 1rem; }
.tabla-wrap { padding: 0; overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .85rem 1rem; border-bottom: 1px solid var(--line); background: #faf9f5; }
.tabla th.num { text-align: right; }
.tabla td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tr.inactivo td { color: var(--muted); }
.tabla .acciones { text-align: right; white-space: nowrap; }
.chip { display: inline-block; background: var(--primary-soft); color: var(--primary-dark); border-radius: 999px; padding: .1rem .7rem; font-weight: 650; font-size: .85rem; }
.chip.gris { background: #eceae3; color: var(--muted); }

.flash { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; background: #e5f4ea; color: #14532d; border: 1px solid #b9e0c6; font-weight: 550; }
.flash.error { background: #fdeceb; color: #7a1913; border-color: #f2c0bc; }

/* ---------- Formularios ---------- */
label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=number], input[type=date], input[type=password], select {
  font: inherit; font-weight: 400; padding: .6rem .7rem; border: 1.5px solid #cfcabc; border-radius: 9px; background: #fff; color: var(--ink); width: 100%; min-height: 42px;
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .9rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin: .8rem 0; }
.con-sufijo { position: relative; display: block; }
.con-sufijo i { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-style: normal; font-weight: 600; pointer-events: none; }
.con-sufijo input { padding-right: 2.4rem; }
fieldset.seg { border: 1.5px solid var(--line); border-radius: 10px; padding: .4rem .9rem .7rem; margin: .8rem 0; display: flex; gap: 1.5rem; flex-wrap: wrap; }
fieldset.seg legend { font-weight: 650; font-size: .85rem; padding: 0 .3rem; }
label.radio { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: 1rem; }
label.radio input { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
.barra-guardar { position: sticky; bottom: 0; padding: .8rem 0; background: linear-gradient(transparent, var(--bg) 40%); }

/* ---------- Diálogos ---------- */
dialog.dlg { border: 0; border-radius: 16px; padding: 0; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); color: var(--ink); }
dialog.dlg::backdrop { background: rgba(15, 30, 30, .5); }
.dlg-body { padding: 1.4rem 1.5rem 1.2rem; display: block; }
.dlg-body > label { margin-bottom: .6rem; }
.dlg-actions { display: flex; gap: .6rem; justify-content: flex-end; align-items: center; margin-top: 1.2rem; flex-wrap: wrap; }
.dlg-actions .grow { flex: 1; }

/* ---------- Planilla semanal ---------- */
.estado { font-size: .9rem; color: var(--ok); font-weight: 650; }
.estado.sucio { color: #a56a00; }
.ayuda { background: var(--accent-soft); box-shadow: none; border: 1px solid #f0dc9c; margin-bottom: 1rem; font-size: .95rem; }
.mini-chk { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--primary); color: #fff; font-size: .75rem; }
.toolbar { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.inline-sel { display: flex; align-items: center; gap: .5rem; font-weight: 600; margin-left: auto; }
.inline-sel select { width: auto; min-height: 40px; }

.planilla-wrap { overflow: auto; max-height: calc(100vh - 230px); position: relative; }
table.planilla { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .92rem; }
.planilla th, .planilla td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fff; }
.planilla thead th { position: sticky; top: 0; z-index: 5; background: var(--primary); color: #fff; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; text-align: center; }
.planilla thead th.sticky-l { text-align: left; }
.planilla .sticky-l { position: sticky; left: 0; z-index: 4; min-width: 215px; max-width: 250px; box-shadow: 2px 0 0 var(--line); }
.planilla thead th.sticky-l { z-index: 8; background: var(--primary-dark); }
.planilla td.nombre { position: sticky; padding-right: 2.4rem; white-space: normal; }
.planilla .nm { font-weight: 650; line-height: 1.2; }
.planilla .sub { font-size: .74rem; color: var(--muted); }
.btn-aj { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); border: 0; background: #eef3f2; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 1rem; }
.btn-aj:hover { background: var(--primary-soft); }
.planilla td.dia, .planilla th.dia { text-align: center; width: 60px; min-width: 60px; padding: .3rem .25rem; }
.planilla th.dia div { font-weight: 700; }
.btn-col { margin-top: .2rem; border: 0; background: rgba(255, 255, 255, .18); color: #fff; font-size: .66rem; font-weight: 600; border-radius: 6px; padding: .12rem .35rem; cursor: pointer; text-transform: none; letter-spacing: 0; }
.btn-col:hover { background: rgba(255, 255, 255, .32); }
.planilla td.dom, .planilla th.dom { background: #f0eee8; color: var(--muted); font-size: .72rem; width: 46px; min-width: 46px; }
.planilla thead th.dom { background: #55625f; color: #fff; }
input.hora { width: 52px; min-height: 36px; padding: .25rem .2rem; text-align: center; font-weight: 650; font-size: 1rem; border-radius: 8px; -moz-appearance: textfield; display: block; margin: 0 auto; }
input.hora::-webkit-outer-spin-button, input.hora::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.chk { display: block; margin: .2rem auto 0; width: 52px; height: 24px; border-radius: 7px; border: 1.5px solid #cfcabc; background: #fff; color: #bbb5a4; font-weight: 800; cursor: pointer; line-height: 1; }
.chk:hover { border-color: var(--primary); color: var(--primary); }
.chk.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.planilla td.acc { text-align: center; white-space: normal; min-width: 84px; width: 84px; }
.btn-mini { display: block; width: 100%; font: inherit; font-size: .72rem; font-weight: 600; padding: .2rem .4rem; margin: .12rem 0; border-radius: 7px; border: 1px solid #d3cebf; background: #fff; cursor: pointer; }
.btn-mini:hover { background: var(--primary-soft); border-color: var(--primary); }
.planilla td.horas, .planilla th.horas { text-align: center; font-weight: 700; background: #f7f6f1; min-width: 56px; }
.planilla thead th.horas { background: var(--primary); }
.planilla td[data-k], .planilla td[data-t] { text-align: right; font-variant-numeric: tabular-nums; }
.planilla td.resumen { background: #f3f8f7; font-weight: 600; }
.planilla td.neto { background: var(--accent-soft); font-weight: 800; font-size: 1.05rem; color: #5a3d00; border-left: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.planilla thead th.neto { background: #8a5f00; }
.planilla td.aporte { color: var(--muted); }
.planilla th.det, .planilla td.det { display: none; }
.planilla.ver-detalle th.det, .planilla.ver-detalle td.det { display: table-cell; }
.planilla tr.sin-horas td:not(.sticky-l):not(.acc) { color: #9aa4a6; }
.planilla tr.sin-horas td.neto { background: #faf6e8; color: #b5a67a; }
.planilla tbody tr:hover td:not(.neto):not(.dom):not(.horas) { background: #fbfaf6; }
.planilla tfoot td, .planilla tfoot td.horas, .planilla tfoot td.resumen, .planilla tfoot td.aporte { position: sticky; bottom: 0; z-index: 3; background: var(--primary-dark); color: #fff; font-weight: 700; border: 0; }
.planilla tfoot td.sticky-l { z-index: 6; }
.planilla tfoot td.neto { background: #8a5f00; color: #fff; border-color: #8a5f00; font-size: 1.1rem; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: #123c38; color: #fff; padding: .8rem 1.3rem; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; z-index: 100; }
.toast.error { background: var(--danger); }

/* ---------- Ingreso ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 2rem; width: min(400px, 100%); display: grid; gap: .9rem; text-align: center; }
.login-card h1 { margin: 0; }
.login-card label { text-align: left; }
.login-card .brand-mark { margin: 0 auto; }
.login-card .flash { text-align: left; margin: 0; }

/* ---------- Teléfono y tablet ---------- */
@media (max-width: 760px) {
  .wrap { padding: 1rem .75rem 4rem; }
  .topbar { flex-direction: column; align-items: flex-start; gap: .4rem; position: static; }
  h1 { font-size: 1.35rem; }
  .head-actions .btn.lg { flex: 1; }
  .planilla .sticky-l { min-width: 170px; }
  .inline-sel { margin-left: 0; }
  .planilla-wrap { max-height: none; }
}
@media print { .no-print { display: none !important; } }
