@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ==========================================================================
   M3 Modernization + Neumorphism — styles.css
   Modern, Minimal, Material Design 3 inspired
   ========================================================================== */

:root {
  /* --- TOKENS: TIPOGRAFÍA M3 --- */
  --font-base: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --font-size-base: 16px;
  --font-size-sm: 14px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-xxl: 28px;

  /* --- TOKENS: GEOMETRÍA M3 --- */
  --radius-panel: 16px;
  --radius-chip: 999px;
  --radius-btn: 10px;
  --radius-input: 8px;
  --space-md: 16px;
  --transition-fast: 120ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-smooth: 240ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-slow: 380ms cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* --- TOKENS: COLORES M3 (Paleta mejorada) --- */
  --color-primary: #1F4E9F;
  --color-primary-light: #5B7FD0;
  --color-primary-lighter: #8BA5DB;
  --color-primary-dark: #162D6E;
  --color-secondary: #FF6B6B;
  --color-secondary-light: #FF9999;
  --color-tertiary: #4ECDC4;
  --color-accent: #5B5BFF;

  --color-success: #10B981;
  --color-success-light: #6EE7B7;
  --color-warning: #F59E0B;
  --color-warning-light: #FCD34D;
  --color-danger: #EF4444;
  --color-danger-light: #FCA5A5;

  /* --- NEUMORPHISM SHADOWS (Mejorados) --- */
  --shadow-neo-xs: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-neo-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-neo-md: 0 8px 20px rgba(0, 0, 0, 0.1);
  --shadow-neo-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --shadow-neo-xl: 0 16px 48px rgba(0, 0, 0, 0.14);
  --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* --- THEME: LIGHT (Modern & Clean) --- */
.theme-light,
[data-theme="light"] {
  --bg-app: #F8F9FA;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F0F2F5;
  --bg-input: #EEF1F6;
  --text-main: #0F1419;
  --text-muted: #71788C;
  --border-subtle: #DDE1E6;
  --border-strong: #C7CDD6;
  --accent: #1F4E9F;
  --accent-container: #E8EFFE;
  --accent-soft: #F0F4FF;

  --hero-gradient: linear-gradient(135deg, #F0F4FF 0%, #F8F9FA 100%);
  --glass-bg: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(31, 78, 159, 0.12);
  --shadow-color: rgba(31, 78, 159, 0.1);
}

/* --- THEME: DARK (Deep & Modern) --- */
.theme-dark,
[data-theme="dark"] {
  --bg-app: #0A0D12;
  --bg-surface: #151B28;
  --bg-elevated: #1F2637;
  --bg-input: #0D1117;
  --text-main: #F5F6F8;
  --text-muted: #A8AFB9;
  --border-subtle: #2C3545;
  --border-strong: #3A4555;
  --accent: #8BA5DB;
  --accent-container: #1E2A4A;
  --accent-soft: #0F1B3D;

  --hero-gradient: linear-gradient(135deg, rgba(139, 165, 219, 0.15) 0%, rgba(31, 78, 159, 0.08) 100%);
  --glass-bg: rgba(21, 27, 40, 0.9);
  --glass-border: rgba(139, 165, 219, 0.2);
  --shadow-color: rgba(0, 0, 0, 0.4);
}

/* --- LEGACY COMPATIBILITY & UTILS --- */
:root {
  --bg: var(--bg-surface);
  --text: var(--text-main);
  --border: var(--border-subtle);
  --muted-text: var(--text-muted);
  --ritual-red: #FF6B6B;
  --ritual-red-muted: rgba(255, 107, 107, 0.08);
  --ritual-red-bright: #FF9999;
  --accent-muted: rgba(31, 78, 159, 0.1);
  --accent-glow: rgba(31, 78, 159, 0.2);
  --glow-subtle: 0 0 20px rgba(255, 107, 107, 0.15);
}

/* ===============================
   CORE STYLES
   =============================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color var(--transition-slow), color var(--transition-slow);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  width: 100%;
}

/* Focus visible styles for accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

* {
  box-sizing: border-box;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--bg-app);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-light);
}

.med-card {
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

h1,
h2,
h3,
.ritual-title {
  font-family: var(--font-base);
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--text-main);
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 1.25rem;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ========================================================================
   MODERN LAYOUT: Header + Sidebar + Content
   ======================================================================== */

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

/* --- M3 HEADER (Top Navigation) --- */
.m3-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  backdrop-filter: blur(12px);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .m3-header {
  background: rgba(21, 27, 40, 0.85);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.m3-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.m3-header-logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: var(--font-base);
  filter: drop-shadow(0 0 10px rgba(31, 78, 159, 0.1));
  animation: logoPresence 0.6s var(--m3-motion-enter);
}

@keyframes logoPresence {
  from { opacity: 0; transform: translateX(-10px); filter: blur(4px); }
  to { opacity: 1; transform: translateX(0); filter: blur(0); }
}

.m3-toggle-sidebar {
  transition: all var(--transition-smooth);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-btn);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
}

.m3-toggle-sidebar svg {
  width: 20px;
  height: 20px;
}

.m3-toggle-sidebar:hover {
  background: var(--accent-container);
  color: var(--color-primary);
  transform: rotate(90deg) scale(1.1);
}

.m3-toggle-sidebar:active {
  transform: rotate(90deg) scale(0.9);
}

.m3-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- M3 SIDEBAR (Lateral Navigation) --- */
.m3-sidebar {
  position: fixed;
  left: 0;
  top: 56px;
  width: 280px;
  height: calc(100vh - 56px);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 16px 12px;
  z-index: 3100; /* Above bottom nav (3000) */
  transition: transform var(--transition-smooth), width var(--transition-smooth);
  box-shadow: var(--shadow-neo-xl);
  padding-bottom: calc(var(--m3-nav-height) + 20px); /* Space for bottom nav */
}

/* --- SIDEBAR BACKDROP (Mobile overlay) --- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 3099;
  opacity: 0;
  transition: opacity var(--transition-smooth);
}
.sidebar-backdrop.open {
  display: block;
  opacity: 1;
}

/* Scroll lock when mobile sidebar is open */
body.sidebar-is-open {
  overflow: hidden;
}

.m3-sidebar.collapsed {
  width: 80px;
}

.m3-sidebar.hidden {
  transform: translateX(-100%);
}

.m3-sidebar-group {
  margin-bottom: 24px;
}

.m3-sidebar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding: 12px 8px 8px;
  display: block;
  margin-bottom: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.m3-sidebar:not(.collapsed) .m3-sidebar-label {
  opacity: 1;
}

.m3-sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 10px;
  margin-bottom: 6px;
  border: none;
  background: transparent;
  border-radius: var(--radius-btn);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m3-sidebar-item:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
  transform: translateX(4px);
}

