/* ══════════════════════════════════════════
   Cuaderna Design System
   Brand: Terracota + Warm tones
   Typography: IBM Plex Serif (headlines) + Inter (body)
   ══════════════════════════════════════════ */

:root {
  /* Brand palette */
  --terracota: #C0805D;
  --terracota-dark: #A06840;
  --terracota-light: #E8D0C0;
  --terracota-subtle: #F5E8DD;
  --rosa: #B87A8E;
  --aguamarina: #6BA5A3;
  --mostaza: #C6AA62;
  --azul-mineral: #4A7A8D;
  --ciruela: #9B6D7B;
  --verde-oliva: #6B8C73;

  /* Neutrals */
  --text: #2D2D3A;
  --text-light: #5C5C6E;
  --text-muted: #9B9BA8;
  --bg: #FDF8F4;
  --bg-warm: #F5EDE6;
  --bg-card: #FFFFFF;
  --white: #FFFFFF;
  --border: #E0D5CC;
  --border-light: #EDE6DE;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(45,45,58,0.04);
  --shadow-sm: 0 1px 4px rgba(45,45,58,0.06), 0 1px 2px rgba(45,45,58,0.04);
  --shadow: 0 4px 12px rgba(45,45,58,0.08), 0 1px 3px rgba(45,45,58,0.04);
  --shadow-lg: 0 8px 24px rgba(45,45,58,0.1), 0 2px 6px rgba(45,45,58,0.04);
  --shadow-xl: 0 16px 40px rgba(45,45,58,0.12);

  /* Shape */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Layout */
  --sidebar-width: 270px;
  --header-height: 60px;
  --content-max: 820px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
  font-family: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

a { color: var(--terracota); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--terracota-dark); }

img { max-width: 100%; height: auto; display: block; }

/* ── Buttons (CTA = Inter Bold 700) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--terracota);
  color: var(--white);
  box-shadow: 0 1px 3px rgba(192,128,93,0.3);
}
.btn-primary:hover { background: var(--terracota-dark); box-shadow: 0 2px 6px rgba(192,128,93,0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-warm); border-color: var(--terracota-light); }

.btn-danger {
  background: #E8564F;
  color: var(--white);
}
.btn-danger:hover { background: #D04440; }

.btn-small { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }

/* Back button = Inter Regular 400 (texto apoyo) */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 8px;
  transition: color var(--transition);
}
.btn-back:hover { color: var(--terracota); }

/* ── Forms (labels = Inter Medium 500) ── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 6px;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: all var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--terracota);
  box-shadow: 0 0 0 3px rgba(192,128,93,0.12);
}

textarea { resize: vertical; min-height: 100px; }

.form-error {
  background: #FEF2F2;
  color: #B91C1C;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid #FECACA;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}
.form-hint strong {
  color: var(--text-light);
  font-weight: 500;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ══════════════════════════════════════════
   LOGIN PAGE — Split layout
   ══════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: var(--bg);
}

.login-split {
  display: flex;
  min-height: 100vh;
}

.login-brand-panel {
  flex: 1;
  background: var(--bg-warm);
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 60px;
  position: relative;
}

.login-brand-inner {
  max-width: 440px;
}

/* Logo image */
.login-logo {
  display: block;
  margin-bottom: 32px;
}

.logo-img {
  display: block;
  width: auto;
  object-fit: contain;
}

.logo-img-login {
  height: 90px;
}

.logo-img-sidebar {
  height: 36px;
}

.login-headline {
  font-family: 'IBM Plex Serif', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 16px;
}

.login-subheadline {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-light);
  line-height: 1.7;
}

.login-brand-footer {
  position: absolute;
  bottom: 32px;
  left: 60px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}

.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg);
}

.login-form-inner {
  width: 100%;
  max-width: 380px;
}

.login-form-title {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

/* Subtitulo login = Inter Regular 400 (texto apoyo) */
.login-form-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-light);
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-form {
  background: var(--white);
  padding: 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

/* ══════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════ */
.app-page {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--terracota-light), var(--terracota-subtle));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--terracota-dark);
  flex-shrink: 0;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-xs);
}

.user-info { display: flex; flex-direction: column; }
/* User name = Inter Medium 500 (subtitulo) */
.user-name { font-weight: 500; font-size: 13px; color: var(--text); }
/* User points = Inter Regular 400 (texto apoyo) */
.user-points {
  font-size: 11px;
  color: var(--terracota);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

/* Nav section labels = Inter Medium 500 uppercase */
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 16px 20px 6px;
  font-weight: 500;
}

/* Nav items = Inter Regular 400 (texto de apoyo) */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 400;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--bg); color: var(--terracota); border-left-color: var(--terracota-light); }
/* Nav item activo = Inter Medium 500 */
.nav-item.active { background: var(--terracota-subtle); color: var(--terracota-dark); font-weight: 500; border-left-color: var(--terracota); }

