/**
 * RESPONSIVE DESIGN FIXES
 * ========================
 * This file contains mobile-first responsive overrides.
 * It should be loaded AFTER styles.css to safely override problematic styles.
 *
 * Breakpoints:
 * - Mobile:  ≤480px (phones portrait)
 * - Tablet:  ≤768px (phones landscape, small tablets)
 * - Desktop: ≤1024px (tablets, small laptops)
 * - Wide:    >1024px (desktops)
 *
 * To disable: simply remove the <link> to this file
 */

/* ===========================================
   CSS VARIABLES FOR RESPONSIVE
   =========================================== */
:root {
    --touch-target-min: 44px;
    --font-min: 0.75rem;
    /* 12px minimum */
    --spacing-mobile: 0.75rem;
    --spacing-tablet: 1rem;
    --spacing-desktop: 1rem;
    --grid-gap: 0.75rem;
    --section-gap: 0.75rem;
    --stack-gap: 0.75rem;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --nav-top-height: calc(72px + var(--safe-area-top));
    --nav-bottom-height: 80px;
}

@media (max-width: 480px) {
    :root {
        --grid-gap: 0.5rem;
        --section-gap: 0.5rem;
        --stack-gap: 0.5rem;
    }
}

@media (min-width: 769px) {
    :root {
        --grid-gap: 0.75rem;
        --section-gap: 0.75rem;
        --stack-gap: 0.75rem;
    }
}

/* ===========================================
   GLOBAL OVERFLOW PREVENTION
   Prevent horizontal scroll on all devices
   =========================================== */
html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Prevent any element from causing horizontal overflow */
img,
video,
iframe,
embed,
object {
    max-width: 100%;
    height: auto;
}

