:root {
  --navy: #01054C;
  --cyan: #00DBFF;
  --cyan-soft: #E0FAFF;
  --bg: #F4F5FA;
  --card: #FFFFFF;
  --text: #0B0E33;
  --muted: #6B6F8E;
  --line: #E4E6F0;
  --note: #ECEEF3;
  --red: #D93D4A;
  --amber: #A86F00;
  --green: #12A36B;
  --radius: 16px;
  --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; min-height: 100%; }
html { color-scheme: only light; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 "Nunito", system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; flex: none; }
h1 { font-size: 24px; font-weight: 800; margin: 6px 0 16px; color: var(--navy); }
h2 { font-size: 19px; font-weight: 800; margin: 26px 0 12px; color: var(--navy); }
h3 { font-size: 15px; font-weight: 800; margin: 0 0 12px; color: var(--navy); }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; margin: 0; }
.link { background: none; border: 0; color: var(--navy); font-weight: 800; cursor: pointer; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Botones ---------- */
.btn { border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 800; cursor: pointer; font-size: 16px; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.accent { background: var(--cyan); color: var(--navy); }
.btn.light { background: #fff; color: var(--navy); }
.btn.ghost { background: #E9EBF4; color: var(--navy); }
.btn.small { padding: 10px 14px; font-size: 14px; border-radius: 12px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 10px; margin-top: 18px; }
.btns .btn { flex: 1; }

/* ---------- Chips y estados ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 700; color: var(--navy); cursor: pointer; white-space: nowrap; }
.chip.sm { padding: 5px 10px; font-size: 13px; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.pill { flex: none; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill.new { background: var(--cyan-soft); color: #00607A; }
.pill.pro { background: #FFF4D6; color: var(--amber); }
.pill.wait { background: #EEE9FF; color: #4B3BA8; }
.pill.ok { background: #E3F8EF; color: var(--green); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); flex: none; }
.dot.off { background: transparent; }

/* ---------- Avisos ---------- */
.demo-banner { background: var(--cyan-soft); color: var(--navy); border-radius: 12px; padding: 8px 12px; font-size: 13px; font-weight: 600; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.demo-banner .link { font-size: 13px; }
.ban { background: #FFF4D6; color: #6B4A00; border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 700; display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.ban svg { width: 20px; height: 20px; }

/* ---------- Barra superior ---------- */
.topbar, .mtop { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar img, .mtop img { height: 26px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--navy); color: #fff; font-weight: 800; font-size: 14px; cursor: pointer; flex: none; }

/* ---------- Empleado ---------- */
.emp { max-width: 760px; margin: 0 auto; padding: calc(16px + var(--safe-t)) 16px calc(40px + var(--safe-b)); }
.opts { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 14px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; transition: border-color .15s; }
.opt:hover { border-color: var(--cyan); }
.opt:active { transform: scale(.99); }
.opt .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--cyan-soft); color: var(--navy); display: flex; align-items: center; justify-content: center; flex: none; }
.opt b { display: block; font-size: 16px; color: var(--navy); }
.opt small { display: block; color: var(--muted); font-size: 13px; }
@media (min-width: 700px) {
  .opts:not(.one) { grid-template-columns: repeat(3, 1fr); }
  .opts:not(.one) .opt { flex-direction: column; align-items: flex-start; padding: 20px; }
  .opts.one { grid-template-columns: repeat(2, 1fr); }
}
.back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--navy); font-weight: 800; cursor: pointer; padding: 4px 0; margin-bottom: 6px; }
.back svg { width: 18px; height: 18px; }
.tagline { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.tagline svg { width: 16px; height: 16px; }
.done { text-align: center; padding: 40px 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.done h1 { margin: 10px 0 0; }
.done .btn { min-width: 220px; margin-top: 16px; }
.big-check { width: 76px; height: 76px; border-radius: 50%; background: var(--cyan-soft); color: var(--navy); display: flex; align-items: center; justify-content: center; }
.big-check svg { width: 38px; height: 38px; }
.big-folio { font-size: 34px; font-weight: 800; color: var(--navy); letter-spacing: .5px; }

/* ---------- Filas de tickets ---------- */
.rows { display: flex; flex-direction: column; gap: 8px; }
.trow { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; }
.trow:active { background: #F7F8FC; }
.tmain { flex: 1; min-width: 0; }
.tmain b { display: block; font-size: 15px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmain small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; gap: 6px; margin-top: 4px; }
.tags i { font-style: normal; font-size: 11px; font-weight: 800; border-radius: 8px; padding: 2px 7px; background: var(--note); color: var(--navy); }
.tags i.u1 { background: #FFF4D6; color: var(--amber); }
.tags i.u2 { background: #FDE6E8; color: var(--red); }
.time { color: var(--muted); font-size: 12px; flex: none; align-self: flex-start; padding-top: 2px; }
.cb { color: var(--navy); display: flex; }
.rows.flat { gap: 0; }
.rows.flat .trow { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.trow.on { background: var(--cyan-soft); box-shadow: inset 3px 0 0 var(--cyan); }
.trow.sel { background: var(--cyan-soft); }

/* ---------- Formularios ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 800; color: var(--muted); margin: 0 0 6px 4px; }
.field input, .field textarea { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 12px 14px; font-size: 16px; outline: none; }
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field textarea:focus, .composer textarea:focus { border-color: var(--navy); }
.err { color: var(--red); font-size: 14px; font-weight: 700; margin: 8px 4px 0; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 12px; overflow: hidden; background: #E6E8F2; border: 0; padding: 0; flex: none; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1.5px dashed #C9CCDB; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(1,5,76,.75); color: #fff; font-size: 16px; line-height: 24px; padding: 0; cursor: pointer; }
.photo-full { width: 100%; max-height: 75vh; object-fit: contain; border-radius: var(--radius); display: block; margin-top: 30px; }

/* ---------- Soporte: estructura ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.main { padding: calc(14px + var(--safe-t)) 0 calc(80px + var(--safe-b)); }
.main > .demo-banner, .mtop { margin-left: 16px; margin-right: 16px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; padding: 6px 10px calc(6px + var(--safe-b)); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabbar .nav { flex: 1; max-width: 160px; flex-direction: column; gap: 2px; padding: 6px; font-size: 11px; color: var(--muted); background: none; position: relative; }
.tabbar .nav.on { color: var(--navy); background: none; }
.tabbar .nav .c { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; }
.nav { border: 0; background: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-weight: 800; font-size: 14px; color: var(--navy); cursor: pointer; width: 100%; text-align: left; }
.nav.on { background: var(--navy); color: #fff; }
.nav .c { margin-left: auto; background: var(--cyan); color: var(--navy); border-radius: 10px; font-size: 11px; font-weight: 800; padding: 1px 7px; }
.page { padding: 0 16px; max-width: 960px; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.phead h1 { margin-bottom: 8px; }

.inbox { display: block; }
.lpane { position: relative; }
.lhead { padding: 0 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.lpane .rows.flat { background: var(--card); border-top: 1px solid var(--line); }
.dpane { display: none; }
.srch { position: relative; display: flex; gap: 8px; }
.srch input { flex: 1; min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 0 12px 0 40px; font-size: 15px; outline: none; }
.srch input:focus { border-color: var(--navy); }
.sicon { position: absolute; left: 12px; top: 12px; color: var(--muted); display: flex; }
.sicon svg { width: 20px; height: 20px; }
.fbtn { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--navy); flex: none; }
.fbtn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.fpanel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.fg label { display: block; font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.act { display: flex; gap: 6px; flex-wrap: wrap; }
.achip { border: 0; background: var(--cyan-soft); color: var(--navy); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 800; cursor: pointer; }
.lhead > .chips { gap: 5px; }
.lhead > .chips .chip { flex: 1 0 auto; font-size: 12.5px; padding: 7px 8px; text-align: center; }
.lbar { display: flex; align-items: center; justify-content: space-between; }
.lbar .muted { margin: 0; font-size: 13px; }
.lbar .link { font-size: 14px; }
.selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--navy); padding: 12px 16px calc(12px + var(--safe-b)); display: flex; gap: 8px; }
.selbar .btn { flex: 1; padding: 12px; font-size: 14px; }

/* ---------- Detalle ---------- */
.dhead, .panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-right: 40px; }
.dhead h2, .panel-head h2 { margin: 0; font-size: 24px; }
.dhead .muted, .panel-head .muted { margin: 2px 0 0; }
.dactions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.kv { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.kv span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.kv b { display: block; font-size: 14px; color: var(--navy); overflow-wrap: anywhere; }
.kv.tap { cursor: pointer; }
.kv.tap:hover { border-color: var(--cyan); }
.kv .link { font-size: 14px; padding: 0; }
.conv { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.msg { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; max-width: 88%; align-self: flex-start; }
.msg.mine { background: var(--cyan-soft); border-color: transparent; align-self: flex-end; }
.msg.note { background: var(--note); border-color: transparent; align-self: stretch; max-width: none; }
.msg small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.msg small svg { width: 13px; height: 13px; }
.msg p { margin: 3px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.sol { background: #E3F8EF; border-radius: 14px; padding: 12px 14px; margin: 14px 0; }
.sol b { color: var(--green); font-size: 13px; }
.sol p { margin: 4px 0 0; white-space: pre-line; }
.sol .muted { margin-top: 6px; font-size: 13px; }
.ask { text-align: center; margin-top: 18px; }
.ask p { font-weight: 800; color: var(--navy); margin: 0; }
.composer { margin-top: 14px; }
.composer textarea { width: 100%; min-height: 84px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 12px 14px; font-size: 15px; outline: none; resize: vertical; }
.cfoot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 10px; }
.ntoggle { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer; }
.ntoggle svg { width: 15px; height: 15px; }
.ntoggle input { width: 16px; height: 16px; accent-color: var(--navy); margin: 0; }
.dempty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 6px; }
.dempty svg { width: 40px; height: 40px; color: #C9CCDB; }

/* ---------- Fallas y resumen ---------- */
.fcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fcard b { color: var(--navy); }
.fcard .muted { margin: 2px 0 0; font-size: 13px; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.metric span { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.metric b { display: block; font-size: 26px; color: var(--navy); font-weight: 800; }
.bgrid { display: grid; gap: 10px; margin-top: 10px; }
.bcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.bcard .muted { margin: 0; }
.brow { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 28px; gap: 10px; align-items: center; font-size: 14px; padding: 5px 0; }
.brow span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brow b { text-align: right; color: var(--navy); }
.sync { margin-top: 18px; font-size: 13px; }
.sync .link { font-size: 13px; }
.bt { height: 8px; background: var(--note); border-radius: 4px; overflow: hidden; }
.bt div { height: 100%; background: var(--cyan); border-radius: 4px; }
@media (min-width: 700px) { .metrics { grid-template-columns: repeat(4, 1fr); } .bgrid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Escritorio ---------- */
@media (min-width: 1000px) {
  .shell { display: flex; height: 100vh; }
  .side { display: flex; flex-direction: column; gap: 4px; width: 232px; flex: none; background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; }
  .side-logo { height: 26px; align-self: flex-start; margin: 2px 8px 22px; }
  .side-me { margin-top: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; padding: 8px; color: var(--navy); }
  .mtop, .tabbar { display: none; }
  .main { flex: 1; min-width: 0; padding: 0; display: flex; flex-direction: column; overflow: auto; }
  .main > .demo-banner { margin: 14px 20px 0; }
  .page { padding: 24px 32px; }
  .inbox { display: flex; flex: 1; min-height: 0; }
  .lpane { width: 400px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
  .lhead { padding: 18px 16px 12px; }
  .lpane .rows.flat { flex: 1; overflow-y: auto; }
  .selbar { position: sticky; }
  .dpane { display: block; flex: 1; min-width: 0; overflow-y: auto; padding: 26px 34px; }
  .dhead { padding-right: 0; }
  .meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .trow:hover { background: #F8F9FC; }
  .trow.on:hover { background: var(--cyan-soft); }
}

/* ---------- Hojas ---------- */
.layer { position: fixed; inset: 0; z-index: 20; background: rgba(1,5,30,.42); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
#picker { z-index: 30; }
.panel { position: relative; background: var(--bg); width: 100%; max-width: 640px; max-height: 94vh; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain; border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + var(--safe-b)); animation: up .2s ease-out; }
.panel h2 { margin-top: 4px; }
@media (min-width: 700px) { .layer { align-items: center; } .panel { border-radius: 24px; } .grab { display: none; } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: #CDD0DE; margin: 0 auto 12px; }
.x { position: absolute; top: 14px; right: 14px; border: 0; background: #E6E8F2; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; color: var(--navy); z-index: 1; }
.pks { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-top: 10px; }
.pks > .muted { padding: 14px; margin: 0; }
.pk { border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; padding: 12px 14px; cursor: pointer; display: flex; gap: 12px; align-items: center; }
.pk:last-child { border-bottom: 0; }
.pk b { color: var(--navy); min-width: 44px; }
.pk span { flex: 1; min-width: 0; }
.pk small { display: block; color: var(--muted); font-size: 13px; }
.pk.sel { background: var(--cyan-soft); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Inicio de sesión / cargando ---------- */
.center { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center; }
.center img.logo { height: 40px; }
.center p { color: var(--muted); margin: 0; max-width: 340px; }
.spinner { width: 34px; height: 34px; border: 4px solid #DDE0EC; border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); z-index: 50; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px; box-shadow: 0 10px 30px rgba(1,5,76,.3); max-width: calc(100% - 32px); text-align: center; }
.center p b { color: var(--navy); }
