/* Layout del panel */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; }
.sidebar .logo { padding: 4px 8px 18px; }
.nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 600; text-decoration: none; transition: background .12s, color .12s; font-size: 14px; }
.nav-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-link .count { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 99px; display: grid; place-items: center; padding: 0 6px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 32px; position: sticky; top: 0; background: rgba(246, 246, 248, .85); backdrop-filter: blur(10px); z-index: 30; border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 22px; }
.topbar .crumbs { font-size: 13px; color: var(--muted); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; }
.view { padding: 8px 32px 48px; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }

/* Plan y sucursal */
.plan-banner { background: var(--accent-soft); color: var(--accent-ink); padding: 10px 32px; font-size: 13.5px; font-weight: 600; }
.plan-banner a { font-weight: 800; margin-left: 6px; }
.plan-banner.warn { background: var(--warning-soft); color: #8a5a00; }
.loc-switch { padding: 0 6px 6px; display: flex; flex-direction: column; gap: 4px; }
.loc-switch .select { height: 36px; font-weight: 700; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.plan-card { padding: 22px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 165, 233, .15); }
.plan-card.featured::before { content: 'Recomendado'; position: absolute; top: -11px; left: 22px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 99px; }
.plan-price { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.plan-price small { font-size: 14px; color: var(--muted); font-weight: 600; }
.plan-feats { list-style: none; padding: 0; margin: 6px 0 10px; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.plan-feats li::before { content: '✓'; color: var(--success); font-weight: 800; margin-right: 8px; }
.plan-feats li.no { color: var(--faint); }
.plan-feats li.no::before { content: '—'; color: var(--faint); }
.usage-row { margin-bottom: 14px; }
.usage-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.usage-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.usage-bar i.hot { background: var(--warning); }
@media (max-width: 960px) { .plans { grid-template-columns: 1fr; } .plan-banner { padding: 10px 16px; } }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { padding: 18px; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stat .k .ic { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; }
.stat .k .ic svg { width: 16px; height: 16px; }
.stat .v { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; margin-top: 10px; }
.stat .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.grid-2-eq { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

/* Chart */
.chart { width: 100%; height: 220px; }
.chart .bar { fill: var(--accent); opacity: .85; transition: opacity .15s; }
.chart .bar:hover { opacity: 1; }
.chart .bar2 { fill: #bae6fd; }
.chart .axis { fill: var(--faint); font-size: 10px; font-family: var(--font); }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: #f5fbff; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .nm { font-weight: 700; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { height: 38px; width: auto; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search .input { padding-left: 38px; width: 100%; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .em-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; margin: 0 auto 14px; font-size: 24px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* Tarjetas (lista) */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.card-tile { padding: 16px; display: flex; flex-direction: column; gap: 14px; cursor: pointer; transition: transform .15s, box-shadow .15s; text-decoration: none; }
.card-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(20,16,40,.09); }
.mini-pass { border-radius: 16px; padding: 16px; min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.mini-pass::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,.08); }
.mini-pass .t { font-weight: 800; font-size: 17px; }
.mini-pass .ty { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .75; font-weight: 700; }
.new-tile { border: 2px dashed var(--border); border-radius: var(--radius); display: grid; place-items: center; min-height: 250px; color: var(--muted); font-weight: 700; text-decoration: none; transition: .15s; gap: 8px; }
.new-tile:hover { border-color: var(--accent); color: var(--accent-ink); background: #f5fbff; }

/* Tipo de tarjeta selector */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.type-opt { border: 1.5px solid var(--border); border-radius: 14px; padding: 16px; cursor: pointer; background: var(--surface); transition: .15s; text-align: left; font: inherit; color: inherit; }
.type-opt:hover { border-color: #7dd3fc; }
.type-opt.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 165, 233,.15); background: #f5fbff; }
.type-opt .e { font-size: 24px; }
.type-opt .n { font-weight: 800; margin-top: 8px; }
.type-opt .d { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.type-opt .badge { margin-top: 10px; }

/* Editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.preview-col { position: sticky; top: 90px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.phone { background: #ebe9f2; border-radius: 34px; padding: 26px 20px; width: 100%; display: flex; justify-content: center; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 18px; width: fit-content; flex-wrap: wrap; }
.tab { padding: 8px 16px; border-radius: 9px; font-weight: 700; font-size: 13.5px; color: var(--muted); cursor: pointer; border: 0; background: transparent; text-decoration: none; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 10px; cursor: pointer; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.swatch.sel { box-shadow: 0 0 0 2px var(--accent); }
.emoji-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.emoji-pick button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-size: 18px; cursor: pointer; }
.emoji-pick button.sel { border-color: var(--accent); background: var(--accent-soft); }

/* Detalle cliente */
.profile-head { display: flex; gap: 16px; align-items: center; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.kv .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv .v { font-weight: 700; margin-top: 2px; word-break: break-word; }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.tl-item:last-child { border-bottom: 0; }
.tl-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 15px; flex-shrink: 0; }
.op-panel { display: flex; flex-direction: column; gap: 10px; }

/* Inbox */
.inbox { display: grid; grid-template-columns: 330px 1fr 290px; height: calc(100vh - 100px); min-height: 520px; overflow: hidden; padding: 0; }
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.inbox-list .head { padding: 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: #fff; font-weight: 600; font-size: 12.5px; cursor: pointer; color: var(--muted); font-family: inherit; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.conv-list { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 11px; padding: 13px 14px; cursor: pointer; border-bottom: 1px solid var(--border); text-decoration: none; transition: background .1s; position: relative; }
.conv:hover { background: #f5fbff; }
.conv.active { background: var(--accent-soft); }
.conv .nm { font-weight: 700; font-size: 13.5px; }
.conv .pv { font-size: 12.5px; color: var(--muted); }
.conv .tm { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.conv .unread-dot { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.chat-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: #fbfbfd; }
.bubble { max-width: 72%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; animation: fadeIn .2s; }
.bubble.out { align-self: flex-end; background: var(--text); color: #fff; border-bottom-right-radius: 5px; }
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.bubble .ttl { font-weight: 800; margin-bottom: 2px; }
.bubble .meta { font-size: 11px; opacity: .65; margin-top: 5px; display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.bubble.in .meta { justify-content: flex-start; }
.bubble .kind { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .7; margin-bottom: 3px; }
.day-sep { align-self: center; font-size: 11.5px; color: var(--faint); font-weight: 600; padding: 4px 0; }
.composer { border-top: 1px solid var(--border); padding: 12px; display: flex; gap: 10px; align-items: flex-end; background: var(--surface); }
.composer .textarea { min-height: 44px; max-height: 140px; height: 44px; resize: none; }
.inbox:not(.has-chat) { grid-template-columns: 330px 1fr; }
.chat-side { border-left: 1px solid var(--border); padding: 18px; overflow-y: auto; }
.online { color: var(--success); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }

/* Push composer */
.push-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.lock-screen { background: linear-gradient(160deg, #0c4a6e, #081624 70%); border-radius: 30px; padding: 40px 16px 60px; min-height: 420px; color: #fff; position: sticky; top: 90px; }
.lock-time { text-align: center; font-size: 56px; font-weight: 300; letter-spacing: -2px; }
.lock-date { text-align: center; font-size: 14px; opacity: .8; margin-bottom: 28px; }
.notif { background: rgba(255,255,255,.18); backdrop-filter: blur(16px); border-radius: 18px; padding: 12px 14px; display: flex; gap: 10px; color: #fff; }
.notif .ap { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; font-size: 18px; background: #fff; }
.notif .t { font-weight: 700; font-size: 13.5px; }
.notif .b { font-size: 13px; opacity: .9; white-space: pre-wrap; word-break: break-word; }
.var-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.var-chips button { font-family: inherit; font-weight: 600; font-size: 12px; border: 1px solid #bae6fd; background: #f5fbff; color: var(--accent-ink); border-radius: 7px; padding: 3px 8px; cursor: pointer; }
.seg-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.seg-opt { border: 1.5px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: center; background: #fff; font-family: inherit; text-align: left; color: inherit; }
.seg-opt.sel { border-color: var(--accent); background: #f5fbff; }
.audience { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--accent-soft); border-radius: 12px; color: var(--accent-ink); font-weight: 600; }
.audience b { font-size: 22px; }

/* Auto-push */
.ap-list { display: flex; flex-direction: column; gap: 12px; }
.ap-item { display: flex; gap: 14px; padding: 16px 18px; align-items: center; }
.ap-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); font-size: 20px; flex-shrink: 0; }

/* Scanner */
.scanner { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 24px; align-items: start; }
.cam { position: relative; background: #0d0b14; border-radius: 18px; overflow: hidden; aspect-ratio: 1; display: grid; place-items: center; color: #fff; }
.cam video { width: 100%; height: 100%; object-fit: cover; }
.cam .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(21, 19, 28, .45); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fadeIn .15s; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 6px; }
.modal-body { padding: 14px 22px; }
.modal-foot { padding: 12px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.x-btn { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 18px; color: var(--muted); }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-form { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; }
.auth-inner { width: 100%; max-width: 380px; }
.auth-art { background: radial-gradient(circle at 30% 18%, rgba(232,196,143,.55) 0, transparent 45%), radial-gradient(circle at 82% 85%, rgba(176,112,63,.6) 0, transparent 42%), linear-gradient(160deg, #2a1b12, #120b07); color: #fff; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px; gap: 28px; position: relative; overflow: hidden; }
.auth-art h2 { font-size: 30px; text-align: center; max-width: 420px; line-height: 1.2; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 28px 0 24px; border-bottom: 1px solid var(--border); }
.auth-tabs a { text-align: center; padding: 12px; font-weight: 700; color: var(--faint); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 15px; }
.auth-tabs a.active { color: var(--text); border-color: var(--text); }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; color: var(--faint); padding: 6px; }
.floaty { animation: floaty 6s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-10px) rotate(-1deg); } }

/* Stars */
.stars { color: #f5b301; letter-spacing: 1px; }
.dist-row { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 8px; }
.dist-bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.dist-bar i { display: block; height: 100%; background: #f5b301; border-radius: 99px; }

.skeleton { background: linear-gradient(90deg, #eeedf3 25%, #f6f5fa 50%, #eeedf3 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.copy-box { display: flex; gap: 8px; }
.copy-box .input { font-family: ui-monospace, monospace; font-size: 12.5px; }

/* Responsive */
@media (max-width: 1200px) {
  .inbox { grid-template-columns: 300px 1fr; }
  .chat-side { display: none; }
  .editor, .push-layout { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 19px; }
  /* En celular: título en su renglón y los botones debajo (antes se encimaban) */
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar #tb-left { flex: 1 1 calc(100% - 60px); min-width: 0; }
  .topbar h1 { overflow-wrap: anywhere; }
  .topbar .actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .topbar .actions:empty { display: none; }
  .view { padding: 8px 16px 40px; }
  .grid-2, .grid-2-eq, .editor, .push-layout, .scanner { grid-template-columns: minmax(0, 1fr); }
  .preview-col, .lock-screen { position: static; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 80px); }
  .inbox.has-chat .inbox-list { display: none; }
  .inbox:not(.has-chat) .chat { display: none; }
  .kv { grid-template-columns: 1fr 1fr; gap: 12px 14px; } /* dos columnas también en celular */
  .profile-head h2 { font-size: 20px; }
  .hide-sm { display: none !important; }
}
@media (min-width: 961px) { .show-sm { display: none !important; } }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