.nav-item svg { flex-shrink: 0; }

.nav-item .nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
}

/* Logout = Inter Regular 400 (texto apoyo) */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  padding: 8px 0;
  width: 100%;
  transition: color var(--transition);
}
.btn-logout:hover { color: #E8564F; }

/* ── Mobile header ── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 90;
  box-shadow: var(--shadow-xs);
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.mobile-menu-btn:hover { background: var(--bg-warm); }

.mobile-title {
  font-family: 'IBM Plex Serif', serif;
  font-weight: 700;
  font-size: 1.15rem;
}

.mobile-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--terracota-light), var(--terracota-subtle));
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(45,45,58,0.4);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

.section { display: none; }
.section.active { display: block; }

.section-header { margin-bottom: 28px; }
/* Subtitulos = Inter Medium 500 */
.section-subtitle { color: var(--text-light); font-size: 15px; font-weight: 500; margin-top: 6px; line-height: 1.5; }

/* ══════════════════════════════════════════
   SEARCH BAR
   ══════════════════════════════════════════ */
.search-bar {
  position: relative;
  margin-bottom: 28px;
  max-width: 600px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 12px 18px;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}

.search-input-wrap:focus-within {
  border-color: var(--terracota);
  box-shadow: 0 0 0 4px rgba(192,128,93,0.1), var(--shadow-sm);
}

.search-input-wrap svg { color: var(--terracota-light); flex-shrink: 0; }
.search-input-wrap:focus-within svg { color: var(--terracota); }

.search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  font-family: 'Inter', sans-serif;
  color: var(--text);
}

.search-input-wrap input::placeholder { color: var(--text-muted); }

.search-clear {
  background: var(--bg-warm);
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.search-clear:hover { background: var(--border); color: var(--text); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 420px;
  overflow-y: auto;
  z-index: 50;
}

.search-group { padding: 6px 0; }
.search-group + .search-group { border-top: 1px solid var(--border-light); }

.search-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 8px 16px 4px;
  font-weight: 700;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
}
.search-item:hover { background: var(--bg); }

.search-item .nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Search result title = Inter Medium 500 (subtitulo) */
.search-item-title { font-size: 13px; font-weight: 500; color: var(--text); display: block; }
.search-item-meta { font-size: 11px; color: var(--text-muted); display: block; margin-top: 1px; }
.search-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ══════════════════════════════════════════
   MODULE GRID (HOME)
   ══════════════════════════════════════════ */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.module-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  position: relative;
}
.module-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }

.module-card-img {
  height: 160px;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}

.module-card-color {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.module-card-body {
  padding: 18px 20px 20px;
}
.module-card-body h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
  line-height: 1.3;
}
.module-card-body p {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   MODULE DETAIL
   ══════════════════════════════════════════ */
.module-layout {
  display: flex;
  gap: 28px;
}

.submodule-sidebar {
  width: 240px;
  flex-shrink: 0;
}

.submodule-list { display: flex; flex-direction: column; gap: 4px; }

.submodule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-light);
  transition: all var(--transition);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.submodule-item:hover { background: var(--bg); color: var(--text); }
/* Submodule activo = Inter Medium 500 */
.submodule-item.active { background: var(--terracota-subtle); color: var(--terracota-dark); font-weight: 500; }

.content-area { flex: 1; min-width: 0; }

.content-list { display: flex; flex-direction: column; gap: 10px; }

.content-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
}
.content-card:hover { box-shadow: var(--shadow-sm); border-color: var(--terracota-light); transform: translateX(4px); }

.content-card-thumb {
  width: 88px;
  height: 66px;
  border-radius: var(--radius-sm);
  background-size: cover;
  background-position: center;
  background-color: var(--bg-warm);
  flex-shrink: 0;
}

/* Content card title = Inter Medium 500 (subtitulo) */
.content-card-info h4 {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}
.content-card-info p {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   CONTENT DETAIL
   ══════════════════════════════════════════ */
.content-detail { max-width: 100%; }

.content-detail h1 {
  font-size: 1.65rem;
  margin-bottom: 10px;
}

.content-detail .content-meta {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 24px;
  line-height: 1.6;
}

.content-detail .content-media {
  margin-bottom: 28px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.content-detail .content-media img { width: 100%; display: block; object-fit: contain; }
.content-detail .content-media iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: var(--radius-lg);
}

.content-detail .content-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
}

