:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1f2428; --line: #30363d;
  --text: #f0f6fc; --muted: #8b949e; --blue: #58a6ff; --green: #238636; --green2: #2ea043;
  --lime: #deff9a; --red: #f85149; --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding-top: var(--safe-t); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.hidden { display: none !important; }

/* Barra superior / navegación */
.top { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 8px 16px; padding-top: calc(8px + var(--safe-t)); margin-top: calc(-1 * var(--safe-t)); }
.brand { font-weight: 700; white-space: nowrap; }
#nav { display: flex; gap: 4px; margin-left: auto; }
#nav button { background: none; border: 0; border-radius: 8px; padding: 6px 12px; color: var(--muted);
  display: flex; align-items: center; gap: 6px; }
#nav button small { font-size: 14px; }
#nav button.active { background: var(--bg); color: var(--text); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + var(--safe-b)); }
h2, h3 { margin: 0 0 10px; }
.muted { color: var(--muted); }

/* Móvil: navegación abajo */
@media (max-width: 700px) {
  .brand { font-size: 15px; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; background: var(--panel);
    border-top: 1px solid var(--line); justify-content: space-around; padding: 6px 4px calc(6px + var(--safe-b)); z-index: 30; }
  #nav button { flex-direction: column; gap: 0; padding: 4px 8px; flex: 1; }
  #nav button span { font-size: 20px; }
  #nav button small { font-size: 11px; }
  main { padding-bottom: calc(90px + var(--safe-b)); }
}

/* Pestañas de año y mes */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.tab { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid transparent;
  color: var(--muted); border-radius: 10px 10px 0 0; padding: 8px 14px; }
.tab.active { background: var(--panel); color: var(--text); font-weight: 700; border-color: var(--line); border-bottom-color: transparent; }
.tab .x { background: none; border: 0; color: var(--muted); padding: 0 2px; font-size: 12px; }
.tab.active .x { color: var(--red); }
.tab-add { display: flex; gap: 6px; flex: 0 0 auto; }
.tab-add input { width: 90px; padding: 6px 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: thin; }
.chip { flex: 0 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; color: var(--muted); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #0d1117; font-weight: 700; }

/* Tarjetas de totales */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 26px; font-weight: 800; }
.value.blue { color: var(--blue); } .value.lime { color: var(--lime); }

/* Botones */
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green2); }
.btn.blue { background: #3498db; border-color: #3498db; color: #fff; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.small { padding: 8px 12px; }
.icon-btn { background: none; border: 0; font-size: 20px; color: var(--muted); padding: 6px 10px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.fab { position: fixed; right: 18px; bottom: calc(86px + var(--safe-b)); z-index: 25; width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); border: 0; font-size: 30px; color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.5); }
@media (min-width: 701px) { .fab { bottom: 24px; } }

/* Lista de turnos */
.shifts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.shift { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; text-align: left; width: 100%; }
.shift:hover { border-color: var(--blue); }
.shift .l1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.shift .l2 { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
.shift .nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 13px; }
.nums b { display: block; font-size: 15px; }
.nums .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.net { color: var(--blue); } .tax { color: var(--red); } .plus { color: var(--lime); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.role { font-size: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); }

/* Calendario */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h2 { margin: 0; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.dow { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; }
.day { background: var(--bg); border: 1px solid var(--line); min-height: 78px; padding: 4px; border-radius: 6px; cursor: pointer; text-align: left; overflow: hidden; }
.day:hover { background: #21262d; }
.day.today { background: var(--panel2); border: 2px solid var(--blue); }
.day.blank { border: 0; background: transparent; cursor: default; }
.day .n { color: var(--muted); font-weight: 700; font-size: 13px; }
.day .tag { background: var(--green); border-radius: 4px; padding: 2px 4px; margin-top: 3px; cursor: pointer; }
.day .tag:hover { background: var(--green2); }
.day .tag b { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day .tag small { font-size: 10px; color: var(--lime); white-space: nowrap; }
@media (max-width: 700px) { .day { min-height: 64px; } .day .tag small { display: none; } .day .tag b { font-size: 10px; } }

/* Gráficos */
.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 22px; }
.bar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar .fill { width: 100%; max-width: 46px; background: var(--blue); border-radius: 4px 4px 0 0; min-height: 1px; }
.bar .v { font-size: 10px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.bar .k { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bar.zero .fill { background: var(--line); }

/* Ajustes */
.grid-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
label { display: block; font-size: 14px; color: var(--muted); }
label input, label select { margin-top: 4px; color: var(--text); font-size: 16px; }
label small { font-weight: 400; }
.list { list-style: none; padding: 0; margin: 8px 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--bg); }
.row-add { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.error { color: var(--red); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.section { margin-bottom: 14px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(1,4,9,.75); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px;
  max-height: 94vh; overflow-y: auto; padding: 14px 16px calc(18px + var(--safe-b)); display: grid; gap: 10px; }
@media (min-width: 701px) { .modal { align-items: center; } .sheet { border-radius: 16px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 0; }
legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.row-plus { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; }
.plus-list { list-style: none; padding: 0; margin: 8px 0 0; }
.plus-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 4px; background: var(--bg); cursor: pointer; font-size: 14px; }
.actions { display: grid; gap: 8px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); background: var(--panel2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 8px; z-index: 80; max-width: 90%; text-align: center; }
