/* ==========================================================================
   HELIO CONTABLE - Modern Premium UI Theme
   Designed for High-Precision Financial & ERP Applications
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Colors */
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --paper: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-subtle: #f1f5f9;

  /* Brand Colors */
  --brand: #2563eb;
  --brand-deep: #1d4ed8;
  --brand-hover: #1e40af;
  --brand-soft: #eff6ff;
  --brand-glow: rgba(37, 99, 235, 0.22);

  /* Sidebar Theme (Ultra-sleek Dark Slate) */
  --sidebar-bg: #0b1120;
  --sidebar-bg-2: #070c18;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f1f5f9;
  --sidebar-item-hover: rgba(255, 255, 255, 0.06);
  --sidebar-item-active: linear-gradient(135deg, #2563eb, #1d4ed8);

  /* Status Colors */
  --ok: #10b981;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --ok-text: #065f46;

  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;

  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;

  --accent: #3b82f6;

  /* Layout & Geometry */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.05), 0 10px 20px -5px rgba(15, 23, 42, 0.04);

  /* Typography */
  --font-display: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", monospace, monospace;
}

/* ── Global Resets ── */
* { box-sizing: border-box; }
html, body { height: 100%; max-width: 100%; }
html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { max-width: 100%; }
button, .btn, .nav-item, .pos-tile, .quick-btn {
  touch-action: manipulation;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

[hidden] { display: none !important; }

/* ── Login Screen (Polished Perseo Split Hero) ── */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(37, 99, 235, 0.15), transparent 60%),
    radial-gradient(ellipse 50% 60% at 90% 80%, rgba(14, 165, 233, 0.12), transparent 50%),
    #eef2f8;
}
.login-card {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  min-height: min(640px, calc(100vh - 48px));
  display: grid;
  grid-template-columns: 1.3fr 0.95fr;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.2);
  animation: rise 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 40px 44px 32px;
  color: #fff;
  background:
    radial-gradient(circle at 80% 20%, rgba(56, 189, 248, 0.25), transparent 45%),
    linear-gradient(160deg, #091530 0%, #0d214d 50%, #081432 100%);
  overflow: hidden;
}
.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.06) 0 1px, transparent 1.5px);
  background-size: 24px 24px;
  opacity: 0.6;
  pointer-events: none;
}
.login-hero > * { position: relative; z-index: 1; }

.hero-brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.hero-brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.35);
}
.hero-brand-icon img,
.hero-brand-icon svg { width: 44px; height: 44px; display: block; }

.brand-mark {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brand);
  margin: 0;
  line-height: 1;
}
.brand-mark.light { color: #fff; font-size: 1.85rem; }
.brand-mark.sm { font-size: 1.35rem; }
.brand-tag {
  margin: 4px 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  font-weight: 700;
  color: rgba(226, 232, 240, 0.7);
}

.login-headline.light {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 2.5vw, 2.1rem);
  max-width: 18ch;
  line-height: 1.22;
  margin: 0 0 12px;
  color: #fff;
}
.login-headline.light span {
  background: linear-gradient(135deg, #7dd3fc, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-sub.light {
  color: rgba(226, 232, 240, 0.8);
  margin: 0 0 20px;
  max-width: 38ch;
  font-size: 0.92rem;
  line-height: 1.5;
}

.login-hero-visual {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 200px;
  margin: 4px 0 16px;
}
.login-hero-visual img {
  width: min(100%, 380px);
  height: auto;
  max-height: 250px;
  object-fit: contain;
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.4));
  animation: floaty 6s ease-in-out infinite;
}
.login-hero-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}
.login-hero-mark strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.login-hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(125, 211, 252, 0.3);
  color: #e0f2fe;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 24px;
  transition: all 0.2s;
}
.login-hero-cta:hover {
  background: rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

.login-trust {
  list-style: none;
  margin: auto 0 0;
  padding: 18px 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.login-trust li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.trust-icon {
  color: #38bdf8;
  display: grid;
  place-items: center;
  margin-top: 2px;
  flex-shrink: 0;
}
.login-trust strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #f8fafc;
}
.login-trust small {
  display: block;
  color: rgba(226, 232, 240, 0.65);
  font-size: 0.7rem;
  line-height: 1.3;
  margin-top: 2px;
}

.login-panel {
  display: flex;
  flex-direction: column;
  padding: 40px 38px 30px;
  background: #ffffff;
}
.panel-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.login-ingress {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink);
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.login-panel-sub {
  margin: 6px 0 18px;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.4;
}

.login-stat {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #0284c7 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 22px;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
}
.stat-badge-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.03em;
  line-height: 1.1;
  font-weight: 800;
}
.login-stat span {
  display: block;
  margin-top: 5px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  font-weight: 600;
  opacity: 0.9;
}

