﻿:root {
  --bg: #eef1f5;
  --paper: #ffffff;
  --ink: #15191f;
  --muted: #5d6673;
  --line: #1c2230;
  --soft-line: #d5dae2;
  --brand: #0f4c81;
  --brand-ink: #ffffff;
  --accent: #f2a900;
  --night: #3a3f8f;
  --morning: #c47f00;
  --afternoon: #c2410c;
  --free: #4b5563;
  --ok: #15803d;
  --warn: #b45309;
  --warn-bg: #fff4dc;
  --err: #b91c1c;
  --err-bg: #fde8e8;
  --me: #ffe066;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(15, 30, 60, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.topbar .logo { font-weight: 800; letter-spacing: .5px; font-size: 18px; white-space: nowrap; }
.topbar .logo span { color: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar a, .topbar .linkbtn { color: #fff; opacity: .9; text-decoration: none; font-size: 14px; background: none; border: 0; cursor: pointer; padding: 6px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 16px 0; background: var(--brand); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: transparent; color: #cfe0f2; padding: 10px 14px; border-radius: 8px 8px 0 0;
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.tabs button.active { background: var(--bg); color: var(--brand); }

main { max-width: 1180px; margin: 0 auto; padding: 14px 16px 90px; }

/* ---------- controles ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--soft-line); background: var(--paper); border-radius: 8px;
  padding: 9px 13px; cursor: pointer; font-weight: 600; min-height: 40px; white-space: nowrap;
}
.btn:hover { border-color: #aab3c0; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1b1300; }
.btn.danger { color: var(--err); }
.btn.whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 5px 9px; min-height: 32px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--soft-line); border-radius: 8px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; background: transparent; padding: 9px 14px; cursor: pointer; font-weight: 600; min-height: 40px; }
.seg button.active { background: var(--brand); color: #fff; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, select.input, input.input {
  border: 1px solid var(--soft-line); border-radius: 8px; padding: 9px 10px; background: #fff; color: var(--ink); min-height: 40px; font-size: 15px;
}
.navdate { display: flex; align-items: center; gap: 6px; }
.navdate .label { font-weight: 700; min-width: 150px; text-align: center; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #e5e7eb; color: #374151; }
.badge.pub { background: #dcfce7; color: var(--ok); }
.badge.draft { background: var(--warn-bg); color: var(--warn); }
.badge.dirty { background: var(--err-bg); color: var(--err); }

.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 17px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---------- planilla (igual al papel) ---------- */
.week-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.week-tabs button { flex: none; border: 1px solid var(--soft-line); background: #fff; border-radius: 99px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.week-tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.day {
  background: var(--paper); border: 2px solid var(--line); margin-bottom: 12px; border-radius: 4px;
  text-transform: uppercase; box-shadow: var(--shadow);
}
.day.unpublished { opacity: .6; }
.day-title {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; letter-spacing: .5px; padding: 6px 8px; border-bottom: 1.5px solid var(--line); font-size: 15px; position: relative;
}
.day-title .tag { position: absolute; right: 8px; text-transform: none; }
.day-body { display: grid; grid-template-columns: 1fr; }
.shift { border-bottom: 1.5px solid var(--line); min-width: 0; }
.shift-head {
  text-align: center; font-size: 13px; font-weight: 700; padding: 4px 6px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: center; gap: 8px; align-items: baseline;
}
.shift-head .hours { font-weight: 500; color: var(--muted); font-size: 11px; text-transform: none; }
.shift.T3 .shift-head { background: #eceefe; color: var(--night); }
.shift.T1 .shift-head { background: #fff6dd; color: var(--morning); }
.shift.T2 .shift-head { background: #ffece2; color: var(--afternoon); }
.shift.libres .shift-head { background: #f1f2f4; color: var(--free); }
.shift-rows { padding: 4px 6px 6px; }
.prow { display: grid; grid-template-columns: 112px 1fr; align-items: start; gap: 4px; min-height: 28px; }
.prow .plabel { font-size: 12px; font-weight: 600; padding-top: 6px; color: #2d3440; white-space: nowrap; }
.slot, .libre-list { list-style: none; margin: 0; padding: 2px 0; min-height: 28px; display: flex; flex-direction: column; gap: 3px; }
.libre-list { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.chip {
  display: flex; align-items: center; gap: 4px; padding: 3px 6px; border-radius: 6px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; line-height: 1.3; min-height: 26px; word-break: break-word;
}
.chip .tagmini { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: #e5e7eb; color: #374151; text-transform: none; }
.chip .tagmini.lic { background: #e0e7ff; color: #3730a3; }
.chip .tagmini.sup { background: #f3e8ff; color: #6b21a8; }
.chip .tagmini.out { background: var(--warn-bg); color: var(--warn); }
.chip.me { background: var(--me); border-color: #e0b400; }
.chip.dim { opacity: .35; }
.chip.err { border-color: var(--err); background: var(--err-bg); }
.chip.warn { border-color: #f0b44c; }
.chip.lic { color: #3730a3; }
.chip.missing { color: #a3aab5; font-style: italic; font-weight: 500; border: 1px dashed #c3c9d2; text-transform: none; font-size: 12px; }

/* editor */
.editable .chip { background: #f4f6f9; border-color: #dfe3ea; cursor: grab; touch-action: manipulation; user-select: none; }
.editable .chip.me { background: var(--me); }
.editable .chip.err { border-color: var(--err); background: var(--err-bg); }
.editable .chip.warn { border-color: #f0b44c; background: #fffaf0; }
.editable .chip .name { flex: 1; }
.editable .chip .lock { font-size: 11px; }
.editable .chip .x { border: 0; background: transparent; cursor: pointer; color: #8b93a1; font-size: 15px; padding: 0 2px; line-height: 1; }
.editable .chip .x:hover { color: var(--err); }
.editable .slot { border-radius: 6px; padding: 2px; }
.editable .slot.under { background: repeating-linear-gradient(45deg, #fff 0 6px, #fff4f4 6px 12px); outline: 1px dashed #f3a3a3; }
.editable .libre-list .chip { background: #fff; }
.add {
  border: 1px dashed #b6bfcc; background: transparent; color: #6b7480; border-radius: 6px; font-size: 12px; cursor: pointer;
  padding: 2px 8px; min-height: 26px; text-transform: none; align-self: flex-start;
}
.add.task { margin-top: 4px; }
.add:hover { border-color: var(--brand); color: var(--brand); }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }

.chip.new { background: #dcfce7 !important; border-color: #16a34a !important; }
.sheet.wide { max-width: 1100px; }
.sheet .sticky-actions { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: #fff; padding: 10px 0; margin-bottom: -6px; border-top: 1px solid var(--soft-line); }
table.cmp { max-width: 520px; }
.suggest { text-transform: none; display: flex; gap: 8px; align-items: center; padding: 6px 10px; background: #eef6ff; border-bottom: 1px solid #c9ddf5; font-size: 13px; color: #123d66; }
.suggest span { flex: 1; }
.suggest small { color: #4b6480; }
.suggest-alert { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shift.closed .shift-head { background: #eceff3; color: #6b7280; }
.closed-msg { text-align: center; font-weight: 800; letter-spacing: 2px; color: #9aa1ab; padding: 14px 0; }
.shift.special .shift-head .hours { color: #b45309; font-weight: 700; }
.refuerzo-badge { background: #dcfce7; color: var(--ok); text-transform: none; font-size: 11px; }
.closed-badge { background: #374151; color: #fff; }
.issues { text-transform: none; border-top: 1px solid var(--soft-line); padding: 6px 10px; font-size: 13px; }
.issues summary { cursor: pointer; font-weight: 600; color: var(--warn); }
.issues.has-err summary { color: var(--err); }
.issues ul { margin: 6px 0 0; padding-left: 18px; }
.issues li.error { color: var(--err); }
.issues li.warn { color: var(--warn); }

@media (min-width: 880px) {
  .day-body { grid-template-columns: 1fr 1.3fr 1.3fr .85fr; }
  .shift { border-bottom: 0; border-right: 1.5px solid var(--line); }
  .shift:last-child { border-right: 0; }
  .libre-list { flex-direction: column; align-items: center; }
  .prow { grid-template-columns: 104px 1fr; }
  .shift.T3 .prow { grid-template-columns: 70px 1fr; }
}

/* ---------- mis turnos ---------- */
.mylist { display: grid; gap: 8px; }
.myday { display: grid; grid-template-columns: 82px 1fr; gap: 10px; align-items: center; background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); border-left: 6px solid var(--free); }
.myday .d { font-weight: 800; line-height: 1.15; }
.myday .d small { display: block; font-weight: 500; color: var(--muted); }
.myday .what { font-weight: 700; }
.myday .what small { display: block; font-weight: 500; color: var(--muted); }
.myday.T3 { border-left-color: var(--night); }
.myday.T1 { border-left-color: var(--morning); }
.myday.T2 { border-left-color: var(--afternoon); }
.myday.L { background: #f7f8fa; }
.myday.LIC { border-left-color: #6366f1; background: #f5f5ff; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.summary .pill { background: #fff; border-radius: 99px; padding: 6px 12px; box-shadow: var(--shadow); font-size: 14px; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14px; background: #fff; }
table.grid th, table.grid td { border-bottom: 1px solid var(--soft-line); padding: 8px; text-align: left; vertical-align: middle; }
table.grid th { background: #f6f7f9; font-size: 12px; text-transform: uppercase; color: var(--muted); position: sticky; top: 0; }
table.grid td.num, table.grid th.num { text-align: center; }
table.grid td.sticky, table.grid th.sticky { position: sticky; left: 0; background: #fff; z-index: 1; }
table.grid th.sticky { background: #f6f7f9; z-index: 2; }
.good { color: var(--ok); font-weight: 700; }
.bad { color: var(--err); font-weight: 700; }
.meh { color: var(--warn); font-weight: 700; }

.form-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .form-grid { grid-template-columns: repeat(4, 1fr); } .form-grid .wide { grid-column: span 2; } }

.alerts { display: grid; gap: 6px; margin-bottom: 12px; }
.alert { padding: 9px 12px; border-radius: 8px; font-size: 14px; background: var(--warn-bg); color: #7a4a00; }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.ok { background: #dcfce7; color: var(--ok); }
.alert.info { background: #e0ecfa; color: var(--brand); }

/* ---------- hojas / modales ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 520px; max-height: 86vh; overflow: auto; border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
}
.sheet h3 { margin: 0 0 4px; }
.sheet .sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.sheet .opts { display: grid; gap: 6px; }
.sheet .opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--soft-line); border-radius: 10px; padding: 10px 12px; background: #fff; cursor: pointer; text-align: left; font-weight: 600; min-height: 46px; }
.sheet .opt:hover { border-color: var(--brand); }
.sheet .opt small { font-weight: 500; color: var(--muted); }
.sheet .opt:disabled { opacity: .45; cursor: not-allowed; }
.sheet .group-title { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 10px 0 2px; font-weight: 700; }
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 16px; } }

.busy { position: fixed; inset: 0; z-index: 60; background: rgba(255, 255, 255, .8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-weight: 700; text-align: center; padding: 20px; }
.spinner { width: 46px; height: 46px; border: 5px solid #d5dde8; border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 70; box-shadow: var(--shadow); max-width: 92vw; font-size: 14px; }

.login { max-width: 380px; margin: 8vh auto; }
.login .field { margin-bottom: 10px; }

/* barra de acciones fija en celular */
.actionbar { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 699px) {
  .actionbar.fixed-mobile {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 14px rgba(0, 0, 0, .1); flex-wrap: nowrap; overflow-x: auto;
  }
  .actionbar.fixed-mobile .btn { flex: 1 0 auto; }
  .navdate .label { min-width: 0; flex: 1; }
  .toolbar > * { flex: 1 1 auto; }
  .hide-mobile { display: none !important; }
}

@media print {
  .topbar, .tabs, .toolbar, .actionbar, .issues, .add, .x { display: none !important; }
  main { padding: 0; }
  .day { box-shadow: none; break-inside: avoid; }
}

/* tabla de empleados compacta */
#emp-table table.grid th, #emp-table table.grid td { padding: 6px 4px; }
#emp-table .input { min-height: 32px; padding: 4px 6px; font-size: 13px; }
#emp-table select.input { width: 84px; }
#emp-table [data-jdias] { width: 56px !important; }
#emp-table th { font-size: 11px; }

