/* ============================================================
   CSS Variables — Light theme (default)
   ============================================================ */
:root {
  --bg:          #ede8df;
  --surface:     #f7f3ec;
  --card:        #f0ece3;
  --card-hover:  #e8e3d9;
  --border:      #d8d0c4;
  --primary:     #1C6A51;
  --primary-h:   #17553f;
  --primary-dim: #dcfce7;
  --danger:      #dc2626;
  --danger-h:    #b91c1c;
  --warn:        #d97706;
  --ok:          #16a34a;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --text-dim:    #475569;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 4px 24px rgba(0,0,0,.08);
  --transition:  .2s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w:   220px;
  --font:        'DM Sans', system-ui, -apple-system, sans-serif;
}

/* Dark theme — tinte frío verdoso, jerarquía de capas */
[data-theme="dark"] {
  /* Capa 1 — fondo principal */
  --bg:          #0f1a17;
  /* Capa 2 — superficies secundarias (sidebar, panels, table) */
  --surface:     #162320;
  /* Capa 3 — cards y elementos elevados */
  --card:        #1d2e28;
  --card-hover:  #243830;
  /* Bordes sutiles con tinte verde */
  --border:      #27403a;

  /* Verde acento — escala */
  --primary:     #1C6A51;
  --primary-h:   #21896a;
  --primary-dim: #0d2820;

  /* Danger */
  --danger:      #c0392b;
  --danger-h:    #e74c3c;

  /* Tipografía — grises suaves, no blancos puros */
  --text:        #d6e8e1;
  --text-muted:  #5e8a7c;
  --text-dim:    #93bfb3;

  /* Efectos */
  --shadow:      0 4px 20px rgba(0,0,0,.45), 0 1px 4px rgba(0,0,0,.3);
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); }

/* ============================================================
   Auth Screen
   ============================================================ */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.auth-logo p {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.auth-tabs {
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 1.75rem;
}

.auth-tab {
  flex: 1;
  padding: .5rem;
  text-align: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  border: none;
  background: none;
}

.auth-tab.active {
  background: var(--primary);
  color: #fff;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: .35rem;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  color: var(--text);
  font-size: .9rem;
  font-family: var(--font);
  transition: border-color var(--transition);
  outline: none;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-group select option {
  background: var(--card);
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .75rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-h); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--card); color: var(--text); }

.btn-sm {
  padding: .35rem .75rem;
  font-size: .8rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  padding: .35rem .5rem;
  font-size: .85rem;
}

/* ============================================================
   App Layout
   ============================================================ */
#app-screen {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 1.4rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.3px;
}

.sidebar-logo span {
  font-size: .72rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: .75rem .6rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link:hover { background: var(--card); color: var(--text); }

.nav-link.active {
  background: var(--primary-dim);
  color: var(--primary);
}

.nav-link .nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }

.sidebar-footer {
  padding: .75rem .6rem;
  border-top: 1px solid var(--border);
}

.user-info {
  padding: .6rem .75rem;
  font-size: .78rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-bottom: .35rem;
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.page-content {
  padding: 1.5rem;
  max-width: 1100px;
}

/* ============================================================
   Views (show/hide)
   ============================================================ */
.view { display: none; }
.view.active { display: block; }

/* ============================================================
   Dashboard
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stat-card .stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: .4rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.section-title {
  font-size: .85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

/* ============================================================
   Film Cards (dashboard)
   ============================================================ */
.film-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .75rem;
  margin-bottom: 2rem;
}

.film-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.film-card:hover {
  border-color: var(--primary);
  background: var(--card-hover);
}

.film-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .5rem;
}

.film-card-title {
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.3;
}

.film-card-brand {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

.film-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .5rem;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}

/* Light badge defaults */
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-teal   { background: var(--primary-dim); color: var(--primary-h); }

