/* 
   360 WORLD S.A.S. - Sync Hub SaaS Style System
   Paleta: Midnight Navy (#0B0F19) + Deep Emerald (#059669) + Warm Amber (#D97706) + Pure White Accents
   Diseñado para impresionar visualmente en reuniones de dirección técnica.
*/

:root {
  --bg-app: #0B0F19;
  --bg-sidebar: #0E1626;
  --bg-card: rgba(20, 30, 48, 0.7);
  --bg-card-hover: rgba(28, 41, 65, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #10B981;
  
  --emerald-500: #10B981;
  --emerald-600: #059669;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  
  --amber-500: #F59E0B;
  --amber-glow: rgba(245, 158, 11, 0.2);
  
  --cyan-500: #06B6D4;
  --indigo-500: #6366F1;
  --rose-500: #F43F5E;
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 40%);
}

/* ================= LOGIN SCREEN ESTILOS ================= */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #111B2E 0%, #080C14 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 480px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 34px;
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modalScale 0.35s ease;
}

@keyframes modalScale {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.login-header {
  text-align: center;
  margin-bottom: 22px;
}

.brand-icon.lg {
  width: 58px;
  height: 58px;
  font-size: 26px;
  margin: 0 auto 14px auto;
}

.login-header h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #FFFFFF;
}

.login-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-security-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--emerald-500);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  margin-top: 12px;
}

/* Demo Accounts Box */
.demo-accounts-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 20px;
}

.demo-acc-title {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: var(--amber-500);
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.demo-acc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.btn-demo-acc {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.btn-demo-acc:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-demo-acc.active {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--emerald-500);
}

.demo-acc-role {
  font-size: 9.5px;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--emerald-500);
}

.demo-acc-name {
  font-size: 11px;
  font-weight: 600;
  color: white;
  margin-top: 2px;
}

/* Form inputs */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-modern {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  color: white;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  outline: none;
  transition: var(--transition);
}

.input-modern:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 10px var(--emerald-glow);
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.eye-toggle {
  position: absolute;
  right: 14px;
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
}

.eye-toggle:hover {
  color: white;
}

.btn-login {
  background: linear-gradient(135deg, var(--emerald-600), var(--emerald-500));
  color: white;
  border: none;
  padding: 13px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
  box-shadow: 0 4px 15px var(--emerald-glow);
  margin-top: 6px;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.login-error {
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid #DC2626;
  color: #F87171;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  text-align: center;
}

.login-footer {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  font-size: 10.5px;
  color: var(--text-dim);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-footer strong {
  color: var(--text-muted);
}

.user-badge-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.btn-user-action {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-user-action:hover {
  color: var(--emerald-500);
  background: rgba(16, 185, 129, 0.15);
}

.btn-logout-icon {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-logout-icon:hover {
  color: #F87171;
  background: rgba(239, 68, 68, 0.15);
}

/* ================= LAYOUT PRINCIPAL ================= */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 8px 20px 8px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--emerald-600), var(--cyan-500));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  box-shadow: 0 0 20px var(--emerald-glow);
}

.brand-title {
  display: block;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.8px;
  color: #FFFFFF;
}

.brand-subtitle {
  display: block;
  font-size: 11px;
  color: var(--emerald-500);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.user-badge-sidebar {
  margin: 18px 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4F46E5, #9333EA);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--amber-500);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  margin-top: 10px;
}

.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 1.2px;
  font-weight: 700;
  padding: 14px 12px 6px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  position: relative;
}

.nav-item i {
  font-size: 15px;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #FFFFFF;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.04));
  border-left: 3px solid var(--emerald-500);
}

.badge-pill {
  margin-left: auto;
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald-500);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.saas-license {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.saas-license i {
  color: var(--emerald-500);
  font-size: 14px;
}

.saas-license strong {
  display: block;
  color: var(--text-muted);
}

/* Main Area */
.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-app);
}

/* Topbar */
.topbar {
  height: 76px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.topbar-left h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
}

.topbar-left p {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.sync-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--emerald-500);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--emerald-500);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--emerald-500);
  animation: pulseAnim 2s infinite;
}

@keyframes pulseAnim {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Botón de Emergencia */
.btn-emergency {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #DC2626, #991B1B);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.35);
}

.btn-emergency:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.55);
}

