:root {
  --bg: #f5f4f0; --card: #fff; --ink: #1d2430; --mute: #6b7280; --line: #e6e3dc;
  --accent: #1d2430; --gold: #b5762a; --goldbg: #f3e7d6;
  --warn: #d97706; --warnbg: #fff4e0; --bad: #c9362f; --badbg: #fde8e6; --ok: #23875a; --okbg: #e3f4ec;
  --r: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
.loading { text-align: center; color: var(--mute); padding: 40px; }
main { padding: 18px 14px 60px; }
.wrap { max-width: 580px; margin: 0 auto; }
.wide { max-width: 1180px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 12.5px; margin: 0 0 8px; color: var(--mute); text-transform: uppercase; letter-spacing: .05em; }
.mute { color: var(--mute); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.center { text-align: center; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* barra superior */
.top { position: sticky; top: 0; z-index: 10; background: var(--ink); color: #fff; display: flex; gap: 8px; align-items: center; padding: 9px 14px; flex-wrap: wrap; }
.top .brand { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.top .brand span { color: #e2b26f; }
.top .btn { background: #2d3748; color: #fff; border-color: #3d4a5e; }
.top .btn.on { background: #fff; color: var(--ink); border-color: #fff; }
.top select { background: #2d3748; color: #fff; border: 1px solid #3d4a5e; border-radius: 9px; padding: 6px 8px; max-width: 220px; }

/* botones y formularios */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 12px; font-weight: 600; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.dark { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.icon { padding: 6px 11px; }
.btn.big { width: 100%; padding: 12px; font-size: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=time], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px;
}
input[type=color] { width: 42px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.inline input, .inline select { width: auto; padding: 6px 8px; font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 8px 0; }
.err-msg { color: var(--bad); font-size: 14px; margin-top: 10px; }
.seg { display: inline-flex; background: #ebe8e1; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; color: var(--mute); font-weight: 600; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.av { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--warn); color: #fff; margin-left: 6px; vertical-align: 2px; }

/* ingreso */
.brandbig { text-align: center; margin: 26px 0 22px; }
.brandbig .logo { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.brandbig .logo span { color: var(--gold); }
.store { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.store:hover { border-color: var(--gold); }
.store .ico { width: 42px; height: 42px; border-radius: 10px; background: var(--goldbg); display: grid; place-items: center; font-size: 20px; }

/* trabajador */
.hello { display: flex; align-items: center; gap: 12px; }
.hello .av { width: 48px; height: 48px; font-size: 16px; }
.banner { background: var(--warnbg); border: 1px solid #f5cf8f; border-radius: var(--r); padding: 12px 14px; }
.banner b { color: #8a4b00; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.kpi .v { font-size: 22px; font-weight: 800; }
.kpi .l { font-size: 11.5px; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }
.bar { height: 7px; border-radius: 9px; background: #ece9e2; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; border-radius: 9px; }
.months { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.months button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 600; white-space: nowrap; position: relative; }
.months button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.months button .pd { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); border: 2px solid var(--bg); }
.wrow { display: grid; grid-template-columns: 62px 1fr auto; gap: 4px 10px; align-items: center; padding: 11px 12px; border-bottom: 1px solid var(--line); position: relative; }
.wrow:last-child { border-bottom: 0; }
.wrow.out { opacity: .55; }
.wrow.today { background: #fbf7ef; }
.wrow.today::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--gold); }
.wrow.changed { background: #fff8ea; }
.wday b { display: block; font-size: 14px; } .wday span { font-size: 12px; color: var(--mute); }
.shift { font-weight: 700; font-size: 15px; }
.was { grid-column: 2 / 4; font-size: 12.5px; color: #8a4b00; }
.was s { color: var(--mute); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .h { font-size: 11px; text-align: center; color: var(--mute); font-weight: 700; padding: 4px 0; }
.cal .c { min-height: 60px; border-radius: 9px; background: #fff; border: 1px solid var(--line); padding: 5px; font-size: 11.5px; position: relative; overflow: hidden; }
.cal .c.x { background: transparent; border-style: dashed; color: var(--mute); }
.cal .c .n { font-weight: 700; font-size: 12px; }
.cal .c.today { outline: 2px solid var(--gold); }
.cal .c.chg::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.cal .c .s { font-weight: 600; margin-top: 2px; line-height: 1.25; word-break: break-word; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--mute); align-items: center; }

/* administración */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--mute); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--ink); }
.akpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 10px; background: var(--badbg); color: #7a1f1a; font-size: 14px; margin-bottom: 6px; }
.alert.ok { background: var(--okbg); color: #14573a; }
.alert.warn { background: var(--warnbg); color: #7a4300; }
.alert.info { background: #eef2f8; color: #27364d; }
.slider { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.slider input[type=range] { flex: 1; min-width: 160px; accent-color: var(--gold); }
.slider .t { font-size: 22px; font-weight: 800; min-width: 72px; text-align: center; }
.plan svg { width: 100%; display: block; touch-action: none; user-select: none; }
.plan.edit svg .zone { cursor: move; }
.plan.edit svg .handle { cursor: nwse-resize; }
.plan.edit svg .lbl { cursor: move; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.plist .pr { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); }
.plist .pr:first-of-type { border-top: 0; }
.plist .pr.off { opacity: .45; }
.plist .nm { font-weight: 600; font-size: 14px; }
.plist .st { font-size: 12px; color: var(--mute); }
table { border-collapse: collapse; width: 100%; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.tbl th { font-size: 11.5px; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.tbl tr.inactive td { color: var(--mute); }
.scroll { overflow-x: auto; }
.xl { font-size: 12px; }
.xl td, .xl th { border: 1px solid #dcd8cf; padding: 4px 6px; white-space: nowrap; }
.xl th { background: #efece6; font-weight: 700; position: sticky; top: 0; }
.xl td.err { background: var(--badbg); color: #7a1f1a; font-weight: 700; }
.xl td.chg { background: #fff1c9; }
.xl td.new { background: #e6f0ff; }
.xl td.code { color: var(--mute); }
.xl tr.isnew td:first-child, .xl tr.isnew td:nth-child(2) { background: #e6f0ff; }
.hm { border-collapse: separate; border-spacing: 3px; width: auto; }
.hm td, .hm th { text-align: center; font-size: 12px; padding: 0; }
.hm th { color: var(--mute); font-weight: 600; padding: 2px 4px; }
.hm td.c { min-width: 46px; height: 36px; border-radius: 7px; font-weight: 800; font-size: 13px; cursor: default; }
.hm td.pk { box-shadow: inset 0 0 0 2px var(--ink); }
.hm td.closed { background: #ecebe7; color: var(--mute); font-weight: 600; }
.hm .dl { text-align: right; padding-right: 8px; white-space: nowrap; font-weight: 600; }
.drop { border: 2px dashed #cfc9bd; border-radius: var(--r); padding: 22px; text-align: center; background: #fbfaf7; }
.drop.over { border-color: var(--gold); background: #fdf7ec; }
.pins td { font-size: 16px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.pins td.pin { font-weight: 800; font-size: 20px; letter-spacing: .15em; }
.issues { max-height: 320px; overflow: auto; }

/* modal y aviso */
dialog { border: 0; border-radius: 14px; padding: 0; max-width: 460px; width: calc(100% - 28px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 24, 32, .45); }
#modal-body { padding: 18px; }
#toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 30px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); }

@media (max-width: 900px) { .akpis { grid-template-columns: 1fr 1fr; } .grid2 { grid-template-columns: 1fr; } }
/* impresión */
.printbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; background: var(--ink); color: #fff; }
.printbar .mute { color: #c9ced6; }
.printbar .btn:not(.gold) { color: var(--ink); }
.printbar .seg button { color: var(--mute); }
.printbar .seg button.on { color: var(--ink); }
.printpage { background: #fff; max-width: 1200px; margin: 16px auto; padding: 18px; border: 1px solid var(--line); }
.printpage h1 { font-size: 20px; }
.ptable { border-collapse: collapse; width: 100%; margin-top: 10px; }
.ptable th, .ptable td { border: 1px solid #b9b4a9; padding: 3px 4px; font-size: 10.5px; text-align: center; vertical-align: top; }
.ptable th { background: #efece6; }
.ptable td.pname { text-align: left; white-space: nowrap; font-weight: 600; }
.ptable td.code { color: #6b7280; }
.ptable tr.parea td { text-align: left; font-weight: 800; text-transform: uppercase; background: #faf8f4; font-size: 10px; }
.ptable.week td, .ptable.week th { font-size: 13px; padding: 6px; }
.ptable.month td { font-size: 9px; padding: 2px; line-height: 1.15; }
.cal-print td { height: 74px; text-align: left; width: 13%; }
.cal-print td.out { background: #f6f5f2; }
.cal-print .pn { font-weight: 800; font-size: 12px; }
.cal-print .ps { font-size: 13px; font-weight: 600; margin-top: 4px; }
@media print {
  .noprint { display: none !important; }
  .printpage { border: 0; margin: 0; padding: 0; max-width: none; }
  .ptable th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  #toast { display: none !important; }
  body.modal-open #app { display: none !important; }
  dialog { position: static; box-shadow: none; max-width: none; width: 100%; }
  dialog .noprint { display: none; }
}