.m3-sidebar-item:active {
  background: var(--accent-container);
  transform: scale(0.98);
}

.m3-sidebar-item.active {
  background: linear-gradient(90deg, var(--accent-container), transparent);
  color: var(--color-primary);
  font-weight: 600;
}

.m3-sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 3px 3px 0;
}

.m3-sidebar-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m3-sidebar-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.m3-sidebar-text {
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.m3-sidebar.collapsed .m3-sidebar-text {
  opacity: 0;
  width: 0;
  margin: 0;
}

/* --- MAIN LAYOUT WRAPPER --- */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.app-content {
  flex: 1;
  margin-left: 280px;
  padding: 20px;
  overflow-y: auto;
  transition: margin-left var(--transition-smooth);
  max-width: none;
}

.m3-sidebar.collapsed ~ .app-content {
  margin-left: 80px;
}

.m3-sidebar.hidden ~ .app-content {
  margin-left: 0;
}

@media (max-width: 768px) {
  .m3-sidebar {
    width: 100%;
    max-width: 280px;
    transform: translateX(-100%); /* hidden by default on mobile */
    z-index: 3100;
  }

  .m3-sidebar:not(.hidden) {
    position: fixed;
    left: 0;
    top: 56px;
    transform: translateX(0); /* visible when not .hidden */
  }

  .m3-sidebar.hidden {
    transform: translateX(-100%);
  }

  .app-content {
    margin-left: 0 !important;
  }
}

/* Layout Containers */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
}

/* Main Content Area */
.main {
  padding: 2rem;
}

@media (max-width: 600px) {
  .staggered-menu-header {
    padding: 16px 20px;
  }

  .sm-panel-item {
    font-size: 32px;
  }

  .sm-panel-list[data-numbering] .sm-panel-item::before {
    left: -25px;
    font-size: 10px;
  }
}

/* --- DOCK NAVIGATION (legacy – hidden, replaced by M3 Bottom Nav) --- */
#dock-container {
  display: none !important;
}

.dock-panel {
  display: flex;
  align-items: flex-end;
  padding: 10px;
  gap: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--shadow-neo-lg), 0 0 0 1px rgba(255, 255, 255, 0.1);
  pointer-events: auto;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
  max-width: 92vw;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dock-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.2s ease;
  will-change: width, height, transform;
}

.dock-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dock-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  transition: transform 0.2s ease, color 0.2s ease;
  pointer-events: none;
}

.dock-icon svg,
.icon svg,
.icon-large svg {
  width: 100%;
  height: 100%;
  stroke-width: 2;
  /* Lighter stroke for elegance */
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock-item:hover .dock-icon {
  transform: translateY(-4px);
  color: var(--accent);
}

.dock-label {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-neo-md);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.dock-item:hover .dock-label {
  opacity: 1;
  transform: translateX(-50%) translateY(-5px);
}

/* Ensure content doesn't get hidden behind dock on mobile */
.app-content {
  padding-bottom: 120px;
}

/* --- COMPACT HOME GRID --- */
.compact-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.compact-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  aspect-ratio: 1 / 1;
  box-shadow: var(--shadow-neo-sm);
}

.compact-card:hover {
  background: var(--bg-elevated);
  border-color: var(--color-primary);
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-neo-md);
  color: var(--color-primary);
}

.compact-card .icon {
  font-size: 24px;
  transition: color var(--transition-fast);
}

.compact-card .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

/* --- DASHBOARD REDESIGN --- */

.home-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 40px;
}

/* Hero Section */
.home-hero-card {
  background: var(--hero-gradient);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-neo-lg);
  transition: all var(--transition-smooth);
}

.home-hero-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(31, 78, 159, 0.1) 0%, transparent 70%);
  animation: floatBg 8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes floatBg {
  0%, 100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-20px, -20px);
  }
}

.home-hero-card h1 {
  font-size: 32px;
  font-weight: 800;
  margin: 0 0 12px 0;
  letter-spacing: -0.03em;
  color: var(--text-main);
  position: relative;
  z-index: 2;
}

.home-hero-card p {
  margin: 0;
  font-size: 15px;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
  line-height: 1.6;
}

.version-tag {
  font-size: 12px;
  background: var(--color-secondary);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  vertical-align: middle;
  font-weight: 600;
  margin-left: 6px;
}

/* Section Titles */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0px;
  /* Grid gap handles spacing */
  padding-left: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
  opacity: 0.7;
}

/* Grids */
.home-grid-primary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.home-grid-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

/* Dashboard Cards */
.dashboard-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition-smooth);
  box-shadow: var(--shadow-neo-sm);
  aspect-ratio: 1 / 0.9;
  position: relative;
  overflow: hidden;
}

.dashboard-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(31, 78, 159, 0.05) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-smooth);
  pointer-events: none;
}

.dashboard-card:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: var(--shadow-neo-lg);
  border-color: var(--color-primary);
  background: var(--accent-container);
}

.dashboard-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-neo-sm);
  background: var(--accent-container);
}

.dashboard-card:hover::before {
  opacity: 1;
}

.dashboard-card .icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.dashboard-card .icon svg {
  width: 24px;
  height: 24px;
}

.dashboard-card .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

/* Primary Feature Card (Fármacos) */
.feature-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  padding: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-neo-sm);
  aspect-ratio: auto;
  transition: all var(--transition-fast);
}

.feature-card:hover {
  box-shadow: var(--shadow-neo-md);
  border-color: var(--color-primary);
}

.feature-card .content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feature-card .icon-large {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.feature-card .icon-large svg {
  width: 42px;
  height: 42px;
}

@media (max-width: 600px) {
  .dashboard-card .icon {
    width: 30px;
    height: 30px;
  }

  .dashboard-card .icon svg {
    width: 22px;
    height: 22px;
  }

  .feature-card .icon-large {
    width: 48px;
    height: 48px;
  }

  .feature-card .icon-large svg {
    width: 34px;
    height: 34px;
  }
}

@media (max-width: 600px) {
  .home-hero-card {
    padding: 24px 16px;
  }
}

.med-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-panel);
  padding: 1.5rem;
  box-shadow: var(--shadow-neo-sm);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-fast), background-color var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.med-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.med-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-neo-lg);
  border-color: var(--color-primary);
}

.med-card:hover::before {
  opacity: 1;
}

/* === INPUTS (M3 + Neumorphism Mejorado) === */
input,
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 2px solid var(--border-subtle);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-input);
  font-family: inherit;
  font-size: 16px; /* Prevent iOS auto-zoom (must be >= 16px) */
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-inset);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-inset), var(--shadow-neo-sm);
  background: var(--bg-surface);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-inset), 0 0 0 4px var(--accent-container);
  background: var(--bg-surface);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