.btn-emergency.paused {
  background: linear-gradient(135deg, #10B981, #059669);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

/* Viewport */
.content-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Channels Ribbon */
.channels-ribbon {
  background: rgba(14, 22, 38, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.ribbon-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.channel-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.channel-pill .status-icon {
  font-size: 10px;
  color: var(--emerald-500);
}

.channel-pill.connected {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.06);
}

.channel-pill.connected .ch-badge {
  color: #34D399;
  font-weight: 700;
}

.channel-pill.paused .status-icon {
  color: var(--rose-500);
}

.channel-pill.disconnected {
  opacity: 0.62;
  background: rgba(255, 255, 255, 0.015);
  border-style: dashed;
}

.channel-pill.disconnected .status-icon {
  color: #64748B;
}

.channel-pill.disconnected .ch-badge {
  color: #94A3B8;
  font-style: italic;
}

.channel-pill .ch-name {
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
}

.channel-pill .ch-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  backdrop-filter: blur(10px);
  transition: var(--transition);
}

.kpi-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.kpi-card.highlight-profit {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(145deg, rgba(20, 30, 48, 0.9), rgba(6, 78, 59, 0.35));
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.icon-teal { background: rgba(6, 182, 212, 0.15); color: var(--cyan-500); }
.icon-amber { background: rgba(245, 158, 11, 0.15); color: var(--amber-500); }
.icon-emerald { background: rgba(16, 185, 129, 0.2); color: var(--emerald-500); }
.icon-cyan { background: rgba(99, 102, 241, 0.15); color: var(--indigo-500); }

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  font-family: var(--font-sans);
  color: #FFFFFF;
  margin-bottom: 8px;
}

.kpi-trend {
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-trend.positive { color: var(--emerald-500); }
.kpi-trend.neutral { color: var(--amber-500); }

/* Glass Cards */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  backdrop-filter: blur(10px);
  margin-bottom: 24px;
}

.two-col-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-header-flex h3 {
  font-size: 16px;
  font-weight: 700;
}

.title-with-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tag-status {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.tag-status.live { background: rgba(16, 185, 129, 0.2); color: var(--emerald-500); }
.tag-status.success { background: rgba(6, 182, 212, 0.2); color: var(--cyan-500); }

/* Tablas Custom */
.table-responsive {
  overflow-x: auto;
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.table-custom th {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border-color);
}

.table-custom td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  vertical-align: middle;
}

.table-custom tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge-channel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-channel.meli { background: rgba(255, 230, 0, 0.15); color: #FFE600; }
.badge-channel.falabella { background: rgba(16, 185, 129, 0.15); color: #10B981; }
.badge-channel.exito { background: rgba(239, 68, 68, 0.15); color: #F87171; }

.status-badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
}

.status-badge.emitida { background: rgba(16, 185, 129, 0.2); color: #10B981; }
.status-badge.empacado { background: rgba(59, 130, 246, 0.2); color: #60A5FA; }

/* Quick Catalog Preview Cards */
.quick-catalog-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quick-product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.quick-product-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

.quick-img {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
}

.quick-info {
  flex: 1;
}

.quick-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  display: block;
}

.quick-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.quick-stock {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--emerald-500);
}

/* Toolbar */
.card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  flex: 1 1 220px;
  max-width: 380px;
}

.toolbar-search input {
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-family: var(--font-sans);
  font-size: 13px;
  width: 100%;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.custom-select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12.5px;
  outline: none;
}

/* Botones */
.btn-primary, .btn-secondary, .btn-ghost, .btn-sm, .btn-danger {
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  border: none;
}

.btn-primary {
  background: var(--emerald-600);
  color: white;
  padding: 9px 18px;
  font-size: 13px;
}
.btn-primary:hover { background: var(--emerald-500); }

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 9px 16px;
  font-size: 13px;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.14); }

.btn-ghost {
  background: transparent;
  color: var(--emerald-500);
  padding: 6px 10px;
  font-size: 12px;
}
.btn-ghost:hover { color: #FFFFFF; }

.btn-sm {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 11.5px;
}
.btn-sm:hover { color: white; background: rgba(255, 255, 255, 0.12); }

.btn-danger {
  background: #DC2626;
  color: white;
  padding: 10px 18px;
}
.btn-danger:hover { background: #B91C1C; }

.table-footer-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-dim);
}

/* Financial Summary Banner */
.financial-summary-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  padding: 18px 24px;
  border-radius: var(--radius-md);
  margin-top: 14px;
}

.fin-box {
  display: flex;
  flex-direction: column;
}

.fin-caption {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
}

.fin-amount {
  font-size: 19px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: white;
}

.fin-box.highlight {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 8px 16px;
  border-radius: 8px;
}

.fin-math {
  font-size: 20px;
  color: var(--text-dim);
  font-weight: 700;
}

