:root {
  --primary: #2A7F83;
  --offwhite: #eaeaea;
  --text-gray: #757575;
  --font-family: 'Roboto', Verdana, Geneva, Tahoma, sans-serif;
  --font-size-base: 16px;
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
}

body {
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  font-size: 0.85rem;
  background-color: var(--offwhite);
  padding: 0 0 2.5rem 0;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, span, a, div, td, th, li {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ========================================================= */
/* Global Persistent Site Header                             */
/* ========================================================= */
.global-site-header {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  border-bottom: 1px solid #d1d5db;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  position: sticky;
  top: 0;
  z-index: 999;
  margin-bottom: 1rem;
}

@media (min-width: 768px) {
  .global-site-header {
    margin-bottom: 1.5rem;
  }
}

.header-inner {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .header-inner {
    padding: 0.65rem 1.25rem;
    gap: 1rem;
  }
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
  transition: opacity 0.15s ease;
  min-width: 0;
  flex-shrink: 1;
}

.brand-link:hover {
  text-decoration: none;
  opacity: 0.85;
}

.brand-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .brand-logo {
    width: 24px;
    height: 24px;
  }
}

.brand-title {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .brand-title {
    font-size: 1.05rem;
  }
}

.brand-tld {
  color: #0d9488;
  font-weight: 900;
}

.brand-badge {
  display: none;
}

@media (min-width: 768px) {
  .brand-badge {
    display: inline-block;
    font-size: 0.65rem;
    background: #e0f2fe;
    color: #0369a1;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .header-nav {
    gap: 0.75rem;
  }
}

.nav-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.32rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  white-space: nowrap;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .nav-search-btn {
    font-size: 0.78rem;
    padding: 0.38rem 0.85rem;
    gap: 0.35rem;
  }
}

.nav-search-btn:hover {
  background: #206265;
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-1px);
}

.nav-btn-text-full {
  display: none;
}

.nav-btn-text-mobile {
  display: inline;
}

@media (min-width: 600px) {
  .nav-btn-text-full {
    display: inline;
  }
  .nav-btn-text-mobile {
    display: none;
  }
}

.header-nav-status {
  display: none;
}

@media (min-width: 768px) {
  .header-nav-status {
    display: inline-block;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
  }
}

h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  text-align: left;
}

h1, h2, h3 {
  color: var(--primary);
}

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

a:hover {
  text-decoration: underline;
}

.main {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.main p.subtitle {
  color: var(--primary);
  text-align: center;
  font-size: 0.8rem;
  margin-top: 0.2rem;
  margin-bottom: 0.5rem;
}

#searchForm {
  width: 100%;
  margin-bottom: 1.5rem;
}

#searchBox {
  color: var(--primary);
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #d4d4d4;
  border-radius: 0.5rem;
  font-size: 15px;
  background: #f1f3f5;
  outline: none;
  transition: 0.2s;
  margin-top: 0.8rem;
  font-family: var(--font-family);
}

#searchBox:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(42, 127, 131, 0.25);
}

#searchButton {
  width: 100%;
  padding: 10px 16px;
  margin-top: 8px;
  border: none;
  border-radius: 0.5rem;
  font-size: 15px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
  font-family: var(--font-family);
}

#searchButton:hover {
  background-color: var(--primary-hover);
}

.search-options {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 0.6rem;
  padding-left: 0.2rem;
}

.filter-refund-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: #4b5563;
  cursor: pointer;
  user-select: none;
}

.filter-refund-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.filter-refund-label:hover span {
  color: var(--primary);
}