/* Explicit Fix for Select Contrast */
select option {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

label {
  display: block;
  margin-bottom: 12px;
}

.muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.mono {
  font-family: var(--font-mono);
}

/* === BUTTONS (M3 + Neumorphism) === */
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-neo-md);
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.nav-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transition: left var(--transition-fast);
}

.nav-btn:hover::before {
  left: 100%;
}

.nav-btn:hover {
  background: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-neo-lg);
}

.nav-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-neo-md);
}

.nav-btn--ghost {
  background: var(--accent-container);
  color: var(--color-primary);
  box-shadow: var(--shadow-neo-xs);
}

.nav-btn--ghost:hover {
  background: var(--accent-soft);
  box-shadow: var(--shadow-neo-sm);
  transform: translateY(-1px);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* === FILLED BUTTON === */
button[type="submit"],
button.btn-filled {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-neo-md);
  position: relative;
  overflow: hidden;
}

button[type="submit"]::before,
button.btn-filled::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transition: left var(--transition-fast);
}

button[type="submit"]:hover,
button.btn-filled:hover {
  background: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-neo-lg);
}

button[type="submit"]:hover::before,
button.btn-filled:hover::before {
  left: 100%;
}

/* === OUTLINED BUTTON === */
button.btn-outlined {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  padding: 11px 23px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

button.btn-outlined:hover {
  background: var(--accent-container);
  box-shadow: var(--shadow-neo-md);
  transform: translateY(-1px);
}

/* === TONAL BUTTON === */
button.btn-tonal {
  background: var(--accent-container);
  color: var(--color-primary);
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-neo-xs);
}

button.btn-tonal:hover {
  background: var(--accent-soft);
  box-shadow: var(--shadow-neo-md);
  transform: translateY(-1px);
}

/* === TABLES (M3 Style Mejorado) === */
.ritual-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border-radius: var(--radius-panel);
  overflow: hidden;
  box-shadow: var(--shadow-neo-md);
}

.ritual-table th {
  text-align: left;
  padding: 16px 14px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: var(--font-base);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border-subtle);
}

.ritual-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 14px;
}

.ritual-table tr:last-child td {
  border-bottom: none;
}

.ritual-table tbody tr {
  transition: background-color var(--transition-fast);
}

.ritual-table tbody tr:hover {
  background: var(--accent-soft);
}

/* Pills & Chips */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-container);
  border: 1px solid var(--color-primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-primary);
  transition: all var(--transition-fast);
  cursor: default;
}

.pill:hover {
  background: var(--accent-soft);
  box-shadow: var(--shadow-neo-sm);
}

/* Animations - Mejoradas */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn var(--transition-smooth) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes staggerIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-in {
  animation: staggerIn var(--transition-smooth) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-down {
  animation: slideDown var(--transition-smooth) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.stagger-1 {
  animation-delay: 60ms;
}

.stagger-2 {
  animation-delay: 120ms;
}

.stagger-3 {
  animation-delay: 180ms;
}

.stagger-4 {
  animation-delay: 240ms;
}

.stagger-5 {
  animation-delay: 300ms;
}

/* Responsive Adjustments */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 270px;
    transform: translateX(-110%);
    transition: transform var(--transition-smooth);
    z-index: 180;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.3);
  }

  .bottom-nav {
    display: grid;
  }

  .main {
    padding: 1rem;
    padding-bottom: 80px;
  }

  .container {
    padding: 0;
  }
}

@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .m3-header {
    padding: 0 16px;
  }

  .nav-btn,
  button.btn-filled {
    padding: 10px 18px;
    font-size: 0.8rem;
  }

  .med-card {
    padding: 1.25rem;
  }

  .home-hero-card {
    padding: 32px 20px;
  }

  .dashboard-card {
    padding: 16px 12px;
  }

  input,
  select,
  textarea {
    padding: 10px 14px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.75rem;
    letter-spacing: -0.01em;
  }

  h2 {
    font-size: 1.25rem;
  }

  .m3-header {
    height: 56px;
    padding: 0 12px;
  }

  .m3-sidebar {
    width: 100%;
  }

  .nav-btn,
  button.btn-filled {
    padding: 10px 16px;
    font-size: 0.75rem;
  }

  .home-hero-card {
    border-radius: 16px;
    padding: 24px 16px;
    margin: 12px;
  }

  .home-hero-card h1 {
    font-size: 22px;
  }

  .modal {
    border-radius: 20px;
    max-width: 90vw;
  }

  .modal-header {
    padding: 28px 24px 16px;
  }

  .modal-body {
    padding: 0 24px 20px;
  }

  .modal-footer {
    padding: 24px;
  }
}

/* Specific view styles */
.home-hero {
  background: linear-gradient(135deg, var(--ritual-red-muted), var(--accent-muted));
  border: 1px solid var(--glass-border);
}

/* Radar specific styles if needed */
.comp-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1200px) {
  .comp-grid {
    grid-template-columns: 400px 1fr;
  }
}

/* Utility classes for results */
.risk-pill {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
}

.risk-pill--low {
  background: var(--risk-low);
}

.risk-pill--mod {
  background: var(--risk-mod);
}

/* ==========================================================================
   ARCADE EXPANSION STYLES (GuruGame)
   ========================================================================== */

.arcade-view {
  background: #000 !important;
  color: #0f0 !important;
  font-family: var(--font-mono) !important;
  padding: 20px;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 255, 0, 0.1), inset 0 0 100px rgba(0, 0, 0, 1);
  border: 10px solid #222;
  min-height: 500px;
}

/* CRT Scanline Effect */
.arcade-view::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  z-index: 2;
  background-size: 100% 4px, 3px 100%;
  pointer-events: none;
}

/* Glitch/Flicker Animation */
@keyframes crt-flicker {
  0% {
    opacity: 0.97;
  }

  5% {
    opacity: 0.95;
  }

  10% {
    opacity: 0.9;
  }

  15% {
    opacity: 0.95;
  }

  20% {
    opacity: 0.98;
  }

  50% {
    opacity: 1;
  }

  80% {
    opacity: 0.95;
  }

  100% {
    opacity: 0.99;
  }
}

.arcade-view::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(18, 16, 16, 0.1);
  opacity: 0;
  z-index: 2;
  pointer-events: none;
  animation: crt-flicker 0.15s infinite;
}

.retro-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #0f0;
  padding-bottom: 10px;
  margin-bottom: 20px;
  font-size: 14px;
}

.arcade-logo {
  font-size: 80px;
  font-weight: 900;
  text-align: center;
  color: #fff;
  text-shadow: 4px 4px #f00, -4px -4px #00f, 0 0 20px rgba(255, 255, 255, 0.5);
  margin-top: 40px;
}

