:root {
    color-scheme: light;
    --bg: #f6f7f4;
    --panel: #ffffff;
    --ink: #1f2a2e;
    --muted: #667275;
    --line: #d9e0dc;
    --primary: #137c68;
    --primary-dark: #0f604f;
    --accent: #f0b429;
    --danger: #b42318;
    --ok: #1d7f45;
    --shadow: 0 16px 45px rgba(22, 38, 44, .11);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 18px;
}

a { color: inherit; text-decoration: none; }

input, textarea, select, button {
    font: inherit;
}

input, textarea, select {
    width: 100%;
    border: 2px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
    color: var(--ink);
}

input:focus, textarea:focus, select:focus {
    outline: 3px solid rgba(19, 124, 104, .2);
    border-color: var(--primary);
}

button, .primary, .quiet-button, .notify-button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    padding: 12px 18px;
    cursor: pointer;
    font-weight: 750;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.disabled-button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    padding: 12px 18px;
    font-weight: 750;
    background: #eef1ef;
    color: #7b8588;
    cursor: not-allowed;
}

.danger-button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    padding: 12px 18px;
    cursor: pointer;
    font-weight: 750;
    background: #fff0ee;
    color: var(--danger);
}

.primary {
    background: var(--primary);
    color: white;
}

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

.quiet-button {
    background: #e8eee9;
    color: var(--ink);
}

.notify-button {
    background: #fff3c4;
    color: #4c3713;
}

.small-button {
    min-height: 42px;
    padding: 10px 14px;
    font-size: 16px;
}

.tiny-button {
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 750;
    background: #e8eee9;
    color: var(--ink);
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 22px;
}

.auth-box, .next-card, .meal-panel, .admin-panel, .form-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-box {
    width: min(100%, 430px);
    padding: 28px;
}

.auth-box h1, .form-panel h1 {
    margin: 14px 0 6px;
    font-size: 34px;
}

.brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    display: inline-grid;
    place-items: center;
    font-weight: 850;
}

.brand-mark.small {
    width: 38px;
    height: 38px;
    font-size: 15px;
}

.muted, .empty, .info {
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 16px;
}