.results {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.med-card {
  background: #ffffff;
  border-radius: 0.6rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
  border: 1px solid #e0e0e0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.med-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.ind-med {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.ind-med-left {
  flex: 1;
}

.ind-med-left h2 {
  text-align: left;
  line-height: 1.3rem;
  font-size: 1.05rem;
  color: var(--primary);
  margin-bottom: 0.2rem;
}

.ind-med-left h2 a {
  color: var(--primary);
}

.ind-med-left p {
  text-align: left;
  font-size: 0.75rem;
  color: var(--text-gray);
  line-height: 1.3;
}

.ind-med-right {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.atc-group {
  font-size: 0.78rem;
  background-color: var(--primary);
  color: var(--offwhite);
  font-weight: 600;
  text-align: left;
  padding: 0.35rem 0.6rem;
  margin-top: 0.6rem;
  margin-bottom: 0.5rem;
  border-radius: 0.4rem;
}

p.headline {
  color: var(--text-gray);
  max-height: 100px;
  overflow-y: auto;
  text-align: justify;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--offwhite);
  margin-top: 0.4rem;
  margin-bottom: 0.2rem;
  padding: 0.4rem 0.6rem;
  font-style: italic;
  background-color: #f8f9fa;
  border-left: 3px solid var(--primary);
  border-radius: 0.2rem;
  font-size: 0.78rem;
  line-height: 1.45;
}

p.headline mark, p.headline mark.hl {
  background-color: #ffe082;
  color: #1a1a1a;
  font-weight: 600;
  padding: 0.05rem 0.25rem;
  border-radius: 2px;
  font-style: normal;
}

.empty-msg {
  text-align: center;
  color: var(--text-gray);
  padding: 2rem 0;
  font-size: 0.85rem;
}

/* Loader Animation */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 2.5rem 0;
}

.loader {
  width: 12px;
  aspect-ratio: 1;
  border-radius: 50%;
  animation: l5 0.8s infinite linear alternate;
}