.arcade-sublogo {
  font-size: 20px;
  text-align: center;
  color: #0f0;
  margin-bottom: 60px;
  letter-spacing: 4px;
}

.blink-text {
  animation: blink 0.8s infinite;
  text-align: center;
  font-weight: bold;
}

@keyframes blink {

  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

.push-start {
  cursor: pointer;
  background: #0f0;
  color: #000;
  padding: 10px 20px;
  display: inline-block;
  margin: 0 auto;
  display: block;
  width: fit-content;
}

/* Highscore entry */
.highscore-entry {
  text-align: center;
  padding-top: 20px;
}

.initials-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 40px 0;
}

.initial-box {
  background: #111;
  border: 2px solid #333;
  width: 60px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.initial-box.active {
  border-color: #0f0;
  box-shadow: 0 0 10px #0f0;
}

.initial-box .char {
  font-size: 40px;
  font-weight: bold;
}

.initial-box .arrow {
  cursor: pointer;
  font-size: 12px;
  color: #444;
}

.initial-box.active .arrow {
  color: #0f0;
}

.retro-btn-confirm {
  background: #f0f;
  color: #fff;
  border: none;
  padding: 15px 30px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 4px 4px #505;
}

.retro-btn-confirm:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px #505;
}

/* Leaderboard */
.leaderboard {
  padding: 20px;
}

.retro-table {
  width: 100%;
  border-spacing: 0 10px;
  font-size: 20px;
}

.retro-table td {
  padding: 10px;
  border-bottom: 2px dashed #222;
}

/* Feedback correctly styled for arcade */
.retro-feedback.correct {
  border: 4px solid #0f0;
  padding: 40px;
  text-align: center;
  background: rgba(0, 255, 0, 0.1);
}

.retro-msg {
  font-size: 40px;
  margin-bottom: 10px;
}

.retro-option-btn {
  background: #111;
  border: 2px solid #0f0;
  color: #0f0;
  padding: 15px;
  width: 100%;
  text-align: left;
  margin-bottom: 10px;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.1s;
}

.retro-option-btn:hover {
  background: #0f0;
  color: #000;
}

.retro-q-text {
  font-size: 20px;
  line-height: 1.4;
  margin-bottom: 20px;
  color: #fff;
}

.retro-hint {
  font-size: 12px;
  color: #888;
  margin-bottom: 30px;
}

/* Comparador */
.comp-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  min-width: 520px;
}

.comp-table th,
.comp-table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.comp-table th:first-child,
.comp-table td:first-child {
  width: 140px;
  font-weight: 800;
  color: var(--text-main);
}

/* Switching */
.switch-visuals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.switch-visual-card {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px;
  background: var(--bg-elevated);
}

.switch-visual-card h4 {
  margin: 0 0 6px;
  font-size: 12px;
}

.switch-visual-card p {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* Ajuste de dosis */
.dose-grid {
  display: grid;
  gap: 12px;
}

.dose-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 12px 14px;
}

.dose-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
}

.dose-panel h5 {
  margin: 0 0 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* Bio-Profiling Styles */
.risk-profile-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

.risk-profile-title {
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.risk-item {
  margin-bottom: 12px;
}

.risk-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.risk-bar-bg {
  height: 6px;
  background: var(--bg-app);
  border-radius: 3px;
  overflow: hidden;
}

.risk-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Footer Contrast Enhancement */
.main .muted[style*="font-size: 12px"],
.main .muted[style*="font-size: 11px"] {
  color: var(--text-main) !important;
  opacity: 0.75;
}

/* Adjustment Search & Chips */
.chip-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-app);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--color-secondary);
  color: var(--text-main);
}

.chip.active {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: white;
}

#adj-search {
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  transition: all 0.2s ease;
}

#adj-search:focus {
  border-color: var(--color-secondary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(183, 28, 28, 0.1);
}

@media (max-width: 600px) {
  .risk-profile-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Custom toggle for dark mode */
#toggleDarkMode {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

#toggleDarkMode:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

/* --- MODALS & OVERLAYS --- */
#disclaimer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex !important;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

#disclaimer-backdrop[aria-hidden="true"] {
  display: none !important;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  display: flex !important;
  flex-direction: column;
  box-shadow: var(--shadow-neo-xl);
  overflow: hidden;
  animation: modalCascade 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalCascade {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 36px 32px 20px;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
  margin: 0;
  font-size: 26px;
  font-family: var(--font-base) !important;
  font-weight: 700;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-body {
  padding: 0 32px 24px;
  overflow-y: auto;
  font-size: 15px;
  color: var(--text-main);
}

.modal-body p {
  margin-bottom: 16px;
}

.modal-list {
  padding-left: 20px;
  margin: 16px 0;
}

.modal-list li {
  margin-bottom: 12px;
  color: var(--text-muted);
}

.modal-footer {
  padding: 32px;
  background: var(--bg-app);
  border-top: 1px solid var(--border-subtle);
  display: flex !important;
  flex-direction: column;
  gap: 20px;
}

.modal-consent {
  display: flex !important;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-consent input {
  width: 22px;
  height: 22px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

#disclaimer-accept {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  border-radius: 16px;
}


.donation-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.2px;
  color: #1f1301;
  background: linear-gradient(135deg, #ffd866 0%, #ffb347 45%, #ff8a00 100%);
  box-shadow: 0 8px 20px rgba(255, 138, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.donation-cta:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 12px 26px rgba(255, 138, 0, 0.45);
  filter: saturate(1.08);
}

.donation-cta:focus-visible {
  outline: 2px solid #ffd866;
  outline-offset: 2px;
}

.donation-cta--inline {
  margin-top: 6px;
}

.donation-cta--small {
  padding: 8px 14px;
  font-size: 12px;
  margin-top: 0;
  box-shadow: 0 4px 12px rgba(255, 138, 0, 0.25);
}

/* --- TOAST FIX --- */
.toast-ritual {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 12px 24px;
  border-radius: 999px;
  box-shadow: var(--shadow-neo-lg);
  border: 1px solid var(--color-secondary);
  z-index: 10000;
  font-weight: 700;
  font-size: 14px;
}

@keyframes star-pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.8;
  }
}

.suggested-strategy span {
  animation: star-pulse 2s infinite ease-in-out;
}

/* --- LAI TO ORAL EQUIVALENCY TABLE --- */
.laivo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.laivo-table th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  text-align: left;
  padding: 12px 16px;
  font-family: var(--font-ritual);
  font-weight: 700;
  font-size: 14px;
  border-bottom: 2px solid var(--border-subtle);
}

.laivo-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.laivo-table tr:last-child td {
  border-bottom: none;
}

.laivo-table tr.highlight-row {
  background: rgba(196, 69, 92, 0.05);
  border-left: 4px solid var(--color-secondary);
}

.laivo-table tr.highlight-row td:first-child {
  color: var(--color-secondary);
}

@media (max-width: 600px) {

  .laivo-table th:nth-child(2),
  .laivo-table td:nth-child(2) {
    display: none;
  }

  .laivo-table th:nth-child(4),
  .laivo-table td:nth-child(4) {
    display: none;
  }
}

/* Mobile Dock Optimization */
@media (max-width: 600px) {
  .dock-panel {
    gap: 8px;
    padding: 8px;
    border-radius: 16px;
  }

  .dock-item {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .dock-icon {
    width: 30px;
    height: 30px;
  }

  .dock-panel::-webkit-scrollbar {
    display: none;
  }
}

/* Install banner polish */
.install-banner[hidden] {
  display: none !important;
}

.install-banner {
  position: fixed;
  left: 50%;
  top: 70px;
  transform: translateX(-50%);
  width: min(90vw, 480px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(31, 78, 159, 0.08), rgba(91, 127, 208, 0.08));
  border: 1px solid rgba(91, 127, 208, 0.3);
  box-shadow: 0 8px 24px rgba(31, 78, 159, 0.12);
  backdrop-filter: blur(12px);
  z-index: 4200;
}

[data-theme="dark"] .install-banner {
  background: linear-gradient(135deg, rgba(31, 78, 159, 0.12), rgba(91, 127, 208, 0.08));
  box-shadow: 0 8px 24px rgba(31, 78, 159, 0.2);
}

.install-banner__text {
  flex: 1;
  min-width: 0;
}

.install-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
  margin-bottom: 2px;
}

.install-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.install-banner__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.install-btn-primary,
.install-btn-dismiss {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.install-btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(31, 78, 159, 0.3);
}

.install-btn-primary:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 6px 16px rgba(31, 78, 159, 0.4);
  transform: translateY(-1px);
}