.content-detail .content-body p { margin-bottom: 18px; }
.content-detail .content-body h2 { margin: 32px 0 14px; font-size: 1.3rem; }
.content-detail .content-body h3 { margin: 24px 0 10px; }
.content-detail .content-body ul, .content-detail .content-body ol { margin: 12px 0 18px 20px; }
.content-detail .content-body li { margin-bottom: 6px; line-height: 1.7; }
.content-detail .content-body pre {
  background: var(--bg-warm);
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  margin: 16px 0;
}
.content-detail .content-body strong { color: var(--text); }
.content-detail .content-body em { color: var(--text-light); }

/* ── Content split layout (60% text left, 40% gallery right) ── */
.content-split {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.content-split-text {
  flex: 6;
  min-width: 0;
}

.content-split-gallery {
  flex: 4;
  min-width: 0;
  position: sticky;
  top: 24px;
}

/* Gallery sidebar */
.content-gallery-side {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.gallery-main-img {
  width: 100%;
  border-radius: var(--radius-lg);
  object-fit: cover;
  display: block;
}

.gallery-thumbs-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.gallery-thumb-sm {
  width: 64px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid transparent;
  transition: all var(--transition);
  opacity: 0.5;
}
.gallery-thumb-sm:hover { opacity: 0.8; }
.gallery-thumb-sm.active { border-color: var(--terracota); opacity: 1; }

.gallery-thumb-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Admin gallery thumb with remove button */
.gallery-thumb-admin { position: relative; display: inline-block; }
.gallery-remove-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #E8564F;
  color: var(--white);
  border: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-remove-btn:hover { background: #D04440; }

/* Provider CTA */
.provider-cta {
  margin: 28px 0;
  padding: 24px;
  background: var(--bg-warm);
  border-radius: var(--radius-lg);
  text-align: center;
}

.provider-cta-btn {
  font-size: 15px;
  padding: 14px 28px;
  text-decoration: none;
}

.content-attachments {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 2px solid var(--border-light);
}

.content-attachments h3 { margin-bottom: 14px; }

.attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 400;
  border: 1px solid var(--border-light);
  transition: border-color var(--transition);
}
.attachment-item:hover { border-color: var(--terracota-light); }
/* Attachment link = Inter Bold 700 (CTA) */
.attachment-item a { color: var(--terracota); font-weight: 700; }
.attachment-item a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════
   COMMUNITY
   ══════════════════════════════════════════ */
.community-layout { display: flex; gap: 28px; }
.community-main { flex: 1; min-width: 0; }
.community-aside { width: 280px; flex-shrink: 0; }

.community-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

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

.filter-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--white);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-light);
}
.filter-btn:hover { border-color: var(--terracota); color: var(--terracota); }
/* Filter activo = CTA = Inter Bold */
.filter-btn.active {
  background: var(--terracota);
  color: var(--white);
  border-color: var(--terracota);
}

.post-feed { display: flex; flex-direction: column; gap: 14px; }

.post-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
}
.post-card:hover { box-shadow: var(--shadow-sm); border-color: var(--terracota-light); }

.post-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.post-card-header .post-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--terracota-light), var(--terracota-subtle));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--terracota-dark);
  flex-shrink: 0;
}

.post-card-header .post-meta { display: flex; flex-direction: column; }
/* Post author = Inter Medium 500 (subtitulo) */
.post-card-header .post-author { font-weight: 500; font-size: 13px; color: var(--text); }
.post-card-header .post-date { font-size: 11px; color: var(--text-muted); }

/* Category badge = Inter Medium 500 */
.post-card-header .post-category {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 500;
}

.post-card h3 { font-size: 1rem; margin-bottom: 8px; }
.post-card .post-body-preview {
  font-size: 13px;
  color: var(--text-light);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
  line-height: 1.6;
}

/* Post footer = Inter Regular 400 (texto apoyo) */
.post-card-footer {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.post-card-footer span { display: flex; align-items: center; gap: 5px; }

/* Post detail */
.post-detail { max-width: 720px; }
.post-detail .post-full-header { margin-bottom: 24px; }
.post-detail h1 { font-size: 1.5rem; margin-bottom: 8px; }
.post-detail .post-full-body {
  font-size: 15px;
  line-height: 1.85;
  margin-bottom: 28px;
  white-space: pre-wrap;
}

.post-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 28px;
}

.like-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-light);
}
/* Like = CTA = Inter Bold */
.like-btn:hover { border-color: #E8564F; color: #E8564F; }
.like-btn.liked { background: #FEF2F2; border-color: #E8564F; color: #E8564F; }

.comments-section h3 { margin-bottom: 18px; }

.comment-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.comment-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.comment-content { flex: 1; }
/* Comment author = Inter Medium 500 */
.comment-author { font-weight: 500; font-size: 13px; }
.comment-date { font-size: 11px; color: var(--text-muted); margin-left: 8px; }
.comment-body { font-size: 13px; margin-top: 4px; line-height: 1.6; color: var(--text-light); }

.comment-form {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  align-items: flex-end;
}
.comment-form textarea { min-height: 60px; flex: 1; }

/* Leaderboard */
.leaderboard-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}
.leaderboard-card h3 { margin-bottom: 14px; font-size: 1rem; }

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  font-size: 13px;
}

