:root { --ink:#1a0f0a; --ink2:#2a1a12; --cream:#f7efe3; --paper:#fffaf2; --line:#eadcc8; --red:#d2223a; --pink:#f6b8c8; --honey:#d39a5b; --wood:#8a4f2a; --ok:#1f9d55; --warn:#d98a00; --muted:#8b7768; --blue:#1e4fa3; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 15px/1.5 "DM Sans", system-ui, sans-serif; }
h1, h2, h3 { font-family: Fredoka, sans-serif; font-weight: 600; }
h3 { margin: 0 0 1rem; font-size: 1.1rem; }
code { background: rgba(138,79,42,.1); padding: 1px 6px; border-radius: 6px; font-size: .85em; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .88rem; margin: 0 0 1rem; }
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .7rem 1.1rem; border: 0; border-radius: 99px; background: var(--ink); color: var(--paper); font: 600 .92rem Fredoka, sans-serif; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn--sm { padding: .5rem .9rem; font-size: .85rem; }
.btn--red { background: var(--red); }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn--ok { background: var(--ok); }
.btn--wa { background: #25d366; color: #062b14; }
.btn--block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }
.f { display: grid; gap: .3rem; margin-bottom: .9rem; }
.f span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.f input, .f select, .f textarea { width: 100%; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; font: inherit; color: inherit; }
.f input:focus, .f select:focus, .f textarea:focus { outline: 2px solid var(--red); outline-offset: 1px; }
.f--inline { margin: 0; }
.err { background: #fde6ea; color: var(--red); padding: .6rem .8rem; border-radius: 10px; font-size: .88rem; }
.chk { display: inline-flex; gap: .4rem; align-items: center; font-size: .9rem; cursor: pointer; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.row--end { justify-content: flex-end; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.login__card { width: min(380px, 100%); background: var(--paper); border-radius: 28px; padding: 32px; text-align: center; }
.login__card img { margin: 0 auto .5rem; }
.login__card h1 { margin: 0; }
.login__card .f { text-align: left; }

/* layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: var(--paper); padding: 20px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side__brand { display: flex; gap: .7rem; align-items: center; padding: 0 8px 20px; }
.side__brand b { font: 700 1.15rem Fredoka; display: block; }
.side__brand small { opacity: .6; }
.side__nav { display: grid; gap: 2px; }
.side__nav a { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 12px; text-decoration: none; color: rgba(255,250,242,.75); font-weight: 500; }
.side__nav a i { font-style: normal; width: 18px; text-align: center; opacity: .7; }
.side__nav a:hover { background: rgba(255,250,242,.06); }
.side__nav a.is-on { background: var(--paper); color: var(--ink); }
.badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 99px; font-size: .72rem; font-weight: 700; padding: 1px 8px; }
.badge--soft { background: var(--honey); color: var(--ink); }
.side__foot { margin-top: auto; display: grid; gap: .4rem; font-size: .85rem; padding: 0 8px; color: rgba(255,250,242,.6); }
.side__foot a { color: inherit; }
.main { padding: 0 clamp(16px, 3vw, 36px) 40px; min-width: 0; }
.top { display: flex; align-items: center; gap: 1rem; padding: 20px 0; position: sticky; top: 0; background: var(--cream); z-index: 5; }
.top h1 { margin: 0; font-size: 1.6rem; }
.top__right { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.clock { font: 600 1rem Fredoka; color: var(--wood); }
.burger { display: none; border: 0; background: var(--ink); color: var(--paper); width: 40px; height: 40px; border-radius: 12px; font-size: 1.1rem; }
.view { display: none; }
.view.is-on { display: block; animation: in .4s ease; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 22px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.grid2 > .card { margin: 0 0 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1rem; }
.toolbar .hint { margin: 0; flex: 1; min-width: 200px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.kpi b { display: block; font: 700 2.2rem/1 Fredoka; margin-top: .4rem; }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi--red { background: var(--red); color: #fff; border-color: var(--red); }
.kpi--red span { color: rgba(255,255,255,.8); }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 20px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: .75rem; color: var(--muted); }
.bar i { display: block; width: 100%; background: var(--honey); border-radius: 8px 8px 4px 4px; min-height: 3px; }
.bar.is-today i { background: var(--red); }
.bar b { color: var(--ink); font-size: .8rem; }
.list { display: grid; gap: 8px; }
.li { display: flex; gap: .8rem; align-items: center; padding: .7rem .9rem; border-radius: 14px; background: var(--cream); }
.li b { font-family: Fredoka; }
.li .r { margin-left: auto; }
.empty { color: var(--muted); padding: 1rem 0; }

/* sala */
.calls { display: grid; gap: 10px; margin-bottom: 18px; }
.call { display: flex; align-items: center; gap: 1rem; padding: 14px 18px; border-radius: 18px; background: var(--red); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.call b { font: 700 1.4rem Fredoka; }
.call .r { margin-left: auto; display: flex; gap: .6rem; align-items: center; }
.call small { opacity: .85; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(210,34,58,.18); } }
.zone-t { margin: 1.2rem 0 .6rem; font-size: 1.1rem; }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.tb { position: relative; aspect-ratio: 1; border-radius: 18px; border: 1px solid var(--line); background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; font: inherit; color: inherit; padding: 6px; }
.tb b { font: 700 1.5rem/1 Fredoka; }
.tb small { font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.2; }
.tb.is-call { background: var(--red); color: #fff; border-color: var(--red); animation: pulse 1.6s infinite; }
.tb.is-call small { color: #fff; }
.tb .ago { position: absolute; top: 6px; right: 8px; font-size: .65rem; font-weight: 700; }

/* tablas */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td small { color: var(--muted); display: block; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700; text-transform: capitalize; background: var(--cream); white-space: nowrap; }
.pill--pendiente { background: #fff1d6; color: #8a5a00; }
.pill--confirmada { background: #dcf5e6; color: #11663a; }
.pill--asistio { background: #dfe8fb; color: var(--blue); }
.pill--cancelada, .pill--no_show { background: #fde6ea; color: var(--red); }
.acts { display: flex; gap: 6px; flex-wrap: wrap; }
.acts select { padding: .35rem .5rem; border-radius: 10px; border: 1px solid var(--line); font: inherit; font-size: .85rem; }

/* carta */
.mcat-a { margin-bottom: 18px; }
.mcat-a h3 small { font-family: "Black Han Sans"; font-weight: 400; color: var(--wood); margin-left: .4rem; }
.mi { display: grid; grid-template-columns: 52px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px dashed var(--line); }
.mi img, .mi .ph { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: var(--cream); display: grid; place-items: center; font-family: "Black Han Sans"; color: var(--wood); }
.mi.is-off { opacity: .5; }
.mi b { font-family: Fredoka; }
.mi small { color: var(--muted); display: block; }
.switch { position: relative; width: 46px; height: 26px; border-radius: 99px; background: var(--line); border: 0; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .25s; }
.switch.is-on { background: var(--ok); }
.switch.is-on::after { left: 23px; }

/* QR */
.qrs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 18px; text-align: center; break-inside: avoid; }
.qr__n { font: 700 2rem/1 Fredoka; margin: 0 0 .2rem; }
.qr__z { color: var(--muted); font-size: .8rem; margin: 0 0 .8rem; }
.qr__code { display: grid; place-items: center; }
.qr__code img, .qr__code canvas { width: 150px !important; height: 150px !important; }
.qr__tip { font-size: .78rem; margin: .8rem 0 0; }
.qr a { font-size: .72rem; color: var(--muted); word-break: break-all; }

/* ajustes */
.hours { display: grid; gap: 8px; margin-bottom: 1rem; }
.hours .h { display: grid; grid-template-columns: 110px auto 1fr 1fr; gap: 10px; align-items: center; }
.hours input[type=time] { padding: .5rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; }

/* sistema */
.health { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.hc { padding: 12px 14px; border-radius: 14px; background: #dcf5e6; color: #11663a; font-weight: 600; font-size: .9rem; }
.hc.bad { background: #fde6ea; color: var(--red); }
.hc small { display: block; font-weight: 400; opacity: .8; }
.errrow { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; background: #fff; }
.errrow header { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.errrow .msg { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; margin: .5rem 0; word-break: break-word; }
.errrow .meta { font-size: .78rem; color: var(--muted); display: flex; gap: 1rem; flex-wrap: wrap; }
.errrow details pre, .filelog pre { white-space: pre-wrap; font-size: .75rem; background: var(--cream); padding: 10px; border-radius: 10px; max-height: 260px; overflow: auto; }
.src { font-size: .7rem; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--ink); color: #fff; }
.src--client { background: var(--blue); }
.hits { font: 700 .85rem Fredoka; color: var(--red); }

.modal { border: 0; border-radius: 24px; padding: 24px; width: min(680px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(26,15,10,.5); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: .75rem 1.2rem; border-radius: 99px; opacity: 0; transition: .35s; pointer-events: none; z-index: 100; max-width: calc(100% - 32px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-err { background: var(--red); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .3s; }
  .side.is-open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .burger { display: block; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .hours .h { grid-template-columns: 1fr 1fr; }
  #soundBtn { font-size: 0; padding: .5rem .7rem; }
  #soundBtn::first-letter { font-size: 1rem; }
  .clock { display: none; }
}
@media print {
  .side, .top, .toolbar, .view:not([data-view="qr"]) { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .qrs { grid-template-columns: repeat(3, 1fr); }
  .qr { border: 1.5px dashed #999; }
}