.install-btn-primary:active {
  transform: translateY(0);
}

.install-btn-dismiss {
  background: transparent;
  color: var(--text-muted);
  min-width: auto;
  padding: 6px 10px;
  font-size: 18px;
  line-height: 1;
}

.install-btn-dismiss:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

@media (max-width: 600px) {
  .install-banner {
    top: 70px;
    width: min(92vw, 360px);
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 14px;
  }

  .install-banner__text {
    text-align: center;
  }

  .install-title {
    font-size: 14px;
  }

  .install-subtitle {
    font-size: 12px;
  }

  .install-banner__actions {
    width: 100%;
    justify-content: center;
  }

  .install-btn-primary {
    flex: 1;
    min-width: 0;
  }
}

/* --- CLINICAL EFFECT TAGS --- */
.effect-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.tag--sep {
  background: rgba(225, 29, 72, 0.1);
  color: #E11D48;
  border: 1px solid rgba(225, 29, 72, 0.2);
}

.tag--metabolic {
  background: rgba(245, 158, 11, 0.1);
  color: #F59E0B;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.tag--cardio {
  background: rgba(59, 130, 246, 0.1);
  color: #3B82F6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.tag--other {
  background: rgba(148, 163, 184, 0.1);
  color: #94A3B8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

/* ============================================================ 
   RETRO GAME: GURU DE LOS ANTIPSICÓTICOS 
   ============================================================ */

:root {
  --retro-green: #001a00;
  --retro-bg: #c0c0c0;
  --retro-panel: #efefef;
  --retro-border-dark: #404040;
  --retro-border-light: #ffffff;
  --retro-blue: #000080;
  --retro-font: 'MS Sans Serif', 'Tahoma', 'Courier New', sans-serif;
}

.retro-game-wrapper {
  background-color: var(--retro-bg);
  color: var(--retro-green);
  font-family: var(--retro-font);
  padding: 1rem;
  border: 2px solid var(--retro-border-dark);
  border-top-color: var(--retro-border-light);
  border-left-color: var(--retro-border-light);
  border-radius: 0;
  max-width: 680px;
  margin: 1rem auto;
  box-shadow: 2px 2px 0 #000;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  text-transform: uppercase;
}

.retro-header {
  background: linear-gradient(90deg, var(--retro-blue), #1084d0);
  color: #fff;
  padding: 0.35rem 0.5rem;
  margin: -1rem -1rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.retro-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.retro-score {
  font-size: 0.9rem;
  background: #000;
  color: #00ff00;
  padding: 2px 8px;
  border: 1px inset #bbb;
}

.retro-question-box {
  background: var(--retro-panel);
  padding: 1rem;
  border: 2px inset #d8d8d8;
  margin-bottom: 1.25rem;
  min-height: 120px;
}

.retro-q-text {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

.retro-hint {
  font-size: 1.1rem;
  font-weight: bold;
}

.retro-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.retro-option-btn {
  background: #e0e0e0;
  border: 2px outset #d8d8d8;
  color: #111;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  font-family: var(--retro-font);
  transition: all 0.1s ease;
  font-size: 0.95rem;
}

.retro-option-btn:hover {
  background: #d6ecff;
}

.retro-option-btn:active {
  border-style: inset;
}

.pixel-bullet {
  margin-right: 8px;
}

.retro-footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
}

.retro-btn-exit {
  background: #e0e0e0;
  color: #111;
  border: 2px outset #d8d8d8;
  padding: 8px 16px;
  font-family: var(--retro-font);
  cursor: pointer;
}

.retro-btn-exit:hover {
  background: #d6ecff;
}

.retro-btn-exit:active {
  border-style: inset;
}

.retro-feedback {
  text-align: center;
  padding: 2rem;
  background: var(--retro-panel);
  border: 2px inset #d8d8d8;
  margin-top: 1rem;
}

.retro-feedback.correct .retro-msg {
  color: var(--retro-green);
}

.retro-feedback.incorrect .retro-msg {
  color: #ff0000;
}

.retro-msg {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.retro-submsg {
  margin-bottom: 1.5rem;
  opacity: 0.7;
}

.retro-btn {
  background: #e0e0e0;
  color: #111;
  border: 2px outset #d8d8d8;
  padding: 10px 20px;
  font-family: var(--retro-font);
  font-weight: bold;
  cursor: pointer;
}

.retro-btn:active {
  border-style: inset;
}

.retro-game-body {
  flex: 1;
  padding: 0.5rem 0;
}

.next-btn {
  background: #0078d7;
  color: #fff;
  border-color: #005a9e;
}

.next-btn:hover {
  background: #005a9e;
}

.animate-pop {
  animation: retroPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes retroPop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .retro-game-wrapper {
    margin: 0;
    width: 100%;
    min-height: 100vh;
    border: none;
  }
}

/* ============================================================
   AFINIDAD POR RECEPTORES — Binding Bar Visualization
   ============================================================ */

.afin-view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0 3rem;
}

.afin-page-header {
  padding: 1.5rem 1rem 1rem;
}

/* Legend card */
.afin-legend-card {
  margin: 0 1rem 1rem;
}

.afin-legend-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.afin-legend-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}

.afin-legend-family {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.afin-legend-family-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 80px;
}

.afin-legend-items {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.afin-legend-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.afin-legend-sq {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid;
  flex-shrink: 0;
}

.afin-legend-lbl {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.afin-legend-footer {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.7;
}

.afin-d2-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #ef4444;
  border-radius: 3px;
  background: #ef444420;
  flex-shrink: 0;
}

/* Chart card */
.afin-chart-card {
  margin: 0 1rem;
  padding: 1rem 0.75rem;
  overflow: hidden;
}

.afin-chart-scroll {
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

/* Axis header */
.afin-axis-header-row {
  display: flex;
  align-items: flex-end;
  margin-bottom: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.afin-axis-header-inner {
  position: relative;
  height: 36px;
  flex-shrink: 0;
}

.afin-axis-arrow {
  position: absolute;
  font-size: 10px;
  color: var(--text-muted);
  top: 0;
  white-space: nowrap;
  font-style: italic;
}

.afin-axis-arrow--left  { left: 0; }
.afin-axis-arrow--right { right: 0; }

.afin-axis-ticks {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 16px;
}

.afin-axis-tick {
  position: absolute;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  bottom: 0;
}

/* Groups */
.afin-groups-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.afin-group {
  margin-top: 0.75rem;
}

.afin-group-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2px;
}

.afin-group-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.afin-group-note {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* Drug rows */
.afin-row {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 6px 0;
  border-radius: 6px;
  transition: background 0.15s;
}

.afin-row:hover {
  background: var(--bg-elevated);
}

.afin-drug-label {
  flex-shrink: 0;
  width: 140px;
  min-width: 140px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  position: sticky;
  left: 0;
  background: var(--bg-surface);
  z-index: 3;
  border-right: 1px solid var(--border-subtle);
}

.afin-row:hover .afin-drug-label {
  background: var(--bg-elevated);
}

/* Track */
.afin-track-outer {
  overflow: visible;
  flex: 1;
}

.afin-track {
  position: relative;
  flex-shrink: 0;
}

/* D2 reference line */
.afin-ref-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dashed #ef4444;
  opacity: 0.6;
  z-index: 1;
  pointer-events: none;
}

/* Horizontal axis line through center */
.afin-axis-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--border-subtle);
  z-index: 0;
  pointer-events: none;
}

/* Receptor squares */
.afin-sq {
  position: absolute;
  border-radius: 4px;
  cursor: default;
  z-index: 2;
  transition: transform 0.12s ease, z-index 0s;
}

.afin-sq:hover {
  transform: scale(1.45);
  z-index: 20;
}

.afin-sq--d2 {
  z-index: 4;
}

.afin-sq--d2:hover {
  transform: scale(1.3);
  z-index: 20;
}

/* CSS tooltip via data-afin-tip */
.afin-sq::after {
  content: attr(data-afin-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.1);
}

.afin-sq:hover::after {
  opacity: 1;
}

/* Small badge label inside NET/SERT squares */
.afin-sq-badge-lbl {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Dark theme tooltip */
.theme-dark .afin-sq::after {
  background: #0f172a;
  border-color: rgba(255,255,255,0.15);
}

/* Responsive: smaller label column on mobile */
@media (max-width: 680px) {
  .afin-drug-label {
    width: 90px;
    min-width: 90px;
    font-size: 11px;
  }

  .afin-legend-grid {
    gap: 8px 12px;
  }

  .afin-legend-family-name {
    min-width: 70px;
    font-size: 10px;
  }

  .afin-legend-lbl {
    font-size: 10px;
  }

  .afin-group-note {
    display: none;
  }
}

/* ============================================================
   DOCK ACTIVE STATE
   ============================================================ */
.dock-item.active .dock-icon {
  color: var(--accent);
}

.dock-item.active {
  background: var(--accent-muted);
  border-radius: 12px;
}

.dock-item.active .dock-label {
  color: var(--accent);
}

/* ============================================================
   COMMAND PALETTE TRIGGER BUTTON
   ============================================================ */
.cmd-trigger {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 2500;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.15s;
  box-shadow: var(--shadow-neo-sm);
  padding: 0;
}

.cmd-trigger svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cmd-trigger:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
  transform: scale(1.05);
}

/* ============================================================
   COMMAND PALETTE OVERLAY
   ============================================================ */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.cmd-palette-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cmd-palette {
  width: min(92vw, 580px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255,255,255,0.06);
  overflow: hidden;
  transform: translateY(-12px) scale(0.98);
  transition: transform 0.18s ease;
}

.cmd-palette-overlay.open .cmd-palette {
  transform: translateY(0) scale(1);
}

.cmd-palette__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.cmd-palette__icon {
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.cmd-palette__header input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  font-family: var(--font-base);
}

.cmd-palette__header input::placeholder {
  color: var(--text-muted);
}

.cmd-palette__esc {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  cursor: pointer;
  flex-shrink: 0;
}

.cmd-palette__results {
  max-height: 380px;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
}

.cmd-palette__group-label {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.cmd-palette__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 0;
}

.cmd-palette__item:hover,
.cmd-palette__item.active {
  background: var(--accent-muted);
}

.cmd-palette__item.active .cmd-palette__item-label {
  color: var(--accent);
}

.cmd-palette__item-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 5px;
  color: var(--text-muted);
}

.cmd-palette__item.active .cmd-palette__item-icon {
  color: var(--accent);
}

.cmd-palette__item-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cmd-palette__item-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cmd-palette__item-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-palette__item-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-palette__empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.cmd-palette__footer {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.cmd-palette__footer kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
}

.cmd-palette__shortcut {
  margin-left: auto;
}

@media (max-width: 600px) {
  .cmd-palette__shortcut {
    display: none;
  }
  .cmd-palette__footer {
    gap: 8px;
  }
}

/* ============================================================
   RISK BADGES (Quick Reference Table)
   ============================================================ */
.risk-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.risk-badge--risk-none {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.risk-badge--risk-low {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.risk-badge--risk-mod {
  background: rgba(245, 158, 11, 0.12);
  color: #D97706;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.risk-badge--risk-high {
  background: rgba(239, 68, 68, 0.12);
  color: #DC2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ============================================================
   QUICK REFERENCE TABLE
   ============================================================ */
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ref-table th {
  background: var(--bg-elevated);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.ref-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.ref-table tbody tr:last-child td {
  border-bottom: none;
}

.ref-table tbody tr:hover {
  background: var(--accent-muted);
}

.ref-table tbody tr:hover td {
  color: var(--text-main);
}

/* Filter chips */
.filter-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-chip.active {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 700px) {
  .ref-table th:nth-child(10),
  .ref-table td:nth-child(10) {
    display: none;
  }
}

@media (max-width: 540px) {
  .ref-table th:nth-child(3),
  .ref-table td:nth-child(3) {
    display: none;
  }
}

/* ==========================================================================
   MATERIAL 3 REDESIGN — Modernización 2026
   Secuencia: nav → home → ficha → comparador → visual
   ========================================================================== */

/* --- M3 TOKENS ----------------------------------------------------------- */
:root {
  --m3-primary: var(--color-secondary);
  --m3-primary-container: rgba(225, 29, 72, 0.12);
  --m3-on-primary: #ffffff;
  --m3-surface: var(--bg-surface);
  --m3-surface-variant: var(--bg-elevated);
  --m3-outline: var(--border-subtle);
  --m3-outline-variant: var(--border-strong);
  --m3-nav-height: 72px;
  --m3-radius-xs: 8px;
  --m3-radius-sm: 12px;
  --m3-radius-md: 16px;
  --m3-radius-lg: 24px;
  --m3-radius-full: 999px;
  --m3-motion-standard: 300ms cubic-bezier(0.2, 0, 0, 1);
  --m3-motion-decelerate: 250ms cubic-bezier(0, 0, 0, 1);
  --m3-motion-enter: 400ms cubic-bezier(0.05, 0.7, 0.1, 1);
  --m3-elevation-1: 0 1px 2px rgba(0,0,0,.07), 0 1px 3px 1px rgba(0,0,0,.05);
  --m3-elevation-2: 0 1px 2px rgba(0,0,0,.07), 0 2px 6px 2px rgba(0,0,0,.07);
  --m3-elevation-3: 0 4px 8px 3px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.08);
}

/* app-content gets extra bottom padding for M3 nav + safe area */
.app-content {
  padding-bottom: calc(var(--m3-nav-height) + env(safe-area-inset-bottom, 0px) + 24px) !important;
}

/* --- M3 BOTTOM NAVIGATION ------------------------------------------------ */
.m3-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: var(--m3-nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--m3-outline);
  display: flex;
  align-items: stretch;
  z-index: 3000;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}

.m3-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px 4px 10px;
  position: relative;
  transition: color var(--m3-motion-standard);
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}

.m3-nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--m3-radius-xs);
}