.login-form { display: grid; gap: 14px; }
.field-label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-secondary);
}
.input-with-icon { position: relative; }
.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.login-form input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 0.92rem;
  transition: all 0.2s;
}
.login-form input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px var(--brand-glow);
}
.btn-login {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.35);
  transition: all 0.2s;
}
.btn-login:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.4);
}

.login-hint {
  margin: 16px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}
.login-hint code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--brand-deep);
}

.login-extras {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.extras-title {
  margin: 0 0 8px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted-light);
  text-transform: uppercase;
}
.extras-row { display: flex; flex-wrap: wrap; gap: 8px; }
.extras-row span {
  font-size: 0.74rem;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 5px 11px;
}

/* ==========================================================================
   APP SHELL & SIDEBAR NAVIGATION
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  background: var(--paper);
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--sidebar-border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  user-select: none;
}

.sidebar-brand {
  padding: 6px 10px 12px;
  border-bottom: 1px solid var(--sidebar-border);
}
.brand-logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  flex-shrink: 0;
}
.brand-logo-icon img,
.brand-logo-icon svg {
  width: 36px;
  height: 36px;
  display: block;
}
.brand-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-pill {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  letter-spacing: 0.04em;
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.brand-sub {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(226, 232, 240, 0.5);
  font-weight: 500;
  margin-top: 1px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}
.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }

.nav-group {
  margin: 16px 12px 6px;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 800;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.86rem;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.nav-item .nav-icon {
  flex-shrink: 0;
  color: #64748b;
  transition: color 0.18s;
}
.nav-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-hover);
}
.nav-item:hover .nav-icon {
  color: #93c5fd;
}
.nav-item.active {
  background: var(--sidebar-item-active);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.nav-item.active .nav-icon {
  color: #ffffff;
}

/* Sidebar Footer (User Card) */
.sidebar-foot {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--sidebar-border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #10b981);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}
.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: rgba(232, 238, 248, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* ==========================================================================
   MAIN CONTENT & TOPBAR
   ========================================================================== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(37, 99, 235, 0.05), transparent 60%),
    var(--paper);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 32px 18px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.btn-nav {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}
.btn-nav:hover { background: #f8fafc; }
.nav-backdrop {
  display: none;
}
.topbar-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}
.topbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.content {
  padding: 24px 32px 48px;
  flex: 1;
}

/* ==========================================================================
   DASHBOARD COMPONENTS
   ========================================================================== */

/* ── Caja Banner ── */
.caja-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.caja-banner.abierta {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid var(--ok-border);
  color: var(--ok-text);
}
.caja-banner.cerrada {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.caja-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.caja-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
  position: relative;
}
.caja-banner.cerrada .caja-dot {
  background: #ea580c;
}
.caja-dot.pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ok);
  animation: pulse-ring 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(0.6); opacity: 0.9; }
  50%, 100% { transform: scale(1.6); opacity: 0; }
}

.caja-headline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.96rem;
}
.badge-sub {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--ok-text);
  padding: 2px 8px;
  border-radius: 6px;
}
.caja-desc {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: #475569;
}
.text-brand { color: var(--brand-deep); font-weight: 700; }

.btn-caja-act {
  background: #ffffff;
  color: var(--ok-text);
  border: 1px solid var(--ok-border);
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}
.btn-caja-act:hover {
  background: #f0fdf4;
  border-color: #86efac;
}