/* Dark badge overrides */
[data-theme="dark"] .badge-green  { background: #0d2e1a; color: #4ade80; }
[data-theme="dark"] .badge-yellow { background: #2e1f05; color: #fbbf24; }
[data-theme="dark"] .badge-red    { background: #2e0f0f; color: #f87171; }
[data-theme="dark"] .badge-blue   { background: #0e2236; color: #60a5fa; }
[data-theme="dark"] .badge-purple { background: #1e0f35; color: #c084fc; }
[data-theme="dark"] .badge-gray   { background: #1d2e28; color: #93bfb3; }

/* ============================================================
   Table
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--card-hover); }

tbody td {
  padding: .7rem 1rem;
  color: var(--text);
}

.actions {
  display: flex;
  gap: .35rem;
  justify-content: flex-end;
}

/* ============================================================
   Page header (for list views)
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: .2rem .4rem;
  border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); background: var(--card); }

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* ============================================================
   Quick Mode
   ============================================================ */
.quick-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}

.quick-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--primary-dim);
  color: var(--primary);
  font-size: .75rem;
  font-weight: 600;
  padding: .25rem .65rem;
  border-radius: 99px;
  letter-spacing: .02em;
}

.btn-link-subtle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .8rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 0;
  transition: color var(--transition);
}

.btn-link-subtle:hover { color: var(--primary); }

.label-optional {
  color: var(--text-muted);
  font-weight: 400;
  font-size: .8em;
}

#q-chip-preview .sc {
  box-shadow:
    0 0 0 2.5px var(--primary),
    0 0 18px rgba(28, 106, 81, .55),
    inset 0 1px 0 rgba(255,255,255,.18),
    0 2px 4px rgba(0,0,0,.35);
}

/* ============================================================
   Alerts / Toast
   ============================================================ */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
}

.alert-error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
[data-theme="dark"] .alert-error   { background: #7f1d1d33; border-color: #991b1b; color: #fca5a5; }
[data-theme="dark"] .alert-success { background: #14532d33; border-color: #166534; color: #86efac; }

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.1rem;
  font-size: .875rem;
  box-shadow: var(--shadow);
  animation: slide-in .2s ease;
  max-width: 320px;
}

.toast.toast-success { border-left: 3px solid var(--ok); }
.toast.toast-error   { border-left: 3px solid var(--danger); }

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .5;
}

.empty-state p {
  font-size: .9rem;
  margin-bottom: 1rem;
}

/* ============================================================
   Filters bar
   ============================================================ */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.filters-bar select,
.filters-bar input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .75rem;
  color: var(--text);
  font-size: .85rem;
  font-family: var(--font);
  outline: none;
}

.filters-bar select:focus,
.filters-bar input:focus { border-color: var(--primary); }