/* Active indicator pill */
.m3-nav-indicator {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 64px;
  height: 32px;
  background: var(--m3-primary-container);
  border-radius: var(--m3-radius-full);
  transition: transform var(--m3-motion-enter), background var(--m3-motion-standard);
  z-index: 0;
}

.m3-nav-item.active .m3-nav-indicator {
  transform: translateX(-50%) scaleX(1);
}

.m3-nav-item.active {
  color: var(--m3-primary);
}

.m3-nav-icon {
  width: 24px;
  height: 24px;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--m3-motion-enter);
}

.m3-nav-item.active .m3-nav-icon {
  transform: translateY(-1px);
}

.m3-nav-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-width var(--m3-motion-standard);
}

.m3-nav-item.active .m3-nav-icon svg {
  stroke-width: 2.5;
}

.m3-nav-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1;
  position: relative;
  z-index: 1;
  transition: font-weight var(--m3-motion-standard);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 68px;
}

.m3-nav-item.active .m3-nav-label {
  font-weight: 700;
}

/* --- BOTTOM SHEET -------------------------------------------------------- */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  z-index: 3100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--m3-motion-standard);
}

.bottom-sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-radius: var(--m3-radius-lg) var(--m3-radius-lg) 0 0;
  z-index: 3200;
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: none;
  transform: translateY(100%);
  transition: transform var(--m3-motion-decelerate);
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.bottom-sheet.open {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--m3-outline);
  margin: 12px auto 0;
}

