:root {
  --primary: #0071e3;
  --primary-strong: #0057b8;
  --primary-soft: rgba(0, 113, 227, 0.1);
  --bg: #f5f5f7;
  --sidebar-bg: #111827;
  --card-bg: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6b7280;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 10px 34px rgba(15, 23, 42, 0.06);
  --radius: 18px;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #dc2626;
  --violet: #8b5cf6;
  --pink: #ec4899;
  --slate: #64748b;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(220, 38, 38, 0.11), transparent 26%),
    radial-gradient(circle at 80% 70%, rgba(0, 113, 227, 0.1), transparent 28%),
    #f5f5f7;
}

.login-card {
  width: min(430px, 100%);
  padding: 34px 30px 30px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.login-brand-stacked {
  justify-content: center;
  padding-bottom: 24px;
}

.login-brand img {
  width: 112px;
  height: 112px;
  object-fit: contain;
}

.login-wordmark {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.login-wordmark strong {
  color: #111827;
  font-size: 17px;
  font-weight: 950;
  letter-spacing: 0.08em;
  line-height: 1;
}

.login-wordmark small {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  text-align: right;
  text-transform: uppercase;
}

.login-copy {
  margin: 26px 0 22px;
  text-align: center;
}

.login-copy h1 {
  margin: 0;
  font-size: 29px;
  letter-spacing: 0;
}

.login-copy p {
  margin: 7px 0 0;
  color: var(--text-secondary);
}

.login-fields {
  display: grid;
  gap: 14px;
}

.login-fields label {
  display: grid;
  gap: 7px;
  color: #475569;
  font-size: 12px;
  font-weight: 850;
}

.login-fields input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.login-fields input:focus {
  border-color: rgba(0, 113, 227, 0.45);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.login-error {
  min-height: 18px;
  margin: 12px 0 0;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 750;
}

.login-submit {
  width: 100%;
  margin-top: 12px;
}

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

.app-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: white;
  padding: 28px 20px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: white;
  text-decoration: none;
  padding: 12px 10px 26px;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  overflow: hidden;
  border-radius: 17px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.brand-mark img {
  width: 88%;
  height: 88%;
  object-fit: contain;
}

.brand-text strong,
.brand-text small {
  display: block;
}

.brand-text strong {
  font-size: 15px;
  letter-spacing: 0.2px;
}

.brand-text small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 12px;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 13px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: rgba(255, 255, 255, 0.68);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: 0.18s ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item .nav-label {
  font-size: 14px;
  font-weight: 600;
}

.sidebar-footer {
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.producer-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.producer-brand span {
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.producer-brand img {
  width: 72px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.22));
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: white;
  color: #111827;
  font-size: 12px;
  font-weight: 800;
}

.user-details span,
.user-details small {
  display: block;
}

.user-details span {
  font-size: 13px;
  font-weight: 700;
}

.user-details small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.54);
  font-size: 11px;
}

.logout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.12);
  color: #fecaca;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.logout-button svg {
  width: 16px;
  height: 16px;
}

.main-content {
  min-width: 0;
  padding: 28px clamp(20px, 4vw, 48px) 48px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}

.page-title h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: 0;
}

.page-title p {
  margin: 7px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  width: min(430px, 32vw);
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: white;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

.search-box svg {
  width: 18px;
  color: #94a3b8;
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
}

.mobile-menu-btn {
  display: none;
}

.view-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card,
.apple-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 14px;
}