@keyframes l5 {
  0%   { box-shadow: 18px 0 #2A7F83, -18px 0 #2A7F8320; background: #2A7F83; }
  33%  { box-shadow: 18px 0 #2A7F83, -18px 0 #2A7F8320; background: #2A7F8320; }
  66%  { box-shadow: 18px 0 #2A7F8320, -18px 0 #2A7F83; background: #2A7F8320; }
  100% { box-shadow: 18px 0 #2A7F8320, -18px 0 #2A7F83; background: #2A7F83; }
}

/* ========================================================= */
/* Single Medicine Page (/lek/:id)                           */
/* ========================================================= */

.single-medicine-main {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-sizing: border-box;
  padding: 0 0.75rem;
}

.back-link {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.back-link a, .back-link-bottom a {
  font-weight: 600;
  color: var(--primary);
}

.back-link-bottom {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
}

.single-med-header {
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  gap: 0.75rem;
  background: #ffffff;
  padding: 1rem;
  border-radius: 0.6rem;
  border: 1px solid #e0e0e0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

@media (min-width: 640px) {
  .single-med-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.25rem;
    gap: 1rem;
  }
}

.single-med-header h1 {
  font-size: 1.35rem;
  text-align: left;
  line-height: 1.2;
  overflow-wrap: break-word;
  word-break: break-word;
}

@media (min-width: 640px) {
  .single-med-header h1 {
    font-size: 1.6rem;
  }
}

.med-subtitle {
  font-size: 0.95rem;
  color: var(--text-gray);
  margin-top: 0.25rem;
}

.atc-code-tag {
  font-size: 0.85rem;
  color: var(--primary);
  margin-top: 0.4rem;
}

/* Document Download Buttons */
.doc-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn-doc {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 0.4rem;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-chpl {
  background-color: var(--primary);
  color: #ffffff !important;
}

.btn-chpl:hover {
  background-color: #23696c;
  text-decoration: none;
}

.btn-leaflet {
  background-color: #f1f3f5;
  color: #334155 !important;
  border: 1px solid #cbd5e1;
}

.btn-leaflet:hover {
  background-color: #e2e8f0;
  text-decoration: none;
}

.info-table {
  display: grid;
  gap: 1rem;
}

.info-group {
  background: #ffffff;
  padding: 1.1rem;
  border-radius: 0.6rem;
  border: 1px solid #e0e0e0;
}

.info-group h3 {
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  color: var(--primary);
}

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

th, td {
  padding: 8px 10px;
  border: 1px solid #eee;
  text-align: left;
}

thead th {
  background-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background-color: #fafafa;
}

.info-group td:first-child {
  font-weight: 600;
  color: var(--primary);
  width: 35%;
}

/* Similar Medicines List */
.similar-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.similar-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: #f8f9fa;
  border-radius: 0.4rem;
  border: 1px solid #eee;
  transition: background-color 0.15s ease;
}

.similar-item:hover {
  background-color: #f1f3f5;
}

.similar-left {
  flex: 1;
}

.similar-title {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.92rem;
  line-height: 1.25;
}

.similar-sub {
  font-size: 0.75rem;
  color: var(--text-gray);
  margin-top: 0.15rem;
}

.similar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.sim-badge {
  background-color: var(--primary);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
}

/* Refundacja Tags & Badges */
.rf-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-right: 0.2rem;
}

.rf-senior {
  background-color: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.rf-child {
  background-color: #d1fae5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.rf-preg {
  background-color: #fce7f3;
  color: #be185d;
  border: 1px solid #fbcfe8;
}

.rf-odp {
  background-color: #fef3c7;
  color: #b45309;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.refund-table th, .refund-table td {
  padding: 6px 8px;
  font-size: 0.78rem;
}

/* ChPL Markdown Section */
.chpl-section {
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 0.6rem;
  border: 1px solid #e0e0e0;
}

.chpl-section h2 {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

.markdown-body {
  font-size: 0.85rem;
  line-height: 1.65;
  color: #333333;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--primary);
  margin-top: 1.2rem;
  margin-bottom: 0.5rem;
}

.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.0rem; }
.markdown-body h4 { font-size: 0.9rem; }

.markdown-body p {
  margin-bottom: 0.8rem;
  text-align: justify;
}

.markdown-body ul,
.markdown-body ol {
  margin-left: 1.5rem;
  margin-bottom: 0.8rem;
}

.markdown-body table {
  margin: 1rem 0;
}

.markdown-body strong {
  color: #1a1a1a;
}

/* App Footer */
.app-footer {
  width: 100%;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid #dcdcdc;
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-gray);
  line-height: 1.5;
}

.app-footer b {
  color: var(--primary);
  font-weight: 700;
}

/* Badges in Search Results */
.rf-badge-nfz {
  background: #dcfce7;
  color: #15803d;
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.4rem;
  border: 1px solid #bbf7d0;
  vertical-align: middle;
}

.badge-gif-tag {
  background: #fffbeb;
  color: #92400e;
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.4rem;
  border: 1px solid #fde68a;
  vertical-align: middle;
}

/* GIF Alert Box on Medicine Detail Page */
.gif-alert-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #d97706;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.gif-alert-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #92400e;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}

.gif-alert-icon {
  font-size: 1.1rem;
}

.gif-alert-desc {
  color: #78350f;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.gif-decision-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.gif-decision-item {
  background: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  border: 1px solid #fde68a;
}

.gif-item-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.gif-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-wycofanie {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.badge-wstrzymanie {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-zakaz {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.badge-inna {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.gif-meta {
  font-size: 0.82rem;
  color: #374151;
}

.gif-series {
  font-size: 0.8rem;
  color: #4b5563;
  margin-top: 0.25rem;
}

.gif-series code {
  background: #f3f4f6;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #1f2937;
}

.gif-link-wrap {
  margin-top: 0.35rem;
}

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

.gif-pdf-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Wikidata Drug-Drug Interactions (Collapsible Accordion)
   ========================================================================== */
.interactions-wrapper {
  margin: 1.75rem 0;
  width: 100%;
}

.interactions-accordion {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.6rem;
  overflow: hidden;
  transition: all 0.2s ease;
}

.interactions-accordion[open] {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.interactions-summary {
  padding: 0.85rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: #f8fafc;
  transition: background 0.15s;
  list-style: none;
}

.interactions-summary::-webkit-details-marker {
  display: none;
}

.interactions-summary:hover {
  background: #f1f5f9;
}

.summary-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.badge-experimental {
  background: #f1f5f9;
  color: #475569;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.summary-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
}

.summary-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.interactions-count-badge {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  border: 1px solid #bae6fd;
}

.interactions-count-badge.badge-empty {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.chevron-icon {
  font-size: 0.75rem;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

.interactions-accordion[open] .chevron-icon {
  transform: rotate(180deg);
}

.interactions-body {
  padding: 1.25rem;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
}

.disclaimer-callout {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #64748b;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.76rem;
  color: #475569;
  line-height: 1.45;
  margin-bottom: 1rem;
}

.interactions-source-info {
  font-size: 0.8rem;
  color: #334155;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed #e2e8f0;
}

.interactions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.interaction-card {
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.15s;
}

.interaction-card:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.interaction-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.inter-substance-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #0f172a;
}

.atc-code-pill {
  background: #e2e8f0;
  color: #334155;
  font-size: 0.68rem;
  font-family: monospace;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  border: 1px solid #cbd5e1;
}

.sample-drugs-wrap {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.sample-drugs-label {
  display: block;
  font-size: 0.68rem;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.sample-drugs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.sample-drug-pill {
  background: #ffffff;
  color: var(--primary);
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s;
}

.sample-drug-pill:hover {
  background: #f1f5f9;
  border-color: var(--primary);
  text-decoration: none;
}

.no-interactions-msg {
  padding: 1rem 0.5rem;
  text-align: center;
  color: #64748b;
  font-size: 0.82rem;
  line-height: 1.5;
}

.no-inter-sub {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.35rem;
}

/* ==========================================================================
   Detailed ATC Hierarchy Tree & Search Fineprint
   ========================================================================== */
.atc-hierarchy-fineprint {
  font-size: 0.73rem;
  color: #64748b;
  margin-top: -0.15rem;
  margin-bottom: 0.5rem;
  line-height: 1.35;
}

.atc-fp-label {
  font-weight: 600;
  color: #475569;
}

.atc-info-group {
  grid-column: 1 / -1;
}

.atc-hierarchy-tree {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.atc-tree-node {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  background: #f8fafc;
  border-left: 3px solid #cbd5e1;
  border-radius: 0 4px 4px 0;
  transition: all 0.15s ease;
}

.atc-tree-node:hover {
  background: #f1f5f9;
  border-left-color: var(--primary);
}

.atc-tree-node.atc-tree-leaf {
  border-left-color: var(--primary);
  background: #f0fdf4;
}

.atc-node-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 140px;
  flex-shrink: 0;
}

.atc-level-tag {
  font-size: 0.65rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
}

.atc-code-tag {
  font-family: monospace;
  font-size: 0.78rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #0f172a;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.atc-tree-leaf .atc-code-tag {
  background: var(--primary);
  color: #ffffff;
}

.atc-node-right {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.atc-node-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: #1e293b;
}

.atc-node-desc {
  font-size: 0.7rem;
  color: #64748b;
}

/* ==========================================================================
   Autocomplete / Suggestions Dropdown
   ========================================================================== */
.search-input-wrap {
  position: relative;
  width: 100%;
}

.suggestions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  overflow: hidden;
  max-height: 380px;
  overflow-y: auto;
  text-align: left;
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background-color 0.15s ease;
  gap: 0.75rem;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
  background-color: #f1f5f9;
}

.sug-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
}

.sug-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sug-texts {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sug-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sug-subtext {
  font-size: 0.72rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sug-type-tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.sug-type-lek {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.sug-type-substancja {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.sug-type-atc {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.sug-type-objaw {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* ==========================================================================
   Wikidata Medical Uses (Zastosowanie) Component
   ========================================================================== */
.uses-count-badge {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.uses-tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.use-tag-item {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.825rem;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}

.use-tag-item:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.use-tag-main {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.use-tag-icon {
  font-size: 0.9rem;
}

.use-tag-name {
  font-weight: 600;
  color: #0f172a;
}

.use-tag-sub {
  font-size: 0.725rem;
  color: #64748b;
}

.use-tag-codes {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.icd-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
}

.icd11-badge {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  transition: all 0.15s ease;
}

.icd11-badge:hover {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
  text-decoration: none;
}

.icd10-badge {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.qid-badge {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
  transition: all 0.15s ease;
}

.qid-badge:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
  text-decoration: none;
}

.icd-type {
  font-size: 0.65rem;
  opacity: 0.8;
  text-transform: uppercase;
}

.icd-code {
  font-weight: 700;
}

.icd-ext-icon {
  font-size: 0.65rem;
  opacity: 0.7;
}

/* ========================================================= */
/* Active Substance Links & Substance Detail Page            */
/* ========================================================= */

.substance-table-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
}

.substance-table-link:hover {
  color: #1e5c5f;
  text-decoration: underline;
}

.substance-link-arrow {
  font-size: 0.75rem;
  opacity: 0.7;
}

.substance-header-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.substance-header-link:hover {
  text-decoration: underline;
}

.substance-detail-main {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0 0.75rem;
}

.substance-header-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.25rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

@media (min-width: 640px) {
  .substance-header-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
  }
}

.substance-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  font-size: 0.725rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}

.substance-title-main {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  text-align: left;
  line-height: 1.25;
  margin-bottom: 0.35rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

@media (min-width: 640px) {
  .substance-title-main {
    font-size: 1.75rem;
  }
}

.substance-badges-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.85rem 0;
  width: 100%;
  box-sizing: border-box;
}

.substance-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 640px) {
  .substance-stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
  }
}

.stat-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-number {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 600;
  margin-top: 0.2rem;
}

.substance-section-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.substance-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.section-card-header {
  padding: 0.9rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-card-body {
  padding: 1.25rem;
}

.substance-products-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  margin-top: 1.5rem;
}

.products-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.tabs-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.filter-search-box input {
  padding: 0.38rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.78rem;
  width: 220px;
  outline: none;
  transition: border-color 0.15s ease;
}

.filter-search-box input:focus {
  border-color: var(--primary);
}

.substance-products-table-wrap {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
}

.substance-products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: left;
}

.substance-products-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #cbd5e1;
  position: sticky;
  top: 0;
  z-index: 10;
}

.substance-products-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.substance-products-table tr:hover td {
  background-color: #f8fafc;
}

.product-name-link {
  color: #0f172a;
  text-decoration: none;
  font-size: 0.82rem;
  transition: color 0.15s ease;
}

.product-name-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.product-form-text {
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.product-moc-pill {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.72rem;
}

.product-holder-text {
  font-size: 0.72rem;
  color: #475569;
}

.composition-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.comp-single {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.comp-combo {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.inter-substance-link {
  color: #0f172a;
  text-decoration: none;
  font-weight: 700;
  transition: color 0.15s ease;
}

.inter-substance-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ========================================================= */
/* Comprehensive Mobile Responsive Styles (Strict 1-Column)  */
/* ========================================================= */

@media (max-width: 768px) {
  html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
  }

  body {
    padding: 0 0 2rem 0;
  }

  .global-site-header {
    width: 100%;
    max-width: 100%;
    margin-bottom: 1rem;
  }

  .header-inner {
    padding: 0.5rem 0.75rem;
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
    gap: 0.4rem;
    box-sizing: border-box;
  }

  .brand-badge {
    display: none !important;
  }

  .header-nav-status {
    display: none !important;
  }

  .nav-btn-text-full {
    display: none !important;
  }

  .nav-btn-text-mobile {
    display: inline !important;
  }

  .nav-search-btn {
    padding: 0.32rem 0.55rem;
    font-size: 0.72rem;
    gap: 0.25rem;
    white-space: nowrap;
  }

  .main,
  .single-medicine-main,
  .substance-detail-main {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    box-sizing: border-box;
  }

  /* Search Form on Mobile */
  #searchForm {
    margin-bottom: 1rem;
    width: 100%;
  }

  .search-input-wrap {
    width: 100%;
  }

  #searchBox {
    font-size: 16px; /* Prevents auto-zoom on mobile devices */
    padding: 10px 14px;
    width: 100%;
    box-sizing: border-box;
  }

  #searchButton {
    padding: 11px 16px;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
  }

  .suggestions-dropdown {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .suggestion-item {
    padding: 0.6rem 0.75rem;
  }

  .sug-title {
    font-size: 0.82rem;
  }

  /* Search Result Cards */
  .med-card {
    padding: 0.85rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .ind-med {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .ind-med-left h2 {
    font-size: 0.98rem;
    line-height: 1.25;
    word-break: break-word;
  }

  .ind-med-right img {
    width: 32px;
    height: 32px;
  }

  .atc-group {
    font-size: 0.72rem;
    padding: 0.3rem 0.5rem;
    word-break: break-word;
  }

  .atc-hierarchy-fineprint {
    font-size: 0.68rem;
    line-height: 1.3;
    word-break: break-word;
  }

  p.headline {
    font-size: 0.74rem;
    padding: 0.35rem 0.5rem;
    text-align: left;
    word-break: break-word;
  }

  /* Single Medicine Page Header */
  .single-med-header {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
  }

  .single-med-header h1 {
    font-size: 1.35rem;
    line-height: 1.2;
    word-break: break-word;
  }

  .header-right {
    display: flex;
    justify-content: flex-end;
  }

  .header-right img {
    width: 40px;
    height: 40px;
  }

  .doc-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
  }

  .btn-doc {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
    box-sizing: border-box;
  }

  /* Info Groups & Tables */
  .info-table {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    width: 100%;
  }

  .info-group {
    padding: 0.85rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .info-group table {
    width: 100%;
    font-size: 0.76rem;
    table-layout: auto;
  }

  .info-group td:first-child {
    width: 40%;
  }

  .info-group td, .info-group th {
    word-break: break-word;
    overflow-wrap: break-word;
    padding: 6px 8px;
  }

  .table-responsive,
  .refund-table,
  .substance-products-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    box-sizing: border-box;
  }

  /* ATC Hierarchy Tree on Mobile */
  .atc-tree-node {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.45rem 0.55rem;
    width: 100%;
    box-sizing: border-box;
  }

  .atc-node-left {
    min-width: auto;
    gap: 0.35rem;
  }

  .atc-node-name {
    font-size: 0.8rem;
    word-break: break-word;
  }

  .atc-node-desc {
    font-size: 0.68rem;
  }

  /* Interactions & Uses */
  .interactions-summary {
    padding: 0.75rem 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .interactions-grid {
    grid-template-columns: 1fr !important;
    gap: 0.6rem;
    width: 100%;
  }

  .interaction-card {
    width: 100%;
    padding: 0.65rem 0.75rem;
    box-sizing: border-box;
  }

  .use-tag-item {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.5rem 0.65rem;
    box-sizing: border-box;
  }

  .use-tag-codes {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* Substance Details Page Mobile */
  .substance-header-card {
    padding: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .substance-title-main {
    font-size: 1.35rem;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .substance-stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem;
    margin-top: 1rem;
    width: 100%;
  }

  .stat-box {
    padding: 0.5rem;
    box-sizing: border-box;
  }

  .stat-number {
    font-size: 1.1rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .products-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
    width: 100%;
    box-sizing: border-box;
  }

  .tabs-group {
    width: 100%;
    display: flex;
    gap: 0.3rem;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.35rem 0.3rem;
    font-size: 0.7rem;
    white-space: nowrap;
  }

  .filter-search-box {
    width: 100%;
  }

  .filter-search-box input {
    width: 100% !important;
    box-sizing: border-box;
    font-size: 14px;
  }

  .section-card-header {
    padding: 0.75rem 0.85rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .section-card-body {
    padding: 0.85rem;
    box-sizing: border-box;
  }

  /* GIF Alert Box */
  .gif-alert-box {
    padding: 0.85rem;
    margin: 1rem 0;
    width: 100%;
    box-sizing: border-box;
  }

  .gif-decision-item {
    padding: 0.65rem 0.75rem;
  }

  /* Similar Medicines */
  .similar-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .similar-right {
    width: 100%;
    justify-content: space-between;
  }

  /* ChPL Section & Markdown */
  .chpl-section {
    padding: 0.85rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .markdown-body {
    font-size: 0.82rem;
    line-height: 1.55;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .markdown-body h1 { font-size: 1.15rem; }
  .markdown-body h2 { font-size: 1.05rem; }
  .markdown-body h3 { font-size: 0.95rem; }

  .markdown-body p {
    text-align: left; /* Left align for readable mobile prose */
  }

  .markdown-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0.75rem 0;
  }

  .markdown-body pre {
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
  }

  .markdown-body img {
    max-width: 100%;
    height: auto;
  }

  .app-footer {
    padding: 1rem 0.75rem;
    font-size: 0.72rem;
  }
}

@media (max-width: 480px) {
  .brand-title {
    font-size: 0.95rem;
  }

  .brand-logo {
    width: 20px;
    height: 20px;
  }

  .nav-search-btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
  }

  .substance-stats-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