.leaderboard-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.leaderboard-item:nth-child(1) .leaderboard-rank { background: var(--mostaza); color: var(--white); }
.leaderboard-item:nth-child(2) .leaderboard-rank { background: var(--text-muted); color: var(--white); }
.leaderboard-item:nth-child(3) .leaderboard-rank { background: var(--terracota); color: var(--white); }

/* Leaderboard name = Inter Regular 400, pts = Inter Bold 700 */
.leaderboard-name { flex: 1; font-weight: 400; }
.leaderboard-pts { font-weight: 700; color: var(--terracota); font-size: 12px; }

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}

.pagination button {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.pagination button:hover { border-color: var(--terracota); color: var(--terracota); }
.pagination button.active { background: var(--terracota); color: var(--white); border-color: var(--terracota); }

/* ══════════════════════════════════════════
   ADMIN
   ══════════════════════════════════════════ */
.admin-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-light);
}

/* Admin tabs = Inter Medium 500 (subtitulo), activo = Bold en color */
.admin-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--terracota); border-bottom-color: var(--terracota); font-weight: 700; }

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-light);
}

.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

/* Table header = Inter Medium 500 (subtitulo) */
.admin-table th {
  background: var(--bg);
  font-weight: 500;
  color: var(--text-light);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.admin-table tr:hover td { background: var(--bg); }

.admin-actions { display: flex; gap: 6px; }

.color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

/* Badges = Inter Medium 500 */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 500;
}
.badge-admin { background: var(--terracota-subtle); color: var(--terracota-dark); }
.badge-user { background: var(--bg-warm); color: var(--text-light); }
.badge-active { background: #ECFDF5; color: #059669; }
.badge-inactive { background: #FEF2F2; color: #DC2626; }

/* ══════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(45,45,58,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}

.modal-header h2 { font-size: 1.15rem; }

.modal-close {
  background: var(--white);
  border: 1px solid var(--border);
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-warm); color: var(--text); }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
}

/* ══════════════════════════════════════════
   ASSISTANT
   ══════════════════════════════════════════ */
.assistant-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--terracota);
  color: var(--white);
  border: none;
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(192,128,93,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 150;
}
.assistant-btn:hover { background: var(--terracota-dark); transform: scale(1.08); box-shadow: var(--shadow-xl), 0 0 0 6px rgba(192,128,93,0.2); }

.assistant-panel {
  display: none;
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 500px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  flex-direction: column;
  z-index: 150;
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.assistant-panel.active { display: flex; }

.assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}
.assistant-header h3 { font-size: 0.95rem; }

.assistant-close {
  background: var(--white);
  border: 1px solid var(--border);
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.assistant-close:hover { background: var(--bg-warm); }

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.assistant-msg {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.6;
  max-width: 85%;
}

.assistant-msg.assistant {
  background: var(--white);
  color: var(--text);
  align-self: flex-start;
  box-shadow: var(--shadow-xs);
}

.assistant-msg.user {
  background: var(--terracota);
  color: var(--white);
  align-self: flex-end;
}

.assistant-input {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border-light);
  background: var(--white);
}
.assistant-input input { flex: 1; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile-first touch optimization
   Touch targets: min 44px (WCAG/iOS HIG)
   Mobile body: 16px minimum
   Spacing: 8px+ between touch targets
   ══════════════════════════════════════════ */

/* ── Tablet (< 1024px) ── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .mobile-header { display: flex; }

  .main-content {
    margin-left: 0;
    padding: 20px;
    padding-top: calc(var(--header-height) + 20px);
  }

  /* Grid 2 columns tablet */
  .module-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }

  /* Module detail: submodules as horizontal scroll */
  .module-layout { flex-direction: column; }
  .submodule-sidebar { width: 100%; }
  .submodule-list {
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .submodule-item {
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 44px; /* Touch target */
    padding: 10px 16px;
  }

  /* Community stacks */
  .community-layout { flex-direction: column; }
  .community-aside { width: 100%; }

  /* Assistant full width on tablet */
  .assistant-panel {
    width: calc(100% - 32px);
    right: 16px;
    bottom: 84px;
    height: 60vh;
  }

  /* Login responsive */
  .login-split { flex-direction: column; }
  .login-brand-panel {
    padding: 40px 24px 32px;
    min-height: auto;
  }
  .login-brand-inner { max-width: 100%; }
  .login-headline { font-size: 1.3rem; }
  .login-brand-footer { display: none; }
  .login-form-panel { padding: 24px; }

  /* Admin tables: horizontal scroll */
  .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table thead, .admin-table tbody, .admin-table tr { display: table; width: 100%; table-layout: auto; }
  .admin-table thead { display: table-header-group; }
  .admin-table tbody { display: table-row-group; }
}

/* ── Mobile (< 640px) ── */
@media (max-width: 640px) {
  /* Typography scaling: 16px minimum for readability */
  body { font-size: 16px; }

  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.05rem; }

  /* Main content: more padding for thumb comfort */
  .main-content { padding: 16px; padding-top: calc(var(--header-height) + 16px); }

  /* Mobile header: touch-friendly */
  .mobile-header { height: 56px; padding: 0 12px; }
  .mobile-menu-btn { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }

  /* Grid 1 column */
  .module-grid { grid-template-columns: 1fr; gap: 14px; }
  .module-card-img { height: 160px; }
  .module-card-body { padding: 16px; }
  .module-card-body h3 { font-size: 1.1rem; }
  .module-card-body p { font-size: 14px; }

  /* Search bar full width */
  .search-bar { max-width: 100%; }
  .search-input-wrap { padding: 12px 16px; }
  .search-input-wrap input { font-size: 16px; } /* Prevent iOS zoom on focus */
  .search-results { max-height: 50vh; }
  .search-item { padding: 12px 16px; min-height: 44px; }

  /* Forms: prevent iOS zoom + touch-friendly */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="url"], textarea, select {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 12px 14px;
    min-height: 44px; /* Touch target */
  }
  .form-group label { font-size: 14px; margin-bottom: 8px; }
  .form-row { grid-template-columns: 1fr; }

  /* Buttons: touch-friendly minimum 44px height */
  .btn { min-height: 44px; padding: 10px 18px; font-size: 14px; }
  .btn-lg { min-height: 48px; padding: 12px 24px; font-size: 16px; }
  .btn-small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .btn-back { min-height: 44px; font-size: 14px; }

  /* Filter buttons: touch-friendly */
  .filter-btn { min-height: 40px; padding: 8px 16px; font-size: 13px; }
  .category-filters { gap: 8px; }

  /* Content cards: touch-friendly */
  .content-card { padding: 14px; min-height: 48px; }
  .content-card-thumb { width: 72px; height: 54px; }
  .content-card-info h4 { font-size: 15px; }
  .content-card-info p { font-size: 13px; }

  /* Gallery: stack on mobile */
  .content-split { flex-direction: column; }
  .content-split-gallery { position: static; }

  /* Content detail: mobile reading */
  .content-detail .content-body { font-size: 16px; line-height: 1.8; }
  .content-detail .content-body h2 { font-size: 1.2rem; margin: 24px 0 12px; }
  .content-detail .content-body pre { font-size: 12px; padding: 12px; }
  .content-detail h1 { font-size: 1.35rem; }

  /* Community: touch targets and readability */
  .community-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .post-card { padding: 16px; }
  .post-card h3 { font-size: 1.05rem; }
  .post-card .post-body-preview { font-size: 14px; }
  .post-card-header .post-avatar { width: 40px; height: 40px; } /* Bigger on mobile */
  .post-card-header .post-author { font-size: 14px; }

  /* Like button: touch target */
  .like-btn { min-height: 44px; padding: 10px 18px; font-size: 14px; }

  /* Post detail: mobile reading */
  .post-detail .post-full-body { font-size: 16px; line-height: 1.8; }

  /* Comments: stack form on mobile */
  .comment-form { flex-direction: column; gap: 10px; }
  .comment-form textarea { min-height: 80px; }
  .comment-form .btn { width: 100%; }
  .comment-body { font-size: 14px; }
  .comment-author { font-size: 14px; }
  .comment-avatar { width: 34px; height: 34px; }

  /* Pagination: touch targets */
  .pagination button { min-height: 40px; min-width: 40px; padding: 8px 12px; font-size: 14px; }
  .pagination { gap: 8px; }

  /* Leaderboard: touch-friendly rows */
  .leaderboard-item { padding: 12px 0; min-height: 44px; font-size: 14px; }
  .leaderboard-rank { width: 28px; height: 28px; font-size: 12px; }

  /* Attachments: touch targets */
  .attachment-item { min-height: 48px; padding: 12px 14px; font-size: 14px; }

  /* Admin: mobile-friendly */
  .admin-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-tab { min-height: 44px; padding: 10px 16px; white-space: nowrap; font-size: 14px; }
  .admin-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .admin-actions { gap: 8px; }
  .admin-actions .btn { min-height: 36px; }

  /* Modal: fullscreen on mobile */
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .modal-close { width: 40px; height: 40px; font-size: 20px; } /* Touch target */
  .modal-header { padding: 16px; position: sticky; top: 0; z-index: 1; }
  .modal-body { padding: 16px; }

  /* Assistant: fullscreen on mobile */
  .assistant-panel {
    width: 100%;
    height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
  .assistant-btn { width: 52px; height: 52px; bottom: 16px; right: 16px; }
  .assistant-close { width: 36px; height: 36px; } /* Touch target */
  .assistant-input { padding: 12px; }
  .assistant-input input { font-size: 16px; min-height: 44px; } /* Prevent zoom */
  .assistant-msg { font-size: 14px; padding: 12px 14px; }

  /* Login mobile */
  .login-brand-panel { padding: 28px 20px 20px; }
  .logo-img-login { height: 70px; }
  .login-headline { font-size: 1.15rem; }
  .login-form-panel { padding: 20px; }
  .login-form { padding: 20px; }
  .login-form-title { font-size: 1.3rem; }

  /* Section headers */
  .section-header { margin-bottom: 20px; }
  .section-subtitle { font-size: 14px; }

  /* Empty state */
  .empty-state { padding: 32px 16px; }
}