/* Text overflow handling */
h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
a,
li {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

/* ===========================================
   GLOBAL TOUCH TARGET FIXES
   Ensure all interactive elements are at least 44x44px
   =========================================== */

/* Buttons and links */
button,
.btn,
.btn-primary,
.btn-secondary,
.btn-demo,
.icon-btn,
a.btn,
input[type="submit"],
input[type="button"] {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

/* Icon buttons specifically */
.icon-btn {
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Checkboxes and radio buttons - wrapper approach */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Make checkbox/radio labels tappable */
label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
}

/* Nav items */
.nav-item {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===========================================
   GLOBAL FONT SIZE FIXES
   Minimum 12px (0.75rem) for readability
   =========================================== */

/* Override any fonts smaller than 13px — senior-friendly minimum */
.text-xs,
.text-sm,
small,
.stat-label,
.nav-item span:not(.material-symbols-outlined),
.pattern-label,
.meal-tag,
.time-cell,
.filter-btn,
caption,
figcaption {
    font-size: max(0.8125rem, inherit) !important; /* 13px minimum for seniors */
}

/* Ensure body text is readable — senior-friendly */
body {
    font-size: clamp(0.9375rem, 2.5vw, 1.0625rem); /* 15px–17px range */
    line-height: 1.6;
}

/* ===========================================
   COMPACT LAYOUT — Global space efficiency
   Reduces wasted whitespace across ALL pages.
   =========================================== */

/* Cards: tighter padding, rounded corners */
.card,
.chart-card,
.profile-card,
.inventory-card {
    padding: 0.875rem !important;
    border-radius: 14px !important;
}

.stat-card {
    padding: 0.75rem !important;
    border-radius: 14px !important;
}

/* Cards that had inner padding via children */
.card > :first-child {
    padding-top: 0;
}

/* Reduce vertical gaps between ALL sections — global */
section,
.section,
.card + .card,
.card + section,
section + section,
section + .card,
.search-bar,
.filter-chips,
.filter-row,
.import-export-row {
    margin-top: 0.75rem;
}

/* All divs inside screen-scroll — reduce gaps */
.screen-scroll > * + * {
    margin-top: 0.625rem;
}

/* Headers: less bottom margin */
h1, h2, h3 {
    margin-bottom: 0.25rem;
}

/* Page headers (Аптечка, Аналітика, etc.) */
.glass-nav,
.top-nav,
header {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Reduce gap in grids */
.features-grid,
.dashboard-stats,
.analytics-grid,
.vitals-grid {
    gap: 0.5rem !important;
}

/* Tighter padding for page content area */
main,
.screen-shell {
    padding-top: 0.25rem;
}

/* Reduce margin-bottom on all elements globally */
.search-bar { margin-bottom: 0.5rem !important; }
.filter-chips { margin-bottom: 0.25rem !important; }
.import-export-row { margin-bottom: 0.5rem !important; }
.alert-card { margin-bottom: 0.5rem !important; }

/* Compact buttons in tool rows */
.import-export-row .btn-secondary,
.scan-actions .btn-secondary,
.scan-actions .btn-primary {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
}

/* ===========================================
   CONTAINER & SPACING RESPONSIVE
   =========================================== */

.container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

@media (min-width: 481px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (min-width: 769px) {
    .container {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        max-width: 100%;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 100%;
    }
}

/* When sidebar is present, container should fill available space */
@media (min-width: 1024px) {
    body.has-sidebar .screen-shell .container {
        max-width: 100%;
    }
}

/* ===========================================
   NAVIGATION RESPONSIVE
   =========================================== */

/* Top navigation */
.glass-nav {
    height: auto;
    min-height: calc(72px + var(--safe-area-top));
    box-sizing: border-box;
    padding: calc(0.5rem + var(--safe-area-top)) 0 0.5rem;
}

.glass-nav .nav-content {
    gap: 0.5rem;
    justify-content: space-between;
}

@media (max-width: 640px) {
    body.has-sidebar .nav-content {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-auto-rows: auto;
        row-gap: 0.5rem;
        align-items: center;
    }

    body.has-sidebar .nav-content .burger-btn {
        grid-column: 1;
        justify-self: start;
    }

    body.has-sidebar .nav-content .nav-actions {
        grid-column: 3;
        justify-self: end;
    }

    body.has-sidebar .nav-content .header-title-wrapper {
        grid-column: 1 / -1;
        text-align: left;
        margin-left: 0;
    }
}

/* Hide text on mobile, show icons only in auth-group */
@media (max-width: 480px) {
    .glass-nav .auth-group {
        gap: 0.5rem;
    }

    .glass-nav .auth-group .btn-secondary,
    .glass-nav .auth-group .btn-primary {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .logo-text {
        font-size: 1.25rem;
    }
}

/* When nav button text is hidden, make buttons icon-sized */
.nav-actions .btn-secondary:has(> .material-symbols-outlined:only-child),
.nav-actions .btn-primary:has(> .material-symbols-outlined:only-child) {
    padding: 0.5rem;
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
}

/* Ensure icon-only nav buttons look clean when text spans are display:none */
.nav-actions .btn-secondary .material-symbols-outlined,
.nav-actions .btn-primary .material-symbols-outlined {
    flex-shrink: 0;
}

/* Bottom navigation */
.bottom-nav {
    padding: 0.5rem 0.5rem calc(0.5rem + var(--safe-area-bottom));
}

.bottom-nav .nav-item {
    padding: 0.25rem;
}

.bottom-nav .nav-item span:not(.material-symbols-outlined) {
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

@media (max-width: 360px) {
    .bottom-nav .nav-item span:not(.material-symbols-outlined) {
        display: none;
        /* Hide text on very small phones, icons only */
    }

    .nav-grid {
        gap: 0.25rem;
    }
}

/* ===========================================
   CARDS & GRIDS RESPONSIVE
   =========================================== */

/* Rhythm & grid consistency */
.stats-grid,
.features-grid,
.med-grid,
.inventory-grid,
.stats-row,
.action-grid,
.patients-grid,
.dashboard-stats,
.role-grid,
.next-actions,
.fitbit-data,
.language-picker-options,
.analytics-grid {
    gap: var(--grid-gap);
}

.stats-grid {
    margin-bottom: var(--section-gap);
}

.section-header {
    margin-bottom: var(--section-gap);
    padding: 0;
}

.action-grid {
    margin-bottom: var(--section-gap);
}

.patients-grid {
    margin-top: var(--section-gap);
}

.dashboard-greeting {
    margin-bottom: var(--section-gap);
}

.med-card {
    margin-bottom: var(--grid-gap);
}

/* Feature cards on landing */
.features-grid {
    display: grid;
}

@media (max-width: 480px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* Med cards grid & Inventory grid */
.med-grid,
.inventory-grid {
    display: grid;
    grid-template-columns: 1fr;
}

@media (min-width: 481px) {

    .med-grid,
    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {

    .med-grid,
    .inventory-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1440px) {

    .med-grid,
    .inventory-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Stats row (analytics) */
.stats-row {
    display: grid;
}

@media (max-width: 420px) {
    .stats-grid.three-cols {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 360px) {
    .stats-grid.three-cols {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 601px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===========================================
   WEEK-VIEW TABLE - CRITICAL FIX
   Transform table to card layout on mobile
   =========================================== */

/* Remove min-width that causes overflow */
.week-table {
    min-width: unset !important;
}

/* Mobile: Hide table, show card view */
@media (max-width: 768px) {
    .week-table-wrapper {
        overflow-x: visible;
    }

    /* Alternative: horizontal scroll with momentum */
    .week-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .week-table {
        font-size: 0.8rem;
    }

    .week-table th,
    .week-table td {
        padding: 0.5rem 0.25rem;
        min-width: 80px;
    }

    .time-cell {
        min-width: 50px !important;
        width: 50px !important;
    }

    /* Make checkboxes easier to tap */
    .week-table input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }

    /* Meal tags */
    .meal-tag {
        font-size: 0.8125rem;
        padding: 0.15rem 0.35rem;
    }
}

/* Very small phones - simplify further */
@media (max-width: 480px) {

    .week-table th,
    .week-table td {
        padding: 0.35rem 0.15rem;
        min-width: 70px;
    }

    .med-name {
        font-size: 0.75rem;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .med-dose {
        font-size: 0.8125rem;
    }
}

/* ===========================================
   MODALS RESPONSIVE
   =========================================== */

.modal-content,
.modal {
    width: calc(100% - 2rem);
    max-width: 420px;
    max-height: calc(100vh - 2rem);
    margin: 1rem;
}

@media (max-width: 480px) {

    .modal-content,
    .modal {
        width: calc(100% - 1rem);
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        border-radius: 16px;
    }

    .modal-content {
        padding: 1rem;
    }
}

/* Full-screen modal on very small phones */
@media (max-width: 360px) {

    .modal-content,
    .modal {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
}

/* ===========================================
   FORMS RESPONSIVE
   =========================================== */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
select,
textarea {
    min-height: var(--touch-target-min);
    font-size: 16px;
    /* Prevents zoom on iOS */
    padding: 0.75rem 1rem;
}

@media (max-width: 480px) {

    input,
    select,
    textarea {
        width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* ===========================================
   HERO SECTION RESPONSIVE
   =========================================== */

.hero-section {
    padding: 2rem 0;
}

.hero-title {
    font-size: clamp(1.75rem, 6vw, 3.5rem);
    line-height: 1.2;
}

.hero-tagline {
    font-size: clamp(0.875rem, 3vw, 1.125rem);
}

.hero-buttons {
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.landing-page .hero-section {
    min-height: auto;
    align-items: flex-start;
    padding-top: 0;
    padding-bottom: var(--section-gap);
    overflow: visible;
}

.landing-page .hero-content {
    padding-top: 0.75rem;
}

.landing-page .screen-shell {
    height: auto;
    min-height: 100vh;
    padding-top: calc(var(--nav-top-height) + var(--section-gap));
}

.landing-page .screen-scroll {
    overflow: visible;
}

.landing-page .hero-buttons .btn,
.landing-page .hero-buttons .btn-primary,
.landing-page .hero-buttons .btn-demo {
    flex: 0 1 auto;
    min-width: 160px;
    max-width: 260px;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .hero-buttons {
        flex-direction: column;
        width: 100%;
        align-items: center;
    }

    .hero-buttons .btn,
    .hero-buttons .btn-primary,
    .hero-buttons .btn-demo {
        width: 100%;
        max-width: 320px;
        min-width: unset;
        justify-content: center;
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .landing-page .hero-section {
        padding-top: 0.25rem;
    }

    .landing-page .hero-content {
        padding-top: 1.25rem;
    }
}

/* ===========================================
   LANDING PAGE: FIT DESKTOP VIEWPORT
   =========================================== */

@media (min-width: 1025px) {
    .landing-page .landing-shell {
        overflow: auto;
        gap: 0.5rem;
        padding-top: calc(var(--nav-top-height) + 1rem);
        padding-bottom: 0.5rem;
    }

    .landing-page .hero-section {
        min-height: auto;
        padding: 0.25rem 0 0;
        align-items: flex-start;
    }

    .landing-page .hero-title {
        font-size: clamp(1.9rem, 3.2vw, 2.7rem);
        margin-bottom: 0.5rem;
    }

    .landing-page .hero-tagline {
        margin-bottom: 0.5rem;
    }

    .landing-page .hero-buttons {
        margin-bottom: 0.5rem;
    }

    .landing-page .features-section {
        padding-top: 0.25rem;
    }

    .landing-page .features-grid {
        gap: 0.5rem;
        padding: 0.25rem 0 0;
    }

    .landing-page .feature-card {
        padding: 0.85rem;
    }

    .landing-page .feature-card p {
        font-size: 0.85rem;
    }

    .landing-page .feature-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 0.75rem;
    }

    .landing-page .hero-content {
        padding-top: 0.5rem;
    }
}

/* ===========================================
   DASHBOARD RESPONSIVE
   =========================================== */

.dashboard-stats {
    display: grid;
    gap: var(--grid-gap);
}

@media (max-width: 480px) {
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .dashboard-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 769px) {
    .dashboard-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Progress ring on mobile */
@media (max-width: 480px) {
    .progress-ring {
        width: 120px;
        height: 120px;
    }
}

/* ===========================================
   ROLE SELECTION CARDS RESPONSIVE
   =========================================== */

.role-grid {
    display: grid;
    gap: var(--grid-gap);
}

@media (max-width: 480px) {
    .role-grid {
        grid-template-columns: 1fr;
    }

    .role-card {
        padding: 1.25rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .role-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* ===========================================
   FILTERS & TABS RESPONSIVE
   =========================================== */

.filter-group,
.tabs,
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn,
.tab-btn {
    min-height: var(--touch-target-min);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

@media (max-width: 480px) {

    .filter-group,
    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.5rem;
    }

    .filter-group::-webkit-scrollbar,
    .tabs::-webkit-scrollbar {
        display: none;
    }

    .filter-btn,
    .tab-btn {
        flex-shrink: 0;
    }
}

/* ===========================================
   PATIENT CARDS / LIST ITEMS RESPONSIVE
   =========================================== */

.patient-card,
.list-item {
    padding: 1rem;
    gap: 0.75rem;
}

@media (max-width: 480px) {

    .patient-card,
    .list-item {
        padding: 0.875rem;
    }

    .patient-avatar {
        width: 40px;
        height: 40px;
    }

    .patient-name {
        font-size: 0.9rem;
    }

    .patient-status {
        font-size: 0.75rem;
    }
}

/* ===========================================
   CHARTS RESPONSIVE
   =========================================== */

.chart-container {
    position: relative;
    width: 100%;
    max-width: 100%;
}

@media (max-width: 480px) {
    .chart-container {
        height: 200px !important;
    }

    canvas {
        max-height: 200px;
    }
}

/* ===========================================
   PRINT SCHEDULE RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
    .print-table {
        font-size: 0.75rem;
    }

    .print-table th,
    .print-table td {
        padding: 0.35rem;
    }
}

/* ===========================================
   APP SCREEN SHELL
   Lock pages to one-screen layouts with internal scroll areas.
   =========================================== */

.app-screen {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

.app-screen .screen-shell {
    display: flex;
    flex-direction: column;
    gap: var(--stack-gap);
    height: 100vh;
    height: 100dvh;
    padding-top: calc(var(--nav-top-height) + var(--section-gap));
    padding-bottom: calc(var(--section-gap) + var(--safe-area-bottom));
    box-sizing: border-box;
    min-height: 0;
}

.screen-stack {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--stack-gap);
    min-height: 0;
}

.screen-fill {
    flex: 1;
    min-height: 0;
}

.screen-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--stack-gap);
}

/* ===========================================
   FIXED ELEMENTS SPACING FIX
   Prevent content overlap with fixed nav
   =========================================== */

/* Safe area for content below fixed top nav */
/* Safe area for content below fixed top nav using variables */
.screen-shell {
    /* Critical Fix: Ensure content never goes under header */
    padding-top: calc(var(--nav-top-height) + var(--section-gap));
    padding-bottom: calc(var(--section-gap) + var(--safe-area-bottom));
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    box-sizing: border-box;
    gap: var(--stack-gap);
}

/* Bottom padding for pages with bottom nav */
body:has(.bottom-nav) .screen-shell,
.has-bottom-nav .screen-shell {
    padding-bottom: calc(var(--nav-bottom-height) + var(--section-gap) + var(--safe-area-bottom));
}

body:has(.bottom-nav) .screen-scroll,
.has-bottom-nav .screen-scroll {
    padding-bottom: calc(var(--nav-bottom-height) + var(--section-gap) + var(--safe-area-bottom));
}

@media (max-width: 480px) {
    .app-screen .screen-shell {
        gap: var(--stack-gap);
        padding-top: calc(var(--nav-top-height) + var(--section-gap));
        padding-bottom: calc(var(--section-gap) + var(--safe-area-bottom));
    }

    body:has(.bottom-nav) .screen-shell {
        padding-bottom: calc(var(--nav-bottom-height) + var(--section-gap) + var(--safe-area-bottom));
    }

    .has-bottom-nav .screen-shell {
        padding-bottom: calc(var(--nav-bottom-height) + var(--section-gap) + var(--safe-area-bottom));
    }
}

@media (min-width: 1025px) {
    .app-screen .screen-shell {
        gap: var(--stack-gap);
        padding-top: calc(var(--nav-top-height) + var(--section-gap));
        padding-bottom: calc(var(--section-gap) + var(--safe-area-bottom));
    }
}

/* FAB positioning - prevent overlap with bottom nav */
.fab {
    bottom: calc(var(--nav-bottom-height) + 1rem);
    right: 1rem;
}

@media (max-width: 480px) {
    .fab {
        bottom: calc(var(--nav-bottom-height) + 0.75rem);
        right: 0.75rem;
        width: 52px;
        height: 52px;
    }
}

/* Demo exit fallback button */
.demo-exit-floating {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0) + 0.5rem);
    right: 0.75rem;
    z-index: 1101;
}

body[data-role="doctor"] .bottom-nav .nav-item span:not(.material-symbols-outlined),
body[data-role="social_worker"] .bottom-nav .nav-item span:not(.material-symbols-outlined) {
    display: none;
}

/* ===========================================
   PAGE-SPECIFIC RESPONSIVE FIXES
   =========================================== */

/* Landing page layout */
body.landing-page.app-screen {
    overflow: hidden;
}

body.landing-page.app-screen .screen-shell,
body.landing-page.app-screen .landing-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding-top: calc(var(--nav-top-height) + var(--section-gap));
}

body.landing-page.app-screen .screen-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: var(--section-gap);
    -webkit-overflow-scrolling: touch;
}

body.landing-page.app-screen .hero-section {
    min-height: auto;
    align-items: flex-start;
    padding-top: 0.5rem;
    padding-bottom: var(--section-gap);
}

body.landing-page.app-screen .hero-content {
    padding-top: 0;
}

body.landing-page.app-screen .hero-tagline {
    margin-bottom: 0.75rem;
}

body.landing-page.app-screen .hero-title {
    margin-bottom: 0.75rem;
}

body.landing-page.app-screen .hero-buttons {
    margin-bottom: var(--section-gap);
}

body.landing-page.app-screen #features {
    scroll-margin-top: calc(var(--nav-top-height) + var(--section-gap));
}

@media (max-width: 480px) {

    body.landing-page.app-screen .screen-shell,
    body.landing-page.app-screen .landing-shell {
        padding-top: calc(var(--nav-top-height) + var(--section-gap));
    }
}

/* Dashboard layout */
@media (max-width: 640px) {
    body.dashboard-page .header-title-wrapper {
        flex-wrap: wrap;
        justify-content: flex-start !important;
        gap: 0.5rem !important;
    }

    body.dashboard-page .nav-actions {
        gap: 0.35rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    body.dashboard-page .nav-actions .btn-secondary {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {

    body.dashboard-page .med-name,
    body.dashboard-page .med-details {
        white-space: normal;
    }
}

@media (max-width: 360px) {
    body.dashboard-page .next-actions {
        grid-template-columns: 1fr;
    }

    body.dashboard-page .btn-next-action.btn-take {
        grid-column: span 1;
    }
}

/* Analytics layout */
.analytics-grid {
    display: grid;
    gap: var(--grid-gap);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

.patterns-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (max-width: 480px) {
    .patterns-grid {
        grid-template-columns: 1fr;
    }
}

/* Stats grid (dashboards) */
@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .stats-grid.three-cols {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* Access management */
.access-container {
    padding-left: var(--spacing-mobile);
    padding-right: var(--spacing-mobile);
}

@media (min-width: 481px) {
    .access-container {
        padding-left: var(--spacing-tablet);
        padding-right: var(--spacing-tablet);
    }
}

@media (min-width: 769px) {
    .access-container {
        padding-left: var(--spacing-desktop);
        padding-right: var(--spacing-desktop);
    }
}

@media (max-width: 640px) {

    .context-card,
    .access-item {
        padding: 1rem;
    }

    .access-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .access-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .permissions-panel {
        padding: 0.6rem 0.75rem;
    }

    .permissions-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

/* Data sharing / invite */
.share-container,
.invite-container {
    padding-left: var(--spacing-mobile);
    padding-right: var(--spacing-mobile);
}

@media (min-width: 481px) {

    .share-container,
    .invite-container {
        padding-left: var(--spacing-tablet);
        padding-right: var(--spacing-tablet);
    }
}

@media (max-width: 640px) {
    .share-card {
        padding: 1.25rem;
    }

    .code-display {
        font-size: 1.6rem;
        letter-spacing: 0.15em;
        padding: 1rem;
        word-break: break-all;
    }

    .invite-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .invite-code {
        font-size: 1rem;
    }

    .revoke-btn {
        width: 100%;
        text-align: center;
    }

    .permission-item {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .person-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .person-info {
        width: 100%;
    }

    .qr-container canvas {
        max-width: 100%;
        height: auto;
    }

    .invite-container #inviteCodeInput {
        letter-spacing: 0.1rem;
    }
}

@media (max-width: 360px) {
    .code-display {
        font-size: 1.35rem;
        letter-spacing: 0.1em;
    }
}

/* Caregiver dashboard */
.caregiver-container {
    padding-left: var(--spacing-mobile);
    padding-right: var(--spacing-mobile);
}

@media (min-width: 481px) {
    .caregiver-container {
        padding-left: var(--spacing-tablet);
        padding-right: var(--spacing-tablet);
    }
}

@media (min-width: 769px) {
    .caregiver-container {
        padding-left: var(--spacing-desktop);
        padding-right: var(--spacing-desktop);
    }
}

@media (max-width: 640px) {
    .stats-summary {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 1rem;
    }

    .patient-info {
        min-width: 0;
    }

    .patient-name,
    .patient-stats {
        word-break: break-word;
    }

    .patient-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
    }

    .patient-stats {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .patient-avatar {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }

    .patient-name {
        font-size: 1rem;
    }

    .patient-stats {
        font-size: 0.8rem;
    }

    .caregiver-container .btn-primary,
    .caregiver-container .btn-secondary {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
    }

    .caregiver-container .btn-primary .material-symbols-outlined,
    .caregiver-container .btn-secondary .material-symbols-outlined {
        font-size: 1.1rem;
    }
}

/* Profile */
@media (max-width: 640px) {

    .profile-card,
    .profile-actions {
        padding: 1.25rem;
    }

    .profile-field {
        flex-direction: column;
        align-items: flex-start;
    }

    .profile-value {
        text-align: left;
    }

    .profile-setting-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .profile-setting-row select {
        width: 100%;
        min-width: 0;
    }

    .fitbit-card {
        padding: 1rem;
    }

    .fitbit-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .fitbit-data {
        grid-template-columns: 1fr;
    }

    .fitbit-zones {
        flex-direction: column;
    }

    .fitbit-actions {
        flex-direction: column;
    }

    .fitbit-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .fitbit-metric {
        text-align: left;
    }

    .fitbit-metric-value {
        justify-content: flex-start;
        font-size: 1.25rem;
    }

    .fitbit-zone {
        text-align: left;
    }
}

/* Auth (login/signup) */
.login-card {
    width: min(420px, 100%);
    padding: 2rem;
}

.login-shell,
.signup-shell {
    width: 100%;
    padding-left: var(--spacing-mobile);
    padding-right: var(--spacing-mobile);
}

@media (max-width: 600px) {

    .login-shell,
    .signup-shell {
        justify-content: flex-start;
        align-items: stretch;
    }

    .login-card {
        padding: 1.5rem;
    }

    .social-row {
        gap: 0.75rem;
        flex-wrap: wrap;
    }
}

/* Demo role selection */
.demo-page-container {
    padding-left: var(--spacing-mobile);
    padding-right: var(--spacing-mobile);
    max-width: 100%;
}

@media (max-width: 640px) {
    .demo-page-container {
        justify-content: flex-start;
    }
}

/* Inventory */
.filter-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.inventory-layout {
    display: flex;
    gap: 1.5rem;
}

.inventory-sidebar {
    flex: 0 0 340px;
}

.inventory-main {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .inventory-layout {
        flex-direction: column;
    }

    .inventory-sidebar {
        flex: none;
        width: 100%;
    }
}

@media (max-width: 640px) {

    .inventory-header,
    .shopping-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .inventory-actions,
    .shopping-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .shopping-item {
        flex-wrap: wrap;
    }

    .import-export-row {
        flex-direction: column;
    }

    .import-export-row .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

/* Inventory nav: hide secondary button text up to 1280px (always icon-only for scan) */
@media (max-width: 1279px) {
    .inventory-page .nav-actions .btn-secondary span:not(.material-symbols-outlined) {
        display: none;
    }
}

/* Inventory nav: hide ALL button text on narrow screens */
@media (max-width: 768px) {
    .inventory-page .nav-actions .btn-primary span:not(.material-symbols-outlined) {
        display: none;
    }
}

/* Medications */
.med-search-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.med-search-row .med-filter-select {
    min-width: 140px;
}

@media (max-width: 600px) {
    .med-search-row {
        flex-direction: column;
    }

    .med-search-row .med-filter-select {
        width: 100%;
    }

    .med-search-row>.btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .med-actions {
        justify-content: flex-start;
    }

    .med-actions .btn-secondary,
    .med-actions .btn-primary {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    body.medications-page .med-actions {
        display: none;
    }

    body.medications-page #medCount {
        display: none;
    }
}

@media (max-width: 640px) {
    body.medications-page .action-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    body.medications-page .action-toolbar .btn-secondary,
    body.medications-page .action-toolbar .btn-primary {
        width: 100%;
        justify-content: center;
        white-space: normal;
    }
}

/* Scan schedule */
.scan-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .scan-actions {
        flex-direction: column;
    }

    .scan-actions .btn-primary,
    .scan-actions .btn-secondary {
        width: 100%;
        min-width: 0 !important;
    }
}

/* Add medication steps */
.step-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

@media (max-width: 600px) {
    .step-nav {
        flex-direction: column;
        align-items: stretch;
    }

    .step-nav .step-spacer {
        display: none;
    }

    .step-nav .btn-primary,
    .step-nav .btn-secondary {
        width: 100%;
    }
}

/* Shared form actions */
.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 600px) {
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%;
    }
}

/* ===========================================
   UTILITY CLASSES FOR RESPONSIVE
   =========================================== */

/* Hide on specific breakpoints */
@media (max-width: 480px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .hide-tablet {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on specific breakpoints */
.show-mobile {
    display: none !important;
}

@media (max-width: 480px) {
    .show-mobile {
        display: block !important;
    }
}

.show-tablet {
    display: none !important;
}

@media (min-width: 481px) and (max-width: 768px) {
    .show-tablet {
        display: block !important;
    }
}

.show-desktop {
    display: none !important;
}

@media (min-width: 769px) {
    .show-desktop {
        display: block !important;
    }
}

/* Text alignment responsive */
@media (max-width: 480px) {
    .text-center-mobile {
        text-align: center !important;
    }
}

/* ===========================================
   ACCESSIBILITY IMPROVEMENTS
   =========================================== */

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid currentColor;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* ===========================================
   SIDEBAR NAV RESPONSIVE - FIXED
   =========================================== */

/* Sidebar buttons — override global 44px touch-target for compact layout */
.sidebar-nav button,
.sidebar-nav .sidebar-group-header,
.sidebar-nav .sidebar-close,
.sidebar-nav .sidebar-item {
    min-height: 0;
    min-width: 0;
}

/* Sidebar Close Button - Hide on Desktop */
.sidebar-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-close:hover {
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
}

@media (min-width: 1024px) {
    .sidebar-close {
        display: none !important;
    }
}

/* Sidebar Layout Fixes - Prevent content overlap on Desktop */
@media (min-width: 1024px) {
    body.has-sidebar .sidebar-nav {
        transform: translateX(0) !important;
        width: var(--sidebar-width);
        height: 100vh;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 900;
        border-right: 1px solid var(--border-color);
        background: var(--bg-card);
    }

    body.has-sidebar .screen-shell {
        padding-left: 0;
    }

    body.has-sidebar main.screen-shell,
    body.has-sidebar .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
        max-width: calc(100% - var(--sidebar-width));
        padding-left: 0;
        box-sizing: border-box;
    }

    body.has-sidebar .glass-nav {
        padding-left: calc(var(--sidebar-width) + 1rem);
    }
}

/* Ensure sidebar is above everything on mobile */
@media (max-width: 1023px) {
    .sidebar-nav {
        z-index: 1200 !important;
    }

    /* Constrain sidebar logo on mobile */
    .sidebar-logo-img {
        width: 32px;
        height: 32px;
        max-width: 32px;
        max-height: 32px;
        flex-shrink: 0;
    }

    .sidebar-logo-text {
        font-size: 1.1rem;
    }

    .sidebar-header {
        padding: 0.75rem 1rem;
        min-height: 56px;
    }

    /* Ensure sidebar item text is visible */
    .sidebar-item {
        font-size: 0.875rem;
        padding: 0.625rem 1rem;
        gap: 0.75rem;
    }

    .sidebar-item .material-symbols-outlined {
        font-size: 20px;
        flex-shrink: 0;
    }

    /* Group headers compact on mobile */
    .sidebar-group-header {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
}

/* ===========================================
   320px BREAKPOINT - ULTRA SMALL SCREENS
   iPhone SE, Galaxy S III, and similar 320px devices
   =========================================== */

@media (max-width: 360px) {
    /* Global padding reductions */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Cards with inline padding: 2rem need override */
    .card[style*="padding: 2rem"],
    .card[style*="padding:2rem"] {
        padding: 1rem !important;
    }

    /* Dashboard header wrap fix */
    .header-title-wrapper {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Profile role grid - single column */
    #roleSwitcherGrid {
        grid-template-columns: 1fr !important;
    }

    /* Consent card padding */
    .consent-card {
        padding: 1.25rem !important;
    }

    /* Contact form padding */
    .contact-content {
        padding: 1rem !important;
    }

    /* Auth nav buttons - icons only */
    .glass-nav .auth-group .btn-secondary,
    .glass-nav .auth-group .btn-primary {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    /* Policy pages padding */
    .policy-container {
        padding: 1rem 0.5rem !important;
    }

    .policy-content {
        padding: 1.25rem 0.75rem !important;
    }

    .policy-content ul {
        padding-left: 1rem;
    }

    /* Data sharing - action buttons wrap */
    .person-card .btn-secondary,
    .person-card .revoke-btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }

    /* Fitbit callback padding */
    body .callback-card {
        padding: 1rem !important;
    }

    /* Access management inline flex wrap */
    .access-item [style*="justify-content: space-between"] {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .sidebar-nav,
    .sidebar-overlay,
    .demo-exit-btn,
    .demo-exit-floating,
    [data-demo-exit],
    #overlayRoot,
    .print-controls,
    .bottom-nav {
        display: none !important;
    }
    body.has-sidebar .screen-shell,
    body.has-sidebar .main-content,
    body.has-sidebar main {
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
    body.has-sidebar {
        padding-left: 0 !important;
    }
}

/* Role info card (doctor/social-worker dashboards) - stack on narrow screens */
@media (max-width: 480px) {
    .role-info-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        padding: 1.25rem !important;
    }
}

/* Dashboard cards - patient info overflow prevention */
.patient-info {
    min-width: 0;
}

/* Dashboard patient cards & stats - narrow screens */
@media (max-width: 360px) {
    .role-info-card {
        padding: 1rem !important;
    }

    .patient-card {
        padding: 1rem !important;
        gap: 0.75rem !important;
    }

    .patient-avatar {
        width: 36px !important;
        height: 36px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .stat-value {
        font-size: 1.5rem !important;
    }

    .stat-card {
        padding: 0.75rem !important;
    }
}

/* Vitals page - grid & dialog fixes for narrow screens */
@media (max-width: 480px) {
    .vitals-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    .vital-card {
        padding: 1rem !important;
    }

    .vital-value {
        font-size: 1.8rem !important;
    }
}

@media (max-width: 360px) {
    .vitals-grid {
        padding: 0.75rem !important;
    }
}

/* Back link tap target fix (policies) */
.back-link {
    min-height: 44px;
    padding: 0.625rem 0;
    display: inline-flex;
    align-items: center;
}

/* ===========================================
   SENIOR-FRIENDLY ENHANCEMENTS
   Larger touch targets, clearer text, better spacing
   for elderly users (65+)
   =========================================== */

/* Medication cards — larger tap area and clearer text */
.med-card,
.medication-card,
.patient-card {
    min-height: 56px;
    padding: 0.875rem 1rem;
}

/* Sidebar navigation — larger items with more spacing */
.sidebar-nav a,
.sidebar-nav .nav-link {
    min-height: 48px;
    padding: 0.75rem 1rem;
    font-size: var(--text-base);
}

/* Stats and numbers — more prominent for quick scanning */
.stat-value,
.stat-number,
.adherence-badge {
    font-weight: 700;
}

/* ===========================================
   DASHBOARD RESPONSIVE LAYOUT
   Two-column layout on wider screens
   =========================================== */

/* Mobile: single column (default) */
.dashboard-layout {
    display: flex;
    flex-direction: column;
}

.dashboard-top {
    display: contents;
}

.dashboard-sidebar-col {
    display: contents;
}

/* Tablet and up: two-column grid */
@media (min-width: 768px) {
    .dashboard-layout {
        display: grid;
        grid-template-columns: 1fr 260px;
        gap: 1rem;
        align-items: start;
        margin-bottom: 0.75rem;
    }

    .dashboard-top {
        display: flex;
        flex-direction: column;
        grid-column: 1;
    }

    /* Compact greeting on desktop */
    .dashboard-top .dashboard-greeting {
        margin-bottom: 0.5rem;
        padding: 0.25rem 0;
    }

    .dashboard-top .dashboard-greeting h1 {
        font-size: 1.5rem;
    }

    .dashboard-top .dashboard-greeting p {
        font-size: 0.9rem;
    }

    .dashboard-sidebar-col {
        display: flex;
        flex-direction: column;
        grid-column: 2;
        grid-row: 1;
        gap: 0.5rem;
        position: sticky;
        top: calc(var(--nav-top-height, 72px) + 0.75rem);
    }

    .dashboard-sidebar-col .stats-grid.three-cols {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        margin-bottom: 0.25rem;
    }

    .dashboard-sidebar-col .stat-card {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        text-align: left;
        padding: 0.625rem 0.75rem !important;
    }

    .dashboard-sidebar-col .stat-icon-wrapper {
        margin: 0;
        flex-shrink: 0;
    }

    .dashboard-sidebar-col .stat-value {
        font-size: 1.25rem;
        line-height: 1;
    }

    .dashboard-sidebar-col .stat-label {
        font-size: 0.7rem;
    }

    .dashboard-sidebar-col .stat-label-details {
        font-size: 0.7rem;
        margin-top: 0;
    }
}

/* Wider screens: more space for sidebar */
@media (min-width: 1100px) {
    .dashboard-layout {
        grid-template-columns: 1fr 300px;
        gap: 1.25rem;
    }
}

/* Med list: two columns on wider screens */
@media (min-width: 768px) {
    .dashboard-med-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.625rem;
    }

    .dashboard-med-list .med-card {
        margin-bottom: 0;
    }
}

/* Constrain dashboard content width for readability on very wide screens */
@media (min-width: 1024px) {
    #dashboardContent {
        max-width: 960px;
    }
}

/* Badge text — ensure readable size */
.badge,
.adherence-badge,
.meal-badge,
.tag {
    font-size: max(0.8125rem, inherit);
    padding: 0.25rem 0.625rem;
}

/* =============================================
   DASHBOARD: Compact layout to fit 4 meds without scroll
   ============================================= */
@media (min-width: 768px) {
    /* Compact dashboard — keep standard nav height, just tighten content */
    .dashboard-page {
        --section-gap: 0.25rem;
        --stack-gap: 0.25rem;
    }

    /* Compact nav actions on dashboard */
    .dashboard-page .nav-actions {
        gap: 0.35rem;
    }

    .dashboard-page .nav-actions .btn-secondary {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .dashboard-page .nav-actions .icon-btn {
        padding: 0.3rem;
    }

    .dashboard-page .nav-actions .icon-btn .material-symbols-outlined {
        font-size: 20px;
    }

    .dashboard-page .header-avatar-btn {
        width: 32px;
        height: 32px;
    }

    /* Patient context bar (caregiver mode) */
    .dashboard-page .dashboard-patient-bar {
        margin-bottom: 0.25rem;
    }

    /* Tighter next-intake card */
    .dashboard-page .next-intake-card {
        padding: 0.625rem 0.75rem;
        margin-bottom: 0.375rem;
        border-radius: 14px;
    }

    .dashboard-page .next-header {
        gap: 0.5rem;
    }

    .dashboard-page .next-med-info {
        margin-bottom: 0.375rem;
        gap: 0.625rem;
    }

    .dashboard-page .next-med-details .next-med-title {
        font-size: 1rem;
        margin-bottom: 0.125rem;
    }

    .dashboard-page .next-actions {
        gap: 0.5rem;
    }

    .dashboard-page .btn-next-action {
        padding: 0.5rem 0.375rem;
        border-radius: 12px;
        font-size: 0.8rem;
    }

    /* Tighter section header */
    .dashboard-page .section-header {
        margin-bottom: 0.375rem;
        margin-top: 0.125rem;
    }

    /* Compact med cards */
    .dashboard-page .dashboard-med-list {
        gap: 0.375rem;
    }

    .dashboard-page .med-card {
        padding: 0.5rem 0.625rem;
        border-radius: 12px;
        margin-bottom: 0;
    }

    /* Tighter layout grid gap */
    .dashboard-page .dashboard-layout {
        margin-bottom: 0.375rem;
        gap: 0.75rem;
    }

    /* Compact sidebar stats */
    .dashboard-page .dashboard-sidebar-col {
        gap: 0.25rem;
    }

    .dashboard-page .dashboard-sidebar-col .stats-grid.three-cols {
        gap: 0.25rem;
        margin-bottom: 0.125rem;
    }

    .dashboard-page .dashboard-sidebar-col .stat-card {
        padding: 0.375rem 0.5rem !important;
    }

    .dashboard-page .dashboard-sidebar-col .stat-value {
        font-size: 1.1rem;
    }

    .dashboard-page .dashboard-sidebar-col .stat-icon-wrapper {
        width: 24px;
        height: 24px;
    }

    .dashboard-page .dashboard-sidebar-col .stat-icon-wrapper .material-symbols-outlined {
        font-size: 14px;
    }
}

/* Time labels in schedule — prominent for medication timing */
.time-label,
.schedule-time,
.med-time {
    font-size: var(--text-base);
    font-weight: 600;
}

/* Form inputs — larger for easier interaction */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
select,
textarea {
    min-height: 48px;
    font-size: var(--text-base);
    padding: 0.625rem 0.875rem;
}

/* Dropdown selects — easier to tap */
select {
    padding-right: 2.5rem;
}

/* Filter buttons — generous tap targets */
.filter-btn,
.tab-btn,
.chip {
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-size: var(--text-sm);
}

/* Week view cells — larger for easy tapping */
@media (max-width: 768px) {
    .week-cell,
    .day-cell {
        min-height: 64px;
        padding: 0.5rem;
    }
}

/* Empty state text — comforting size */
.empty-state p,
.empty-state-text {
    font-size: var(--text-lg);
    line-height: 1.6;
}