/* ============================================================
   Mobile hamburger
   ============================================================ */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: .25rem .5rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {

  /* ---- Layout base ---- */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }
  .main-content { margin-left: 0; padding-bottom: 80px; width: 100%; min-width: 0; overflow-x: hidden; }
  .hamburger { display: block; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-content { padding: 0 1rem 1.5rem; width: 100%; box-sizing: border-box; }

  /* ---- Top bar ---- */
  .top-bar {
    background: var(--bg);
    border-bottom: none;
    padding: .75rem 1rem;
  }
  .top-bar h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.03em; }

  /* ---- Mobile hero ---- */
  .mobile-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.4rem;
    margin-bottom: 1rem;
    margin-top: .25rem;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(28,106,81,.25);
  }
  .mobile-hero-eyebrow {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.7);
    margin-bottom: .15rem;
  }
  .mobile-hero-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.03em;
  }
  .mobile-hero-icon { font-size: 2.4rem; }

  /* ---- Mobile search ---- */
  .mobile-search-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .65rem 1.1rem;
    margin-bottom: 1.25rem;
    cursor: pointer;
  }
  .mobile-search-icon { font-size: 1rem; color: var(--text-muted); }
  .mobile-search-placeholder { font-size: .875rem; color: var(--text-muted); }

  /* ---- Stat cards → horizontal scroll ---- */
  .stats-grid {
    display: flex;
    overflow-x: auto;
    gap: .6rem;
    margin-bottom: 1.5rem;
    padding-bottom: .4rem;
    scrollbar-width: none;
  }
  .stats-grid::-webkit-scrollbar { display: none; }
  .stat-card { flex: 0 0 auto; min-width: 108px; padding: .85rem 1rem; }
  .stat-card .stat-value { font-size: 1.75rem; }

  /* ---- Section titles ---- */
  .section-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.01em;
    text-transform: none;
    color: var(--text);
    margin-bottom: .75rem;
  }

  /* ---- Film cards → 2 columnas ---- */
  .film-cards { grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1.5rem; }
  .film-card { padding: .85rem .8rem; }
  .film-card-title { font-size: .85rem; }

  /* ---- Filters scroll ---- */
  .filters-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: .25rem;
  }
  .filters-bar::-webkit-scrollbar { display: none; }
  .filters-bar select, .filters-bar input { flex-shrink: 0; }

  /* ---- Tables → tarjetas ---- */
  .table-wrapper { border: none; background: transparent; }
  .table-wrapper table { display: block; }
  .table-wrapper thead { display: none; }
  .table-wrapper tbody { display: flex; flex-direction: column; gap: .6rem; }
  .table-wrapper tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: .85rem 1rem;
  }
  .table-wrapper tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .25rem 0;
    border: none;
    font-size: .875rem;
  }
  .table-wrapper tbody td:first-child { font-weight: 600; }
  .table-wrapper tbody td .actions { justify-content: flex-end; width: 100%; }

  /* ---- Bottom nav pill ---- */
  .bottom-nav {
    display: flex;
    border-top: none;
    box-shadow: 0 -4px 20px rgba(0,0,0,.09);
    padding: .45rem .6rem calc(.5rem + env(safe-area-inset-bottom));
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 2px;
  }
  [data-theme="dark"] .bottom-nav { box-shadow: 0 -4px 20px rgba(0,0,0,.4); }

  .bottom-nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: .45rem .65rem;
    border-radius: 999px;
    min-width: 40px;
    font-size: 0;           /* oculta label en inactivo */
  }
  .bottom-nav-item .bnav-icon { font-size: 1.3rem; line-height: 1; }
  .bottom-nav-item .nav-label {
    font-size: .8rem;
    font-weight: 600;
    font-family: var(--font);
    margin-left: .3rem;
    white-space: nowrap;
  }

  /* Activo: pill verde con icono + label */
  .bottom-nav-item.active {
    background: var(--primary);
    color: #fff;
    padding: .45rem 1rem;
    font-size: .8rem;       /* muestra label */
  }
  .bottom-nav-item.active .bnav-icon { font-size: 1.1rem; }

  /* Botón + FAB: mantiene círculo, ignora pill */
  .bottom-nav-add {
    padding: 0 !important;
    background: transparent !important;
    font-size: 0 !important;
  }
  .bottom-nav-plus {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary);
    color: #fff !important;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem !important;
    font-weight: 300;
    box-shadow: 0 4px 12px rgba(28,106,81,.4);
  }
}

/* Desktop: oculta elementos exclusivos de móvil */
@media (min-width: 769px) {
  .mobile-hero, .mobile-search-bar { display: none; }
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   Bottom nav (mobile)
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: .55rem .25rem;
  font-size: .65rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: color var(--transition);
}

.bottom-nav-item span:first-child { font-size: 1.25rem; line-height: 1; }
.bottom-nav-item.active { color: var(--primary); }

.bottom-nav-add {
  position: relative;
}

.bottom-nav-plus {
  width: 2.4rem;
  height: 2.4rem;
  background: var(--primary);
  color: #fff !important;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem !important;
  font-weight: 300;
  line-height: 1;
  margin-bottom: 1px;
}

/* Theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: .8rem;
  font-family: var(--font);
  cursor: pointer;
  margin-bottom: .5rem;
  transition: var(--transition);
}
.theme-toggle:hover { background: var(--card); color: var(--text); }

/* ============================================================
   Headings — tracking negativo para personalidad
   ============================================================ */
h1, h2, h3, h4 {
  letter-spacing: -0.025em;
}

/* ============================================================
   Interacciones — estados claros
   ============================================================ */
.btn:active {
  transform: scale(0.97);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus {
  box-shadow: 0 0 0 3px rgba(28, 106, 81, 0.35);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   Misc utils
   ============================================================ */
/* ============================================================
   Gear tabs
   ============================================================ */
.gear-tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: 1.25rem;
  width: fit-content;
}

.gear-tab {
  padding: .45rem 1.1rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.gear-tab:hover { color: var(--text); }

.gear-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.gear-panel { display: none; }
.gear-panel.active { display: block; }

/* ── Sortable table headers ── */
.th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.th-sortable:hover { color: var(--text); background: var(--card-hover); }
.th-sortable.th-active { color: var(--primary); }
.th-sort-icon { font-size: .8em; opacity: .35; margin-left: 2px; }
.th-sort-icon.sorted { opacity: 1; color: var(--primary); }

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .8rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }

/* ============================================================
   Film Detail View
   ============================================================ */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.detail-brand {
  font-size: .9rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

.detail-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .3rem;
  flex-shrink: 0;
}

.detail-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-bottom: 1.25rem;
}