/* ── Quick Action Grid ── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.quick-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  text-align: left;
}
.quick-btn:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  box-shadow: var(--shadow-md);
}
.quick-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.quick-btn:hover .quick-icon-badge { transform: scale(1.05); }

.quick-icon-badge.emerald { background: #ecfdf5; color: #059669; }
.quick-icon-badge.blue { background: #eff6ff; color: #2563eb; }
.quick-icon-badge.purple { background: #f5f3ff; color: #7c3aed; }
.quick-icon-badge.amber { background: #fffbeb; color: #d97706; }

.quick-content strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}
.quick-content span {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
}
.quick-hover-arrow {
  margin-left: auto;
  color: var(--muted-light);
  font-size: 1rem;
  transition: all 0.2s;
}
.quick-btn:hover .quick-hover-arrow {
  color: var(--brand);
  transform: translateX(3px);
}
[data-go],
.dash-link {
  cursor: pointer;
}
.dash-link:focus-visible,
.quick-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ── KPI / Stat Cards ── */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px 22px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: rise 0.4s ease-out backwards;
}
.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}
.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.stat-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}
.stat-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.stat-icon-wrap.blue { background: #eff6ff; color: var(--brand); }
.stat-icon-wrap.emerald { background: #ecfdf5; color: #059669; }
.stat-icon-wrap.purple { background: #f5f3ff; color: #7c3aed; }
.stat-icon-wrap.teal { background: #f0fdfa; color: #0d9488; }

.stat-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
  line-height: 1.15;
}
.stat-value.accent { color: var(--brand); }

.stat-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.pill-metric {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pill-metric.positive { background: #ecfdf5; color: #065f46; }
.pill-metric.negative { background: #fef2f2; color: #991b1b; }
.pill-metric.warning { background: #fffbeb; color: #92400e; }
.pill-metric.neutral { background: #f1f5f9; color: #475569; }
.stat-sub-muted { font-size: 0.74rem; color: var(--muted); }

/* ── Panels & Split View ── */
.panel-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.panel h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.panel-sub {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.badge-time {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}
.badge-pill-alert {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* ── Modern Chart ── */
.chart-wrapper {
  padding-top: 10px;
}
.chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 150px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
  cursor: pointer;
  position: relative;
}
.chart-val {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--brand-deep);
  min-height: 14px;
}
.chart-bar {
  width: 100%;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #60a5fa 0%, var(--brand) 100%);
  min-height: 6px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.chart-bar-wrap:hover .chart-bar {
  background: linear-gradient(180deg, #38bdf8 0%, #1d4ed8 100%);
  transform: scaleY(1.04);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.chart-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Stock Alerts List ── */
.list-low {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.list-low li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #fffbf5;
  border: 1px solid #fed7aa;
  border-radius: 12px;
}
.stock-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stock-code {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: #c2410c;
}
.stock-name {
  font-size: 0.86rem;
  color: var(--ink);
}
.stock-badge-pill {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffedd5;
  color: #9a3412;
}
.panel-summary-row {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line-subtle);
  font-size: 0.8rem;
  color: var(--muted);
}
.panel-summary-row strong { color: var(--ink); }

/* ── Financial Health Bar ── */
.finance-health-bar {
  display: flex;
  align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 22px;
  overflow: hidden;
}
.fh-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  transition: background 0.15s;
}
.fh-card:hover { background: var(--line-subtle); }
.fh-divider {
  width: 1px;
  background: var(--line);
  margin: 12px 0;
  flex-shrink: 0;
}
.fh-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.fh-banks .fh-icon { background: #eff6ff; color: #2563eb; }
.fh-margin.pos .fh-icon { background: #ecfdf5; color: #059669; }
.fh-margin.neg .fh-icon { background: #fef2f2; color: #dc2626; }
.fh-cxc .fh-icon { background: #fffbeb; color: #d97706; }
.fh-cxp .fh-icon { background: #fdf4ff; color: #9333ea; }
.fh-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.fh-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fh-value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.fh-value.warn-val { color: #d97706; }
.fh-value.danger-val { color: #dc2626; }
.fh-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.fh-pct.pos { color: #059669; font-weight: 700; }
.fh-pct.neg { color: #dc2626; font-weight: 700; }

/* ── KPI Period Header ── */
.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.kpi-title-block { display: flex; flex-direction: column; gap: 3px; }
.kpi-section-title {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}
.kpi-period-label {
  font-size: 0.8rem;
  color: var(--muted-light);
}

/* ── Period Selector ── */
.period-selector {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--shadow-xs);
}
.period-btn {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
.period-btn:hover { color: var(--ink); background: var(--line-subtle); }
.period-btn.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* ── Stat animation stagger ── */
.stat-anim-1 { animation: rise 0.38s ease-out both; }
.stat-anim-2 { animation: rise 0.38s 0.05s ease-out both; }
.stat-anim-3 { animation: rise 0.38s 0.1s ease-out both; }
.stat-anim-4 { animation: rise 0.38s 0.15s ease-out both; }

/* ── KPI stat icon: amber variant ── */
.stat-icon-wrap.amber { background: #fffbeb; color: #d97706; }

/* ── Dual Chart ── */
.dual-chart-wrap { padding-top: 6px; }
.dual-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.chart-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  cursor: pointer;
  gap: 5px;
  transition: opacity 0.15s;
}
.chart-group:hover { opacity: 0.85; }
.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
  flex: 1;
}
.chart-bar {
  flex: 1;
  border-radius: 5px 5px 2px 2px;
  min-height: 3px;
  transition: height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.bar-ventas {
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}
.bar-compras {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
  box-shadow: 0 2px 6px rgba(217,119,6,0.2);
}
.chart-group:hover .bar-ventas { filter: brightness(1.1); }
.chart-group:hover .bar-compras { filter: brightness(1.1); }
.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.blue-dot { background: #2563eb; }
.amber-dot { background: #d97706; }
.chart-summary-row {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-subtle);
  font-size: 0.8rem;
  color: var(--muted);
}
.chart-summary-row strong { font-weight: 700; }
.text-blue { color: #2563eb; }
.text-amber { color: #d97706; }
.text-green { color: #059669; }
.text-red { color: #dc2626; }
.muted-sm { font-size: 0.8rem; color: var(--muted); }

/* ── Payment Methods ── */
.payment-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.payment-row { display: flex; flex-direction: column; gap: 6px; }
.payment-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.payment-label { display: flex; align-items: center; gap: 8px; }
.payment-icon { color: var(--muted); display: flex; }
.payment-name { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.payment-meta { display: flex; align-items: center; gap: 10px; }
.payment-pct {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 40px;
  text-align: right;
}
.payment-total {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 80px;
  text-align: right;
}
.payment-bar-track {
  height: 6px;
  background: var(--line-subtle);
  border-radius: 999px;
  overflow: hidden;
}
.payment-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── SRI Semaphore ── */
.sri-semaphore {
  border-top: 1px solid var(--line-subtle);
  padding-top: 14px;
  margin-top: 16px;
}
.semaphore-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}
.sri-env-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: auto;
}
.sri-env-badge.test { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.sri-env-badge.prod { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.semaphore-rows { display: flex; flex-direction: column; gap: 6px; }
.semaphore-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}
.sem-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.semaphore-item.ok .sem-dot { background: #10b981; }
.semaphore-item.warn .sem-dot { background: #f59e0b; }
.semaphore-item.danger .sem-dot { background: #ef4444; }
.semaphore-item.ok { color: #065f46; }
.semaphore-item.warn { color: #92400e; }
.semaphore-item.danger { color: #991b1b; }

/* ── Top Products ── */
.top-products-list { display: flex; flex-direction: column; gap: 14px; }
.top-prod-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.top-rank {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.top-prod-info { flex: 1; min-width: 0; }
.top-prod-name-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.top-prod-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-prod-code {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  flex-shrink: 0;
}
.top-prod-bar-wrap {
  height: 4px;
  background: var(--line-subtle);
  border-radius: 999px;
  overflow: hidden;
}
.top-prod-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.top-prod-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.top-prod-total {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}
.top-prod-qty { font-size: 0.72rem; color: var(--muted); }

/* ── Operational Alerts ── */
.alerts-list { display: flex; flex-direction: column; gap: 14px; }
.alert-group { display: flex; flex-direction: column; gap: 8px; }
.alert-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
}
.warn-lbl { background: #fffbeb; color: #92400e; }
.info-lbl { background: #eff6ff; color: #1d4ed8; }
.alert-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 9px;
  border: 1px solid var(--line);
  gap: 8px;
}
.alert-row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alert-row-code {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
}
.alert-row-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alert-row-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}
.alert-row-badge.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-row-badge.danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-row-ok {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  color: #065f46;
  font-weight: 600;
  padding: 10px 12px;
  background: #ecfdf5;
  border-radius: 10px;
  border: 1px solid #a7f3d0;
}
.alert-see-more {
  background: none;
  border: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.15s;
  text-align: left;
}
.alert-see-more:hover { background: var(--brand-soft); }

/* ==========================================================================
   DATA TABLES & BADGES
   ========================================================================== */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}
table.data th {
  background: #f8fafc;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-subtle);
  vertical-align: middle;
  color: var(--ink);
  transition: background 0.15s;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #f8fafc; }

.font-mono { font-family: var(--font-mono); font-size: 0.82rem; }
.text-bold { font-weight: 700; }
.type-pill {
  font-size: 0.74rem;
  font-weight: 600;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 6px;
  color: #475569;
}
.client-name { font-weight: 500; color: #1e293b; }
.money {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Modern Status Badges with Status Dot */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
  border: 1px solid var(--ok-border);
}
.badge-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
}
.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}
.badge-muted {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* ==========================================================================
   BUTTONS & FORM CONTROLS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e8eef8;
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }
.btn-block { width: 100%; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.toolbar input, .toolbar select,
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-width: 0;
  font-size: 0.88rem;
  transition: all 0.15s;
}
.toolbar input:focus, .toolbar select:focus,
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.toolbar input { flex: 1; min-width: 200px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
}
.money-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  transition: all 0.15s;
}
.money-input:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.money-input span {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: #f8fafc;
  border-right: 1px solid var(--line);
  font-weight: 800;
  color: var(--brand);
  font-size: 0.95rem;
}
.money-input input {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  flex: 1;
  min-width: 0;
}
.vence-box {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border: 1px dashed #93c5fd;
  border-radius: 12px;
  background: #eff6ff;
}
.vence-box-title {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--brand-deep, #1d4ed8);
}

/* ==========================================================================
   MODAL WINDOW
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 28px 30px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  animation: rise 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  color: var(--ink);
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}
.items-editor { margin-top: 12px; }
.items-editor table { font-size: 0.84rem; }
.items-editor input { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; }

/* ==========================================================================
   POINT OF SALE (POS)
   ========================================================================== */
.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 16px;
  align-items: start;
  overflow: hidden;
}
.pos-main { min-width: 0; overflow: hidden; }
.pos-scan-input {
  width: 100%;
  padding: 16px 20px !important;
  font-size: 1.15rem !important;
  border: 2px solid var(--brand) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 0 0 4px var(--brand-glow) !important;
  letter-spacing: 0.02em;
}
.pos-favorites {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.pos-tile {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: var(--radius);
  padding: 0;
  text-align: left;
  cursor: pointer;
  min-height: 118px;
  box-shadow: var(--shadow-xs);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.pos-tile-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  min-height: 118px;
  padding: 12px;
}
.pos-tile:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
}
.pos-tile-name {
  font-weight: 700;
  font-size: 0.84rem;
  line-height: 1.3;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-height: 2.2em;
  max-height: 2.6em;
}
.pos-tile-price {
  font-family: var(--font-display);
  color: var(--brand-deep);
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: auto;
}
.pos-tile-stock {
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--muted);
}

.pos-side {
  position: sticky;
  top: 90px;
  z-index: 2;
  min-width: 0;
  max-height: calc(100vh - 120px);
  overflow-x: hidden;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.pos-side-meta {
  margin: 0 0 12px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}
.pos-cart { display: grid; gap: 8px; margin: 14px 0; min-height: 140px; }
.pos-cart-line {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-subtle);
  font-size: 0.88rem;
}
.pos-qty { display: flex; align-items: center; gap: 6px; }
.pos-qty button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.15s;
}
.pos-qty button:hover { background: #e2e8f0; }
.pos-totals {
  padding: 16px 0;
  border-top: 2px solid var(--ink);
  margin-bottom: 12px;
}
.pos-totals > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.pos-total-num {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--brand);
}
.pos-pay-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1080px) {
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
    min-height: 100dvh;
  }
  .main { min-height: 100dvh; }
  .btn-nav { display: grid; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    z-index: 80;
    transform: translateX(-105%);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    border-right: 1px solid var(--sidebar-border);
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
  }
  .nav-backdrop[hidden] { display: none !important; }

  .topbar {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    gap: 10px;
    flex-wrap: wrap;
  }
  .topbar h2 { font-size: 1.2rem; }
  .topbar-eyebrow { font-size: 0.62rem; }
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .topbar-actions:empty { display: none; }
  .topbar-actions .btn { min-height: 40px; }
  .panel { padding: 16px; }
  .panel-header { flex-wrap: wrap; gap: 10px; }
  .field-with-scan { flex-wrap: wrap; }
  .content {
    padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
  }

  .login-screen {
    padding: 0;
    align-items: stretch;
  }
  .login-card {
    grid-template-columns: 1fr;
    width: 100%;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    border: 0;
  }
  .login-hero {
    padding: 18px 20px 16px;
    padding-top: max(18px, env(safe-area-inset-top));
  }
  .login-hero-copy,
  .login-hero-visual,
  .login-hero-cta,
  .login-trust { display: none; }
  .hero-brand-wrap { margin-bottom: 0; }
  .login-panel {
    padding: 22px 20px calc(28px + env(safe-area-inset-bottom));
  }
  .login-form input { font-size: 16px; }
  .login-stat strong { font-size: 1.1rem; }

  .pos-layout { grid-template-columns: 1fr; gap: 14px; }
  .pos-side { position: static; max-height: none; padding: 16px; }
  .pos-scan-input { font-size: 16px !important; padding: 14px 14px !important; }
  .pos-favorites { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pos-tile, .pos-tile-body { min-height: 112px; }
  .pos-tile-body { padding: 10px; }
  .pos-cart-line {
    grid-template-columns: 1fr auto auto;
    gap: 8px;
  }
  .pos-cart-line > :first-child { grid-column: 1 / -1; }
  .pos-qty button { width: 36px; height: 36px; }
  .pos-total-num { font-size: 1.5rem; }

  .caja-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .caja-banner .btn { width: 100%; }

  .quick-grid { gap: 10px; }
  .quick-btn { padding: 14px 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input { min-width: 0; width: 100%; font-size: 16px; }
  .toolbar select, .form-grid input, .form-grid select, .form-grid textarea {
    font-size: 16px;
    width: 100%;
  }

  table.data { min-width: 620px; }
  .table-container { -webkit-overflow-scrolling: touch; }

  .modal { padding: 0; align-items: end; }
  .modal-card {
    width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1; min-height: 44px; }

  .nav-item { min-height: 44px; }
}

@media (max-width: 600px) {
  .quick-grid { grid-template-columns: 1fr; }
  .grid-stats { grid-template-columns: 1fr; }
  .stat { padding: 16px; }
  .login-ingress { font-size: 1.25rem; }
  .extras-row span { font-size: 0.7rem; }
  .pos-scan-row { gap: 8px; }
  .pos-scan-row .btn-scan { padding: 0 12px !important; }
}

@media (max-width: 380px) {
  .pos-favorites { grid-template-columns: 1fr; }
  .topbar-eyebrow { display: none; }
}


/* ── Licencias admin ── */
.lic-stats { margin-bottom: 18px; }
.lic-toolbar { align-items: stretch; }
.lic-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lic-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.lic-chip.active {
  background: var(--brand-soft);
  border-color: #93c5fd;
  color: var(--brand-deep);
}
.lic-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lic-total {
  margin: 14px 0 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--brand);
}

.perm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-secondary);
}
.perm-item small { color: var(--muted); font-weight: 500; }
.perm-locked { opacity: 0.85; }
@media (max-width: 600px) {
  .perm-grid { grid-template-columns: 1fr; }
}

.modal-card.modal-wide { width: min(980px, 100%); }
.fast-head { display: grid; gap: 8px; margin-bottom: 14px; }
.fast-head h3 { margin: 0; }
.fast-search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.fast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.fast-card {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  text-align: left;
  cursor: pointer;
  min-height: 160px;
}
.fast-card:hover { border-color: var(--brand); box-shadow: 0 8px 20px rgba(37,99,235,.12); }
.fast-card.fast-added { background: #ecfdf5; border-color: #10b981; }
.fast-ico { font-size: 2.4rem; line-height: 1; }
.fast-open {
  margin-top: auto;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand);
}
.fast-img, .prod-thumb {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 10px;
  background: #eff6ff;
  display: grid;
  place-items: center;
  font-size: 2.2rem;
}
.prod-thumb-sm { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; font-size: 1.1rem; display: grid; place-items: center; background: #eff6ff; }
.fast-price { color: var(--brand); font-weight: 800; }
.pos-price-toggle { display: flex; gap: 6px; margin-bottom: 10px; }
.pos-price-toggle button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pos-cart-line { grid-template-columns: 1fr auto auto auto; }
.pos-line-desc { width: 72px; font-size: 0.78rem; padding: 4px 6px; }
.prod-img-box { display: flex; gap: 12px; align-items: center; }
.prod-img-box img, .prod-img-box .prod-thumb { width: 88px; height: 88px; }
.install-banner {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px;
}
.offline-dot { font-size: 0.75rem; font-weight: 700; color: #b45309; }
.abono-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* barcode-scan-deploy */