/* ── Small phones (< 380px) ── */
@media (max-width: 380px) {
  .main-content { padding: 12px; padding-top: calc(var(--header-height) + 12px); }
  h1 { font-size: 1.3rem; }
  .module-card-img { height: 140px; }
  .post-card { padding: 14px; }
  .login-brand-panel { padding: 24px 16px 16px; }
  .logo-img-login { height: 55px; }
  .login-headline { font-size: 1.05rem; }
  .login-subheadline { font-size: 13px; }
}

/* ── Utility ── */
.hidden { display: none !important; }
.admin-only { display: none; }
body.is-admin .admin-only { display: flex; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* ══════════════════════════════════════════
   CRM — UI/UX optimized + mobile touch targets
   ══════════════════════════════════════════ */

/* CRM Tabs */
.crm-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-light);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* CRM tabs = Inter Medium 500, active = Bold 700 */
.crm-tab {
  padding: 12px 20px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 44px;
}
.crm-tab:hover { color: var(--text); }
.crm-tab.active { color: var(--terracota); border-bottom-color: var(--terracota); font-weight: 700; }

/* CRM Search */
.crm-search-wrap { flex: 1; max-width: 360px; }
.crm-search-input {
  width: 100%;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  color: var(--text);
  background: var(--white);
  min-height: 44px;
}
.crm-search-input::placeholder { color: var(--text-muted); }
.crm-search-input:focus { border-color: var(--terracota); outline: none; box-shadow: 0 0 0 3px rgba(192,128,93,0.12); }