.text-danger { color: #F87171 !important; }
.text-success { color: #34D399 !important; }
.mt-4 { margin-top: 20px; }
.mt-3 { margin-top: 16px; }

/* Bóveda de APIs */
.api-vault-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 18px;
}

.api-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
}

.api-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.api-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.api-title-row i {
  font-size: 22px;
}

.icon-meli { color: #FFE600; }
.icon-falabella { color: #10B981; }
.icon-exito { color: #EF4444; }
.icon-dian { color: #3B82F6; }

.api-status-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.api-status-badge.configured {
  background: rgba(245, 158, 11, 0.2);
  color: var(--amber-500);
}

.api-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.input-code {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: white;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

.input-code:focus {
  border-color: var(--emerald-500);
}

.w-100 { width: 100%; }
.text-xs { font-size: 11px; }

.badge-status-ready {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--emerald-500);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* DIAN Stats */
.dian-live-stats {
  display: flex;
  gap: 14px;
  margin-top: 14px;
}

.stat-pill {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill.success { background: rgba(16, 185, 129, 0.15); color: #34D399; }
.stat-pill.neutral { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.stat-pill.warning { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }

/* MÓDULO DE USUARIOS Y ROLES (Punto 10) */
.user-roles-banner {
  background: linear-gradient(145deg, rgba(20, 30, 48, 0.85), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.perm-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
}

.perm-pill.yes {
  background: rgba(16, 185, 129, 0.18);
  color: #34D399;
}

.perm-pill.no {
  background: rgba(239, 68, 68, 0.12);
  color: #F87171;
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #111827;
  border: 1px solid rgba(220, 38, 38, 0.4);
  border-radius: var(--radius-md);
  padding: 30px;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
}

.modal-icon.danger {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.2);
  color: #EF4444;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 16px auto;
}

.modal-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 32px;
  background: #1E293B;
  border: 1px solid var(--emerald-500);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 10000;
}

.toast.show {
  display: flex;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}


/* ================= FASE 1: INTELIGENCIA P&L, COSTOS, RENTABILIDAD & ANALYTICS ================= */
.phase1-kpi-grid-6 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}

.phase1-kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.phase1-kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.phase1-kpi-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.p1-kpi-card {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
}

.p1-kpi-card.positive {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.1), rgba(15, 23, 42, 0.78));
}

.p1-kpi-card.negative {
  border-color: rgba(244, 63, 94, 0.22);
}

.p1-kpi-card.clickable {
  cursor: pointer;
}

.p1-kpi-card.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--emerald-500);
}

.p1-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.p1-kpi-value {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.p1-kpi-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.p1-pnl-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
}

.pnl-eq-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13.5px;
}

.pnl-eq-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  margin-top: 12px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 16px;
  color: #34D399;
}

.pnl-derived-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.pnl-derived-pill {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pnl-derived-pill span {
  font-size: 11px;
  color: var(--text-muted);
}

.pnl-derived-pill strong {
  font-size: 20px;
  font-family: var(--font-mono);
  color: var(--amber-500);
}

.p1-bar-item {
  margin-bottom: 11px;
}

.p1-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

.p1-progress-track {
  width: 100%;
  height: 9px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  overflow: hidden;
}

.p1-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald-600), var(--emerald-500));
  border-radius: 99px;
  transition: width 0.35s ease;
}

.p1-subtabs {
  display: inline-flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.28);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.p1-subtab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.p1-subtab:hover {
  color: var(--text-main);
}

.p1-subtab.active {
  background: var(--emerald-600);
  color: #FFFFFF;
}

.p1-subview {
  display: none;
}

.p1-subview.active {
  display: block;
}

.p1-inline-input {
  width: 112px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
}

.p1-narrative-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.14), rgba(99, 102, 241, 0.12));
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.p1-top-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.p1-top-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
}

