/* MedLookup */
:root {
    --brand: #0d7a6f;
    --brand-dark: #095c54;
    --brand-soft: #e3f3f0;
    --ink: #17252a;
    --muted: #5f6f73;
    --line: #e2e8e9;
    --bg: #f6f8f8;
    --card: #ffffff;
    --rx: #6a3fb5;
    --rx-soft: #efe8fb;
    --otc: #1d6fb8;
    --otc-soft: #e4f0fb;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --warn: #9a6200;
    --warn-soft: #fff4dc;
    --radius: 14px;
}

body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
main { flex: 1; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
code { color: var(--ink); background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: .85em; }
mark { background: #ffe58a; padding: 0 2px; border-radius: 3px; }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

/* ---------- nav ---------- */
.site-nav { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 0; }
.navbar-brand { font-weight: 700; color: var(--ink) !important; display: flex; align-items: center; gap: 10px; font-size: 1.25rem; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.1rem; }
.site-nav .nav-link { color: var(--muted); font-weight: 500; border-radius: 8px; padding: 8px 12px !important; }
.site-nav .nav-link:hover { color: var(--ink); background: var(--bg); }
.site-nav .nav-link.active { color: var(--brand); background: var(--brand-soft); }
.navbar-toggler { border: 0; font-size: 1.6rem; }
.site-nav .nav-link { white-space: nowrap; }
.navbar-toggler:focus { box-shadow: none; }
.cabinet-count { background: var(--brand); font-size: .7em; vertical-align: 2px; }

/* ---------- hero + page heads ---------- */
.hero { background: linear-gradient(160deg, #0d7a6f 0%, #0b5f6b 100%); color: #fff; padding: 72px 0 56px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); }
.hero .lead { opacity: .9; max-width: 640px; }
.page-head { background: #fff; border-bottom: 1px solid var(--line); padding: 28px 0; }
.page-head h1 { font-size: 1.9rem; margin-bottom: 8px; }

.search-box { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
    padding: 6px 6px 6px 14px; max-width: 760px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.search-box > i { color: var(--muted); }
.search-box input { flex: 1; border: 0; outline: 0; min-width: 0; padding: 8px 4px; font-size: 1rem; background: transparent; }
.search-box select { border: 0; background: var(--bg); border-radius: 8px; padding: 8px; color: var(--muted); font-size: .9rem; max-width: 150px; }
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13,122,111,.15); }
.search-box-lg { padding: 8px 8px 8px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.18); border: 0; }
.search-box-lg input { font-size: 1.1rem; padding: 10px 4px; }
.search-box-lg .btn { padding: 10px 22px; }
@media (max-width: 575px) {
    .search-box { flex-wrap: wrap; }
    .search-box input { flex-basis: calc(100% - 30px); }
    .search-box select { flex: 1; max-width: none; }
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips-label { opacity: .8; font-size: .9rem; }
.chip { color: #fff; background: rgba(255,255,255,.14); border-radius: 999px; padding: 4px 12px; font-size: .9rem; text-decoration: none; }
.chip:hover { background: rgba(255,255,255,.28); color: #fff; }

/* ---------- home ---------- */
.tool { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 22px; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .15s; }
.tool:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.07); color: var(--ink); }
.tool i { font-size: 1.6rem; color: var(--brand); margin-bottom: 6px; }
.tool span { color: var(--muted); font-size: .92rem; }
.section-title { font-size: 1.3rem; margin-bottom: 16px; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.class-card { display: flex; flex-direction: column; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    text-decoration: none; color: var(--ink); font-weight: 600; }
.class-card small { color: var(--muted); font-weight: 400; }
.class-card:hover { border-color: var(--brand); color: var(--brand); }
.more-link { display: inline-block; margin-top: 14px; font-weight: 600; text-decoration: none; }

/* ---------- recalls ---------- */
.recall-list { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.recall-list li + li { border-top: 1px solid var(--line); }
.recall-list a { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; text-decoration: none; color: var(--ink); }
.recall-list a:hover { background: var(--bg); }
.recall-list .badge { align-self: flex-start; }
.recall-list small { color: var(--muted); }
.recall-reason { color: var(--muted); font-size: .92rem; }
.recall-list.compact { border: 0; border-radius: 0; }
.recall-list.compact a { padding: 10px 0; font-size: .9rem; }
.recall-list.compact a:hover { background: none; }
.recall-list.compact a:hover .recall-product { color: var(--brand); }
.badge.class-classi { background: var(--danger); }
.badge.class-classii { background: #c76a00; }
.badge.class-classiii { background: #6b7a7e; }

/* ---------- search results ---------- */
.result-count { color: var(--ink); font-weight: 600; }
.result-list { display: flex; flex-direction: column; gap: 10px; }
.result { display: flex; align-items: center; gap: 16px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.result:hover { border-color: var(--brand); color: var(--ink); box-shadow: 0 4px 14px rgba(0,0,0,.05); }
.result h3 { font-size: 1.15rem; margin: 0; }
.result-main { flex: 1; min-width: 0; }
.result-side { display: flex; flex-direction: column; text-align: right; max-width: 220px; color: var(--muted); }
.result > .bi-chevron-right { color: var(--muted); }
.generic { color: var(--muted); font-size: .95rem; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 8px; font-size: .88rem; color: var(--muted); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; text-decoration: none; }
.tag-rx { background: var(--rx-soft); color: var(--rx); }
.tag-otc { background: var(--otc-soft); color: var(--otc); }
.tag-class { background: var(--brand-soft); color: var(--brand); }
@media (max-width: 575px) { .result-side { display: none; } }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty > i { font-size: 2.6rem; color: var(--line); }
.empty h2 { font-size: 1.3rem; color: var(--ink); margin-top: 10px; }

/* ---------- drug page ---------- */
.drug-head { background: #fff; border-bottom: 1px solid var(--line); padding: 22px 0 26px; }
.drug-head h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: 4px; }
.generic-name { color: var(--muted); margin-bottom: 4px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.drug-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.boxed-warning { border: 2px solid var(--danger); background: var(--danger-soft); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.boxed-warning h2 { color: var(--danger); font-size: 1.1rem; }
.boxed-warning p:last-child { margin-bottom: 0; }
.glance { background: var(--brand-soft); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.glance h2 { font-size: 1.1rem; color: var(--brand-dark); }
.glance p { margin: 0; }
.label-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 14px; scroll-margin-top: 16px; }
.label-section h2 { font-size: 1.15rem; margin-bottom: 10px; }
.label-text { line-height: 1.65; color: #2c3a3e; overflow-wrap: anywhere; }
.label-text p { margin-bottom: .7em; }
.label-text.clamp { max-height: 15em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.show-more { font-weight: 600; text-decoration: none; color: var(--brand); }

.side-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }
.side-card h3 { font-size: 1rem; margin-bottom: 10px; }
.toc ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 12px; font-size: .9rem; }
.toc li { padding: 3px 0; break-inside: avoid; }
.toc a { text-decoration: none; }
@media (min-width: 992px) { .toc ul { columns: 1; } }
.product + .product { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.product ul { padding-left: 18px; margin: 6px 0 0; font-size: .85rem; color: var(--muted); }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: 1fr 70px auto; gap: 8px; align-items: center; font-size: .88rem; padding: 3px 0; }
.bar { background: var(--bg); border-radius: 4px; height: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.bar-value { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; min-width: 48px; text-align: right; }

/* ---------- browse ---------- */
.browse-tabs .nav-link { color: var(--muted); font-weight: 600; }
.browse-tabs .nav-link.active { background: var(--brand); }
.letters { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 14px; }
.letters a { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; text-decoration: none; font-weight: 600;
    color: var(--ink); background: var(--bg); }
.letters a:hover { background: var(--brand-soft); color: var(--brand); }
.letters a.active { background: var(--brand); color: #fff; }
.filter-input { max-width: 360px; }
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.name-grid a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; background: var(--card); border: 1px solid var(--line);
    border-radius: 9px; text-decoration: none; color: var(--ink); font-size: .93rem; }
.name-grid a:hover { border-color: var(--brand); color: var(--brand); }
.name-grid small { color: var(--muted); }

/* ---------- lookup ---------- */
.gs1-info { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.gs1-info > div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.gs1-info small { display: block; color: var(--muted); font-size: .78rem; }
.lookup-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 14px; }
.lookup-card h2 { font-size: 1.4rem; margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; margin: 18px 0 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }

/* ---------- interactions ---------- */
.ix-form { max-width: 760px; }
.ix-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.ix-row { display: flex; gap: 4px; }
.ix-pair { background: var(--card); border: 1px solid var(--line); border-left-width: 5px; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 12px; }
.ix-pair-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.ix-pair h2 { font-size: 1.15rem; margin: 0; }
.ix-status { font-weight: 600; font-size: .9rem; }
.ix-found { border-left-color: var(--danger); }
.ix-found .ix-status { color: var(--danger); }
.ix-class { border-left-color: #d08a00; }
.ix-class .ix-status { color: var(--warn); }
.ix-none { border-left-color: #8fb9b3; }
.ix-none .ix-status { color: var(--muted); }
.ix-hits { list-style: none; padding: 0; margin: 0; }
.ix-hits li { padding: 10px 0; border-top: 1px solid var(--line); font-size: .93rem; line-height: 1.55; }
.ix-hits small { display: block; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- my medicines ---------- */
.cab-add { display: flex; gap: 8px; max-width: 560px; margin-bottom: 6px; }
.cab-add .btn { white-space: nowrap; }
.cab-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.cab-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.cab-item-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.cab-item-head > div { flex: 1; }
.cab-item h2 { font-size: 1.15rem; margin: 0; }
.cab-item h2 a { text-decoration: none; color: var(--ink); }
.cab-item h2 a:hover { color: var(--brand); }
.cab-item .form-label { margin-bottom: 2px; color: var(--muted); }
.cab-refill { margin-top: 10px; font-weight: 600; }
.cab-refill.due { color: var(--danger); }
.cab-refill.ok { color: var(--brand); }

/* ---------- accounts ---------- */
.nav-account { display: flex; gap: 8px; align-items: center; margin-left: 12px; }
@media (max-width: 1199px) { .nav-account { margin: 10px 0 4px; } }
.auth-card { max-width: 460px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; }
.auth-card h1 { font-size: 1.6rem; }
.cab-item.saving { opacity: .7; }

/* ---------- admin ---------- */
.admin-tabs-wrap { position: relative; }
.admin-tabs {
    gap: 4px;
    position: relative;
    flex-wrap: nowrap;                 /* always one row, never stacked */
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs .nav-item { flex: none; scroll-snap-align: start; }
.admin-tabs .nav-link { white-space: nowrap; }
/* Fade + arrow on whichever side has more tabs */
.admin-tabs-wrap::before, .admin-tabs-wrap::after {
    content: ""; position: absolute; top: 0; bottom: 0; width: 56px; pointer-events: none; opacity: 0; transition: opacity .2s; z-index: 1;
}
.admin-tabs-wrap::before { left: 0; background: linear-gradient(to right, var(--bg, #f6f8f8) 40%, transparent); }
.admin-tabs-wrap::after { right: 0; background: linear-gradient(to left, var(--bg, #f6f8f8) 40%, transparent); }
.admin-tabs-wrap.fade-left::before, .admin-tabs-wrap.fade-right::after { opacity: 1; }
.admin-tabs-arrow {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    border: 1px solid var(--line); background: var(--card, #fff); color: var(--ink);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.admin-tabs-arrow[hidden] { display: none; }
.admin-tabs-arrow.left { left: 0; }
.admin-tabs-arrow.right { right: 0; }
.admin-tabs .nav-link { color: var(--muted); font-weight: 600; }
.admin-tabs .nav-link.active { background: var(--brand); color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
    text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--brand); color: var(--ink); }
.stat i { color: var(--brand); font-size: 1.3rem; }
.stat strong { font-size: 1.7rem; line-height: 1.2; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .88rem; }
.day-bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; height: 140px; align-items: end; }
.day-bars > div { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.day-bars span { width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.day-bars small { color: var(--muted); font-size: .72rem; }
.admin-table { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.admin-table .table { --bs-table-bg: transparent; }
.admin-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.admin-table td, .admin-table th { padding: 10px 14px; }
.run-log { background: #0f1f22; color: #cde8e3; border-radius: var(--radius); padding: 16px 18px; max-height: 60vh; overflow: auto; font-size: .85rem; white-space: pre-wrap; }

/* ---------- footer ---------- */
.site-footer { background: #fff; border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: .9rem; margin-top: 40px; }

/* ---------- print: just the content ---------- */
@media print {
    .site-nav, .site-footer, .drug-actions, .search-box, .show-more, .toc, .cab-add, .cab-remove, .page-head .btn { display: none !important; }
    body { background: #fff; }
    .label-text.clamp { max-height: none; -webkit-mask-image: none; mask-image: none; }
    .label-section, .side-card, .cab-item { break-inside: avoid; border-color: #ccc; }
}

/* Link to the mobile version, shown on small screens only */
.mobile-hint { display: block; padding: 10px 16px; background: var(--brand, #0d7a6f); color: #fff; text-align: center; font-weight: 600; font-size: .9rem; text-decoration: none; }
.mobile-hint:hover { color: #fff; }

/* ---------- admin panel / account opened from the mobile site ---------- */
body.in-app { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.app-bar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 8px;
    min-height: 56px; padding: env(safe-area-inset-top) 8px 0 4px;
    background: var(--brand); color: #fff;
}
.app-bar a { color: #fff; text-decoration: none; }
.app-bar-back { display: flex; align-items: center; gap: 4px; padding: 10px 8px; font-weight: 600; white-space: nowrap; }
.app-bar-title { flex: 1; min-width: 0; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar-home { display: grid; place-items: center; width: 44px; height: 44px; font-size: 1.25rem; }
.app-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: flex; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 1px solid var(--line);
}
.app-tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .72rem; font-weight: 500; text-decoration: none; }
.app-tabbar a i { font-size: 1.35rem; line-height: 1; }
.app-tabbar a.on { color: var(--brand); }
