/* Píldora POS · Tablero armable */
.tb-page { --tb-gap: 16px; --tb-drawer: 384px; max-width: 1680px; }
.tb-page.tb-drawer-open { max-width: min(1680px, calc(100vw - var(--side) - var(--tb-drawer) - 8px)); }
.tb-head h1 { font-size: 28px; }
.tb-head .btn svg { width: 18px; height: 18px; }

/* ---------- Rejilla ---------- */
.tb-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--tb-gap); align-items: stretch; grid-auto-flow: row dense; }
.tb-w { position: relative; min-width: 0; display: flex; flex-direction: column; border-radius: var(--r-lg); }
.tb-s-s { grid-column: span 3; } .tb-s-m { grid-column: span 4; } .tb-s-l { grid-column: span 6; } .tb-s-xl { grid-column: span 8; } .tb-s-full { grid-column: span 12; }
.tb-w-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tb-w-body > * { flex: 1; min-width: 0; }
.tb-w-body .kpi { height: 100%; }
.tb-panel { display: flex; flex-direction: column; height: 100%; margin: 0; }
.tb-panel-body { flex: 1; }
.tb-panel .panel-head { gap: 10px; }
.tb-page { grid-template-columns: minmax(0, 1fr); }
.tb-page > * { min-width: 0; }
.tb-panel .list-row { min-width: 0; }
.tb-panel .list-row .grow { min-width: 0; }
.tb-panel .list-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-empty { padding: 26px 18px; }
.tb-kpi { position: relative; display: flex; flex-direction: column; justify-content: flex-start; gap: 4px; }
.tb-kpi-btn { align-self: flex-start; margin-top: auto; }
.tb-kpi:has(.tb-kpi-btn) .kpi-foot { margin-bottom: 12px; }
.tb-muted-v { color: var(--ink-3); }
.tb-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); margin-right: 7px; vertical-align: 1px; }
.tb-error { display: grid; gap: 4px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px dashed var(--line); color: var(--ink-2); font-size: 14px; height: 100%; align-content: center; }

/* Bienvenida */
.tb-hello { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 22px 26px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-soft); position: relative; overflow: hidden; }
.tb-hello::after { content: ""; position: absolute; right: -60px; top: -70px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--pill) 38%, transparent) 0%, transparent 70%); pointer-events: none; }
.tb-hello h1 { font-size: 26px; }
.tb-hello p { margin-top: 4px; text-transform: none; }
.tb-hello > * { position: relative; z-index: 1; }

