/* SIAPP Portal — estilos base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.5;
}
:root {
  --brand: #7c3aed;
  --brand-dark: #5b21b6;
  --brand-light: #ede9fe;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c4b5fd;
  --sidebar-active: #7c3aed;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --border: #e2e8f0;
  --text-muted: #64748b;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }

/* ───── Login ───── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #5b21b6 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%; max-width: 420px;
  padding: 40px 32px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 28px; font-weight: 700;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.login-logo p { color: var(--text-muted); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 6px; color: #475569; }
.field input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  outline: none; transition: all 0.15s;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,58,237,0.1); }
.btn-primary {
  background: var(--brand); color: white;
  padding: 12px; border-radius: 8px;
  font-weight: 600; font-size: 14px;
  transition: all 0.15s;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.error-msg {
  background: #fef2f2; color: var(--danger);
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; border: 1px solid #fecaca;
}

/* ───── Layout ───── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0;
  width: 240px; height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
}
.sidebar-header { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-header h1 { color: white; font-size: 18px; font-weight: 700; letter-spacing: -0.5px; }
.sidebar-header p { color: var(--sidebar-text); font-size: 11px; margin-top: 2px; }
.empresa-switcher {
  margin: 12px; padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: white; font-size: 12px;
  cursor: pointer; outline: none;
  width: calc(100% - 24px);
}
.empresa-switcher option { background: var(--sidebar-bg); color: white; }
.nav-section { padding: 8px 0; }
.nav-section-title {
  padding: 12px 18px 6px; font-size: 11px;
  color: rgba(255,255,255,0.4); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 18px; color: var(--sidebar-text);
  font-size: 13.5px; cursor: pointer;
  transition: all 0.12s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active {
  background: rgba(124,58,237,0.15);
  color: white; border-left-color: var(--brand);
}
.nav-icon { font-size: 16px; opacity: 0.85; width: 18px; text-align: center; }
.sidebar-footer {
  margin-top: auto; padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong { color: white; font-size: 13px; display: block; }
.user-info small { color: var(--sidebar-text); font-size: 11px; display: block; }
.btn-logout {
  color: var(--sidebar-text); font-size: 14px;
  padding: 6px 8px; border-radius: 6px;
  transition: all 0.12s;
}
.btn-logout:hover { background: rgba(255,255,255,0.08); color: white; }

.main-content {
  margin-left: 240px;
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  background: white;
  height: 56px;
  display: flex; align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.topbar h2 { font-size: 16px; font-weight: 600; }
.breadcrumb { color: var(--text-muted); font-size: 13px; margin-left: auto; }
.page { padding: 24px; flex: 1; }
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-header .actions { margin-left: auto; display: flex; gap: 8px; }

/* ───── Cards & KPIs ───── */
.kpi-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 24px;
}
.kpi {
  background: white; border-radius: 12px;
  padding: 18px 20px; border: 1px solid var(--border);
  transition: all 0.15s;
}
.kpi:hover { border-color: var(--brand); box-shadow: 0 6px 20px rgba(0,0,0,0.04); }
.kpi-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-icon { float: right; font-size: 22px; opacity: 0.5; }

.card {
  background: white; border-radius: 12px;
  border: 1px solid var(--border); padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; background: #f8fafc; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
td { padding: 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #f8fafc; }
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 12px; font-size: 11px;
  font-weight: 600; text-transform: uppercase;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-default { background: #f1f5f9; color: #475569; }

.btn { padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; transition: all 0.15s; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-secondary { background: #f1f5f9; color: var(--text-muted); }
.btn-secondary:hover { background: #e2e8f0; color: #0f172a; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

/* ───── Kanban CRM ───── */
.kanban {
  display: flex; gap: 12px;
  overflow-x: auto; padding-bottom: 16px;
}
.kanban-col {
  background: #f8fafc; border-radius: 10px;
  min-width: 260px; padding: 14px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.kanban-col-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid;
}
.kanban-col-title { font-size: 13px; font-weight: 600; }
.kanban-col-count {
  background: white; padding: 2px 8px;
  border-radius: 10px; font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}
.kanban-card {
  background: white; padding: 12px;
  border-radius: 8px; margin-bottom: 8px;
  border: 1px solid var(--border);
  cursor: pointer; transition: all 0.12s;
}
.kanban-card:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,0.05); transform: translateY(-1px); }
.kanban-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.kanban-card-meta { font-size: 11px; color: var(--text-muted); }
.kanban-card-monto { font-weight: 600; color: var(--success); margin-top: 6px; font-size: 13px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: #0f172a; }
.empty-state p { font-size: 13px; }

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}
