:root {
  --bg: #f5f3ef; --panel: #fff; --ink: #1f2326; --muted: #6b7075; --line: #e3dfd8;
  --accent: #0f5c6e; --accent-ink: #fff; --ok: #2e7d4f; --warn: #c77d12; --bad: #b3362f; --vip: #8a5cc2;
  --radius: 10px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.ghost { background: transparent; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; }
input[type=number] { width: 80px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--accent); }
.datebox { display: flex; gap: 4px; align-items: center; }
#tabs { display: flex; gap: 4px; margin-left: auto; }
#tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
main { padding: 16px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.kpis { display: flex; gap: 14px; margin-left: auto; color: var(--muted); flex-wrap: wrap; }
.kpis b { color: var(--ink); font-size: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.grid2 { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* Agenda */
.shift-h { font-weight: 600; margin: 10px 0 6px; display: flex; justify-content: space-between; color: var(--muted); }
.res { display: grid; grid-template-columns: 48px 34px 1fr auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; margin-bottom: 6px; background: #fff; cursor: pointer; }
.res:hover { border-color: var(--accent); }
.res .t { font-weight: 700; } .res .p { text-align: center; background: var(--bg); border-radius: 6px; padding: 2px; }
.res .n { overflow: hidden; } .res .n small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res select { font-size: 12px; padding: 3px; }
.st-pending { border-left-color: var(--warn); } .st-arrived { border-left-color: #3a7bd5; } .st-seated { border-left-color: var(--ok); }
.st-finished { opacity: .6; } .st-cancelled, .st-no_show { opacity: .45; border-left-color: var(--bad); } .st-waitlist { border-left-color: #999; border-style: dashed; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--bg); color: var(--muted); margin-left: 4px; }
.badge.vip { background: var(--vip); color: #fff; } .badge.alg { background: #fde7c7; color: #8a4b00; } .badge.bad { background: var(--bad); color: #fff; } .badge.lock { background: #dfe9ec; color: var(--accent); }

.timeline { overflow: auto; max-height: calc(100vh - 170px); }
.tl { position: relative; min-width: max-content; }
.tl-row { display: flex; height: 30px; border-bottom: 1px solid var(--line); }
.tl-label { position: sticky; left: 0; z-index: 2; width: 90px; flex: none; background: #fff; padding: 6px 8px; font-size: 12px; border-right: 1px solid var(--line); }
.tl-track { position: relative; flex: none; background-image: repeating-linear-gradient(90deg, transparent 0 44px, var(--line) 44px 45px); }
.tl-zone { position: sticky; left: 0; background: var(--bg); font-weight: 600; padding: 4px 8px; font-size: 12px; }
.tl-head { display: flex; position: sticky; top: 0; z-index: 3; background: #fff; border-bottom: 1px solid var(--line); }
.tl-head .tl-label { font-weight: 600; }
.tl-hour { position: absolute; top: 6px; font-size: 11px; color: var(--muted); }
.bar { position: absolute; top: 3px; height: 23px; border-radius: 5px; background: var(--accent); color: #fff; font-size: 11px; padding: 3px 6px; white-space: nowrap; overflow: hidden; cursor: pointer; }
.bar.st-pending { background: var(--warn); } .bar.st-seated { background: var(--ok); } .bar.st-arrived { background: #3a7bd5; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); z-index: 1; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 30px 12px; overflow: auto; }
.modal-box { background: #fff; border-radius: 14px; width: min(760px, 100%); padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal h3 { margin: 0 0 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; align-items: flex-end; }
.row > label { flex: 1; min-width: 120px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.slot { padding: 5px 9px; font-size: 12px; }
.slot.no { opacity: .4; text-decoration: line-through; }
.slot.re { border-style: dashed; }
.slot.sel { background: var(--accent); color: #fff; border-color: var(--accent); opacity: 1; text-decoration: none; }
.tablepick { max-height: 160px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.cinfo { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-bottom: 10px; }

/* Plano */
.plano { display: grid; grid-template-columns: 1fr 280px; gap: 14px; }
@media (max-width: 1000px) { .plano { grid-template-columns: 1fr; } }
.zone-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.zone-tabs button.active { background: var(--accent); color: #fff; }
svg.floor { width: 100%; height: auto; background: #fbfaf8; border: 1px solid var(--line); border-radius: var(--radius); touch-action: none; }
svg .tbl { cursor: grab; }
svg .tbl .shape { stroke: #8b8f93; stroke-width: 1.5; }
svg .tbl.free .shape { fill: #e3f1e8; } svg .tbl.busy .shape { fill: #f6d6d3; } svg .tbl.soon .shape { fill: #fcebc9; } svg .tbl.off .shape { fill: #eee; stroke-dasharray: 4 3; }
svg .tbl.sel .shape { stroke: var(--accent); stroke-width: 3; }
svg text { font-size: 12px; pointer-events: none; user-select: none; }
svg text.sub { font-size: 10px; fill: #555; }

/* Tablas */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
table.list tr.click:hover { background: var(--bg); cursor: pointer; }
.cfg section { margin-bottom: 18px; }
.cfg h3 { margin: 0 0 10px; }
.shift-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.wd { display: flex; gap: 6px; }
.muted { color: var(--muted); font-size: 12px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 99; }
#toast.show { opacity: 1; } #toast.err { background: var(--bad); }

/* ---------- Vista Sala (estilo CoverManager, oscuro) ---------- */
.sala { --sbg: #1d2023; --spanel: #2a2e32; --sline: #3a3f44; --sink: #e9e6e1; --smuted: #9aa0a6; --syellow: #ffd72e;
  background: var(--sbg); color: var(--sink); margin: -16px; padding: 12px; min-height: calc(100vh - 58px); }
.sbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.sshifts { display: flex; gap: 6px; }
.sshifts button, .sfloors button, .sbtn, .stime button { background: transparent; color: var(--sink); border: 1px solid var(--sline); border-radius: 6px; padding: 7px 12px; font-weight: 600; font-size: 12px; letter-spacing: .3px; }
.sshifts button.on, .sfloors button.on { background: var(--syellow); color: #222; border-color: var(--syellow); }
.sbtn.primary { background: var(--syellow); color: #222; border-color: var(--syellow); }
.skpi { display: flex; gap: 14px; color: var(--smuted); font-size: 13px; margin-left: auto; }
.skpi b { color: var(--sink); font-size: 15px; }
.sgrid { display: grid; grid-template-columns: minmax(360px, 460px) 1fr; gap: 12px; }
@media (max-width: 1000px) { .sgrid { grid-template-columns: 1fr; } }
.slist { background: var(--spanel); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; max-height: calc(100vh - 150px); }
.ssearch { background: #1f2326; border: 1px solid var(--sline); color: var(--sink); margin-bottom: 8px; }
.shead, .srow { display: grid; grid-template-columns: 52px 46px 1fr 34px 108px; gap: 6px; align-items: center; }
.shead { font-size: 11px; color: var(--smuted); padding: 4px 8px; text-transform: uppercase; }
.srows { overflow: auto; }
.srow { background: #33383d; border-left: 5px solid #7cb342; border-radius: 6px; padding: 8px; margin-bottom: 6px; cursor: pointer; font-size: 13px; }
.srow:hover { background: #3b4147; }
.srow.dim { opacity: .5; }
.smesa { font-weight: 700; } .nomesa { color: #e57373; }
.shora { font-weight: 600; } .spax { text-align: center; font-weight: 700; }
.snom small { display: block; color: var(--smuted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stsel { width: 100%; border: 0; border-radius: 12px; font-size: 11px; font-weight: 600; padding: 4px 6px; }
.sempty { color: var(--smuted); padding: 20px; text-align: center; }
.sfloor { background: var(--spanel); border-radius: 10px; padding: 10px; }
.sfloorbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.sfloors { display: flex; gap: 6px; }
.stime { display: flex; gap: 4px; align-items: center; }
.stime select { background: #1f2326; color: var(--sink); border: 1px solid var(--sline); font-weight: 700; }
.slegend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--smuted); margin-left: auto; }
.slegend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.sfwrap { position: relative; }
#sfloor { width: 100%; height: auto; max-height: calc(100vh - 210px); border-radius: 8px; touch-action: none; display: block; }
#sfloor text { font-size: 12.5px; pointer-events: none; user-select: none; }
#sfloor .zlabel { fill: #b9a77a; font-size: 15px; font-weight: 600; letter-spacing: .5px; opacity: .85; }
#sfloor .stbl { cursor: pointer; }
.tpop { position: absolute; z-index: 20; background: #fff; color: #222; border-radius: 10px; padding: 10px; width: 240px; box-shadow: 0 10px 30px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 6px; }
.tpop .tph { font-weight: 700; } .tpop .tph span { font-weight: 400; color: #777; font-size: 12px; }
.tpop .tpr { font-size: 13px; padding: 5px; border-radius: 6px; cursor: pointer; } .tpop .tpr:hover { background: #f1f1f1; }
.tpop .tpr i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.tpop .tpe { color: #777; font-size: 13px; }
.tpop .sbtn { color: #222; border-color: #ddd; text-align: left; }

/* ---------- Resumen anual ---------- */
.rkpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.rkpis .big { font-size: 26px; font-weight: 700; margin: 2px 0; }
.rgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1000px) { .rgrid { grid-template-columns: 1fr; } }
.rchart { width: 100%; height: auto; }
.rchart .bv { font-size: 11px; fill: #1f2326; } .rchart .bl { font-size: 11px; fill: #6b7075; }
.rchart .bar:hover path { fill: #0a3f4c; }
.hcal { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.hmt { font-weight: 600; font-size: 13px; margin-bottom: 4px; } .hmt span { color: #6b7075; font-weight: 400; font-size: 12px; }
.hgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.hd { font-size: 10px; color: #6b7075; text-align: center; }
.hc { aspect-ratio: 1; border-radius: 3px; cursor: pointer; }
.hc.empty { background: transparent; cursor: default; }
.hc:not(.empty):hover { outline: 2px solid #1f2326; }
.hlegend { display: flex; gap: 3px; align-items: center; font-size: 11px; color: #6b7075; margin-bottom: 10px; }
.hlegend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.rtip { position: fixed; z-index: 60; background: #1f2326; color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; pointer-events: none; }

/* Sala: lista por horas + cronograma oscuro */
.sright { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.shour { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 8px 4px; color: var(--syellow); cursor: pointer; border-bottom: 1px solid var(--sline); margin: 6px 0 6px; }
.shour span { color: var(--smuted); font-size: 12px; }
.slist { max-height: none; }
.srows { max-height: calc(100vh - 230px); }
.stl { background: var(--spanel); border-radius: 10px; padding: 10px; }
.tltitle { font-weight: 600; margin-bottom: 6px; } .tltitle span { color: var(--smuted); font-weight: 400; font-size: 12px; }
.tlscroll { overflow: auto; max-height: 360px; border-radius: 6px; background: #24282b; }
.tlin { position: relative; }
.tlhead, .tlarr, .tlr { display: flex; }
.tlhead { position: sticky; top: 0; z-index: 3; background: #2f3439; height: 26px; }
.tlarr { position: sticky; top: 26px; z-index: 3; background: #2a2e32; height: 20px; border-bottom: 1px solid var(--sline); }
.tll { position: sticky; left: 0; z-index: 2; width: 92px; flex: none; background: #2f3439; padding: 4px 8px; font-size: 12px; font-weight: 600; border-right: 1px solid var(--sline); }
.tll span { color: var(--smuted); font-weight: 400; font-size: 11px; }
.tlarr .tll { font-size: 11px; color: var(--smuted); padding: 2px 8px; background: #2a2e32; }
.tlt { position: relative; flex: none; }
.tlhead .tlt, .tlr .tlt { background-image: repeating-linear-gradient(90deg, #3a3f44 0 1px, transparent 1px 36px), repeating-linear-gradient(90deg, #4a5056 0 1px, transparent 1px 144px); }
.tlh { position: absolute; top: 5px; margin-left: 4px; font-size: 12px; font-weight: 700; color: var(--sink); pointer-events: none; }
.tlslot { position: absolute; top: 0; bottom: 0; cursor: pointer; } .tlslot:hover { background: rgba(255,215,46,.18); }
.tla { position: absolute; top: 2px; text-align: center; font-size: 11px; font-weight: 700; color: var(--syellow); }
.tlz { position: sticky; left: 0; padding: 4px 8px; font-size: 11px; font-weight: 700; color: #b9a77a; background: #23272a; text-transform: uppercase; letter-spacing: .5px; }
.tlr { height: 26px; border-bottom: 1px solid #30353a; }
.tlbar { position: absolute; top: 3px; height: 20px; border-radius: 4px; font-size: 11px; font-weight: 600; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.tlbar:hover { filter: brightness(1.15); z-index: 1; }
.tlnow { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--syellow); z-index: 4; pointer-events: none; box-shadow: 0 0 6px rgba(255,215,46,.7); }
/* Entradas por franja */
.arrt td { vertical-align: top; }
.abar { position: relative; height: 12px; background: #eef0f1; border-radius: 4px; margin-top: 3px; }
.afill { height: 100%; background: #0f5c6e; border-radius: 4px; }
.afill.over { background: #b3362f; }
.alim { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #1f2326; }
.anames { font-size: 11px; color: #555; margin-top: 3px; }
.aover { color: #b3362f; font-weight: 700; }
.emptyslot td { color: #aaa; }

.st-reconfirmed { border-left-color: #43a047; } .bar.st-reconfirmed { background: #43a047; }
/* Comunicaciones */
.pvwrap { display: grid; grid-template-columns: 1fr 280px; gap: 14px; margin-top: 10px; }
@media (max-width: 900px) { .pvwrap { grid-template-columns: 1fr; } }
#pvFrame { width: 100%; height: 760px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.smsbox { background: #e9f5e9; border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.commsbox { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.commsbox .row button { font-size: 12px; padding: 5px 9px; }
.modal-box { width: min(860px, 100%); }
.sbtn.sonline.on { border-color: #2e7d32; color: #7ee08a; }
.sbtn.sonline.off { background: #b3362f; border-color: #b3362f; color: #fff; }
.sbtn.sonline.part { border-color: #ef8a00; color: #ffb65c; }
.onrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid #eee; }
.onrow.dis { opacity: .45; }
.onsw { min-width: 110px; border: 0; border-radius: 20px; padding: 9px 14px; font-weight: 800; letter-spacing: .5px; cursor: pointer; color: #fff; }
.onsw.on { background: #2e7d32; } .onsw.off { background: #b3362f; }
#restartBtn.upd { background: #ffc72c; color: #222; border-color: #ffc72c; font-weight: 700; }
.agwrap { max-width: 900px; margin: 0 auto; padding: 18px; }
.agwrap textarea { width: 100%; font: inherit; padding: 12px; border: 1px solid #ccc; border-radius: 10px; margin-bottom: 8px; }
.agex { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
.chip { border: 1px solid #ddd; background: #fafafa; border-radius: 16px; padding: 5px 11px; font-size: 12px; cursor: pointer; }
.agcard { border: 1px solid #e3e3e3; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.agq div { margin-top: 4px; font-size: 15px; }
.aga { background: #f4f7fb; border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.agacts { list-style: none; padding: 0; margin: 6px 0 10px; } .agacts li { padding: 4px 0; } .agacts li.bad { color: #999; }
.agacts .err { color: #b3362f; }
.agcfg { margin-top: 24px; } .agcfg summary { cursor: pointer; font-weight: 600; }
