:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  /* Paleta EYCOT: azul marino del logo + acento rojo del marco */
  --primary: #1e3a5f;
  --primary-700: #15294a;
  --primary-900: #0d1d36;
  --primary-100: #e6ebf2;
  --accent: #dc2626;
  --accent-700: #b91c1c;
  --accent-100: #fee2e2;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --gray: #6b7280;
  --gray-bg: #f3f4f6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 12px 32px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* AUTH GATE */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #15294a 50%, #0d1d36 100%);
  padding: 20px;
}

.auth-card {
  background: white;
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.auth-logo {
  display: block;
  width: 180px;
  height: auto;
  margin: 0 auto 12px;
}

.auth-card h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px;
}

.auth-sub {
  color: var(--text-muted);
  margin: 0 0 32px;
}

.auth-foot {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-soft);
}

/* APP LAYOUT */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}

.brand-logo {
  width: 100%;
  max-width: 180px;
  height: auto;
  display: block;
}

.brand-sub {
  font-size: 11px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 8px;
  color: rgba(255,255,255,0.7);
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 12px;
}

/* SIDEBAR CLIENTE ACTIVO */
.sidebar-cliente { padding: 0 12px 12px; }

.sb-import-btn {
  width: 100%;
  background: rgba(220, 38, 38, 0.18);
  border: 1px solid rgba(220, 38, 38, 0.4);
  color: white;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
}
.sb-import-btn:hover { background: rgba(220, 38, 38, 0.28); }

.sb-cliente {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
}
.sb-cliente-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: rgba(255,255,255,0.55);
  margin-bottom: 4px;
  font-weight: 600;
}
.sb-cliente-name {
  font-size: 12px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.sb-cliente-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  font-family: monospace;
  margin-bottom: 8px;
}
.sb-cliente-actions {
  display: flex;
  gap: 4px;
}
.sb-cliente-actions button {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: none;
  color: white;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
}
.sb-cliente-actions button:hover { background: rgba(255,255,255,0.15); }

.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.5);
  padding: 16px 12px 8px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-link.active {
  background: rgba(255,255,255,0.15);
  color: white;
  font-weight: 600;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  display: inline-block;
  text-align: center;
}

.sidebar-foot {
  padding: 16px 12px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 16px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
}

.vendedor-card {
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 12px;
}

.vendedor-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: rgba(255,255,255,0.55);
  margin-bottom: 8px;
  font-weight: 600;
}

.vendedor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.btn-vendedor-edit {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
}
.btn-vendedor-edit:hover { background: rgba(255,255,255,0.2); }

.user-folio-prefix {
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  font-family: monospace;
  margin-top: 2px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  padding: 2px 0;
  cursor: pointer;
  text-align: left;
}

.user-logout:hover { color: white; text-decoration: underline; }

/* MAIN CONTENT */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.badge {
  background: var(--primary-100);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.view {
  flex: 1;
  padding: 32px;
  max-width: 1400px;
  width: 100%;
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .view { padding: 16px; }
  .topbar { padding: 12px 16px; }
}