.text-link {
    display: inline-block;
    margin-top: 18px;
    color: var(--primary-dark);
    font-weight: 750;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(246, 247, 244, .95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
}

.app-title {
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 850;
}

.logo-img {
    display: block;
    width: 210px;
    max-width: 58vw;
    height: auto;
}

.logo-img.large {
    width: 240px;
    max-width: 100%;
}

.menu-toggle {
    width: 52px;
    height: 52px;
    padding: 0;
    background: #e8eee9;
    display: grid;
    place-content: center;
    gap: 5px;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    border-radius: 999px;
    background: var(--ink);
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(31, 42, 46, .28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.side-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 21;
    width: min(86vw, 360px);
    height: auto;
    max-height: 100dvh;
    padding: 22px 22px max(22px, env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: -18px 0 48px rgba(22, 38, 44, .18);
    transform: translateX(105%);
    transition: transform .2s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.menu-open .menu-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.menu-open .side-menu {
    transform: translateX(0);
}

.menu-head {
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
    margin-bottom: 10px;
}

.menu-user {
    position: relative;
    margin: 14px 0 0;
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(19, 124, 104, .16);
    border-radius: 8px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #f2fbf7 0%, #e5f4ed 100%);
    color: var(--primary-dark);
    font-size: 18px;
    font-weight: 900;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 7px 16px rgba(22, 38, 44, .07);
}

.menu-user-avatar,
.menu-user-fallback {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 50%;
}

.menu-user-avatar {
    object-fit: cover;
    background: #edf1ee;
}

.menu-user-fallback {
    background: linear-gradient(135deg, var(--primary), #6bb49e);
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, .3);
}

.side-menu a {
    display: flex;
    align-items: center;
    min-height: 54px;
    border-radius: 8px;
    padding: 10px 14px;
    background: #f6f7f4;
    font-weight: 800;
}

.side-menu a.active {
    background: var(--primary);
    color: #fff;
}

.side-menu .admin-return-link {
    background: #fff3c4;
    color: #4c3713;
    border: 2px solid rgba(240, 180, 41, .35);
}

.side-menu .logout-link {
    margin-top: auto;
    background: #fff0ee;
    color: var(--danger);
}

.side-menu .mobile-side-home {
    display: none;
}

.menu-notices {
    display: grid;
    gap: 8px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
    margin: 6px 0;
}

.menu-notices button {
    width: 100%;
}

.shell {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 18px 14px 40px;
    display: grid;
    gap: 18px;
}

.shell.single {
    max-width: 1120px;
    grid-template-columns: 1fr;
}

.home-launch {
    display: grid;
    gap: 16px;
    border: 1px solid rgba(19, 124, 104, .14);
    border-radius: 8px;
    padding: 18px;
    background:
        linear-gradient(135deg, rgba(19, 124, 104, .12), transparent 34%),
        linear-gradient(180deg, #ffffff 0%, #f2fbf7 100%);
    box-shadow: var(--shadow);
}

.home-launch-head h1 {
    margin: 0;
    font-size: clamp(34px, 9vw, 58px);
    line-height: 1;
}

.home-launch-head p:last-child {
    margin: 8px 0 0;
}

.home-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.home-action {
    min-height: 138px;
    display: grid;
    align-content: space-between;
    gap: 8px;
    border: 1px solid rgba(31, 42, 46, .08);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
    box-shadow: 0 12px 24px rgba(22, 38, 44, .09);
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.home-action:hover,
.home-action:focus {
    transform: translateY(-2px);
    border-color: rgba(19, 124, 104, .32);
    box-shadow: 0 16px 30px rgba(22, 38, 44, .14);
}

.home-action:active {
    transform: translateY(1px);
}

.home-action span {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e7f5ef;
    color: var(--primary-dark);
    font-weight: 950;
}

.home-action strong {
    font-size: 22px;
    line-height: 1.08;
}

.home-action small {
    color: var(--muted);
    font-weight: 750;
}

.home-action.is-active,
.home-action.family-action.is-active {
    background: linear-gradient(135deg, var(--primary) 0%, #0f604f 100%);
    color: #fff;
    cursor: default;
}

.home-action.is-active span,
.home-action.family-action.is-active span {
    background: rgba(255, 255, 255, .92);
    color: var(--primary-dark);
}

.home-action.is-active small,
.home-action.family-action.is-active small {
    color: rgba(255, 255, 255, .82);
}

.mobile-home-link {
    display: none;
}

.admin-shell > .home-launch {
    grid-column: 1 / -1;
}

.next-card {
    padding: 20px;
    display: grid;
    gap: 16px;
}

.priority-card {
    border: 3px solid rgba(19, 124, 104, .22);
    scroll-margin-top: 92px;
}

.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.control-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.all-doses-heading {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.all-doses-heading h2,
.all-doses-heading p {
    margin: 0;
}

.all-doses-heading .muted {
    margin-top: 6px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary-dark);
    font-size: 16px;
    font-weight: 850;
    text-transform: uppercase;
}

.next-card h1 {
    margin: 0;
    font-size: clamp(31px, 8vw, 52px);
    line-height: 1.05;
}

.time {
    margin: 10px 0 0;
    font-size: 40px;
    font-weight: 850;
    color: var(--primary-dark);
}

.next-list, .dose-list, .medicine-grid {
    display: grid;
    gap: 12px;
}

.dose-line, .dose-card, .medicine-card {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfb;
}

.featured-dose {
    grid-template-columns: 72px 1fr auto;
}

.dose-line img, .dose-card img, .medicine-card img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    background: #edf1ee;
}

.dose-line span {
    display: block;
    color: var(--muted);
}

.days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.days a {
    min-height: 70px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    border: 2px solid var(--line);
    background: white;
    font-weight: 850;
}

.days a.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.meal-panel, .admin-panel, .form-panel {
    padding: 16px;
}

.form-panel, .week-panel, .user-list-panel, .user-detail-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 16px;
}

.search-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 16px;
}

.cima-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    margin: 4px 0 16px;
    padding: 12px;
    border: 1px solid rgba(31, 42, 46, .08);
    border-radius: 8px;
    background: #fbfcfb;
}

.cima-brand img {
    max-width: min(210px, 42vw);
    max-height: 58px;
    object-fit: contain;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.search-status {
    margin: 12px 0 0;
}

.error-text {
    color: var(--danger);
    font-weight: 800;
}

.search-results {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.search-card {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 14px;
    align-items: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfb;
}

.search-card img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    background: #edf1ee;
}

.clean-search-card {
    border-left: 5px solid var(--primary);
}

.search-card h2 {
    margin: 0 0 8px;
    font-size: 21px;
    line-height: 1.18;
}

.search-card p {
    margin: 4px 0;
}

.active-substance {
    color: var(--primary-dark);
    font-weight: 850;
}

.info-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.info-chip {
    display: inline-grid;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 9px;
    background: #fff;
}

.info-chip strong {
    color: var(--muted);
    font-size: 13px;
}

.info-chip em {
    color: var(--ink);
    font-style: normal;
    font-weight: 750;
}

.doc-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.medicine-doc-links {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.medicine-doc-links .doc-button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 14px;
}

.search-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.search-actions .primary {
    min-height: 44px;
}

.doc-button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    padding: 8px 12px;
    background: #fff3c4;
    color: #4c3713;
    font-size: 15px;
    font-weight: 850;
}

.doc-button::before {
    content: "PDF";
    margin-right: 8px;
    border-radius: 6px;
    padding: 2px 5px;
    background: #137c68;
    color: #fff;
    font-size: 11px;
}

.search-pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.search-pagination button,
.search-pagination a {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    background: #fff;
    color: var(--ink);
    font-weight: 850;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-pagination button.active,
.search-pagination a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    cursor: default;
}

.search-pagination button:disabled,
.search-pagination a.disabled {
    opacity: .45;
    cursor: default;
    pointer-events: none;
}

.search-pagination .edge-page {
    min-width: 86px;
}

.meal-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.meal-tabs a,
.meal-tabs span {
    min-height: 54px;
    display: grid;
    place-items: center;
    border: 2px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-weight: 850;
}

.meal-tabs a.active,
.meal-tabs span.active {
    border-color: var(--accent);
    background: #fff3c4;
}

.meal-tabs span.disabled {
    border-style: dashed;
    background: #eef1ef;
    color: #8a9698;
    cursor: not-allowed;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 18px 0 12px;
}

.section-head h2, .form-panel h2 {
    margin: 0;
    font-size: 24px;
}

.empty.big {
    padding: 26px 8px;
    text-align: center;
}

.dose-card {
    grid-template-columns: 78px 1fr;
}

.current-meals .dose-card {
    border-width: 2px;
    background: #fff;
}

.dose-main h3, .medicine-card h3 {
    margin: 0 0 5px;
    font-size: 22px;
}

.dose-main p, .medicine-card p {
    margin: 3px 0;
}

.dose-amount {
    font-size: 21px;
    font-weight: 850;
}

.dose-visual {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-pills {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
}

.inline-pills .pill-icon {
    width: 30px;
    height: 18px;
}

.inline-pills .pill-icon.half {
    width: 20px;
}

.taken {
    background: #dff3e7;
    color: var(--ok);
}

.medicine-card {
    grid-template-columns: 72px 1fr auto;
}

.simple-medicine-card {
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
}

.medicine-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.medicine-actions form {
    margin: 0;
}

.medicine-card.inactive {
    opacity: .58;
}

.alert {
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #eef8f2;
    color: var(--ok);
}

.alert.error {
    background: #fff0ee;
    color: var(--danger);
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
}

.preview {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    cursor: zoom-in;
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(31, 42, 46, .78);
}

.image-lightbox img {
    max-width: min(92vw, 760px);
    max-height: 78vh;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.image-lightbox button {
    position: fixed;
    top: 16px;
    right: 16px;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff;
    color: var(--ink);
    font-weight: 850;
}

.autocomplete-field {
    position: relative;
}

.autocomplete-help {
    margin: 6px 0 0;
    font-size: 15px;
}

.autocomplete-error {
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 15px;
    font-weight: 800;
}

.autocomplete-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 4px);
    z-index: 8;
    display: grid;
    gap: 6px;
    max-height: 330px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.autocomplete-results[hidden] {
    display: none;
}

.autocomplete-option {
    display: grid;
    gap: 3px;
    width: 100%;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fbfcfb;
    color: var(--ink);
    text-align: left;
}

.autocomplete-option:hover,
.autocomplete-option:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(19, 124, 104, .16);
}

.autocomplete-option strong {
    font-size: 16px;
}

.autocomplete-option span {
    color: var(--primary-dark);
    font-weight: 750;
}

.autocomplete-option small {
    color: var(--muted);
}

.schedule-editor {
    display: grid;
    gap: 10px;
}

details {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
    overflow: hidden;
}

summary {
    cursor: pointer;
    padding: 16px;
    font-weight: 850;
}

.schedule-row {
    display: grid;
    grid-template-columns: 150px 1fr 1fr;
    gap: 10px;
    padding: 0 14px 14px;
}

.owner-note {
    margin: 0 0 18px;
    color: var(--primary-dark);
    font-weight: 800;
}

.repeat-tool {
    display: grid;
    gap: 10px;
    border: 2px dashed rgba(19, 124, 104, .35);
    border-radius: 8px;
    padding: 14px;
    background: #f4fbf8;
}

.repeat-tool h3,
.repeat-tool p {
    margin: 0;
}

.repeat-tool h3 {
    font-size: 21px;
}

.schedule-row.compact {
    padding: 0;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    padding: 4px 0 10px;
}

.week-day {
    min-width: 0;
    min-height: 360px;
    border: 1px solid rgba(31, 42, 46, .08);
    border-radius: 8px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
    box-shadow: 0 12px 30px rgba(22, 38, 44, .08);
}

.week-day.today {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 2px rgba(19, 124, 104, .18), 0 16px 36px rgba(19, 124, 104, .12);
}

.week-day h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.week-meal {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    min-height: 112px;
    margin-top: 10px;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    border: 1px solid rgba(31, 42, 46, .08);
    font-weight: 850;
    overflow-wrap: anywhere;
    box-shadow: 0 8px 18px rgba(22, 38, 44, .07);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.week-meal > span {
    min-width: 0;
    line-height: 1.2;
}

.week-meal:hover,
.week-meal:focus {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(22, 38, 44, .12);
}

.week-meal.meal-desayuno {
    background: linear-gradient(135deg, #fff7d8, #ffffff 74%);
    border-color: #f4d270;
}

.week-meal.meal-comida {
    background: linear-gradient(135deg, #eaf8ef, #ffffff 74%);
    border-color: #9ed7b2;
}

.week-meal.meal-cena {
    background: linear-gradient(135deg, #ece9ff, #ffffff 74%);
    border-color: #bcb4f3;
}

.week-meal.empty-meal {
    background: #f2f4f2;
    color: #7c888a;
    box-shadow: none;
}

.week-meal.empty-meal:hover,
.week-meal.empty-meal:focus {
    transform: none;
    box-shadow: none;
}

.pill-stack {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    max-width: 118px;
    min-height: 34px;
    flex-wrap: wrap;
}

.pill-icon {
    width: 34px;
    height: 20px;
    flex: 0 0 auto;
    filter: drop-shadow(0 2px 4px rgba(22, 38, 44, .16));
}

.pill-icon.half {
    width: 22px;
}

.pill-more,
.no-dose {
    min-height: 28px;
    border-radius: 999px;
    padding: 4px 8px;
    display: inline-grid;
    place-items: center;
    background: rgba(255, 255, 255, .78);
    color: var(--muted);
    font-size: 13px;
}

.no-dose {
    font-weight: 800;
}

.hover-pop {
    grid-column: 1 / -1;
    display: none;
    margin-top: 12px;
    background: #f6f7f4;
    border: 1px solid #e5ebe7;
    border-radius: 8px;
    padding: 10px;
}

.week-meal:hover .hover-pop,
.week-meal:focus .hover-pop,
.week-meal:focus-within .hover-pop {
    display: grid;
    gap: 8px;
}

.hover-item {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 8px;
    align-items: center;
}

.hover-item + .hover-item {
    margin-top: 8px;
}

.hover-item img {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    object-fit: cover;
    background: #edf1ee;
}

.hover-item p {
    margin: 0;
    font-size: 15px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.hover-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 3px;
}

.hover-pills .pill-icon {
    width: 28px;
    height: 16px;
}

.hover-pills .pill-icon.half {
    width: 18px;
}

.admin-shell {
    width: min(1240px, 100%);
    margin: 0 auto;
    padding: 18px 14px 40px;
    display: grid;
    grid-template-columns: minmax(240px, 330px) 1fr;
    gap: 18px;
    align-items: start;
}

.admin-shell > .alert {
    grid-column: 1 / -1;
}

.user-list {
    display: grid;
    gap: 12px;
}

.user-pill-row {
    position: relative;
}

.user-pill {
    position: relative;
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    gap: 10px;
    border: 2px solid rgba(31, 42, 46, .08);
    border-radius: 8px;
    padding: 14px 104px 14px 12px;
    background: linear-gradient(180deg, #ffffff 0%, #edf5f1 100%);
    box-shadow: 0 12px 22px rgba(22, 38, 44, .12), inset 0 1px 0 rgba(255, 255, 255, .9);
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
}

.admin-user-pill {
    grid-template-columns: 1fr;
}

.user-pill-avatar {
    width: 42px;
    height: 42px;
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
    border-radius: 50%;
    object-fit: cover;
    background: #edf1ee;
}

.user-pill-avatar.fallback {
    background: linear-gradient(135deg, var(--primary), #6bb49e);
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, .35), 0 5px 12px rgba(19, 124, 104, .22);
}

.user-pill:hover,
.user-pill:focus {
    border-color: rgba(19, 124, 104, .34);
    box-shadow: 0 16px 28px rgba(22, 38, 44, .16), inset 0 1px 0 rgba(255, 255, 255, .9);
    transform: translateY(-1px);
}

.user-pill:active {
    transform: translateY(1px) scale(.99);
    box-shadow: 0 4px 10px rgba(22, 38, 44, .12), inset 0 2px 6px rgba(22, 38, 44, .08);
}

.user-pill.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, #0f604f 100%);
    color: #fff;
    box-shadow: 0 16px 30px rgba(19, 124, 104, .26), inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.user-pill.active .user-pill-avatar.fallback {
    background: #fff;
    box-shadow: inset 0 0 0 8px #dff3e7, 0 5px 12px rgba(0, 0, 0, .12);
}

.user-pill-name {
    grid-column: 2;
    font-weight: 850;
    font-size: 19px;
}

.admin-user-pill .user-pill-name {
    grid-column: 1;
}

.user-pill small {
    grid-column: 2;
    color: var(--muted);
    font-weight: 750;
}

.admin-user-pill small {
    grid-column: 1;
}

.user-status-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.user-status-line span {
    border-radius: 999px;
    padding: 3px 8px;
    background: rgba(19, 124, 104, .1);
    color: var(--primary-dark);
    font-size: 13px;
    line-height: 1.2;
}

.user-pill.active small {
    color: rgba(255, 255, 255, .82);
}

.user-pill.active .user-status-line span {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

.user-pdf-button {
    position: absolute;
    top: 50%;
    right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    border: 0;
    border-radius: 7px;
    padding: 5px 8px;
    color: #4c3713;
    background: #fff3c4;
    box-shadow: none;
    font-size: 13px;
    font-weight: 850;
    text-align: center;
    text-decoration: none;
    transform: translateY(-50%);
    transition: box-shadow .14s ease, background .14s ease;
}

.user-pdf-button::before {
    content: "PDF";
    margin-right: 5px;
    border-radius: 6px;
    padding: 1px 4px;
    background: #137c68;
    color: #fff;
    font-size: 10px;
}

.user-pdf-button:hover,
.user-pdf-button:focus {
    background: #ffe9a0;
    box-shadow: 0 8px 16px rgba(22, 38, 44, .1);
}

.user-pdf-button:active {
    box-shadow: none;
}

.family-empty-state {
    min-height: 260px;
    display: grid;
    align-content: center;
}

.admin-form,
.admin-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 18px;
}

.admin-actions form {
    display: grid;
    gap: 8px;
}

.account-form {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfb;
}

.profile-photo-field {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 12px;
    align-items: center;
}

.profile-photo-field img,
.profile-photo-field > span {
    width: 72px;
    height: 72px;
    border-radius: 50%;
}

.profile-photo-field img {
    object-fit: cover;
    background: #edf1ee;
}

.profile-photo-field > span {
    background: linear-gradient(135deg, var(--primary), #6bb49e);
    box-shadow: inset 0 3px 7px rgba(255, 255, 255, .3);
}

.admin-schedule {
    display: grid;
    gap: 12px;
}

.admin-schedule-day {
    border: 1px solid rgba(31, 42, 46, .09);
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbf9 100%);
    box-shadow: 0 10px 24px rgba(22, 38, 44, .07);
    overflow: hidden;
}

.admin-schedule-day summary {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 900;
    list-style: none;
}

.admin-schedule-day summary::-webkit-details-marker {
    display: none;
}

.admin-schedule-day summary::after {
    content: "+";
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e7f5ef;
    color: var(--primary-dark);
    font-size: 22px;
    line-height: 1;
}

.admin-schedule-day[open] summary::after {
    content: "-";
}

.admin-schedule-day summary span {
    font-size: 21px;
}

.admin-schedule-day summary em {
    margin-left: auto;
    border-radius: 999px;
    padding: 5px 10px;
    background: #fff3c4;
    color: #4c3713;
    font-size: 14px;
    font-style: normal;
    font-weight: 900;
}

.admin-schedule-content {
    display: grid;
    gap: 10px;
    padding: 0 14px 14px;
}

.admin-schedule-meal {
    display: grid;
    gap: 6px;
    border-left: 4px solid var(--primary);
    border-radius: 0 8px 8px 0;
    padding: 10px 0 10px 12px;
    background: rgba(255, 255, 255, .72);
}

.admin-schedule-meal strong {
    color: var(--primary-dark);
}

.admin-schedule-meal ul {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.admin-schedule-meal li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid rgba(31, 42, 46, .06);
}

.admin-schedule-meal em {
    flex: 0 0 auto;
    color: var(--ink);
    font-style: normal;
    font-weight: 850;
}

@media (min-width: 800px) {
    .shell {
        padding-top: 28px;
        grid-template-columns: 1.05fr .95fr;
        align-items: start;
    }

    .next-card {
        grid-column: 1 / 2;
    }

    .all-doses-heading,
    .days {
        grid-column: 1 / 2;
    }

    .meal-panel {
        grid-column: 2 / 3;
        grid-row: 1 / span 2;
    }

    .form-panel,
    .shell.single > * {
        grid-column: 1 / -1;
    }

    .dashboard-shell {
        grid-template-columns: 1fr;
    }

    .dashboard-shell .next-card,
    .dashboard-shell .all-doses-heading,
    .dashboard-shell .days,
    .dashboard-shell .meal-panel {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}

@media (max-width: 620px) {
    body { font-size: 17px; }
    .topbar { padding: 10px 12px; }
    .shell { padding: 12px 10px 30px; }
    .home-launch { display: none; }
    .dashboard-shell .home-launch { display: grid; }
    .dashboard-shell:not(.mobile-dose-view) .priority-card { display: none; }
    .dashboard-shell.mobile-dose-view .home-launch { display: none; }
    .mobile-home-link {
        display: flex;
        width: 100%;
    }
    .side-menu .mobile-side-home {
        display: flex;
    }
    .logo-img { width: 174px; }
    .days { gap: 6px; }
    .days a { min-height: 62px; font-size: 16px; }
    .meal-tabs {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .meal-tabs a,
    .meal-tabs span {
        min-height: 38px;
        padding: 5px 10px;
        font-size: 16px;
        line-height: 1.15;
        text-align: center;
    }
    .meal-tabs a[href*="meal=desayuno"],
    .meal-tabs span:first-child {
        background: #fff7d8;
        border-color: #f4d270;
        color: #4c3713;
    }
    .meal-tabs a[href*="meal=comida"],
    .meal-tabs span:nth-child(2) {
        background: #eaf8ef;
        border-color: #9ed7b2;
        color: #0f604f;
    }
    .meal-tabs a[href*="meal=cena"],
    .meal-tabs span:nth-child(3) {
        background: #ece9ff;
        border-color: #bcb4f3;
        color: #37315f;
    }
    .meal-tabs a.active,
    .meal-tabs span.active {
        border-color: var(--primary);
        box-shadow: inset 0 0 0 2px rgba(19, 124, 104, .18);
    }
    .dose-card, .medicine-card {
        grid-template-columns: 68px 1fr;
    }
    .featured-dose form, .medicine-actions, .medicine-actions .quiet-button, .medicine-actions .danger-button {
        grid-column: 1 / -1;
        width: 100%;
    }
    .featured-dose {
        grid-template-columns: 68px 1fr;
    }
    .two-cols, .schedule-row, .admin-form, .admin-actions, .admin-shell, .search-form {
        grid-template-columns: 1fr;
    }
    .user-pill-row {
        display: block;
    }
    .user-pdf-button {
        right: 10px;
    }
    .search-card { grid-template-columns: 52px 1fr; }
    .search-card img { width: 52px; height: 52px; }
    .admin-shell { padding: 12px 10px 30px; }
    .week-grid { grid-template-columns: 1fr; }
    .week-day { min-width: 0; min-height: 0; }
    .week-meal {
        grid-template-columns: 1fr;
        gap: 8px;
        min-height: 118px;
        padding: 14px;
    }
    .pill-stack {
        justify-content: flex-start;
        max-width: none;
    }
    .hover-pop {
        display: grid;
        gap: 8px;
        margin-top: 8px;
    }
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }
    .section-head .primary {
        width: 100%;
    }
    .control-actions,
    .control-actions .quiet-button,
    .control-actions .primary {
        width: 100%;
    }
}