.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.card-description {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.card-body {
  padding: 18px 24px 24px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.summary-card {
  overflow: hidden;
}

.summary-header {
  background: linear-gradient(135deg, rgba(0, 113, 227, 0.12), rgba(17, 24, 39, 0.04));
  border-bottom: 1px solid var(--border);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 14px;
}

.kpi-card {
  display: flex;
  min-height: 128px;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: white;
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.kpi-label {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.kpi-value {
  margin: 14px 0 0;
  font-size: 26px;
  font-weight: 850;
  letter-spacing: 0;
}

.kpi-icon,
.module-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}

.kpi-icon svg,
.module-icon svg {
  width: 19px;
  height: 19px;
}

.tone-green { color: var(--green); background: rgba(22, 163, 74, 0.11); }
.tone-amber { color: var(--amber); background: rgba(245, 158, 11, 0.12); }
.tone-red { color: var(--red); background: rgba(220, 38, 38, 0.11); }
.tone-violet { color: var(--violet); background: rgba(139, 92, 246, 0.12); }
.tone-pink { color: var(--pink); background: rgba(236, 72, 153, 0.12); }
.tone-slate { color: var(--slate); background: rgba(100, 116, 139, 0.12); }
.tone-blue, .tone-sky, .tone-indigo, .tone-emerald { background: var(--primary-soft); color: var(--primary); }

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  transition: 0.18s ease;
}

.btn {
  min-height: 42px;
  padding: 0 15px;
  font-size: 14px;
}

.btn svg {
  width: 17px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-dark {
  background: #111827;
  color: white;
}

.btn-ghost {
  background: #f1f5f9;
  color: #334155;
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.icon-btn {
  width: 38px;
  height: 38px;
  background: #f8fafc;
  color: #475569;
}

.icon-btn:hover,
.btn-ghost:hover,
.btn-soft:hover {
  filter: brightness(0.97);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 20px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters input,
.filters select,
.input-field input,
.input-field select,
.input-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.filters input,
.filters select {
  min-width: 170px;
  height: 40px;
  padding: 0 12px;
}

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 18px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  text-align: left;
  vertical-align: top;
}

th {
  color: #64748b;
  background: #fbfcfe;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.muted {
  color: var(--text-secondary);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.Confirmado,
.badge.Aprobado,
.badge.Realizado,
.badge.Completada,
.badge.Recurrente,
.badge.Firmado,
.badge.Ingreso,
.badge.Activo,
.badge.Administrador {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.badge.Tentativo,
.badge.Reservado,
.badge.Enviado,
.badge.Contactado,
.badge.Pendiente,
.badge.Planificada,
.badge.Borrador,
.badge.Invitado,
.badge.Comercial,
.badge.Operador {
  background: rgba(245, 158, 11, 0.13);
  color: #b45309;
}

.badge.Cancelado,
.badge.Perdido,
.badge.Rechazado,
.badge.Vencido,
.badge.Egreso,
.badge.Urgente,
.badge.Inactivo,
.badge.Solo-lectura {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.config-kpis {
  grid-template-columns: repeat(3, minmax(145px, 1fr));
}

.icon-config {
  color: #94a3b8;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: #e9eef5;
}

.section-tabs button {
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 9px 12px;
  color: #475569;
  cursor: pointer;
  font-weight: 750;
}

.section-tabs button.active {
  background: white;
  color: #111827;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(88px, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.calendar-day {
  min-height: 115px;
  padding: 9px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: white;
}

.calendar-day strong {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: #64748b;
}

.calendar-event {
  display: block;
  margin-top: 6px;
  padding: 6px 7px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.map-shell {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
}

.arg-map {
  position: relative;
  min-height: 410px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(0, 113, 227, 0.16), transparent 25%),
    linear-gradient(180deg, #eff6ff, #ffffff);
}

.province-pin {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid rgba(0, 113, 227, 0.18);
  border-radius: 999px;
  background: white;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.09);
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
}

.province-pin::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.funnel {
  display: grid;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 12px;
}

.funnel-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.funnel-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.stat-line:last-child {
  border-bottom: 0;
}

.dialog {
  width: min(920px, calc(100vw - 28px));
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: transparent;
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(5px);
}

.dialog-card {
  overflow: hidden;
  border-radius: 22px;
  background: white;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.24);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfe;
}

.dialog-header h2 {
  margin: 0;
  font-size: 21px;
}

.dialog-header p {
  margin: 6px 0 0;
  color: var(--text-secondary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-height: min(64vh, 650px);
  overflow-y: auto;
  padding: 24px;
}

.input-field.full,
.input-field:has(textarea) {
  grid-column: 1 / -1;
}

.input-field label {
  display: block;
  margin-bottom: 7px;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.input-field input,
.input-field select,
.input-field textarea {
  padding: 11px 12px;
}

.input-field textarea {
  min-height: 90px;
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--border);
}

.empty-state {
  padding: 46px 24px;
  text-align: center;
  color: var(--text-secondary);
}

@media (max-width: 1220px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(145px, 1fr));
  }

  .hero-panel,
  .layout-grid,
  .map-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    width: 280px;
    transition: 0.2s ease;
  }

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

  .mobile-menu-btn {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: white;
    box-shadow: var(--shadow);
  }

  .top-bar {
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-box {
    width: 100%;
  }

  .kpi-grid,
  .quick-actions,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