/* Quote/Invoice number field */
.crm-number-field {
  background: var(--bg-warm) !important;
  font-weight: 700;
  color: var(--terracota) !important;
  text-align: center;
}

/* ── Document lines (quotes/invoices) ── */
.crm-doc-line {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.crm-doc-line .crm-line-title { flex: 2; }
.crm-doc-line .crm-line-desc { flex: 3; }
.crm-doc-line .crm-line-qty { flex: 0 0 70px; text-align: center; }
.crm-doc-line .crm-line-price { flex: 1; min-width: 90px; text-align: right; }

.crm-doc-line input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  background: var(--white);
  min-height: 40px;
}
.crm-doc-line input:focus { border-color: var(--terracota); outline: none; }
.crm-doc-line input::placeholder { color: var(--text-muted); }

.crm-line-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #FEF2F2;
  color: #DC2626;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.crm-line-remove:hover { background: #FEE2E2; }

/* Total with IVA breakdown */
.crm-total {
  padding: 14px 12px 0;
  margin-top: 8px;
  border-top: 2px solid var(--border-light);
}

.crm-total-row {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-light);
  margin-bottom: 4px;
}

.crm-total-row span:last-child { min-width: 100px; text-align: right; }

.crm-total-final {
  font-size: 18px;
  font-weight: 700;
  color: var(--terracota);
  font-family: 'IBM Plex Serif', serif;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ── Template selector ── */
.crm-template-selector {
  display: flex;
  gap: 12px;
}

.crm-template-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
  flex: 1;
  text-align: center;
  min-height: 80px;
}
.crm-template-option:hover { border-color: var(--terracota-light); background: var(--bg); }
.crm-template-option.active { border-color: var(--terracota); background: var(--terracota-subtle); }
.crm-template-option input { display: none; }
.crm-template-option span { font-size: 14px; font-weight: 500; }

/* ── Related items ── */
.crm-related-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 400;
  margin-bottom: 8px;
  border-left: 3px solid var(--terracota);
  transition: background var(--transition);
  flex-wrap: wrap;
}
.crm-related-item:hover { background: var(--bg-warm); }
.crm-related-item span { flex: 1; min-width: 0; }
.crm-related-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── CRM Responsive — Tablet ── */
@media (max-width: 1024px) {
  .crm-search-wrap { max-width: 100%; }
}

