/* OB Apps — kit de diseño compartido por las aplicaciones de demostración. */
:root {
	--bg: #f5f6f8;
	--panel: #fff;
	--ink: #0f172a;
	--ink-2: #334155;
	--muted: #64748b;
	--line: #e6e8ec;
	--soft: #f1f3f6;
	--acc: #4f7cff;
	--acc-ink: #fff;
	--ok: #16a34a;
	--warn: #d97706;
	--bad: #dc2626;
	--r: 12px;
	--shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
	--ease: cubic-bezier(0.16, 1, 0.3, 1);
	--font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
svg { display: block; flex: none; }

.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

/* Barra lateral */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 18px 14px; background: #0f172a; color: #cbd5e1; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand i { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--acc); color: var(--acc-ink); font-style: normal; font-size: 15px; box-shadow: 0 6px 18px -6px var(--acc); }
.brand small { display: block; font-weight: 400; font-size: 11.5px; color: #94a3b8; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: inherit; text-align: left; font-weight: 500; transition: background 0.2s, color 0.2s; }
.nav:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav.on { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav.on svg { color: var(--acc); }
.nav .count { margin-left: auto; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); font-size: 11.5px; }
.side .sep { margin: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; }
.side .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); font-size: 13px; }
.side .me small { display: block; color: #94a3b8; font-size: 11.5px; }
.reset { margin: 8px 10px 0; padding: 0; border: 0; background: none; color: #64748b; font-size: 12px; text-align: left; text-decoration: underline; }

/* Contenido */
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 24px; background: rgba(245, 246, 248, 0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.top .sub { color: var(--muted); font-size: 13px; }
.top .grow { flex: 1; }
.search { display: flex; align-items: center; gap: 8px; width: min(320px, 34vw); height: 38px; padding: 0 12px; border-radius: 10px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); }
.content { padding: 22px 24px 40px; display: grid; gap: 18px; align-content: start; }
.view { display: none; gap: 18px; align-content: start; }
.view.on { display: grid; animation: fadeUp 0.5s var(--ease); }
.content > *, .view > *, .card { min-width: 0; }

/* Piezas */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; white-space: nowrap; transition: transform 0.15s, background 0.2s, box-shadow 0.2s; }
.btn:hover { background: var(--soft); }
.btn:active { transform: scale(0.97); }
.btn.p { background: var(--acc); color: var(--acc-ink); box-shadow: 0 6px 16px -8px var(--acc); }
.btn.p:hover { filter: brightness(1.06); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.ok { background: var(--ok); color: #fff; box-shadow: none; }
.btn.bad { color: var(--bad); }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); position: relative; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px #fff; }

.card { padding: 18px; border-radius: var(--r); background: var(--panel); box-shadow: var(--shadow); }
.card h3 { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; border-radius: var(--r); background: var(--panel); box-shadow: var(--shadow); animation: fadeUp 0.6s var(--ease) both; }
.kpi:nth-child(2) { animation-delay: 0.05s; } .kpi:nth-child(3) { animation-delay: 0.1s; } .kpi:nth-child(4) { animation-delay: 0.15s; }
.kpi span { color: var(--muted); font-size: 12.5px; }
.kpi b { display: block; margin: 4px 0 2px; font-size: 24px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--ok); }
.kpi em.down { color: var(--bad); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--ink-2); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }
.badge.acc { background: color-mix(in srgb, var(--acc) 14%, #fff); color: color-mix(in srgb, var(--acc) 80%, #000); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; font-size: 13px; transition: background 0.2s, color 0.2s; }
.chip.on { background: var(--ink); color: #fff; box-shadow: none; }

.av { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: hsl(var(--h, 220) 70% 92%); color: hsl(var(--h, 220) 60% 32%); font-size: 11.5px; font-weight: 700; flex: none; }
.av.sm { width: 24px; height: 24px; font-size: 10px; }

.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; cursor: default; user-select: none; }
.table th[data-sort] { cursor: pointer; }
.table th[data-sort]:hover { color: var(--ink); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
.table tr { transition: background 0.3s; }
.table tbody tr:hover { background: #fafbfc; }
.table tr.flash { animation: flash 1.2s ease; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); outline: 0; transition: box-shadow 0.2s; }
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { box-shadow: inset 0 0 0 2px var(--acc); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

dialog.modal { width: min(480px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 16px; background: var(--panel); color: var(--ink); box-shadow: 0 40px 80px -20px rgba(15, 23, 42, 0.45); }
dialog.modal::backdrop { background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop 0.35s var(--ease); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal header h3 { font-size: 17px; }
.modal .body { display: grid; gap: 12px; padding: 12px 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 360px; padding: 12px 14px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.5); animation: toastIn 0.45s var(--ease); }
.toast.out { animation: toastOut 0.35s ease forwards; }
.toast svg { color: #4ade80; }
.toast.warn svg { color: #fbbf24; }

.empty { padding: 30px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
.thumb { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: hsl(var(--h, 220) 80% 95%); font-size: 18px; flex: none; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--soft); }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-weight: 600; font-size: 13px; transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.only-m { display: none; }

/* Barra inferior en móvil */
.tabbar { display: none; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes flash { 0% { background: color-mix(in srgb, var(--acc) 18%, #fff); } 100% { background: transparent; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
	.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 820px) {
	.app { grid-template-columns: 1fr; }
	.side { display: none; }
	.top { height: 58px; padding: 0 14px; gap: 8px; }
	.top .sub, .top .hide-m { display: none; }
	.top h1 { font-size: 16px; white-space: nowrap; }
	.search { width: auto; flex: 1; min-width: 0; }
	.content { padding: 14px 14px 96px; }
	.kpis { gap: 10px; }
	.kpi { padding: 12px 14px; }
	.kpi b { font-size: 19px; }
	.grid2 { grid-template-columns: 1fr; }
	.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
	.tabbar button { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; }
	.tabbar button.on { color: var(--acc); }
	.toasts { left: 12px; right: 12px; bottom: 76px; }
	.toast { min-width: 0; max-width: none; }
	.hide-sm { display: none !important; }
	.only-m { display: revert; }
}
