/* =========================================================
   Nóminas Semanales — estilos
   Cambia los colores de marca en :root para ajustarlos a tu empresa
   ========================================================= */
:root {
  --primary: #1f3a5f;
  --primary-600: #2a4d7a;
  --accent: #2e86ab;
  --extra: #c0631b;          /* color de horas extra */
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #dde3ea;
  --text: #1d2733;
  --muted: #6b7785;
  --ok: #2f855a;
  --ok-bg: #e6f4ec;
  --warn: #b7791f;
  --error: #c53030;
  --error-bg: #fdecec;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.r { text-align: right; } .c { text-align: center; }
.warn { color: var(--warn); font-weight: 600; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; }

/* ---------- Botones e inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 6px; cursor: pointer; font: inherit; font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f0f3f7; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }
.btn.danger-ghost { color: var(--error); border-color: #f2c4c4; }
.btn.danger-ghost:hover { background: var(--error-bg); }
.btn.pulse { box-shadow: 0 0 0 3px rgba(46, 134, 171, .35); }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 4px; color: var(--muted); }
.icon-btn:hover { background: #eef2f6; color: var(--text); }
.link { background: none; border: 0; color: #c9d6e6; cursor: pointer; padding: 2px 0; font: inherit; font-size: 12px; text-align: left; }
.link:hover { color: #fff; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus { outline: 2px solid rgba(46, 134, 171, .35); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: #3d4a59; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; }

/* ---------- Alertas, badges, toast ---------- */
.alert { padding: 10px 12px; border-radius: 6px; font-size: 13px; }
.alert.error { background: var(--error-bg); color: var(--error); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.borrador { background: #fff4e0; color: #9c5d00; }
.badge.cerrada { background: var(--ok-bg); color: var(--ok); }
.toast { position: fixed; bottom: 20px; right: 20px; padding: 12px 16px; border-radius: 8px; color: #fff; background: var(--ok); box-shadow: var(--shadow); z-index: 100; max-width: 380px; }
.toast.error { background: var(--error); }

/* ---------- Login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, #16293f 100%); }
.login-card { background: var(--surface); padding: 32px; border-radius: 12px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-logo { width: 48px; height: 48px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.login-title { font-size: 20px; color: var(--primary); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--primary); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; font-weight: 700; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 32px; height: 32px; border-radius: 7px; background: #fff; color: var(--primary); display: grid; place-items: center; }
#nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
#nav a { display: flex; align-items: center; gap: 10px; color: #d6e0ec; text-decoration: none; padding: 9px 10px; border-radius: 6px; margin-bottom: 2px; }
#nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
#nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav-ico { width: 20px; text-align: center; }
.nav-section { text-transform: uppercase; font-size: 10.5px; letter-spacing: .08em; color: #8fa5bf; padding: 16px 10px 6px; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 4px; }
.user-chip { display: flex; flex-direction: column; margin-bottom: 6px; }
.user-chip small { color: #9fb3ca; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar h2 { font-size: 18px; flex: 1; color: var(--primary); }
#btn-menu { display: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- Tarjetas y tablas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card-head { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.card-title, .section-title { font-size: 15px; color: var(--primary); margin-bottom: 10px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--border); background: #fafbfc; }
.table td { padding: 9px 10px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
.table tr.clickable:hover td { background: #f6f9fc; cursor: pointer; }
.table tr.inactive td { opacity: .55; }
.table.compact td { padding: 5px 6px; }
.table td.empty { text-align: center; color: var(--muted); padding: 30px; }
.table-scroll { overflow-x: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters > * { flex: 1 1 180px; }
.filters.rep label.check { flex: 0 0 auto; margin-bottom: 8px; }
.rep-btns { display: flex; gap: 8px; flex: 1 1 100%; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: none; padding: 10px 16px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid h3 { font-size: 14px; color: var(--primary); margin-top: 6px; }
.span2 { grid-column: span 2; }
.form-grid.one .span2 { grid-column: auto; }
fieldset.perms { border: 1px solid var(--border); border-radius: 6px; display: grid; gap: 6px; padding: 10px 12px; }
fieldset.perms legend { font-weight: 600; font-size: 12.5px; padding: 0 4px; }

/* ---------- Modal ---------- */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog.wide { width: min(860px, 96vw); }
dialog::backdrop { background: rgba(15, 25, 40, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; color: var(--primary); }
.modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: #fafbfc; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown .menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); min-width: 160px; z-index: 10; }
.dropdown.open .menu { display: block; }
.dropdown .menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; cursor: pointer; font: inherit; }
.dropdown .menu button:hover { background: #f0f3f7; }

/* ---------- Hoja semanal ---------- */
.nom-head { display: flex; flex-direction: column; gap: 8px; }
.inline-input { width: auto; min-width: 280px; margin-left: 8px; border-color: transparent; font-weight: 600; }
.inline-input:hover { border-color: var(--border); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar select { width: auto; min-width: 260px; }
.sheet-wrap { padding: 0; overflow-x: auto; }
.sheet { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1060px; }
.sheet td.r, .table td.r, .table tfoot td { white-space: nowrap; }
.table td.r small { color: var(--muted); }
.sheet th { background: var(--primary); color: #fff; font-size: 12px; font-weight: 600; padding: 8px 6px; position: sticky; top: 0; }
.sheet th.day { text-align: center; }
.sheet th.day small { display: block; font-weight: 400; opacity: .8; }
.sheet th.sun { background: #3a5578; }
.sheet td { border-bottom: 1px solid #e6eaef; padding: 6px; vertical-align: top; }
.sheet tbody tr:hover td { background: #f8fafc; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 170px; max-width: 200px; border-right: 1px solid #e6eaef; }
.sheet th.sticky-col { background: var(--primary); z-index: 2; }
.who { font-weight: 600; }
.day-cell { text-align: center; width: 92px; min-width: 92px; position: relative; padding: 6px 3px !important; }
.day-cell input { padding: 3px 2px; font-size: 12px; margin-bottom: 3px; text-align: center; }
.day-cell.ro { font-size: 12.5px; padding-top: 10px; }
.cell-res { display: block; font-size: 11.5px; color: var(--muted); min-height: 15px; }
.ex { color: var(--extra); }
b.ex { font-weight: 600; }
.dot { position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.sheet tfoot td { background: var(--primary); color: #fff; font-weight: 600; padding: 10px 6px; border: 0; }
.sheet tfoot .ex { color: #ffd2a8; }
.sheet tfoot .sticky-col { background: var(--primary); }
.row-acts { white-space: nowrap; }

/* ---------- Reportes ---------- */
.report-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--primary); padding-bottom: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.rh-emp { font-size: 17px; font-weight: 700; color: var(--primary); }
.rh-tit { font-weight: 600; }
.rh-meta { text-align: right; font-size: 12.5px; color: var(--muted); }
.report-table th { background: var(--primary); color: #fff; }
.report-table tbody tr:nth-child(even) td { background: #f7f9fb; }
.report-table tfoot td { background: #d9e2ec; font-weight: 700; border-top: 2px solid var(--primary); }

/* ---------- Roles ---------- */
.roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.role-head { display: flex; justify-content: space-between; align-items: baseline; }
.role ul { list-style: none; padding: 0; margin: 8px 0; font-size: 12.5px; display: grid; gap: 3px; }
.role li.yes { color: var(--ok); } .role li.no { color: #a0aab5; }

/* ---------- Móvil ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  #btn-menu { display: inline-block; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .table { font-size: 13px; }
  .card:has(> .table) { overflow-x: auto; }
}

/* ---------- Ausencias / horas extra en la hoja ---------- */
.legend { display: inline-block; width: 11px; height: 11px; border: 1px solid #c9d3dd; vertical-align: -1px; margin: 0 3px 0 8px; }
.legend.aus { background: #fde8e8; } .legend.he { background: #fff3d6; }
.day-cell.is-aus { background: #fde8e8 !important; }
.day-cell.is-he { background: #fff3d6 !important; }
.aus-txt { color: #b03a3a; }
.aus-btn { position: absolute; top: 2px; left: 2px; width: 16px; height: 14px; padding: 0; font-size: 9px; line-height: 12px; font-weight: 700;
  border: 1px solid var(--border); background: #fff; color: var(--muted); border-radius: 3px; cursor: pointer; opacity: .55; }
.day-cell:hover .aus-btn, .aus-btn.on { opacity: 1; }
.aus-btn.on { background: #c53030; border-color: #c53030; color: #fff; }
.day-cell.is-aus .cell-res { padding-top: 22px; }
.day-cell { padding-top: 14px !important; }
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 12px 2px; border-top: 1px solid var(--border); }
.menu-label:first-child { border-top: 0; }
.dropdown .menu { min-width: 230px; }
.dropdown .menu button { padding-left: 22px; }

/* ---------- Reporte Control Horario / Recapitulación (vista) ---------- */
.ch { padding: 0 0 18px; overflow-x: auto; }
.ch-band { background: #1f3a5f; color: #fff; font-weight: 700; font-size: 13px; padding: 9px 22px; display: flex; justify-content: space-between; border-radius: 8px 8px 0 0; }
.ch-title { color: #1f3a5f; font-size: 26px; margin: 18px 22px 2px; }
.ch-sub { margin: 0 22px 10px; font-size: 13px; }
.ch-legend { display: flex; gap: 28px; justify-content: center; font-size: 12px; color: #666; margin-bottom: 12px; }
.ch-legend i { display: inline-block; width: 18px; height: 20px; border: 1px solid #c9d3dd; vertical-align: middle; margin-right: 8px; }
.ch-legend i.aus { background: #fde8e8; } .ch-legend i.he { background: #fff3d6; }
.ch-table { width: calc(100% - 44px); margin: 0 22px 14px; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.ch-table th, .ch-table td { border: 1px solid #c9d3dd; padding: 5px 8px; text-align: left; }
.ch-table thead tr:last-child th { background: #2e7d8c; color: #fff; }
.ch-table th.ch-day { background: #1f3a5f; color: #fff; font-size: 15px; }
.ch-table tbody tr:nth-child(even) td { background: #f2f5f8; }
.ch-table tr.he td { background: #fff3d6 !important; }
.ch-table tr.aus td { background: #fde8e8 !important; }
.ch-table td.b { font-weight: 700; }
.ch-table.recap th.ch-group { color: #fff; font-size: 15px; padding: 8px; }
.ch-table.recap thead tr.navy th { background: #1f3a5f; }
.ch-table.recap td, .ch-table.recap th { padding: 8px; }
.ch-table.recap td:not(:first-child), .ch-table.recap tr.navy th:not(:first-child) { text-align: center; }
.ch-table.recap tfoot td { background: #e3e9ef; font-weight: 700; border-top: 2px solid #1f3a5f; }