/* ── CRM Responsive — Mobile ── */
@media (max-width: 640px) {
  /* Tabs: scrollable, touch-friendly */
  .crm-tab { padding: 12px 16px; font-size: 13px; min-height: 44px; }

  /* Search: full width */
  .crm-search-wrap { max-width: 100%; }
  .crm-search-input { font-size: 16px; } /* Prevent iOS zoom */

  /* Document lines: full stack on mobile */
  .crm-doc-line {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px;
  }
  .crm-doc-line .crm-line-title,
  .crm-doc-line .crm-line-desc { flex: 1 1 100%; min-width: 0; text-align: left; }
  .crm-doc-line .crm-line-qty { flex: 1 1 30%; }
  .crm-doc-line .crm-line-price { flex: 1 1 60%; min-width: 0; text-align: left; }
  .crm-doc-line input { min-height: 44px; font-size: 16px; } /* Touch target + prevent zoom */
  .crm-line-remove {
    width: 44px;
    height: 44px;
    align-self: flex-end;
    font-size: 20px;
  }

  /* Template selector: stack */
  .crm-template-selector { flex-direction: column; }
  .crm-template-option { min-height: 56px; padding: 16px; }

  /* Total: bigger on mobile */
  .crm-total { font-size: 20px; padding: 16px 0 0; }

  /* Admin toolbar in CRM: stack */
  .admin-toolbar { flex-direction: column; gap: 12px; align-items: stretch; }
}

/* ── CRM Dashboard ── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.dash-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

.dash-card-value {
  font-family: 'IBM Plex Serif', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--terracota);
  line-height: 1.2;
}

.dash-card-label {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
  margin-top: 4px;
}

.dash-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.dash-section {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.dash-section h3 {
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.dash-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dash-kpi {
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
}

.dash-kpi-value {
  display: block;
  font-family: 'IBM Plex Serif', serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.dash-kpi-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* Bar chart (CSS only) */
.dash-bars { display: flex; flex-direction: column; gap: 8px; }

.dash-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.dash-bar-label {
  width: 70px;
  flex-shrink: 0;
  text-align: right;
  color: var(--text-light);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-bar-track {
  flex: 1;
  height: 18px;
  background: var(--bg-warm);
  border-radius: 4px;
  overflow: hidden;
}

.dash-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.dash-bar-value {
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  font-weight: 700;
  color: var(--text);
  font-size: 11px;
}

.dash-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

@media (max-width: 640px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-kpis { grid-template-columns: 1fr; }
  .dash-card-value { font-size: 1.5rem; }
  .dash-bar-label { width: 50px; font-size: 10px; }
  .dash-bar-value { width: 70px; font-size: 10px; }
}

/* ── CRM Settings layout + Invoice Preview ── */
.settings-layout { display: flex; gap: 32px; align-items: flex-start; }
.settings-form { flex: 1; max-width: 560px; }
.settings-preview { flex: 1; min-width: 320px; position: sticky; top: 24px; }

.invoice-preview {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text);
  box-shadow: var(--shadow);
  min-height: 400px;
}

.invoice-preview span { color: var(--text-light); font-size: 9px; }
.invoice-preview strong { font-weight: 700; }

/* Classic */
.prev-classic .prev-bar { height: 4px; border-radius: 2px; margin-bottom: 14px; }
.prev-classic .prev-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.prev-classic .prev-doc-type { text-align: right; font-size: 14px; color: var(--terracota); }
.prev-classic .prev-sep { border-top: 1px solid var(--border); margin: 10px 0; }
.prev-classic .prev-client { margin-bottom: 14px; font-size: 9px; color: var(--terracota); }

/* Modern */
.prev-modern { position: relative; padding-left: 8px; }
.prev-modern .prev-sidebar-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--azul-mineral); border-radius: 2px; }
.prev-modern .prev-title { font-size: 14px; color: var(--azul-mineral); font-weight: 700; margin-bottom: 12px; }
.prev-modern .prev-two-col { display: flex; gap: 20px; margin-bottom: 14px; font-size: 9px; }
.prev-modern .prev-two-col > div { flex: 1; }
.prev-modern .prev-two-col strong { color: var(--azul-mineral); font-size: 8px; }

/* Minimal */
.prev-minimal .prev-center { text-align: center; margin-bottom: 10px; }
.prev-minimal .prev-sep-thin { border-top: 0.5px solid var(--text); margin: 8px 0 12px; }
.prev-minimal > div:nth-child(3) { margin-bottom: 14px; font-size: 10px; }