.pareto-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.pareto-badge.killer { background: rgba(16, 185, 129, 0.2); color: #34D399; border: 1px solid rgba(16, 185, 129, 0.4); }
.pareto-badge.potencial { background: rgba(245, 158, 11, 0.2); color: #FBBF24; border: 1px solid rgba(245, 158, 11, 0.4); }
.pareto-badge.cola { background: rgba(148, 163, 184, 0.2); color: #CBD5E1; border: 1px solid rgba(148, 163, 184, 0.3); }

/* ================= MOBILE RESPONSIVE & PWA (iPHONE / ANDROID) ================= */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-title-group {
  min-width: 0;
}

.btn-mobile-menu,
.btn-close-sidebar {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-mobile-menu:hover,
.btn-close-sidebar:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--emerald-500);
  color: #FFFFFF;
}

.mobile-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(4px);
  z-index: 1150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* Tablet y Celular (<= 992px): Sidebar se convierte en Drawer deslizable */
@media (max-width: 992px) {
  body {
    min-height: 100dvh;
    overflow-x: hidden;
  }

  .app-layout {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 300px);
    max-width: 300px;
    height: 100dvh;
    z-index: 1200;
    transform: translateX(-106%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 14px 0 42px rgba(0, 0, 0, 0.65);
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-sidebar-backdrop.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .btn-mobile-menu {
    display: inline-flex;
  }

  .btn-close-sidebar {
    display: inline-flex;
    margin-left: auto;
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .main-wrapper {
    width: 100%;
    min-width: 0;
    height: 100dvh;
  }

  .topbar {
    height: auto;
    min-height: 62px;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px 14px;
    gap: 10px;
  }

  .topbar-left {
    gap: 10px;
    flex: 1;
    min-width: 0;
  }

  .topbar-left h1 {
    font-size: 15.5px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-left p {
    display: none;
  }

  .topbar-right {
    gap: 8px;
    flex-shrink: 0;
  }

  .sync-status-indicator {
    padding: 7px 10px;
  }

  .sync-status-indicator .sync-text {
    display: none;
  }

  .btn-emergency {
    padding: 9px 12px;
    font-size: 11px;
    gap: 6px;
  }

  .content-viewport {
    padding: 14px 14px max(28px, env(safe-area-inset-bottom)) 14px;
    -webkit-overflow-scrolling: touch;
  }

  .glass-card {
    padding: 16px;
    margin-bottom: 16px;
    min-width: 0;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
  }

  .two-col-grid,
  .api-vault-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .phase1-kpi-grid-6,
  .phase1-kpi-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .phase1-kpi-grid-3,
  .phase1-kpi-grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card-header-flex {
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
  }

  .card-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-search {
    max-width: 100%;
    width: 100%;
  }

  .toolbar-actions {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .financial-summary-banner {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px;
  }

  .financial-summary-banner .fin-math {
    display: none;
  }

  .financial-summary-banner .fin-box {
    flex: 1 1 42%;
  }

  .dian-live-stats {
    flex-wrap: wrap;
    gap: 8px;
  }

  .p1-subtabs {
    display: flex;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .p1-subtabs::-webkit-scrollbar {
    display: none;
  }

  .p1-subtab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .table-custom {
    min-width: 620px;
  }

  .modal-overlay {
    padding: 12px;
    align-items: flex-start;
    overflow-y: auto;
  }

  .modal-card {
    width: 100%;
    max-width: 96vw !important;
    padding: 20px 16px;
    margin: auto 0;
    max-height: 92dvh;
    overflow-y: auto;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: max(16px, env(safe-area-inset-bottom));
    justify-content: center;
    text-align: center;
  }
}

/* Smartphones (<= 640px): Optimización táctil iPhone & Android */
@media (max-width: 640px) {
  .login-overlay {
    padding: 12px;
    overflow-y: auto;
    align-items: flex-start;
  }

  .login-card {
    padding: 22px 18px;
    margin: auto 0;
  }

  .login-header h2 {
    font-size: 20px;
  }

  .demo-acc-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .btn-emergency {
    padding: 9px 11px;
  }

  .btn-emergency #emergency-label {
    display: none;
  }

  .channels-ribbon {
    padding: 12px 14px;
    margin-bottom: 14px;
  }

  .channels-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi-card {
    padding: 16px;
  }

  .kpi-value,
  .p1-kpi-value {
    font-size: 20px;
  }

  .pnl-derived-row {
    grid-template-columns: 1fr;
  }

  .pnl-eq-row {
    font-size: 12.5px;
    gap: 8px;
  }

  .pnl-eq-total {
    font-size: 14px;
    padding: 12px;
  }

  .table-footer-pagination {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions > button {
    width: 100%;
    justify-content: center;
  }

  /* Apilar formularios y grids inline de 2/3 columnas en pantallas angostas */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Evitar auto-zoom automático de Safari iOS al tocar inputs (< 16px) */
  input,
  select,
  textarea,
  .input-modern,
  .input-code,
  .custom-select,
  .p1-inline-input,
  .toolbar-search input {
    font-size: 16px !important;
  }

  .btn-primary,
  .btn-secondary,
  .btn-login,
  .btn-danger {
    min-height: 42px;
  }
}