.bottom-sheet-title {
  padding: 16px 20px 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.bottom-sheet-divider {
  height: 1px;
  background: var(--m3-outline);
  margin: 4px 20px 8px;
}

.bottom-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 16px 24px;
}

@media (min-width: 480px) {
  .bottom-sheet-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.sheet-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--m3-radius-md);
  border: 1px solid var(--m3-outline);
  background: var(--bg-surface);
  cursor: pointer;
  color: var(--text-main);
  transition: background var(--m3-motion-standard), border-color var(--m3-motion-standard),
              transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

.sheet-nav-item:hover {
  background: var(--m3-primary-container);
  border-color: var(--m3-primary);
}

.sheet-nav-item:active {
  transform: scale(0.96);
}

.sheet-nav-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--m3-primary);
}

.sheet-nav-item span {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: var(--text-main);
}

.sheet-theme-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--m3-radius-md);
  border: 1px solid var(--m3-outline);
  background: var(--bg-surface);
  cursor: pointer;
  color: var(--text-main);
  margin: 0 16px 8px;
  transition: background var(--m3-motion-standard);
  font-size: 13px;
  font-weight: 600;
}

.sheet-theme-item:hover {
  background: var(--m3-primary-container);
}

.sheet-theme-icon {
  font-size: 20px;
}

/* --- HOME SEARCH HERO ---------------------------------------------------- */
.home-search-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 16px 20px;
  gap: 16px;
  background: var(--hero-gradient);
  border: 1px solid var(--border-subtle);
  border-radius: var(--m3-radius-lg);
  position: relative;
  overflow: hidden;
}

.home-search-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(225,29,72,.07), transparent);
  pointer-events: none;
}

.home-search-hero h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -.02em;
  color: var(--text-main);
  line-height: 1.1;
  font-family: var(--font-base);
}

.home-search-hero p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 380px;
}

.home-search-wrapper {
  position: relative;
  width: 100%;
  max-width: 520px;
}

.home-search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1.5px solid var(--m3-outline);
  border-radius: var(--m3-radius-full) !important;
  padding: 14px 20px 14px 48px !important;
  font-size: 15px;
  color: var(--text-main);
  font-family: var(--font-base);
  box-shadow: var(--m3-elevation-2);
  transition: border-color var(--m3-motion-standard), box-shadow var(--m3-motion-standard);
}

.home-search-input:focus {
  outline: none;
  border-color: var(--m3-primary) !important;
  box-shadow: var(--m3-elevation-3), 0 0 0 3px var(--m3-primary-container) !important;
}

