/* CRM Estudios — Design system */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-primary-soft: #eff6ff;
  --color-primary-muted: #dbeafe;
  --color-accent: #0d9488;
  --color-link: #1e40af;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-main);
  background: linear-gradient(145deg, var(--color-primary-soft) 0%, #f0f4f8 35%, #e8edf4 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}

/* ——— Layout ——— */
.min-h-screen { min-height: 100vh; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overflow-x-auto { overflow-x: auto; }
.hidden { display: none; }
.w-full { width: 100%; }
.max-w-sm { max-width: 24rem; }
.max-w-lg { max-width: 32rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-6xl { max-width: 72rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-12 { margin-top: 3rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.pt-2 { padding-top: 0.5rem; }
.inline-block { display: inline-block; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-2xl { font-size: 1.625rem; line-height: 2rem; letter-spacing: -0.02em; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; letter-spacing: -0.02em; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; letter-spacing: -0.01em; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-primary { color: var(--color-link); }

.link-action {
  color: var(--color-link);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary-muted);
  transition: background 0.15s, color 0.15s;
}

.link-action:hover {
  background: var(--color-primary-muted);
  color: var(--color-primary-dark);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.15rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff !important;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--color-primary) 50%, transparent);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}
.text-slate-400 { color: #94a3b8; }
.text-slate-500 { color: var(--text-muted); }
.text-slate-600 { color: #475569; }
.text-slate-900 { color: var(--text-main); }
.text-red-600 { color: #dc2626; }
.text-yellow-600 { color: #ca8a04; }
.text-white { color: #fff; }
.bg-slate-50 { background-color: #f8fafc; }
.bg-white { background-color: #fff; }
.border-b { border-bottom-width: 1px; }
.border-t { border-top-width: 1px; }
.border-l-4 { border-left-width: 4px; }
.border-slate-100 { border-color: #f1f5f9; }
.border-slate-200 { border-color: var(--border); }
.border-red-500 { border-color: #ef4444; }
.border-yellow-400 { border-color: #facc15; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.z-40 { z-index: 40; }
.h-8 { height: 2rem; }
.w-8 { width: 2rem; }
.h-10 { height: 2.5rem; }
.w-10 { width: 2.5rem; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius); }
.object-cover { object-fit: cover; }
.cursor-pointer { cursor: pointer; }
.last\:border-0:last-child { border-bottom: none; }

/* ——— Header ——— */
.app-header {
  background: linear-gradient(120deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-header-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 1 auto;
  min-width: 0;
  max-width: clamp(5.5rem, 18vw, 9.5rem);
}

.app-header-nav-wrap {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.app-header-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.45) transparent;
  -webkit-overflow-scrolling: touch;
  padding: 0.1rem 0;
}

.app-header-nav::-webkit-scrollbar {
  height: 4px;
}

.app-header-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 999px;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.app-header-estudio-form {
  min-width: 0;
  max-width: 7.5rem;
}

.app-header .brand-link {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header .brand-link:hover { opacity: 0.92; }

.app-header .logo-ring {
  ring: 2px solid rgba(255,255,255,0.35);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-sm);
}

.app-header .nav-link {
  flex-shrink: 0;
  padding: 0.45rem 0.75rem;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.app-header .nav-link:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.app-header .nav-link-active {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.app-header .user-chip {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.95);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.app-header .btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.app-header .btn-ghost:hover { background: rgba(255, 255, 255, 0.22); }

.app-header select.input-field {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.35rem 0.6rem;
  width: 100%;
  max-width: 7.5rem;
}

.app-header select.input-field option { color: #0f172a; background: #fff; }

/* ——— Main & footer ——— */
.app-main { flex: 1; padding: 1.5rem 1rem 2rem; }

.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.45);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(8px);
}

/* ——— Page header ——— */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin: 0;
}

.page-header p {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.page-header-accent {
  width: 2.5rem;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-muted));
  border-radius: 2px;
  margin-bottom: 0.5rem;
}

/* ——— Cards ——— */
.card {
  background: var(--surface);
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-accent {
  border-left: 4px solid var(--color-primary);
}

.card-list-item {
  background: var(--surface);
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--color-primary-muted);
  transition: transform 0.15s, box-shadow 0.15s;
}

.card-list-item:hover {
  box-shadow: var(--shadow-md);
  border-left-color: var(--color-primary);
}

/* ——— Monitoreo operadores ——— */
.monitor-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.monitor-card {
  background: var(--surface);
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.monitor-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.monitor-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-main);
}

.monitor-card-count {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary-muted);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  line-height: 1.4;
}

.monitor-client-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
}

.monitor-client-list li {
  font-size: 0.8125rem;
  line-height: 1.45;
  padding: 0.4rem 0;
  border-top: 1px solid #f1f5f9;
}

.monitor-client-list li:first-child {
  border-top: none;
  padding-top: 0;
}

.monitor-client-name {
  font-weight: 500;
  color: var(--color-link);
  text-decoration: none;
}

.monitor-client-name:hover {
  text-decoration: underline;
}

.monitor-client-meta {
  color: var(--text-muted);
}

.monitor-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0;
}

.presupuesto-resumen-dl dt { color: var(--text-muted); }
.presupuesto-resumen-dl dd { font-weight: 500; }

/* ——— Buttons ——— */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.9rem;
  background: var(--surface);
  color: #334155;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary-muted);
  color: var(--color-primary-dark);
}

.inline-form { display: inline; margin: 0; }
.inline-form button { cursor: pointer; border: none; font-family: inherit; }

/* ——— Forms ——— */
.input-field {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-field:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #334155;
}

.form-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-primary-muted);
  margin-bottom: 0.75rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ——— Nav (login / inner) ——— */
.nav-link {
  padding: 0.375rem 0.5rem;
  color: #475569;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 0.25rem;
}

.nav-link:hover { background: #f1f5f9; color: var(--color-primary); }

/* ——— Tables ——— */
.table-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.07);
  box-shadow: var(--shadow-sm);
}

.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; background: #fff; }

.table th, .table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

.table th {
  font-weight: 600;
  color: #334155;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, #e2e8f0 0%, #f1f5f9 100%);
  border-bottom: 1px solid #cbd5e1;
}

.table tbody tr:hover td { background: var(--color-primary-soft); }

.table tbody tr:last-child td { border-bottom: none; }

/* ——— Badges & alerts ——— */
.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--color-primary) 55%, transparent);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: color-mix(in srgb, var(--color-accent) 18%, #fff);
  color: #0f766e;
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, #fff);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 0.25rem;
}

.badge-estado-activo {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.badge-estado-inactivo {
  background: #f1f5f9;
  color: #64748b;
  border-color: #e2e8f0;
}

.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-success, .alert-info {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.alert-error, .alert-danger {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.alert-warning {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.accent-primary { accent-color: var(--color-primary); }

/* ——— Login ——— */
.body-guest {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 50%, #3b82f6 100%);
  background-attachment: fixed;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
}

.login-messages-wrap {
  width: 100%;
  max-width: 24rem;
  margin: 0 auto 0.75rem;
  position: relative;
  z-index: 2;
}

.login-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.12) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 40%);
  pointer-events: none;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 45%, #3b82f6 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.12) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 40%);
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 24rem;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  border-radius: 1rem;
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.login-brand p { margin: 0; font-size: 0.875rem; color: var(--text-muted); }

.login-dot {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--color-primary) 50%, transparent);
}

/* ——— Stat cards (reportes) ——— */
.stat-card {
  text-align: center;
  background: linear-gradient(180deg, #fff 0%, var(--color-primary-soft) 100%);
  border: 1px solid var(--color-primary-muted);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* ——— Responsive ——— */
@media (min-width: 640px) {
  .sm\:block { display: block; }
  .sm\:flex-row { flex-direction: row; }
  .sm\:items-center { align-items: center; }
  .sm\:items-start { align-items: flex-start; }
  .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-main { padding: 2rem 1.5rem; }
}

@media (max-width: 640px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .app-header-brand { max-width: clamp(4.5rem, 28vw, 7rem); }
  .app-header .brand-link { font-size: 0.9rem; }
  .app-header .nav-link { padding: 0.4rem 0.55rem; font-size: 0.75rem; }
  .app-header-estudio-form { max-width: 5.5rem; }
  .app-header select.input-field { max-width: 5.5rem; }
}

@media (min-width: 1024px) {
  .app-header-brand { max-width: 11rem; }
  .app-header-inner { gap: 0.75rem; }
}

@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:inline { display: inline; }
}
