/* TuMarketSV — Sistema de diseño "Editorial claro" (línea A).
   Identidad propia: serif Fraunces para títulos, Inter para cuerpo, morado→naranja,
   superficies blancas, hairlines, una sola acción naranja. Mobile-first. */

:root {
    --primary: #7c3aed;        /* morado */
    --primary-700: #6d28d9;
    --primary-50: #f3f0fb;
    --accent: #e8843c;         /* naranja — UNA acción */
    --accent-600: #d9722b;
    --ink: #1f2430;
    --muted: #6b7280;
    --faint: #9ca3af;
    --line: #ececf1;
    --bg: #f7f7fb;
    --ok: #16a34a;
    --card: #ffffff;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 18, 32, .04), 0 8px 24px rgba(16, 18, 32, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { overflow-x: hidden; } /* cinturón anti-desborde: ningún elemento empuja la página en móvil */
body {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.serif { font-family: 'Fraunces', Georgia, serif; }

/* Marca */
.wordmark { font-family: 'Fraunces', serif; font-weight: 600; font-size: 19px; letter-spacing: -.01em; }
.wordmark b { color: var(--primary); font-weight: 700; }
.wordmark span { color: var(--accent); }

/* Layout app */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--card); border-right: 1px solid var(--line);
    padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-group { color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; margin: 18px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px;
    color: #41464f; font-weight: 500; margin-bottom: 2px; }
.nav-item svg { width: 17px; height: 17px; stroke: currentColor; }
.nav-item:hover { background: #faf9fe; }
.nav-item.active { background: var(--primary-50); color: var(--primary-700); }
.main { min-width: 0; }

/* Hamburguesa: oculta en desktop; el media query móvil la muestra para abrir la nav off-canvas. */
.nav-toggle { display: none; align-items: center; justify-content: center; width: 34px; height: 34px;
    margin-right: 6px; background: #fff; color: #5b4b8a; border: 1px solid #ece9f2; border-radius: 9px;
    cursor: pointer; flex: 0 0 auto; }
.nav-toggle svg { width: 18px; height: 18px; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 14px; padding: 16px 26px; border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.7); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; margin: 0; }
.topbar .sub { color: var(--faint); font-size: 12px; }
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px;
    background: #fbfbfd; font-size: 13px; }
.search input:focus { outline: none; border-color: #d6d3e8; background: #fff; }
.content { padding: 22px 26px 40px; }

/* Botones — naranja = la acción */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 9px;
    font-weight: 600; font-size: 13px; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #d6d3e8; }
.btn-block { width: 100%; justify-content: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-50); color: var(--primary-700);
    display: grid; place-items: center; font-weight: 700; font-size: 13px; }

/* KPIs — fila hairline estilo CMC */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi { padding: 14px 16px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: none; }
.kpi .k-label { color: var(--faint); font-size: 11px; margin-bottom: 5px; }
.kpi .k-value { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.kpi .k-delta { font-size: 11px; font-weight: 600; margin-top: 3px; }
.k-up { color: var(--ok); } .k-flat { color: var(--faint); }

/* Cards / grid */
.grid-2 { display: grid; grid-template-columns: 1fr 340px; gap: 16px; margin-top: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h3 { font-family: 'Fraunces', serif; font-size: 15px; margin: 0 0 2px; }
.card .muted { color: var(--muted); font-size: 12px; }
.big-num { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin: 8px 0 2px; }

/* Lista últimos DTE */
.dte-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid #f3f3f7; }
.dte-row:last-child { border-bottom: none; }
.chip { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: var(--primary-50); color: var(--primary-700); }
.chip.fc { background: #eef6ee; color: var(--ok); }
.dte-row .name { flex: 1; font-weight: 500; }
.dte-row .amt { font-weight: 600; }
.sello { color: var(--ok); font-size: 11px; font-weight: 600; }

/* Sparkline */
.spark { width: 100%; height: 70px; display: block; }
.spark path { fill: none; stroke: var(--primary); stroke-width: 2; }
.spark .area { fill: url(#g); stroke: none; opacity: .12; }

/* Forms */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #41464f; margin-bottom: 5px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; background: #fff; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; align-items: end; }
.note { font-size: 12px; color: var(--muted); overflow-wrap: break-word; }
.alert { padding: 11px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 12px; }
.alert-ok { background: #eef8ef; color: #166534; border: 1px solid #cfeacf; }
.alert-err { background: #fdf0f0; color: #9b1c1c; border: 1px solid #f3d2d2; }

/* Tablas (listados) */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.tabs { display: inline-flex; gap: 4px; background: #f1f0f6; padding: 3px; border-radius: 9px; }
.tab { padding: 7px 13px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; border: none; background: transparent; }
.tab.active { background: #fff; color: var(--primary-700); box-shadow: var(--shadow); }
.tbl { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em;
    padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fbfbfd; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid #f3f3f7; font-size: 13px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fbfaff; }
.tbl .right, .tbl th.right { text-align: right; }
.tbl tfoot td { font-weight: 700; background: #fbfbfd; border-top: 1px solid var(--line); }
/* Móvil (<=860px, sidebar oculto): las tablas anchas (Libros de IVA 9 col, Recepción, etc.) se
   vuelven su PROPIO scroller horizontal en vez de empujar la página. Fix del overflow de móvil. */
@media (max-width: 860px) {
    .content { overflow-x: hidden; }
    .tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tbl thead, .tbl tbody, .tbl tfoot { display: table; width: 100%; min-width: 620px; }
    .mod-hero { flex-direction: column; align-items: flex-start; }
    .mod-hero p { max-width: 100%; }
}
.pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.pill.contrib { background: var(--primary-50); color: var(--primary-700); }
.pill.consumidor { background: #eef6ee; color: var(--ok); }
.estado { font-size: 11px; font-weight: 600; }
.estado.aceptado, .estado.firmado { color: var(--ok); }
.estado.rechazado, .estado.error { color: #b91c1c; }
.link { color: var(--primary); font-weight: 600; cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-rail { background: linear-gradient(150deg, var(--primary) 0%, var(--primary-700) 55%, var(--accent) 130%); color: #fff;
    padding: 56px 52px; display: flex; flex-direction: column; justify-content: center; }
.login-rail .serif { font-size: 34px; line-height: 1.15; font-weight: 600; }
.login-rail p { opacity: .9; font-size: 15px; max-width: 360px; }
.login-form { display: grid; place-items: center; padding: 40px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h2 { font-family: 'Fraunces', serif; font-size: 22px; margin: 0 0 4px; }

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    /* Nav OFF-CANVAS: antes .sidebar quedaba display:none SIN forma de reabrirla → móvil sin
       navegación para ningún rol. Ahora se desliza desde la izquierda con la hamburguesa. */
    .sidebar { position: fixed; left: 0; top: 0; z-index: 1200; width: 264px; max-width: 82vw;
        height: 100vh; transform: translateX(-100%); transition: transform .22s ease;
        box-shadow: 0 0 40px rgba(20, 16, 40, .22); }
    .sidebar.open { transform: translateX(0); }
    .nav-backdrop { position: fixed; inset: 0; background: rgba(20, 16, 40, .42); z-index: 1150; display: none; }
    .nav-backdrop.open { display: block; }
    .nav-toggle { display: inline-flex; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .kpi:nth-child(2n) { border-right: none; }
    .kpi { border-bottom: 1px solid var(--line); }
    .grid-2 { grid-template-columns: 1fr; }
    .login-wrap { grid-template-columns: 1fr; }
    .login-rail { display: none; }
    .row { grid-template-columns: 1fr; }
}

/* ============ Módulos — lanzador tipo app-grid ============ */
.mod-hero { display:flex; align-items:center; gap:20px; background:linear-gradient(135deg,#7b2ff7 0%,#7c3aed 45%,#e8843c 130%);
    color:#fff; border-radius:16px; padding:22px 26px; margin-bottom:6px; box-shadow:var(--shadow); }
.mod-hero .serif { font-family:'Fraunces',serif; font-size:23px; font-weight:600; line-height:1.2; }
.mod-hero p { margin:4px 0 0; opacity:.92; font-size:13px; max-width:520px; }
.mod-hero .hero-emoji { font-size:40px; line-height:1; }
.mod-section { margin-top:24px; }
.mod-section .h { display:flex; align-items:baseline; gap:10px; margin:0 0 12px; }
.mod-section .h h3 { font-family:'Fraunces',serif; font-size:15px; margin:0; }
.mod-section .h .muted { color:var(--faint); font-size:12px; }
.mod-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(158px,1fr)); gap:14px; }
.mod-card { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:15px;
    display:flex; flex-direction:column; gap:9px; align-items:flex-start; transition:transform .14s, box-shadow .14s, border-color .14s; cursor:pointer; min-height:132px; }
.mod-card:hover { border-color:#d6d3e8; box-shadow:0 6px 20px rgba(16,18,32,.08); transform:translateY(-2px); }
.mod-card img { width:50px; height:50px; border-radius:13px; object-fit:cover; }
.mod-glyph { width:50px; height:50px; border-radius:13px; display:grid; place-items:center; color:#fff;
    font-family:'Fraunces',serif; font-weight:700; font-size:21px; }
.mod-card .m-name { font-weight:600; font-size:13.5px; line-height:1.25; }
.mod-card .m-foot { margin-top:auto; display:flex; align-items:center; gap:8px; width:100%; }
.m-pill { font-size:10px; font-weight:700; padding:3px 8px; border-radius:999px; }
.m-pill.on { background:#eef6ee; color:var(--ok); }
.m-pill.off { background:#f1f0f6; color:var(--muted); }
.mod-card .m-go { margin-left:auto; color:var(--primary); font-weight:700; font-size:15px; }
.mod-card.locked { opacity:.7; }
.mod-card.pronto { opacity:.5; cursor:default; pointer-events:none; }
.mod-card.pronto:hover { transform:none; box-shadow:none; border-color:var(--line); }
.m-pill.pronto { background:#f5f0ff; color:#7c3aed; }

/* ============ POS ============ */
.pos { display:grid; grid-template-columns:1fr 340px; gap:16px; }
.pos-search input { width:100%; padding:11px 13px; border:1px solid var(--line); border-radius:10px; font-size:14px; margin-bottom:12px; }
.pos-prods { display:grid; grid-template-columns:repeat(auto-fill,minmax(132px,1fr)); gap:11px; }
.pos-prod { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:13px; cursor:pointer; transition:.12s; }
.pos-prod:hover { border-color:var(--primary); box-shadow:var(--shadow); }
.pos-prod .pp-name { font-weight:600; font-size:12.5px; min-height:32px; }
.pos-prod .pp-price { font-family:'Fraunces',serif; font-weight:600; color:var(--primary-700); margin-top:6px; }
.cart { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; position:sticky; top:88px; align-self:start; }
.cart h3 { font-family:'Fraunces',serif; font-size:16px; margin:0 0 10px; }
.cart-row { display:flex; align-items:center; gap:8px; padding:8px 0; border-bottom:1px solid #f3f3f7; font-size:13px; }
.cart-row .cr-name { flex:1; }
.cart-row .cr-qty { color:var(--muted); }
.cart-tot { display:flex; justify-content:space-between; padding:10px 0 4px; font-weight:600; }
.cart-tot.grand { font-family:'Fraunces',serif; font-size:20px; color:var(--ink); border-top:1px solid var(--line); margin-top:6px; padding-top:10px; }
.qbtn { width:22px; height:22px; border-radius:6px; border:1px solid var(--line); background:#fff; cursor:pointer; font-weight:700; color:var(--muted); }

/* stat tiles (reportes) */
.stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:14px; }
.stat { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:18px; }
.stat .s-label { color:var(--faint); font-size:12px; }
.stat .s-value { font-family:'Fraunces',serif; font-size:26px; font-weight:600; margin-top:6px; }
.bar-row { display:flex; align-items:center; gap:10px; margin:9px 0; font-size:13px; }
.bar-row .bl { width:120px; color:var(--muted); }
.bar-track { flex:1; height:9px; background:#f1f0f6; border-radius:999px; overflow:hidden; }
.bar-fill { height:100%; background:linear-gradient(90deg,var(--primary),var(--accent)); border-radius:999px; }

@media (max-width:860px){ .pos{ grid-template-columns:1fr; } .cart{ position:static; } }
/* Movil: drawer de comanda del restaurante — recupera ancho y evita recorte a la derecha */
@media (max-width:860px){
  .drawer-body{ padding:14px; }
  #ai-grid{ grid-template-columns:repeat(auto-fill,minmax(104px,1fr)) !important; }
  #ai-cats{ margin:0 -14px 8px; padding:0 14px; }
}

/* ============================================================
   COMPONENTES REUTILIZABLES — sin dependencias externas
   Uso: ver comentarios de snippet en cada bloque.
   ============================================================ */

/* ---- MODAL -----------------------------------------------
   Snippet:
     <div id="mi-modal" class="modal" role="dialog" aria-modal="true" aria-labelledby="mi-modal-ttl">
       <div class="modal-box">
         <div class="modal-head"><span id="mi-modal-ttl" class="serif">Titulo</span><button class="modal-close" aria-label="Cerrar">&times;</button></div>
         <div class="modal-body">Contenido</div>
         <div class="modal-foot"><button class="btn btn-ghost modal-close">Cancelar</button><button class="btn btn-primary">Confirmar</button></div>
       </div>
     </div>
     TMSV.modal.open('mi-modal') / TMSV.modal.close('mi-modal')
   ---------------------------------------------------------- */
.modal {
    display: none; position: fixed; inset: 0; z-index: 400;
    background: rgba(15,12,30,.45); backdrop-filter: blur(3px);
    align-items: center; justify-content: center; padding: 16px;
}
.modal.open { display: flex; }
.modal-box {
    background: var(--card); border-radius: var(--radius); width: 100%; max-width: 520px;
    box-shadow: 0 8px 40px rgba(16,18,32,.18); display: flex; flex-direction: column;
    max-height: calc(100vh - 40px); overflow: hidden;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 14px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.modal-head .serif { font-family: 'Fraunces', serif; font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none; cursor: pointer; color: var(--faint); font-size: 20px;
    line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.modal-close:hover { background: var(--primary-50); color: var(--primary-700); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
    padding: 14px 20px; border-top: 1px solid var(--line);
    display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0;
}
@media (max-width: 860px) { .modal-box { max-width: 100%; } }

/* ---- DRAWER (panel lateral) ------------------------------
   Snippet:
     <div id="mi-drawer" class="drawer" role="dialog" aria-modal="true" aria-label="Detalle">
       <div class="drawer-box">
         <div class="drawer-head"><span class="serif">Panel</span><button class="drawer-close" aria-label="Cerrar">&times;</button></div>
         <div class="drawer-body">Contenido</div>
       </div>
     </div>
     TMSV.drawer.open('mi-drawer') / TMSV.drawer.close('mi-drawer')
   ---------------------------------------------------------- */
.drawer {
    display: none; position: fixed; inset: 0; z-index: 400;
    background: rgba(15,12,30,.35); backdrop-filter: blur(2px);
}
.drawer.open { display: block; }
.drawer-box {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 380px; max-width: 100vw;
    background: var(--card); box-shadow: -4px 0 32px rgba(16,18,32,.14);
    display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.drawer.open .drawer-box { transform: translateX(0); }
.drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 14px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.drawer-head .serif { font-family: 'Fraunces', serif; font-size: 16px; font-weight: 600; }
.drawer-close {
    background: none; border: none; cursor: pointer; color: var(--faint); font-size: 20px;
    line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.drawer-close:hover { background: var(--primary-50); color: var(--primary-700); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
@media (max-width: 860px) { .drawer-box { width: 100vw; } }

/* ---- STEPPER (wizard de pasos) ---------------------------
   Snippet:
     <div class="stepper" id="wiz">
       <div class="stepper-nav">
         <div class="step-item active"><div class="step-dot">1</div><span>Datos</span></div>
         <div class="step-item"><div class="step-dot">2</div><span>Detalle</span></div>
         <div class="step-item"><div class="step-dot">3</div><span>Confirmar</span></div>
       </div>
       <div class="stepper-panels">
         <div class="step-panel active">Panel 1</div>
         <div class="step-panel">Panel 2</div>
         <div class="step-panel">Panel 3</div>
       </div>
       <div class="stepper-foot">
         <button class="btn btn-ghost" id="wiz-prev">Atras</button>
         <button class="btn btn-primary" id="wiz-next">Siguiente</button>
       </div>
     </div>
     const s = TMSV.stepper(document.getElementById('wiz'));
     document.getElementById('wiz-next').onclick = () => s.next();
     document.getElementById('wiz-prev').onclick = () => s.prev();
   ---------------------------------------------------------- */
.stepper-nav {
    display: flex; gap: 0; margin-bottom: 20px; position: relative;
}
.stepper-nav::before {
    content: ''; position: absolute; left: 15px; right: 15px; top: 15px;
    height: 2px; background: var(--line); z-index: 0;
}
.step-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    flex: 1; position: relative; z-index: 1;
}
.step-dot {
    width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid var(--line); background: var(--card);
    display: grid; place-items: center; font-size: 12px; font-weight: 700;
    color: var(--faint); transition: background .2s, border-color .2s;
}
.step-item.active .step-dot { border-color: var(--primary); background: var(--primary); color: #fff; }
.step-item.done .step-dot { border-color: var(--ok); background: var(--ok); color: #fff; }
.step-item span { font-size: 11px; font-weight: 600; color: var(--faint); }
.step-item.active span { color: var(--primary-700); }
.step-item.done span { color: var(--ok); }
.stepper-panels { position: relative; }
.step-panel { display: none; }
.step-panel.active { display: block; }
.stepper-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
}
@media (max-width: 860px) { .step-item span { font-size: 10px; } }

/* ---- TIMELINE (linea de tiempo) --------------------------
   Snippet:
     <ul class="timeline">
       <li class="tl-item">
         <div class="tl-dot ok"></div>
         <div class="tl-body">
           <div class="tl-head"><strong>Documento sellado</strong><span class="tl-time">hace 2h</span></div>
           <p class="tl-text">DTE FC enviado al MH correctamente.</p>
         </div>
       </li>
     </ul>
     Variantes tl-dot: (sin clase)=morado  ok=verde  err=rojo  muted=gris
   ---------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.tl-item::before {
    content: ''; position: absolute; left: 9px; top: 20px; bottom: 0;
    width: 2px; background: var(--line);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
    width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary-50); border: 2px solid var(--primary);
    margin-top: 2px; z-index: 1;
}
.tl-dot.ok  { background: #eef6ee; border-color: var(--ok); }
.tl-dot.err { background: #fdf0f0; border-color: #b91c1c; }
.tl-dot.muted { background: var(--line); border-color: var(--faint); }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.tl-head strong { font-weight: 600; font-size: 13px; }
.tl-time { font-size: 11px; color: var(--faint); margin-left: auto; }
.tl-text { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ---- BOARD (columnas kanban) -----------------------------
   Snippet:
     <div class="board" id="mi-board">
       <div class="board-col" data-col="pendiente">
         <div class="board-col-head">
           <span class="board-col-title">Pendiente</span><span class="board-col-count">3</span>
         </div>
         <div class="board-card" draggable="true" data-id="1">
           <div class="bc-title">Cotizacion #42</div>
           <div class="bc-meta">Cliente · $120</div>
           <div class="bc-foot"><span class="chip">CCF</span><span class="tl-time">hoy</span></div>
         </div>
       </div>
     </div>
     TMSV.board.init('mi-board', function(cardId, fromCol, toCol){ ... })
   ---------------------------------------------------------- */
.board { display: flex; gap: 14px; overflow-x: auto; align-items: flex-start; padding-bottom: 8px; }
.board-col {
    background: #f7f6fc; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px; min-width: 240px; max-width: 280px; flex-shrink: 0;
}
.board-col-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.board-col-title { font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.board-col-count { font-size: 11px; font-weight: 700; background: var(--line); color: var(--muted); padding: 2px 7px; border-radius: 999px; }
.board-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 14px; margin-bottom: 8px; cursor: grab; transition: box-shadow .14s, border-color .14s;
}
.board-card:active { cursor: grabbing; }
.board-card:hover { box-shadow: var(--shadow); border-color: #d6d3e8; }
.board-card.drag-over { border-color: var(--primary); background: var(--primary-50); }
.bc-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.bc-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.bc-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@media (max-width: 860px) { .board { flex-direction: column; } .board-col { min-width: 0; max-width: 100%; width: 100%; } }

/* ---- AGENDA (vista dia/semana) ---------------------------
   Snippet:
     <div class="agenda" id="mi-agenda" data-view="day">
       <div class="agenda-head">
         <button class="btn btn-ghost btn-sm" data-agenda-prev>&#8249;</button>
         <span class="agenda-range serif"></span>
         <button class="btn btn-ghost btn-sm" data-agenda-next>&#8250;</button>
         <div class="tabs" style="margin-left:auto">
           <button class="tab active" data-agenda-view="day">Dia</button>
           <button class="tab" data-agenda-view="week">Semana</button>
         </div>
       </div>
       <div class="agenda-body"></div>
     </div>
     const ag = TMSV.agenda.init('mi-agenda');
     ag.load([{ id:1, title:'Reunion', start:'09:00', end:'10:00', color:'#7c3aed', meta:'Sala A' }]);
   ---------------------------------------------------------- */
.btn-sm { padding: 6px 10px; font-size: 12px; }
.agenda { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.agenda-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.agenda-range { font-family: 'Fraunces', serif; font-size: 15px; font-weight: 600; }
.agenda-body { overflow-y: auto; max-height: 480px; }

/* semana */
.agenda-week-head { display: grid; border-bottom: 1px solid var(--line); }
.aw-corner, .aw-day-head { border-right: 1px solid var(--line); }
.aw-day-head { text-align: center; padding: 8px 4px; font-size: 11px; font-weight: 700; color: var(--muted); }
.aw-day-head.today { color: var(--primary-700); background: var(--primary-50); }
.agenda-week-grid { display: grid; }
.aw-hour-label { height: 48px; border-bottom: 1px solid #f3f3f7; border-right: 1px solid var(--line); padding: 4px 6px; font-size: 10px; color: var(--faint); }
.aw-day-col { border-right: 1px solid var(--line); position: relative; }
.aw-slot { height: 48px; border-bottom: 1px solid #f3f3f7; }

/* dia */
.agenda-day-grid { display: grid; grid-template-columns: 48px 1fr; }
.ad-hour-col { border-right: 1px solid var(--line); }
.ad-events { position: relative; }
.ad-slot { height: 48px; border-bottom: 1px solid #f3f3f7; }

/* evento */
.ag-event {
    position: absolute; left: 3px; right: 3px; border-radius: 7px;
    background: var(--primary-50); border-left: 3px solid var(--primary);
    padding: 3px 7px; overflow: hidden; cursor: pointer; z-index: 2;
    font-size: 11.5px; font-weight: 600; color: var(--primary-700);
    transition: box-shadow .12s;
}
.ag-event:hover { box-shadow: var(--shadow); }
.ag-event .ae-time { font-size: 10px; font-weight: 400; color: var(--muted); }
@media (max-width: 860px) { .aw-day-head { font-size: 9px; padding: 6px 2px; } }
