:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --nav: #0f2b45;
  --nav2: #091a2b;
  --teal: #0f766e;
  --teal2: #0d9488;
  --orange: #f59e0b;
  --red: #ef4444;
  --green: #10b981;
  --blue: #0284c7;
  --purple: #7928ca;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 14px 28px -4px rgba(15, 23, 42, 0.08), 0 8px 12px -4px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

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

.hidden {
  display: none !important;
}

/* ==============================================================================
   APP SHELL LAYOUT (DESKTOP & RESPONSIVE)
   ============================================================================== */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

aside {
  background: linear-gradient(180deg, var(--nav) 0%, var(--nav2) 100%);
  color: #d7e2eb;
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.aside-brand {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
  flex-shrink: 0;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: 14px;
}

.aside-brand b {
  display: block;
  line-height: 1.2;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
}

.aside-brand span {
  font-size: 10.5px;
  color: #8bb7c8;
  font-weight: 500;
}

nav {
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
}

nav::-webkit-scrollbar {
  width: 5px;
}

nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

nav .section-label {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: #648ca4;
  margin: 14px 12px 6px;
  font-weight: 800;
  text-transform: uppercase;
}

nav a.nav-link {
  width: 100% !important;
  color: #a3c1d6 !important;
  padding: 10px 14px !important;
  border-radius: 9px !important;
  margin: 2px 0 !important;
  font-size: 13px !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  text-decoration: none !important;
  transition: all 0.16s ease !important;
}

nav a.nav-link .nav-icon {
  width: 20px !important;
  text-align: center !important;
  font-size: 15px !important;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

nav a.nav-link .nav-text {
  flex: 1 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-weight: 500 !important;
  font-size: 13px !important;
}

nav a.nav-link:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
  transform: translateX(2px);
}

nav a.nav-link.active {
  background: linear-gradient(90deg, rgba(13, 148, 136, 0.3) 0%, rgba(13, 148, 136, 0.1) 100%) !important;
  color: #ffffff !important;
  border-left: 3px solid #2dd4bf !important;
  font-weight: 700 !important;
}

.aside-user {
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d9488, #0f766e);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.aside-user div:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.aside-user b,
.aside-user span {
  display: block;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aside-user b {
  color: #ffffff;
}

.aside-user span {
  color: #8bb7c8;
}

.workspace {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ==============================================================================
   TOPBAR & HEADER
   ============================================================================== */
.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.breadcrumb b {
  color: var(--ink);
  font-weight: 700;
}

.datebox {
  text-align: right;
}

.datebox span {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
}

.datebox b {
  display: block;
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 700;
}

.mobile-menu {
  display: none;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

#content {
  padding: 28px 32px 60px;
  max-width: 1560px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.page-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

/* ==============================================================================
   MINIMALIST KPI & STATS CARDS
   ============================================================================== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #cbd5e1;
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent, var(--teal));
}

.stat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.stat-icon {
  background: color-mix(in srgb, var(--accent, var(--teal)) 12%, white);
  color: var(--accent, var(--teal));
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 17px;
  flex-shrink: 0;
}

.stat strong {
  display: block;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  margin: 10px 0 4px;
  letter-spacing: -0.02em;
}

.stat small {
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat small.up {
  color: #16a34a !important;
}

.stat small.down {
  color: #dc2626 !important;
}

/* ==============================================================================
   CARDS & GRIDS
   ============================================================================== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 12px;
}

.card h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}

/* Hero del Perfil de Socio */
.profile-hero {
  background: linear-gradient(135deg, #0f2b45 0%, #0f766e 100%);
  color: #ffffff;
  border-radius: 16px;
  padding: 24px 28px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 25px rgba(15, 118, 110, 0.15);
}

.profile-hero small {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #5eead4;
}

.profile-hero h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 4px 0;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.profile-hero p {
  margin: 0;
  color: #a5f3fc;
  font-size: 13px;
}

/* ==============================================================================
   TABLES & BADGES (MODERN & MINIMALIST)
   ============================================================================== */
.table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
}

.table thead th {
  background-color: #f8fafc !important;
  color: #64748b !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  border-bottom: 1.5px solid var(--line) !important;
  padding: 12px 14px !important;
}

.table tbody td {
  padding: 14px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  font-size: 13px !important;
  color: #334155 !important;
  vertical-align: middle !important;
}

.table tbody tr:hover td {
  background-color: #f8fafc !important;
}

.badge {
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.bg-primary-subtle { background: #e0f2fe !important; color: #0284c7 !important; }
.bg-success-subtle { background: #dcfce7 !important; color: #16a34a !important; }
.bg-warning-subtle { background: #fef3c7 !important; color: #d97706 !important; }
.bg-danger-subtle { background: #ffe4e6 !important; color: #e11d48 !important; }
.bg-purple { background: #7928ca !important; color: #ffffff !important; }

/* Botones */
.btn-custom, .btn.primary, .btn-primary {
  border: none;
  background: linear-gradient(135deg, #0f766e, #0d9488);
  color: #ffffff;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 4px 10px rgba(15, 118, 110, 0.2);
  transition: all 0.18s ease;
}

.btn-custom:hover, .btn.primary:hover, .btn-primary:hover {
  background: linear-gradient(135deg, #0d6d66, #0b8277);
  box-shadow: 0 6px 14px rgba(15, 118, 110, 0.3);
  transform: translateY(-1px);
  color: #ffffff;
}

/* Formularios */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field label, .form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.field input, .field select, .form-control, .form-select {
  width: 100%;
  height: 42px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  padding: 0 13px;
  font-size: 13.5px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus, .field select:focus, .form-control:focus, .form-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

/* Gráfico de Barras */
.chart-wrapper {
  height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 25px 10px 10px;
  border-bottom: 2px solid var(--line);
  position: relative;
}

.chart-col:hover .bar-fill {
  transform: scaleY(1.03);
  filter: brightness(1.1);
}

.chart-col:hover .bar-tooltip {
  color: #0d9488 !important;
  transform: scale(1.08);
}

/* Credencial QR */
.qr-layout {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  gap: 24px;
}

.member-card {
  background: linear-gradient(145deg, #0d2b45, #0f766e);
  color: #ffffff;
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.member-card-head {
  display: flex;
  text-align: left;
  gap: 12px;
  align-items: center;
}

.member-card-head b {
  display: block;
  font-size: 13px;
  color: #ffffff;
}

.member-card-head span {
  display: block;
  font-size: 10px;
  color: #99f6e4;
  letter-spacing: 0.04em;
}

.qr-image {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px;
  width: 240px;
  height: 240px;
  margin: 20px auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.qr-image img {
  width: 100%;
  height: 100%;
}

.member-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin: 12px 0 4px;
  color: #ffffff;
}

/* ==============================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ============================================================================== */
@media(max-width: 1200px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media(max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  aside {
    transform: translateX(-100%);
  }
  aside.open {
    transform: none;
  }
  .workspace {
    grid-column: 1;
  }
  .topbar {
    padding: 0 16px;
  }
  .mobile-menu {
    display: inline-block;
  }
  #content {
    padding: 20px 16px 60px;
  }
  .grid-2, .qr-layout {
    grid-template-columns: 1fr;
  }
}

@media(max-width: 560px) {
  .stats {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .page-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}