/* Shared preview table */
.prev-table { width: 100%; border-collapse: collapse; margin: 12px 0 8px; font-size: 9px; }
.prev-table th { background: var(--terracota); color: white; padding: 4px 6px; text-align: left; font-size: 8px; font-weight: 700; }
.prev-table td { padding: 4px 6px; border-bottom: 1px solid var(--border-light); }
.prev-table tr:nth-child(even) td { background: #F9F5F1; }
.prev-table td:last-child, .prev-table th:last-child { text-align: right; }
.prev-table td:nth-child(3), .prev-table th:nth-child(3) { text-align: center; }
.prev-table td:nth-child(4), .prev-table th:nth-child(4) { text-align: right; }

.prev-totals { text-align: right; font-size: 9px; color: var(--text-light); margin-top: 6px; }
.prev-totals > div { margin-bottom: 2px; }
.prev-total-final { font-size: 12px; font-weight: 700; color: var(--terracota); margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }

@media (max-width: 1024px) {
  .settings-layout { flex-direction: column; }
  .settings-preview { position: static; min-width: 0; width: 100%; }
  .settings-form { max-width: 100%; }
}

/* CRM Status badges */
.badge-crm-pending { background: rgba(198,170,98,0.15); color: #9E8A3E; }
.badge-crm-accepted { background: rgba(107,165,163,0.15); color: #4A8A88; }
.badge-crm-invoiced { background: rgba(74,122,141,0.15); color: var(--azul-mineral); }
.badge-crm-sent { background: rgba(155,109,123,0.15); color: var(--ciruela); }
.badge-crm-paid { background: #ECFDF5; color: #059669; }

.mt-8 { margin-top: 8px; }

/* ── Image Picker Component ── */
.img-picker-preview {
  margin-bottom: 10px;
}

.img-picker-preview img {
  max-height: 80px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  display: block;
}

.img-picker-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Media picker modal grid */
.media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
}

.media-picker-item {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  background: var(--bg-warm);
}

.media-picker-item:hover {
  border-color: var(--terracota);
  box-shadow: var(--shadow-sm);
}

.media-picker-item img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}

.media-picker-info {
  padding: 6px 8px;
}

.media-picker-name {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-picker-meta {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

/* ══════════════════════════════════════════
   MEDIA LIBRARY
   ══════════════════════════════════════════ */
.media-stats { margin-bottom: 20px; }

.media-usage-bar {
  height: 10px;
  background: var(--border-light);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}

.media-usage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--aguamarina), var(--terracota));
  border-radius: 5px;
  transition: width 0.4s ease;
}

.media-usage-text {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.media-item {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
}
.media-item:hover { box-shadow: var(--shadow-sm); border-color: var(--terracota-light); }

.media-preview {
  height: 120px;
  background: var(--bg-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-icon {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--white);
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.media-info {
  padding: 10px 12px 4px;
}

.media-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.media-actions {
  display: flex;
  gap: 4px;
  padding: 6px 12px 10px;
}

.media-actions .btn { font-size: 11px; padding: 4px 8px; }

@media (max-width: 640px) {
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .media-preview { height: 100px; }
  .media-actions .btn { min-height: 36px; }
}

/* ── Status badges (maintenance / coming soon) ── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}

.status-badge.status-coming-soon {
  background: rgba(74,122,141,0.12);
  color: var(--azul-mineral);
}

.status-badge.status-maintenance {
  background: rgba(198,170,98,0.15);
  color: #9E8A3E;
}

.status-icon {
  display: inline-block;
  font-size: 8px;
  margin-right: 6px;
  vertical-align: middle;
}

.status-icon.status-coming-soon { color: var(--azul-mineral); }
.status-icon.status-maintenance { color: var(--mostaza); }

/* Cards with status */
.module-card--coming_soon,
.module-card--maintenance { opacity: 0.75; }
.module-card--coming_soon:hover,
.module-card--maintenance:hover { opacity: 0.9; }

.submodule-item--coming_soon,
.submodule-item--maintenance { opacity: 0.6; }

.submodule-item .status-badge { margin-bottom: 0; margin-left: auto; font-size: 10px; padding: 2px 8px; }

.content-card-info .status-badge { margin-bottom: 4px; }

.content-card--coming_soon,
.content-card--maintenance { opacity: 0.65; }

/* Status message in modal */
.status-message {
  text-align: center;
  padding: 24px 16px;
}

.status-message-icon {
  font-size: 48px;
  margin-bottom: 16px;
  line-height: 1;
}

.status-message h3 {
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.status-message p {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.6;
}

/* ── Focus states for accessibility ── */
.btn:focus-visible, .nav-item:focus-visible, .filter-btn:focus-visible,
.submodule-item:focus-visible, .admin-tab:focus-visible, .crm-tab:focus-visible,
.crm-template-option:focus-visible, .pagination button:focus-visible {
  outline: 2px solid var(--terracota);
  outline-offset: 2px;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
