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

:root {
  --primary: #2358DE;
  --primary-dark: #1a45c0;
  --primary-soft: #eef2ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --nav-h: 68px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button, input, select { font-family: inherit; }

/* Shell centers content on large screens */
.app-shell {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--primary);
  color: #fff;
  padding: 14px 18px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.app-header .sub {
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 2px;
  font-weight: 400;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: none;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.icon-btn:hover,
.icon-btn:active {
  background: rgba(255,255,255,0.28);
  color: #fff;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 16px 6px;
}

.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.03);
}

.stat-number {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-card.warn .stat-number { color: var(--warn); }
.stat-card.urgent .stat-number { color: var(--danger); }

.stat-label {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 4px;
}

/* Views */
.view {
  display: none;
  padding: 4px 16px 28px;
  animation: fadeIn 0.2s ease;
}

.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.view-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 10px 0 12px;
  letter-spacing: -0.02em;
}

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filters::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Item cards */
.item-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 14px 14px 16px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.03);
  border-left: 4px solid #d1d5db;
}

.item-card.ok { border-left-color: var(--success); }
.item-card.soon { border-left-color: var(--warn); }
.item-card.expired {
  border-left-color: var(--danger);
  background: #fff8f8;
}

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

.item-body h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 3px;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.item-body p {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-ok { background: #d1fae5; color: #047857; }
.badge-soon { background: #fef3c7; color: #b45309; }
.badge-expired { background: #fee2e2; color: #b91c1c; }
.badge-otc { background: #d1fae5; color: #047857; }
.badge-rx { background: #fee2e2; color: #b91c1c; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 0;
}

/* Forms */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.03);
}

.form-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.form-card label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-card input,
.form-card select,
.form-card textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  margin-bottom: 12px;
  background: #fff;
  color: var(--text);
  appearance: none;
}

.form-card input:focus,
.form-card select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 88, 222, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

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

.btn-sm {
  width: auto;
  padding: 10px 16px;
  font-size: 0.85rem;
}

/* FAB */
.fab {
  position: fixed;
  right: max(18px, calc(50% - 340px + 18px));
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(35, 88, 222, 0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.fab.visible { display: flex; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: center;
  align-items: stretch;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.bottom-nav-inner {
  max-width: 680px;
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 4px;
  cursor: pointer;
  color: #9ca3af;
  font-size: 0.68rem;
  font-weight: 500;
  max-width: 90px;
  transition: color 0.15s;
}

.nav-item .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 600;
}

/* Kit */
.kit-row {
  background: var(--card);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.03);
  cursor: pointer;
}

.kit-row input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.kit-row h4 {
  font-size: 0.9rem;
  font-weight: 600;
}

.kit-row p {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.progress-wrap {
  background: #e5e7eb;
  border-radius: 999px;
  height: 8px;
  margin: 8px 0 14px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  width: 0%;
  transition: width 0.35s ease;
  border-radius: 999px;
}

/* Empty */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty .big {
  font-size: 2.75rem;
  margin-bottom: 10px;
  line-height: 1;
}

.empty strong {
  display: block;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 4px;
}

/* Modal */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}

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

.modal {
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 8px 18px 28px;
  width: 100%;
  max-width: 680px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0.5; }
  to { transform: none; opacity: 1; }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: #d1d5db;
  border-radius: 4px;
  margin: 8px auto 16px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 12px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
  font-weight: 500;
}
.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}
#exp-fecha-wrap {
  margin-bottom: 0;
}
.modal h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.modal-close {
  float: right;
  background: var(--bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-top: 16px;
  line-height: 1.5;
  border: 1px solid var(--border);
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.link-row a,
.link-row button {
  font-size: 0.8rem;
  padding: 9px 13px;
  border-radius: 10px;
  background: var(--primary-soft);
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

/* Pages (farmacias) */
.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px calc(var(--nav-h) + 24px);
}

.page h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  line-height: 1.25;
}

.page .lead {
  color: var(--muted);
  margin-bottom: 18px;
  font-size: 0.95rem;
}

.page .card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.03);
}

.page .card h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 650;
}

.page .card p,
.page .card li {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
}

.page ul {
  padding-left: 1.15rem;
  margin: 6px 0;
}

.page .highlight {
  background: var(--primary-soft);
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0 0 16px;
  font-size: 0.88rem;
  color: #1e3a8a;
  line-height: 1.5;
}

.sponsor-chip {
  display: inline-block;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  margin: 4px 4px 4px 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}

/* Cookie */
.cookie-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  z-index: 150;
  max-width: 656px;
  margin: 0 auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  font-size: 0.8rem;
  display: none;
  line-height: 1.45;
}

.cookie-banner .actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.cookie-banner .btn-primary {
  width: auto;
  padding: 9px 16px;
  font-size: 0.8rem;
}

.cookie-banner .btn-secondary {
  background: transparent;
  border: 1px solid #475569;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 500;
}

@media (min-width: 700px) {
  body { background: #e8ecf2; }
  .app-shell {
    box-shadow: 0 0 0 1px rgba(0,0,0,0.04), 0 20px 50px rgba(0,0,0,0.08);
    min-height: 100dvh;
    border-radius: 0;
  }
  .page {
    padding-left: 24px;
    padding-right: 24px;
  }
  .view {
    padding-left: 20px;
    padding-right: 20px;
  }
}


.wiki-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.wiki-link:hover { text-decoration: underline; }