.home-search-input::placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.home-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.home-search-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Quick task chips below search */
.home-task-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.home-task-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--m3-radius-full);
  border: 1px solid var(--m3-outline);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
  white-space: nowrap;
  box-shadow: var(--m3-elevation-1);
  -webkit-tap-highlight-color: transparent;
}

.home-task-chip:hover {
  background: var(--m3-primary-container);
  border-color: var(--m3-primary);
  color: var(--m3-primary);
  transform: translateY(-1px);
  box-shadow: var(--m3-elevation-2);
}

.home-task-chip:active {
  transform: translateY(0);
}

/* --- RECENTS SECTION ----------------------------------------------------- */
.recents-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recents-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.recents-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.recents-list::-webkit-scrollbar {
  display: none;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--m3-radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--m3-outline);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  transition: all 120ms ease;
  flex-shrink: 0;
  box-shadow: var(--m3-elevation-1);
}

.recent-chip:hover {
  background: var(--m3-primary-container);
  border-color: var(--m3-primary);
  color: var(--m3-primary);
}

.recent-chip svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.6;
}

/* --- CLINICAL RISK CHIPS (M3 redesign) ----------------------------------- */
.risk-chip-m3 {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--m3-radius-xs);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  font-family: var(--font-base);
  line-height: 1.4;
}

.risk-chip-m3 .risk-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.risk-chip-m3--low {
  background: rgba(16,185,129,.1);
  color: #059669;
  border: 1px solid rgba(16,185,129,.25);
}
.risk-chip-m3--low .risk-dot { background: #10b981; }

.risk-chip-m3--mod {
  background: rgba(245,158,11,.1);
  color: #d97706;
  border: 1px solid rgba(245,158,11,.25);
}
.risk-chip-m3--mod .risk-dot { background: #f59e0b; }

.risk-chip-m3--high {
  background: rgba(239,68,68,.1);
  color: #dc2626;
  border: 1px solid rgba(239,68,68,.25);
  font-weight: 800;
}
.risk-chip-m3--high .risk-dot { background: #ef4444; }

.risk-chip-m3--none {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--m3-outline);
  font-weight: 500;
}
.risk-chip-m3--none .risk-dot { background: var(--text-muted); opacity: 0.4; }

/* --- MED CARD DETAILS EXPAND (M3 polish) --------------------------------- */
.med-card__details {
  border: none !important;
  border-top: 1px solid var(--m3-outline) !important;
  padding-top: 10px !important;
  margin-top: 12px !important;
}

.med-card__details > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 2px 0;
  transition: color var(--m3-motion-standard);
}

.med-card__details > summary::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  transition: transform var(--m3-motion-standard);
  margin-left: auto;
  flex-shrink: 0;
}

.med-card__details[open] > summary::after {
  transform: rotate(180deg);
}

.med-card__details > summary:hover {
  color: var(--text-main);
}

.med-card__details > summary::-webkit-details-marker {
  display: none;
}

/* PK section inside details */
.pk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.pk-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-radius-sm);
  padding: 8px 10px;
}

.pk-cell__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.pk-cell__value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

/* --- SKELETON LOADERS ---------------------------------------------------- */
@keyframes skeleton-shimmer {
  from { background-position: -200% 0; }
  to   { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--bg-elevated) 25%,
    var(--bg-surface)  50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--m3-radius-sm);
}

.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
}
.skeleton-line--sm  { height: 10px; width: 60%; }
.skeleton-line--lg  { height: 16px; }
.skeleton-chips {
  display: flex;
  gap: 6px;
}
.skeleton-chip {
  height: 22px;
  width: 60px;
  border-radius: var(--m3-radius-full);
}

/* --- CMD TRIGGER (updated position for M3) ------------------------------- */
.cmd-trigger {
  position: fixed;
  top: 8px;
  right: 12px;
  z-index: 150; /* inside header stack */
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-radius-full);
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--m3-motion-standard);
}

@media (max-width: 480px) {
  .cmd-trigger {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    top: 10px;
    right: 8px;
  }
}

.cmd-trigger:hover {
  color: var(--m3-primary);
  border-color: var(--m3-primary);
  background: var(--m3-primary-container);
}

.cmd-trigger svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- INSTALL BANNER (M3 polish) ----------------------------------------- */
.install-banner {
  position: fixed;
  bottom: calc(var(--m3-nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2500;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-radius-lg);
  padding: 12px 16px;
  box-shadow: var(--m3-elevation-3);
  max-width: min(420px, calc(100vw - 32px));
  width: 100%;
}

/* --- FARMACOS TABS (M3 style) -------------------------------------------- */
.m3-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-elevated);
  border-radius: var(--m3-radius-sm);
  padding: 4px;
  margin-bottom: 16px;
}

.m3-tab {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: var(--m3-radius-xs);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--m3-motion-standard);
}

.m3-tab.active {
  background: var(--bg-surface);
  color: var(--m3-primary);
  box-shadow: var(--m3-elevation-1);
}

/* --- PERLA CLÍNICA (M3 redesign) ----------------------------------------- */
.perla-card {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(59,130,246,.06);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--m3-radius-sm) var(--m3-radius-sm) 0;
}

.perla-card__label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 4px;
}

.perla-card__text {
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.45;
}

/* --- HOME QUICK CARDS (M3 style) ---------------------------------------- */
.home-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.home-quick-card {
  background: var(--bg-surface);
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-radius-md);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  transition: all var(--m3-motion-standard);
  box-shadow: var(--m3-elevation-1);
}

.home-quick-card:hover {
  background: var(--m3-primary-container);
  border-color: var(--m3-primary);
  box-shadow: var(--m3-elevation-2);
  transform: translateY(-2px);
}

.home-quick-card:active {
  transform: translateY(0);
}

.home-quick-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--m3-radius-sm);
  background: var(--m3-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--m3-primary);
}

.home-quick-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-quick-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.home-quick-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Feature primary card */
.home-feature-card {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all var(--m3-motion-standard);
  box-shadow: var(--m3-elevation-1);
}

.home-feature-card:hover {
  border-color: var(--m3-primary);
  box-shadow: var(--m3-elevation-2), 0 0 0 1px var(--m3-primary-container);
  transform: translateY(-2px);
}

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

.home-feature-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
}

.home-feature-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.home-feature-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--m3-radius-md);
  background: var(--m3-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--m3-primary);
}

.home-feature-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* DB count badge */
.home-db-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--m3-radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--m3-outline);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* --- MOTION: page transition ---------------------------------------------- */
@keyframes m3FadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.m3-fade-in {
  animation: m3FadeSlideIn var(--m3-motion-decelerate) both;
}