.detail-row {
  display: grid;
  grid-template-columns: 1.5rem 7rem 1fr;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
}

.detail-icon { font-size: 1rem; }

.detail-label {
  color: var(--text-muted);
  font-size: .82rem;
}

.detail-value {
  color: var(--text);
  font-weight: 500;
}

.detail-notes {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.detail-notes-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

.detail-notes-body {
  font-size: .9rem;
  color: var(--text-dim);
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .detail-card { padding: 1.25rem; margin: 0; border-radius: var(--radius); }
  .detail-title { font-size: 1.25rem; }
  .detail-row { grid-template-columns: 1.5rem 6rem 1fr; }
  .detail-actions { position: fixed; bottom: 4rem; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: .75rem 1rem; z-index: 10; }
}

/* ============================================================
   Stock Chip — mini visual etiqueta de emulsión
   ============================================================ */
.sc {
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 5px;
  gap: 2px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 2px 4px rgba(0,0,0,.35);
  user-select: none;
  overflow: hidden;
  text-align: center;
}

.sc--sm { width: 46px; height: 46px; }
.sc--md { width: 58px; height: 58px; }
.sc--lg { width: 76px; height: 76px; }

.sc-brand {
  font-size: 6px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  opacity: .78;
  line-height: 1;
}

.sc-name {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.2;
}

.sc--lg .sc-brand { font-size: 8px; }
.sc--lg .sc-name  { font-size: 10.5px; }

/* Cuando tiene imagen real */
.sc--has-img { padding: 0; }
.sc-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 6px;
}

/* ============================================================
   Timeline — formato tabs + colapso año/mes
   ============================================================ */

/* ── Tabs de formato ── */
.tl-fmt-tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: 1.5rem;
}

.tl-fmt-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .5rem .6rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tl-fmt-tab:hover { color: var(--text); }

.tl-fmt-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.tl-fmt-icon { font-size: 1rem; line-height: 1; }
.tl-fmt-label { font-size: .875rem; }

.tl-fmt-count {
  background: var(--primary-dim);
  color: var(--primary);
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  padding: .1rem .45rem;
  min-width: 1.3rem;
  text-align: center;
  line-height: 1.6;
}

.tl-fmt-panel { display: none; }
.tl-fmt-panel.active { display: block; }

/* ── Botones colapsables (año / mes) ── */
.tl-collapse-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: .55rem .65rem;
  border-radius: var(--radius);
  font-family: var(--font);
  transition: background var(--transition);
  text-align: left;
}

.tl-collapse-btn:hover { background: var(--card); }

.tl-collapse-year {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text);
}

.tl-collapse-month {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-dim);
}

.tl-collapse-count {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.tl-chevron {
  margin-left: auto;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform var(--transition);
  transform: rotate(0deg);
  display: inline-block;
  line-height: 1;
}

.tl-collapse-btn.open .tl-chevron { transform: rotate(90deg); }

/* Botón mes: sangría */
.tl-collapse-btn--month { padding-left: 1rem; }

/* ── Bloques ── */
.tl-root { max-width: 680px; }

.tl-year-block { margin-bottom: .35rem; }

.tl-year-body  { padding-bottom: .5rem; }

.tl-month-block { margin-bottom: .15rem; }

.tl-month-body { padding-left: .5rem; }

/* ── Entradas (spine + card) ── */
.tl-entries {
  display: flex;
  flex-direction: column;
  padding-left: .5rem;
}

.tl-entry {
  display: flex;
  gap: 0;
  cursor: pointer;
}

.tl-spine {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 2rem;
  flex-shrink: 0;
}

.tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: .95rem;
  border: 2px solid var(--bg);
  background: var(--border);
}

.tl-dot--35mm  { background: var(--primary); }
.tl-dot--120   { background: #3b82f6; }
.tl-dot--s8    { background: #d97706; }

.tl-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  margin-top: 3px;
  min-height: 1rem;
}

.tl-entry:last-child .tl-line { display: none; }

.tl-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .85rem 1rem;
  margin-bottom: .5rem;
  transition: var(--transition);
}

.tl-card:hover {
  border-color: var(--primary);
  background: var(--card-hover);
}

.tl-card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.tl-card-brand {
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: .45rem;
}

.tl-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .3rem;
}