/* Meta del día */
.tb-goal { gap: 6px; }
.tb-goal-row { display: flex; align-items: center; gap: 14px; }
.tb-goal-row > div { display: grid; gap: 2px; }
.tb-ring { width: 64px; height: 64px; flex: none; transform: rotate(-90deg); }
.tb-ring circle { fill: none; stroke-width: 11; }
.tb-ring-bg { stroke: var(--line-soft); }
.tb-ring-fg { stroke: var(--pill); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.kpi--hero .tb-ring-bg { stroke: rgba(255,255,255,.18); }

/* Mini indicadores (resumen del mes) */
.tb-mini-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line-soft); border-top: 1px solid var(--line-soft); flex: 1; }
.tb-mini-kpis > div { background: var(--surface); padding: 16px 18px; display: grid; gap: 4px; align-content: center; }
.tb-mini-kpis span { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.tb-mini-kpis b { font-family: var(--display); font-size: 22px; letter-spacing: -.01em; }
.tb-mini-kpis > div:last-child { border-bottom-right-radius: var(--r-lg); }

/* Checador de precios */
.tb-tool { display: grid; gap: 10px; align-content: start; }
.tb-cp-res { margin: 0 -18px -16px; }
.tb-cp-res > p { padding: 10px 18px 16px; }
.tb-cp-price { font-family: var(--display); font-size: 20px; color: var(--teal); }

/* Accesos rápidos */
.tb-shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.tb-shortcut { display: grid; justify-items: start; gap: 10px; padding: 14px; border-radius: var(--r-md); border: 1px solid var(--line-soft); background: var(--bg); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; transition: background .15s, border-color .15s, transform .1s; }
.tb-shortcut svg { width: 22px; height: 22px; color: var(--teal); }
.tb-shortcut:hover { background: var(--teal-soft); border-color: transparent; }
.tb-shortcut:active { transform: translateY(1px); }

/* Notas */
.tb-notes { min-height: 140px; height: 100%; resize: vertical; background: color-mix(in srgb, var(--pill) 9%, var(--surface)); border-color: color-mix(in srgb, var(--pill) 35%, var(--line)); line-height: 1.55; }

/* Destello al agregar */
.tb-flash > .tb-w-body > * { animation: tbFlash 1.1s ease; }
@keyframes tbFlash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pill) 80%, transparent); } 40% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--pill) 55%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Barra de edición de cada función ---------- */
.tb-w-bar { display: none; }
.tb-editing .tb-w { outline: 2px dashed color-mix(in srgb, var(--teal) 35%, transparent); outline-offset: 4px; }
.tb-editing .tb-w-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; padding: 4px 4px 4px 2px; min-height: 40px; }
.tb-editing .tb-w-body { pointer-events: none; user-select: none; }
.tb-editing .tb-w-body > * { opacity: .92; }
.tb-grip { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: grab; touch-action: none; }
.tb-grip:hover { background: var(--teal-soft); color: var(--teal); border-color: transparent; }
.tb-grip:active { cursor: grabbing; }
.tb-grip svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.tb-w-name { flex: 1; min-width: 0; font-weight: 700; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sizes { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); flex: none; }
.tb-sizes button { min-width: 30px; height: 26px; padding: 0 7px; border: 0; border-radius: var(--r-pill); background: transparent; font-size: 12.5px; font-weight: 700; color: var(--ink-3); cursor: pointer; }
.tb-sizes button:hover { color: var(--ink); }
.tb-sizes button[aria-pressed="true"] { background: var(--teal); color: #fff; }
.tb-w-ic { width: 32px; height: 32px; flex: none; background: var(--surface); border-color: var(--line); }
.tb-w-rm:hover { background: var(--red-soft); color: var(--red); }

.tb-dragging { position: fixed !important; z-index: 80; pointer-events: none; box-shadow: var(--shadow-pop); transform: rotate(-1deg) scale(1.01); opacity: .96; background: var(--bg); outline-style: solid !important; }
.tb-ph { border-radius: var(--r-lg); border: 2px dashed var(--teal); background: color-mix(in srgb, var(--teal) 7%, transparent); }

/* ---------- Barra superior de edición ---------- */
.tb-editbar { display: none; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px 12px 18px; margin-bottom: 18px; border-radius: var(--r-lg); background: var(--teal-ink); color: #fff; position: sticky; top: 10px; z-index: 30; box-shadow: var(--shadow-pop); }
.tb-editing .tb-editbar { display: flex; }
.tb-editbar-txt { display: flex; align-items: center; gap: 10px; font-size: 14px; color: rgba(255,255,255,.86); }
.tb-editbar-txt > svg { width: 20px; height: 20px; color: var(--pill); flex: none; }
.tb-editbar-txt b { color: #fff; }
.tb-kbd { display: inline-grid; place-items: center; width: 22px; height: 22px; vertical-align: -6px; border-radius: 6px; background: rgba(255,255,255,.14); }
.tb-kbd svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.tb-editbar-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.tb-editbar .btn:not(.btn-pay):not(.btn-primary) { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; }
.tb-editbar .btn-primary { background: #fff; border-color: #fff; color: var(--teal-ink); }

/* ---------- Tablero vacío ---------- */
.tb-blank { grid-column: 1 / -1; display: grid; justify-items: center; text-align: center; gap: 10px; padding: 54px 20px; border-radius: var(--r-lg); border: 2px dashed var(--line); background: var(--surface); }
.tb-blank-art { display: flex; gap: 10px; margin-bottom: 8px; }
.tb-blank-art .tb-mini { width: 86px; height: 70px; padding: 8px; border-radius: 14px; background: var(--bg); }
.tb-blank-art .tb-mini:nth-child(2) { transform: translateY(-8px); }
.tb-blank p { max-width: 420px; }
.tb-blank .btn { margin-top: 8px; }

/* ---------- Miniaturas ---------- */
.tb-mini .a { fill: color-mix(in srgb, var(--ink) 14%, transparent); }
.tb-mini .b { fill: color-mix(in srgb, var(--teal) 55%, transparent); }
.tb-mini .c { fill: var(--pill); }
.tb-mini .ring { fill: none; stroke: color-mix(in srgb, var(--ink) 12%, transparent); stroke-width: 6; }
.tb-mini .ringfg { fill: none; stroke: var(--pill); stroke-width: 6; stroke-linecap: round; }

/* ---------- Menú de funciones ---------- */
.tb-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: var(--tb-drawer); z-index: 60; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -24px 0 60px -30px rgba(7, 46, 44, .4); display: flex; flex-direction: column; animation: tbIn .22s ease; }
.tb-drawer[hidden] { display: none; }
@keyframes tbIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.tb-editing .tb-s-s .tb-w-name { display: none; }
.tb-editing .tb-s-s .tb-w-bar { justify-content: space-between; }
.tb-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 22px 22px 12px; }
.tb-drawer-head p { margin-top: 4px; }
.tb-tabs { margin: 0 22px 12px; }
.tb-search { margin: 0 22px; }
.tb-cats { padding: 12px 22px 4px; flex-wrap: wrap; overflow: visible; }
.tb-cats .chip { font-size: 13px; }
.tb-cards { flex: 1; overflow-y: auto; padding: 8px 14px 24px; display: grid; gap: 8px; align-content: start; overscroll-behavior: contain; }
.tb-card { display: grid; grid-template-columns: 76px 1fr 30px; gap: 12px; align-items: center; width: 100%; padding: 10px; border-radius: var(--r-md); border: 1px solid var(--line-soft); background: var(--surface); text-align: left; cursor: pointer; transition: border-color .15s, background .15s, transform .08s; }
.tb-card:hover { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 4%, var(--surface)); }
.tb-card:active { transform: scale(.99); }
.tb-card-art { position: relative; display: grid; place-items: center; width: 76px; height: 62px; border-radius: 12px; background: var(--bg); }
.tb-card-art .tb-mini { width: 60px; height: 48px; }
.tb-card-ic { position: absolute; right: -6px; bottom: -6px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--teal); color: #fff; border: 2px solid var(--surface); }
.tb-card-ic svg { width: 14px; height: 14px; }
.tb-card-txt { display: grid; gap: 3px; min-width: 0; }
.tb-card-txt b { font-size: 14.5px; color: var(--ink); }
.tb-card-txt span { font-size: 12.8px; color: var(--ink-2); line-height: 1.35; }
.tb-card-txt em { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.tb-card-act { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--pill); color: var(--teal-ink); }
.tb-card-act svg { width: 16px; height: 16px; }
.tb-card.is-on { background: var(--bg); border-style: dashed; }
.tb-card.is-on .tb-card-act { background: var(--green-soft); color: var(--green); }

.tb-plants { flex: 1; overflow-y: auto; padding: 4px 14px 24px; display: grid; gap: 10px; align-content: start; }
.tb-plant { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: var(--r-md); border: 1px solid var(--line-soft); }
.tb-plant-prev { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; padding: 6px; border-radius: 10px; background: var(--bg); align-content: start; min-height: 64px; }
.tb-plant-prev i { height: 8px; border-radius: 3px; background: color-mix(in srgb, var(--teal) 50%, transparent); }
.tb-plant-prev i:first-child { background: var(--pill); }
.tb-plant-txt { display: grid; gap: 3px; min-width: 0; }
.tb-plant-txt b { font-size: 14.5px; }
.tb-plant-txt span { font-size: 12.8px; color: var(--ink-2); line-height: 1.35; }
.tb-plant--reset { grid-template-columns: 1fr auto; border-style: dashed; }

/* Ajustes de función */
.tb-lbl { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.tb-check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tb-check { padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--r-md); font-size: 14px; }
.tb-check svg { width: 17px; height: 17px; color: var(--teal); flex: none; }

/* ---------- Responsivo ---------- */
@media (max-width: 1400px) {
  .tb-page { --tb-drawer: 348px; }
  .tb-drawer-open .tb-s-s { grid-column: span 4; }
  .tb-drawer-open .tb-s-m { grid-column: span 6; }
  .tb-drawer-open .tb-s-l, .tb-drawer-open .tb-s-xl { grid-column: span 12; }
}
@media (max-width: 1180px) {
  .tb-page.tb-drawer-open { max-width: 1680px; }
  .tb-drawer { top: auto; left: 0; width: auto; height: min(78vh, 680px); border-left: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; box-shadow: 0 -24px 60px -20px rgba(7, 46, 44, .45); animation-name: tbUp; }
  @keyframes tbUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
  .tb-drawer::before { content: ""; position: absolute; top: 8px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 9px; background: var(--line); }
  .tb-s-s { grid-column: span 6; } .tb-s-m { grid-column: span 6; } .tb-s-l, .tb-s-xl { grid-column: span 12; }
  .tb-drawer-open .tb-s-s, .tb-drawer-open .tb-s-m { grid-column: span 6; }
}
@media (max-width: 900px) {
  .tb-page { --tb-gap: 12px; }
  .tb-s-m, .tb-drawer-open .tb-s-m { grid-column: span 12; }
  .tb-hello { padding: 18px; }
  .tb-hello h1 { font-size: 22px; }
  .tb-hello .btn { width: 100%; }
  .tb-editbar { top: 6px; padding: 10px 12px; }
  .tb-editbar-txt { display: none; }
  .tb-editbar-btns { width: 100%; display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 6px; }
  .tb-editbar-btns .btn { padding: 0 8px; min-width: 0; }
  .tb-editing .tb-w-bar { flex-wrap: wrap; }
  .tb-w-name { order: 0; }
  .tb-check-grid { grid-template-columns: 1fr; }
  .tb-head .actions .btn-primary { padding: 0 14px; }
}
@media (max-width: 520px) {
  .tb-s-s, .tb-drawer-open .tb-s-s { grid-column: span 6; }
  .tb-s-s .kpi-value { font-size: 22px; }
  .tb-s-s .kpi { padding: 14px; }
  .tb-panel .list-row .avatar { display: none; }
  .tb-editing .tb-s-s .tb-w-name { display: none; }
  .tb-editing .tb-s-s .tb-w-bar { flex-wrap: nowrap; gap: 3px; }
  .tb-editing .tb-s-s .tb-grip { width: 30px; height: 30px; }
  .tb-editing .tb-s-s .tb-w-ic { width: 28px; height: 28px; }
  .tb-editing .tb-s-s .tb-sizes { padding: 2px; }
  .tb-editing .tb-s-s .tb-sizes button { min-width: 22px; height: 24px; padding: 0 3px; font-size: 12px; }
}
@media print { .tb-page { display: none; } }
@media (prefers-reduced-motion: reduce) { .tb-drawer, .tb-flash > .tb-w-body > *, .tb-ring-fg { animation: none; transition: none; } }