.tl-card-cam { margin-top: .25rem; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .tl-fmt-label { display: none; }   /* solo icono + número en mobile */
  .tl-fmt-tab   { padding: .5rem .4rem; }
  .tl-fmt-icon  { font-size: 1.15rem; }
  .tl-root      { max-width: 100%; }
  .tl-month-body { padding-left: 0; }
}

/* ============================================================
   Stats — Módulo de estadísticas
   ============================================================ */

/* ── Layout general ── */
#stats-view {
  max-width: 820px;
  padding-bottom: 3rem;
}

.stats-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.stats-section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 1.1rem;
}

.stats-empty {
  color: var(--text-muted);
  font-size: .85rem;
}

/* ── ① Hero ── */
.stats-hero {
  margin-bottom: 1.25rem;
}

.stats-hero-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.stats-hero-card {
  flex: 1 1 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  text-align: center;
}

.stats-hero-card--s8 {
  border-color: #b45309;
  background: color-mix(in srgb, #b45309 8%, var(--surface));
}

.stats-hero-num {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--primary);
  line-height: 1.1;
}

.stats-hero-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: .3rem;
}

.stats-hero-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── ② ADN fílmico ── */
.dna-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.dna-card {
  flex: 1 1 160px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .5rem;
}

.dna-card-title {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.dna-dominant {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.dna-card-value {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
}

.dna-card-sub {
  font-size: .78rem;
  color: var(--text-muted);
}

.dna-chip-lg {
  margin: .25rem 0;
}

.dna-cam-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.dna-type-bar {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  gap: 1px;
}

.dna-bar-seg { height: 100%; border-radius: 4px; min-width: 2px; transition: width .4s ease; }
.dna-bar--color { background: #1c6a51; }
.dna-bar--bw    { background: #374151; }
.dna-bar--slide { background: #b45309; }

.dna-type-legend {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .72rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  justify-content: center;
}

.dna-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── ③ Gráfico de barras apiladas por año ── */
.stats-section-title-row {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 1.1rem;
}

.stats-section-title-row .stats-section-title {
  margin-bottom: 0;
}

.year-no-date {
  font-size: .72rem;
  color: var(--text-muted);
  font-style: italic;
}

.year-chart {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  height: 155px; /* espacio para etiquetas y tendencias */
  margin-bottom: .85rem;
}

.year-bar-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  flex: 1;
  cursor: pointer;
  border-radius: var(--radius);
  padding: .25rem .15rem .25rem;
  transition: background var(--transition);
}

.year-bar-wrap:hover { background: var(--card-hover); }
.year-bar-wrap--selected { background: var(--card); outline: 2px solid var(--primary); outline-offset: 1px; }
.year-bar-wrap--peak  .year-bar-stacked { filter: brightness(1.08); }

/* Tendencia */
.year-trend {
  font-size: .6rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 4px;
  line-height: 1.4;
  white-space: nowrap;
}
.year-trend--up { color: #16a34a; background: rgba(22,163,74,.12); }
.year-trend--dn { color: var(--danger); background: rgba(220,38,38,.1); }
.year-trend--eq { color: var(--text-muted); background: var(--card); }

.year-bar-count {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-dim);
}

/* Barra apilada */
.year-bar-stacked {
  width: 100%;
  max-width: 44px;
  display: flex;
  flex-direction: column-reverse; /* 35mm en la base, S8 arriba */
  border-radius: 5px 5px 2px 2px;
  overflow: hidden;
  transition: filter var(--transition);
}

/* Segmentos por formato */
.yseg          { min-height: 2px; transition: flex .4s ease; }
.yseg--35mm    { background: #1c6a51; }
.yseg--120     { background: #7c3aed; }
.yseg--s8      { background: #b45309; }

.year-bar-label {
  font-size: .63rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}

/* Tooltip CSS-only */
.year-bar-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .65rem;
  font-size: .72rem;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 30;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  color: var(--text);
}

.year-bar-wrap:hover .year-bar-tooltip { opacity: 1; }

/* Leyenda de formatos */
.year-chart-legend {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
  margin-bottom: .6rem;
}

.ycl-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.ycl-label {
  font-size: .75rem;
  color: var(--text-dim);
  margin-right: .5rem;
}

.ycl-hint {
  margin-left: auto;
  font-size: .7rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Panel expandible de detalle por año ── */
.year-detail-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .28s cubic-bezier(0.4,0,0.2,1), opacity .22s ease;
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  margin-top: .75rem;
}

.year-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem .6rem;
  border-bottom: 1px solid var(--border);
}

.year-detail-title-group {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
}

.year-detail-year {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary);
}

.year-detail-total {
  font-size: .82rem;
  color: var(--text-muted);
}

.year-detail-fmt-badges { display: flex; gap: .35rem; flex-wrap: wrap; }

.fmt-badge {
  font-size: .7rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
}
.fmt-badge.fmt-35mm { background: rgba(28,106,81,.18); color: #1c6a51; }
.fmt-badge.fmt-120  { background: rgba(124,58,237,.15); color: #7c3aed; }
.fmt-badge.fmt-s8   { background: rgba(180,83,9,.15); color: #b45309; }

.year-detail-close {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .85rem;
  padding: .2rem .5rem;
  transition: var(--transition);
  flex-shrink: 0;
}
.year-detail-close:hover { background: var(--card-hover); color: var(--text); }

.year-detail-body {
  padding: 1rem 1rem .85rem;
}

.year-detail-sub-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

.year-detail-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: .25rem;
}

.year-detail-top-em {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.year-detail-em-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}
.year-detail-em-sub {
  font-size: .75rem;
  color: var(--text-muted);
}

/* Heatmap mensual */
.heat-row {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.heat-cell {
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 3px;
  cursor: default;
  transition: filter .15s;
}
.heat-cell:hover { filter: brightness(1.3); }

.heat-label {
  font-size: .55rem;
  color: rgba(255,255,255,.75);
  font-weight: 600;
}

/* ── ④ Rankings ── */
.rankings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.rankings-col-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .65rem;
}

.rank-num {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 14px;
  text-align: right;
  flex-shrink: 0;
}

.rank-cam-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-name {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .25rem;
}

.rank-bar {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.rank-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .4s ease;
}

.rank-count {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── ⑤ Distribución ── */
.dist-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.dist-col-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}

.dist-label {
  font-size: .78rem;
  color: var(--text-dim);
  width: 68px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dist-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.dist-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .4s ease;
  min-width: 3px;
}

.dist-count {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

/* ── ⑥ Tipos de foto ── */
.photo-types { display: flex; flex-direction: column; gap: .5rem; }

.photo-type-row {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.photo-type-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.photo-type-name {
  font-size: .82rem;
  color: var(--text-dim);
  width: 160px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── ⑦ Sugerencias ── */
.suggestions { display: flex; flex-direction: column; gap: .85rem; }

.suggestion-card {
  display: flex;
  gap: .85rem;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.suggestion-chip { flex-shrink: 0; }

.suggestion-body { flex: 1; min-width: 0; }

.suggestion-stock {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .3rem;
}

.suggestion-text {
  font-size: .82rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Responsive Stats ── */
@media (max-width: 768px) {
  /* Hero: 2 cards por fila, última no se estira sola */
  .stats-hero-num        { font-size: 1.4rem; }
  .stats-hero-card       { flex: 1 1 calc(50% - .375rem); }

  /* Secciones: menos padding en pantallas estrechas */
  .stats-section         { padding: 1rem; margin-bottom: 1rem; }
  .stats-section-title-row { flex-wrap: wrap; }

  /* ADN — columna full-width, sin flip a row */
  .dna-grid              { flex-direction: column; }
  /* dna-card mantiene su layout columna — no aplicar flex-direction:row */

  /* Rankings — columna única */
  .rankings-grid         { grid-template-columns: 1fr; }

  /* Distribución — columna única */
  .dist-grid             { grid-template-columns: 1fr; }

  /* Tipos de foto */
  .photo-type-name       { width: 110px; }

  /* Gráfico de años */
  .year-chart            { gap: .25rem; height: 145px; overflow: visible; }
  .year-bar-stacked      { max-width: 100%; }
  .year-bar-tooltip      { display: none; } /* tooltip no aplica en táctil */
  .ycl-hint              { display: none; }

  /* Heatmap mensual: celdas más compactas */
  .heat-cell             { aspect-ratio: unset; height: 26px; }
  .heat-label            { font-size: .48rem; }

  /* Panel de detalle: split a columna */
  .year-detail-split     { grid-template-columns: 1fr; gap: .85rem; }
  .year-detail-header    { flex-wrap: wrap; gap: .4rem; }
  .year-detail-title-group { flex-wrap: wrap; }
}
