/**
 * Page-specific Styles
 */

/* ========== Auth Pages (Split Screen Redesign) ========== */
.auth-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
    margin: 0;
    padding: 0;
    z-index: 50;
}

/* Desktop Split Layout */
@media (min-width: 900px) {
    .auth-page {
        flex-direction: row;
        overflow: hidden;
    }
}

/* ----- Hero Panel (Left Side on Desktop, Top on Mobile) ----- */
.auth-hero {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--spacing-8);
    background: linear-gradient(135deg, #101524, #1a2235);
    overflow: hidden;
    min-height: 300px;
}

@media (min-width: 900px) {
    .auth-hero {
        flex: 1.2;
        padding: var(--spacing-12);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
        z-index: 2;
    }
}

/* Background image overlay */
.auth-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../assets/images/auth_hero.png');
    background-size: cover;
    background-position: center;
    opacity: 0.6;
    mix-blend-mode: overlay;
    z-index: 0;
    animation: slowZoom 20s infinite alternate ease-in-out;
}

@keyframes slowZoom {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}

/* Overlay gradient to ensure text readability */
.auth-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(26, 26, 46, 0.4) 0%, rgba(26, 26, 46, 0.9) 100%);
    z-index: 0;
}

.auth-hero-content {
    position: relative;
    z-index: 1;
    max-width: 500px;
    margin: 0 auto;
}

.auth-hero-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
    margin-bottom: var(--spacing-8);
}

.auth-hero-logo img {
    width: 60px;
    height: 60px;
}

.auth-hero-logo h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--color-white);
    letter-spacing: -0.5px;
    margin: 0;
}

.auth-hero-text h2 {
    font-size: 42px;
    font-weight: 700;
    color: var(--color-white);
    line-height: 1.2;
    margin-bottom: var(--spacing-4);
    background: linear-gradient(135deg, #fff, var(--color-primary-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-hero-text p {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

@media (max-width: 899px) {
    .auth-hero-text h2 {
        font-size: 32px;
    }

    .auth-hero-logo {
        margin-bottom: var(--spacing-6);
        justify-content: center;
    }

    .auth-hero-content {
        text-align: center;
    }
}

/* ----- Auth Form Panel (Right Side on Desktop, Bottom Sheet on Mobile) ----- */
.auth-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-6);
    background: var(--bg-primary);
    position: relative;
    z-index: 1;
    overflow-y: auto;
}

@media (max-width: 899px) {
    .auth-hero {
        height: 100vh;
        flex: none;
        padding-bottom: var(--spacing-12);
    }

    .auth-wrapper {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        max-height: 90vh;
        border-radius: 30px 30px 0 0;
        margin-top: 0;
        padding-top: var(--spacing-8);
        padding-bottom: var(--spacing-12);
        box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.7);
        transform: translateY(100%);
        transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 20;
        overflow-y: auto;
    }

    .auth-page.form-open .auth-wrapper {
        transform: translateY(0);
    }

    .auth-page.form-open .auth-hero-overlay {
        background: linear-gradient(to bottom, rgba(16, 21, 36, 0.8) 0%, rgba(16, 21, 36, 0.98) 100%);
        transition: background 0.5s ease;
    }

    .auth-page.form-open .auth-mobile-actions {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
}

.auth-mobile-actions {
    display: none;
    flex-direction: column;
    gap: var(--spacing-4);
    margin-top: var(--spacing-10);
}

@media (max-width: 899px) {
    .auth-mobile-actions {
        display: flex;
        animation: fadeIn 0.6s ease 0.3s both;
    }
}

@media (min-width: 900px) {
    .mobile-back-btn {
        display: none !important;
    }
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    padding: var(--spacing-8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

@media (max-width: 480px) {
    .auth-card {
        padding: var(--spacing-6);
        border: none;
        background: transparent;
        box-shadow: none;
    }
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-2);
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: var(--spacing-8);
}

.auth-footer {
    text-align: center;
    margin-top: var(--spacing-8);
    color: var(--text-secondary);
    font-size: 15px;
}

.auth-footer a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
    padding: 0 4px;
}

.auth-footer a:hover {
    color: var(--color-primary-light);
}

/* Hero */
.dash-hero {
    margin-bottom: 24px;
}

.dash-greeting {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 8px;
    line-height: 1.2;
}

.dash-name {
    background: linear-gradient(135deg, var(--color-primary), var(--color-success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dash-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: var(--text-muted);
    margin: 0;
}

.dash-date svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

/* Stats Row */
.dash-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.dash-stat-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.25s ease;
}

.dash-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.1);
}

.dash-stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dash-stat-icon svg {
    width: 22px;
    height: 22px;
}

.dash-stat-icon.taken {
    background: rgba(38, 222, 129, 0.12);
    color: var(--color-success);
}

.dash-stat-icon.pending {
    background: rgba(78, 205, 196, 0.12);
    color: var(--color-primary);
}

.dash-stat-icon.devices {
    background: rgba(254, 202, 87, 0.12);
    color: var(--color-accent);
}

.dash-stat-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.dash-stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.dash-stat-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Sections */
.dash-section {
    margin-bottom: 28px;
}

.dash-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.dash-section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.dash-section-title svg {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
    opacity: 0.8;
}

.dash-section-link {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    transition: opacity 0.2s;
}

.dash-section-link:hover {
    opacity: 0.8;
}

/* Schedule */
.dash-schedule {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dash-schedule-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    border-left: 3px solid var(--color-primary);
    transition: all 0.2s ease;
}

.dash-schedule-item:hover {
    background: var(--bg-card-hover);
}

.dash-schedule-item.completed {
    border-left-color: var(--color-success);
    opacity: 0.65;
}

.dash-schedule-item.missed {
    border-left-color: var(--color-error);
}

.dash-schedule-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 52px;
    flex-shrink: 0;
}

.dash-time-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.dash-time-period {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.dash-schedule-divider {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.dash-schedule-content {
    flex: 1;
    min-width: 0;
}

.dash-schedule-med {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-schedule-detail {
    font-size: 15px;
    color: var(--text-muted);
}

.dash-schedule-status {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
}

.dash-schedule-status svg {
    width: 20px;
    height: 20px;
}

.dash-schedule-status.completed {
    color: var(--color-success);
    background: rgba(38, 222, 129, 0.12);
}

.dash-schedule-status.missed {
    color: var(--color-error);
    background: rgba(252, 92, 101, 0.12);
}

.dash-schedule-status.upcoming {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

/* Dashboard Dispensers */
.dash-dispensers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.dash-disp-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s ease;
}

.dash-disp-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-color: rgba(78, 205, 196, 0.2);
}

.dash-disp-accent {
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-success));
}

.dash-disp-top {
    padding: 14px 16px 8px;
}

.dash-disp-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.dash-disp-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.dash-disp-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    padding: 3px 10px 3px 6px;
    border-radius: 20px;
}

.dash-disp-status.online {
    background: rgba(38, 222, 129, 0.12);
    color: var(--color-success);
}

.dash-disp-status.offline {
    background: rgba(108, 117, 125, 0.15);
    color: var(--text-muted);
}

/* Dispenser slot rows */
.dash-disp-rows {
    padding: 4px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dash-disp-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    transition: background 0.15s ease;
}

.dash-disp-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.dash-disp-row-num {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.dash-disp-row-med {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-disp-row-med.empty {
    color: var(--text-muted);
    font-weight: 500;
}

.dash-disp-row-dash {
    font-size: 14px;
    color: var(--text-muted);
    opacity: 0.4;
    margin-right: 6px;
}

.dash-disp-row-ring {
    position: relative;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dash-disp-row-count {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
}

.dash-disp-row-count.good {
    color: var(--color-primary);
}

.dash-disp-row-count.warning {
    color: var(--color-warning);
}

.dash-disp-row-count.critical {
    color: var(--color-error);
}

/* Dashboard Empty State */
.dash-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}

.dash-empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    opacity: 0.3;
}

.dash-empty-icon svg {
    width: 48px;
    height: 48px;
}

.dash-empty h3 {
    margin: 0 0 4px;
    font-size: 15px;
    color: var(--text-secondary);
}

.dash-empty p {
    margin: 0;
    font-size: 13px;
}

/* Mobile Responsive */
@media (max-width: 767px) {
    .dash-greeting {
        font-size: 28px;
    }

    .dash-stats {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
    }

    .dash-stat-card {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .dash-stat-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .dash-stat-icon svg {
        width: 18px;
        height: 18px;
    }

    .dash-stat-value {
        font-size: 24px;
    }

    .dash-stat-label {
        font-size: 11px;
    }

    .dash-dispensers-grid {
        grid-template-columns: 1fr;
    }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-4);
}

.section-title {
    font-size: 34px;
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.5px;
}

.section-link {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
}

/* Today's Schedule */
.schedule-timeline {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
}

.schedule-item {
    display: flex;
    gap: var(--spacing-4);
    padding: var(--spacing-4);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--color-primary);
}

.schedule-item.completed {
    border-left-color: var(--color-success);
    opacity: 0.7;
}

.schedule-item.missed {
    border-left-color: var(--color-error);
}

.schedule-item.upcoming {
    border-left-color: var(--color-accent);
}

.schedule-time {
    flex-shrink: 0;
    width: 60px;
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary);
}

.schedule-content {
    flex: 1;
}

.schedule-med-name {
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--spacing-1);
}

.schedule-dosage {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.schedule-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.schedule-status-icon {
    width: 24px;
    height: 24px;
}

.schedule-status-icon.completed {
    color: var(--color-success);
}

.schedule-status-icon.missed {
    color: var(--color-error);
}

/* ========== Dispensers Page ========== */
.dispensers-grid {
    display: grid;
    gap: var(--spacing-4);
}

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

.dispenser-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dispenser-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    border-color: rgba(78, 205, 196, 0.2);
}

/* Gradient accent bar at top */
.dcard-accent {
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-success));
}

/* Header */
.dcard-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px 12px;
}

.dcard-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.15), rgba(38, 222, 129, 0.1));
    border: 1px solid rgba(78, 205, 196, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    flex-shrink: 0;
}

.dcard-icon svg {
    width: 22px;
    height: 22px;
}

.dcard-info {
    flex: 1;
    min-width: 0;
}

.dcard-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.dcard-meta {
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dcard-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px 2px 6px;
    border-radius: 20px;
}

.dcard-status-badge.online {
    background: rgba(38, 222, 129, 0.12);
    color: var(--color-success);
}

.dcard-status-badge.offline {
    background: rgba(108, 117, 125, 0.15);
    color: var(--text-muted);
}

.dcard-slot-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Slots rows */
.dcard-slots {
    padding: 4px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dcard-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    transition: background 0.2s ease;
}

.dcard-slot:hover {
    background: rgba(255, 255, 255, 0.06);
}

.dcard-slot-num {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.dcard-slot-name {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dcard-slot-empty-text {
    color: var(--text-muted);
    font-weight: 500;
}

.dcard-slot-dash {
    font-size: 14px;
    color: var(--text-muted);
    opacity: 0.4;
    margin-right: 10px;
}

/* Mini Ring */
.dcard-slot-ring-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dcard-mini-ring {
    display: block;
}

.dcard-ring-count {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
}

.dcard-ring-count.good {
    color: var(--color-primary);
}

.dcard-ring-count.warning {
    color: var(--color-warning);
}

.dcard-ring-count.critical {
    color: var(--color-error);
}

/* Actions */
.dcard-actions {
    display: flex;
    gap: 8px;
    padding: 10px 16px 14px;
}

.dispenser-action {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.dispenser-action svg {
    width: 18px;
    height: 18px;
}

.dispenser-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-action-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: var(--bg-primary);
    background-size: 200% auto;
    transition: all 0.3s ease;
}

.btn-action-primary:hover:not(:disabled) {
    background-position: right center;
    box-shadow: 0 4px 14px rgba(78, 205, 196, 0.35);
    transform: translateY(-2px);
}

.btn-action-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-action-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Pairing */
.pair-card {
    display: block;
    width: 100%;
    text-align: center;
    padding: var(--spacing-8) var(--spacing-4);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pair-card:hover {
    border-color: var(--color-primary);
    background: var(--bg-card-hover);
}

.pair-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--spacing-4);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pair-icon svg {
    width: 48px;
    height: 48px;
}

.pairing-code-display {
    font-size: var(--font-size-4xl);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.5em;
    color: var(--color-accent);
    padding: var(--spacing-6);
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    margin: var(--spacing-4) 0;
}

/* ========== Medications Page ========== */

/* Page Header */
.med-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.med-page-title {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.med-page-title svg {
    width: 28px;
    height: 28px;
    color: var(--color-primary);
}

.med-page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.med-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.med-action-btn svg {
    width: 18px;
    height: 18px;
}

.med-action-btn.primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: var(--bg-primary);
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.25);
    background-size: 200% auto;
    transition: all 0.3s ease;
}

.med-action-btn.primary:hover {
    background-position: right center;
    box-shadow: 0 6px 16px rgba(78, 205, 196, 0.35);
    transform: translateY(-2px);
}

.med-action-btn.secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.08);
}

.med-action-btn.secondary:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Medication Card List */
.med-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

/* Medication Card */
.med-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.25s ease;
}

.med-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.med-card-checkbox-wrapper {
    padding: var(--spacing-2);
}

.med-card-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.med-card-accent.interaction-warning {
    background: var(--bg-warning);
}

.med-card-accent {
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}

.med-card-body {
    padding: 16px;
}

.med-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.med-card-info {
    flex: 1;
    min-width: 0;
}

.med-card-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.med-card-dosage {
    font-size: 15px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.med-card-slot {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: rgba(78, 205, 196, 0.12);
    color: var(--color-primary);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}

.med-card-instructions {
    font-size: 15px;
    color: var(--text-muted);
    margin-top: 5px;
    opacity: 0.8;
}

.med-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.med-card-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.med-card-btn svg {
    width: 18px;
    height: 18px;
}

.med-card-btn.edit-btn:hover {
    color: var(--color-primary);
    border-color: rgba(78, 205, 196, 0.3);
    background: rgba(78, 205, 196, 0.08);
}

.med-card-btn.delete-btn:hover {
    color: var(--color-error);
    border-color: rgba(252, 92, 101, 0.3);
    background: rgba(252, 92, 101, 0.08);
}

/* Card Bottom: Schedule + Countdown */
.med-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.med-card-times {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.med-card-time-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    background: rgba(78, 205, 196, 0.1);
    border: 1px solid rgba(78, 205, 196, 0.15);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
}

.med-card-next {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-primary);
    white-space: nowrap;
}

.med-card-next svg {
    flex-shrink: 0;
}

.med-card-next.urgent {
    color: var(--color-error);
}

/* Next dose countdown (used by updateCountdowns) */
.next-dose-countdown {
    font-weight: 600;
}

.next-dose-urgent {
    color: var(--color-error);
}

/* Add medication form */
.add-med-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

.frequency-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-2);
}

.frequency-option {
    padding: var(--spacing-3);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.frequency-option:hover {
    border-color: var(--color-primary);
}

.frequency-option.selected {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.1);
}

/* Times per day selector */
.times-per-day-selector {
    display: flex;
    gap: var(--spacing-2);
    flex-wrap: wrap;
}

.times-btn {
    padding: var(--spacing-2) var(--spacing-4);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.times-btn:hover {
    border-color: var(--color-primary);
}

.times-btn.selected {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.15);
    color: var(--color-primary);
}

/* Schedule times list */
.schedule-times-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
}

.schedule-time-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

.dose-label {
    min-width: 60px;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-weight: var(--font-weight-medium);
}

.time-input {
    max-width: 140px;
}

/* Next dose countdown */
.next-dose {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    margin-top: var(--spacing-2);
}

.next-dose-icon {
    width: 16px;
    height: 16px;
}

.next-dose-urgent {
    color: var(--color-error);
}

.schedule-times-display {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-2);
    margin-top: var(--spacing-2);
}

.schedule-time-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-1) var(--spacing-2);
    background: rgba(var(--color-primary-rgb), 0.15);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    color: var(--color-primary);
}

.time-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-2);
}

.time-chip {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-2) var(--spacing-3);
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
}

.time-chip input {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 60px;
    text-align: center;
}

.day-selector {
    display: flex;
    gap: var(--spacing-2);
}

.day-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.day-btn.selected {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--text-inverse);
}

/* ========== Schedule Page ========== */

/* Page Header */
.sched-page-header {
    margin-bottom: 20px;
}

.sched-page-title {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.sched-page-title svg {
    width: 24px;
    height: 24px;
    color: var(--color-primary);
}

/* Date Navigator */
.sched-date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.sched-nav-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.sched-nav-btn svg {
    width: 18px;
    height: 18px;
}

.sched-nav-btn:hover {
    color: var(--color-primary);
    background: var(--bg-card-hover);
    border-color: rgba(78, 205, 196, 0.2);
}

.sched-current-date {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 200px;
    text-align: center;
}

/* Week Selector */
.sched-week {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 24px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.sched-week::-webkit-scrollbar {
    display: none;
}

.sched-day {
    flex: 1;
    min-width: 50px;
    padding: 10px 6px;
    text-align: center;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.sched-day:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.08);
}

.sched-day.selected {
    background: var(--color-primary);
    color: var(--text-inverse);
    border-color: var(--color-primary);
    box-shadow: 0 4px 16px rgba(78, 205, 196, 0.3);
}

.sched-day.today:not(.selected) {
    border-color: var(--color-primary);
}

.sched-day-name {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.sched-day.selected .sched-day-name {
    color: var(--text-inverse);
    opacity: 0.85;
}

.sched-day-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.sched-day.selected .sched-day-num {
    color: var(--text-inverse);
}

.sched-day-dots {
    display: flex;
    gap: 3px;
    justify-content: center;
    min-height: 6px;
}

.sched-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-primary);
}

.sched-day.selected .sched-dot {
    background: var(--text-inverse);
}

.sched-dot.done {
    background: var(--color-success);
}

.sched-day.selected .sched-dot.done {
    background: var(--text-inverse);
}

/* Summary Pills */
.sched-summary {
    margin-bottom: 18px;
}

.sched-summary-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sched-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 20px;
}

.sched-pill svg {
    width: 15px;
    height: 15px;
}

.sched-pill.total {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.sched-pill.taken {
    background: rgba(38, 222, 129, 0.12);
    color: var(--color-success);
}

.sched-pill.missed {
    background: rgba(252, 92, 101, 0.12);
    color: var(--color-error);
}

.sched-pill.upcoming {
    background: rgba(78, 205, 196, 0.1);
    color: var(--color-primary);
}

/* Schedule Timeline */
.sched-timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sched-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    border-left: 3px solid var(--color-primary);
    transition: all 0.2s ease;
}

.sched-item:hover {
    background: var(--bg-card-hover);
}

.sched-item.completed {
    border-left-color: var(--color-success);
    opacity: 0.7;
}

.sched-item.missed {
    border-left-color: var(--color-error);
}

/* Time */
.sched-item-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 52px;
    flex-shrink: 0;
}

.sched-item-time-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.sched-item-time-period {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.sched-item-line {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

/* Content */
.sched-item-content {
    flex: 1;
    min-width: 0;
}

.sched-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 3px;
}

.sched-item-med {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sched-item-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.sched-item-badge svg {
    width: 14px;
    height: 14px;
}

.sched-item-badge.completed {
    background: rgba(38, 222, 129, 0.12);
    color: var(--color-success);
}

.sched-item-badge.missed {
    background: rgba(252, 92, 101, 0.12);
    color: var(--color-error);
}

.sched-item-badge.upcoming {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.sched-item-detail {
    font-size: 15px;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 767px) {
    .sched-page-title {
        font-size: 24px;
    }

    .sched-current-date {
        font-size: 15px;
        min-width: 160px;
    }

    .sched-day {
        min-width: 44px;
        padding: 8px 4px;
    }

    .sched-day-num {
        font-size: 14px;
    }
}

/* ========== Caregivers Page ========== */
.caregiver-tabs {
    margin-bottom: var(--spacing-6);
}

.caregiver-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
}

.caregiver-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
    padding: var(--spacing-4);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
}

.caregiver-info {
    flex: 1;
}

.caregiver-name {
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--spacing-1);
}

.caregiver-role {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.permission-badge {
    font-size: var(--font-size-xs);
    padding: var(--spacing-1) var(--spacing-2);
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
}

.permission-badge.viewer {
    color: var(--text-secondary);
}

.permission-badge.editor {
    color: var(--color-accent);
}

.permission-badge.admin {
    color: var(--color-primary);
}

.invite-form {
    padding: var(--spacing-4);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-6);
}

/* ========== History Page ========== */
.history-filters {
    display: flex;
    gap: var(--spacing-2);
    overflow-x: auto;
    padding-bottom: var(--spacing-2);
    margin-bottom: var(--spacing-4);
    -webkit-overflow-scrolling: touch;
}

.filter-chip {
    padding: 10px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-chip.active {
    background: var(--color-primary);
    color: var(--text-inverse);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
}

.history-item {
    display: flex;
    gap: var(--spacing-4);
    padding: var(--spacing-4);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
}

.history-icon {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-icon svg {
    width: 22px;
    height: 22px;
}

.history-icon.dispense {
    background: rgba(78, 205, 196, 0.2);
    color: var(--color-primary);
}

.history-icon.taken {
    background: rgba(38, 222, 129, 0.2);
    color: var(--color-success);
}

.history-icon.missed {
    background: rgba(252, 92, 101, 0.2);
    color: var(--color-error);
}

.history-icon.refill {
    background: rgba(254, 202, 87, 0.2);
    color: var(--color-accent);
}

.history-content {
    flex: 1;
}

.history-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: var(--spacing-1);
    color: var(--text-primary);
}

.history-meta {
    font-size: 15px;
    color: var(--text-muted);
}

.history-photo {
    flex-shrink: 0;
    width: 68px;
    height: 68px;
    border-radius: var(--radius-md);
    object-fit: cover;
    cursor: pointer;
}

/* ========== Settings Page ========== */
.settings-section {
    margin-bottom: var(--spacing-6);
}

.settings-section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--spacing-4);
    padding-bottom: var(--spacing-2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section-title svg {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
    opacity: 0.8;
}

.settings-list {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.settings-item.list-item-clickable {
    cursor: pointer;
    transition: background var(--transition-fast);
}

.settings-item.list-item-clickable:hover {
    background: var(--bg-card-hover);
}

.settings-item-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    flex: 1;
}

.settings-item-icon {
    width: 28px;
    height: 28px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.settings-item-icon svg {
    width: 28px;
    height: 28px;
}

.settings-item-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.settings-item-value {
    font-size: 15px;
    color: var(--text-muted);
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 52px;
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

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

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    background: var(--color-white);
    border-radius: var(--radius-full);
    transition: transform var(--transition-fast);
}

.toggle.active::after {
    transform: translateX(20px);
}

/* Settings controls */
.settings-select {
    padding: var(--spacing-2) var(--spacing-3);
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    min-width: 120px;
}

.settings-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.settings-input {
    padding: var(--spacing-2) var(--spacing-3);
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    width: 100px;
    text-align: center;
}

.settings-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Profile section */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-6);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-6);
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    font-weight: 800;
    color: var(--text-inverse);
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(78, 205, 196, 0.25);
}

.profile-name {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.profile-email {
    color: var(--text-muted);
    font-size: 16px;
}

.profile-meta {
    margin-top: 12px;
    display: flex;
    gap: var(--spacing-4);
    font-size: 15px;
    color: var(--text-muted);
}

/* Device info cards in settings */
.settings-devices-grid {
    display: grid;
    gap: var(--spacing-4);
}

.settings-device-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-4);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-device-card:hover {
    border-color: var(--color-primary);
    background: var(--bg-card-hover);
}

.device-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-3);
}

.device-card-name {
    font-weight: var(--font-weight-semibold);
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.device-card-status {
    font-size: var(--font-size-xs);
    padding: var(--spacing-1) var(--spacing-2);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-medium);
}

.device-card-status.online {
    background: rgba(38, 222, 129, 0.15);
    color: var(--color-success);
}

.device-card-status.offline {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.device-card-info {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-3);
    font-size: var(--font-size-sm);
}

.device-card-info-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-1);
    color: var(--text-secondary);
}

.device-card-info-item svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

/* WiFi signal bars */
.wifi-signal {
    display: flex;
    align-items: center;
    gap: var(--spacing-1);
}

.wifi-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.wifi-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.wifi-bar {
    width: 3px;
    background: var(--text-muted);
    border-radius: 1px;
}

.wifi-bar.bar-1 {
    height: 4px;
}

.wifi-bar.bar-2 {
    height: 7px;
}

.wifi-bar.bar-3 {
    height: 10px;
}

.wifi-bar.bar-4 {
    height: 13px;
}

.wifi-signal.excellent .wifi-bar {
    background: var(--color-success);
}

.wifi-signal.good .wifi-bar.bar-1,
.wifi-signal.good .wifi-bar.bar-2,
.wifi-signal.good .wifi-bar.bar-3 {
    background: var(--color-success);
}

.wifi-signal.fair .wifi-bar.bar-1,
.wifi-signal.fair .wifi-bar.bar-2 {
    background: var(--color-warning);
}

.wifi-signal.poor .wifi-bar.bar-1 {
    background: var(--color-error);
}

/* Device details list */
.device-details-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.device-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-2) var(--spacing-3);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

.device-detail-label {
    color: var(--text-muted);
    font-weight: var(--font-weight-medium);
}

.device-detail-value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: var(--spacing-1);
}

.device-detail-slots {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-2);
}

.device-slots-list {
    display: flex;
    gap: var(--spacing-2);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.device-slot-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
    min-width: 0;
    padding: var(--spacing-1) var(--spacing-1);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
}

.device-slot-mini.assigned {
    background: rgba(67, 97, 238, 0.15);
    border: 1px solid rgba(67, 97, 238, 0.3);
}

.device-slot-mini .slot-number {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.device-slot-mini .slot-pill-count {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

/* Slot calibration buttons */
.slot-calibration {
    display: flex;
    gap: var(--spacing-1);
    margin-top: var(--spacing-1);
    width: 100%;
}

.btn-calib {
    flex: 1 1 0;
    min-width: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(67, 97, 238, 0.4);
    background: rgba(67, 97, 238, 0.12);
    color: var(--text-primary);
    cursor: pointer;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-calib:hover:not(:disabled) {
    background: rgba(67, 97, 238, 0.3);
}

.btn-calib:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Quiet hours input */
.quiet-hours-input {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.quiet-hours-input input[type="time"] {
    padding: var(--spacing-2);
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

/* Caregiver section */
.caregiver-list-settings {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
}

.caregiver-item-settings {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.caregiver-avatar-small {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-semibold);
    color: var(--text-inverse);
}

.caregiver-info {
    flex: 1;
}

.caregiver-name {
    font-weight: var(--font-weight-medium);
}

.caregiver-role {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* Danger section */
.danger-section {
    margin-top: var(--spacing-6);
}

.danger-btn {
    background: rgba(252, 92, 101, 0.1);
    color: var(--color-error);
    border: 1px solid rgba(252, 92, 101, 0.3);
}

.danger-btn:hover {
    background: rgba(252, 92, 101, 0.2);
    border-color: var(--color-error);
}

/* Export buttons */
.export-buttons {
    display: flex;
    gap: var(--spacing-2);
}

.export-btn {
    flex: 1;
    padding: var(--spacing-2) var(--spacing-3);
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.export-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(78, 205, 196, 0.1);
}

/* Logout button */
.logout-btn {
    width: 100%;
    margin-top: var(--spacing-6);
}

/* ========== Dispenser Detail Page (Redesigned) ========== */

/* Device Info Card */
.device-info-card {
    padding: var(--spacing-5);
    margin-bottom: var(--spacing-6);
}

.device-info-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

@media (min-width: 768px) {
    .device-info-grid {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.device-status-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-3);
    width: 100%;
}

@media (min-width: 768px) {
    .device-status-section {
        flex-direction: row;
        width: auto;
    }
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
}

.status-badge.status-online {
    background: rgba(38, 222, 129, 0.15);
    color: var(--color-success);
}

.status-badge.status-offline {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.status-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.status-online .status-pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.last-seen {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.device-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-3);
}

@media (min-width: 768px) {
    .device-meta {
        display: flex;
        gap: var(--spacing-6);
        flex-wrap: wrap;
    }
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    padding: var(--spacing-3);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
}

@media (min-width: 768px) {
    .meta-item {
        flex-direction: row;
        text-align: left;
        background: transparent;
        padding: 0;
        gap: var(--spacing-2);
    }
}

.meta-item svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

@media (min-width: 768px) {
    .meta-item svg {
        width: 16px;
        height: 16px;
    }
}

.meta-label {
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (min-width: 768px) {
    .meta-label {
        font-size: var(--font-size-sm);
        text-transform: none;
        letter-spacing: normal;
    }
}

.meta-value {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-size: 16px;
}

.device-actions {
    display: flex;
    gap: var(--spacing-3);
    margin-top: var(--spacing-4);
    padding-top: var(--spacing-4);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Slots Table */
.slots-section {
    margin-bottom: var(--spacing-6);
}

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-4);
}

.section-header-row .section-subtitle {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    font-size: 22px;
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

.section-header-row .section-subtitle svg {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
}

.link-primary {
    color: var(--color-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.link-primary:hover {
    opacity: 0.8;
}

.slots-table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    overflow-x: auto;
}

.slots-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.slots-table thead {
    background: rgba(255, 255, 255, 0.03);
}

.slots-table th {
    padding: var(--spacing-3) var(--spacing-4);
    text-align: left;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.slots-table td {
    padding: var(--spacing-4);
    vertical-align: middle;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.slots-table tbody tr:last-child td {
    border-bottom: none;
}

.slots-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.slot-row.slot-disabled {
    opacity: 0.5;
}

/* Table columns */
.col-slot {
    width: 80px;
}

.col-medication {
    min-width: 180px;
}

.col-pills {
    width: 160px;
}

.col-status {
    width: 100px;
}

.col-actions {
    width: 220px;
    text-align: right;
}

.slot-number-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: white;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-lg);
    border-radius: var(--radius-md);
}

.med-cell {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-1);
}

.med-cell .med-name {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

.no-medication {
    color: var(--text-muted);
    font-style: italic;
    font-size: var(--font-size-sm);
}

/* Slot schedule display */
.slot-schedule-times {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-1);
    margin-top: var(--spacing-1);
}

.slot-next-dose {
    display: inline-flex;
    align-items: center;
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
    margin-top: var(--spacing-1);
}

.slot-next-dose.next-dose-urgent {
    color: var(--color-error);
    animation: pulse-urgent 1s infinite;
}

@keyframes pulse-urgent {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Pills progress */
.pills-cell {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.pill-progress {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.pill-progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.pill-progress-bar.good {
    background: linear-gradient(90deg, var(--color-success), #2ecc71);
}

.pill-progress-bar.warning {
    background: linear-gradient(90deg, var(--color-warning), #f39c12);
}

.pill-progress-bar.critical {
    background: linear-gradient(90deg, var(--color-error), #e74c3c);
}

.pill-count-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Slot status badge */
.slot-status-badge {
    display: inline-flex;
    padding: var(--spacing-1) var(--spacing-3);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
}

.slot-status-badge.enabled {
    background: rgba(38, 222, 129, 0.15);
    color: var(--color-success);
}

.slot-status-badge.disabled {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: var(--spacing-2);
    justify-content: flex-end;
}

.action-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-1);
}

.action-buttons .btn svg {
    width: 14px;
    height: 14px;
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(78, 205, 196, 0.1);
}

.btn-icon {
    padding: var(--spacing-2);
}

/* Activity Section */
.activity-section {
    margin-bottom: var(--spacing-6);
}

/* Danger Zone */
.danger-section {
    margin-bottom: var(--spacing-6);
}

.card-danger {
    border: 1px solid rgba(252, 92, 101, 0.3);
    background: rgba(252, 92, 101, 0.05);
    overflow: hidden;
}

.danger-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-4);
    border-bottom: 1px solid rgba(252, 92, 101, 0.2);
}

.danger-icon {
    width: 24px;
    height: 24px;
    color: var(--color-error);
}

.danger-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-error);
    margin: 0;
}

.danger-body {
    padding: var(--spacing-4);
}

.danger-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-4);
    line-height: 1.5;
}

.danger-body .btn {
    width: 100%;
}

/* Activity list improvements */
.activity-list {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg {
    width: 18px;
    height: 18px;
}

.activity-icon.dispense {
    background: rgba(78, 205, 196, 0.15);
    color: var(--color-primary);
}

.activity-icon.taken {
    background: rgba(38, 222, 129, 0.15);
    color: var(--color-success);
}

.activity-icon.missed {
    background: rgba(252, 92, 101, 0.15);
    color: var(--color-error);
}

.activity-icon.refill {
    background: rgba(254, 202, 87, 0.15);
    color: var(--color-accent);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--spacing-1);
}

.activity-time {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.empty-state-small {
    padding: var(--spacing-6);
    text-align: center;
    color: var(--text-muted);
}

/* ========== Confirm Prescription Page ========== */
.confirm-prescription-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-4);
}

@media (min-width: 900px) {
    .confirm-prescription-container {
        grid-template-columns: 350px 1fr;
        align-items: start;
    }
}

.photo-section {
    position: relative;
}

@media (min-width: 900px) {
    .photo-section {
        position: sticky;
        top: var(--spacing-4);
    }
}

.photo-section .card {
    overflow: hidden;
}

.photo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.photo-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.confidence-badge {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    padding: var(--spacing-1) var(--spacing-2);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
}

.confidence-badge.text-success {
    background: rgba(38, 222, 129, 0.15);
    color: var(--color-success);
}

.confidence-badge.text-warning {
    background: rgba(254, 202, 87, 0.15);
    color: var(--color-warning);
}

.confidence-badge.text-error {
    background: rgba(252, 92, 101, 0.15);
    color: var(--color-error);
}

.photo-content {
    padding: var(--spacing-4);
    text-align: center;
    background: var(--bg-tertiary);
}

.photo-content img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.photo-footer {
    padding: var(--spacing-4);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.medications-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

/* Medication confirm cards */
.medication-confirm-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.med-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-4);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.med-card-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.med-card-body {
    padding: var(--spacing-4);
}

.form-row {
    display: flex;
    gap: var(--spacing-3);
    margin-bottom: var(--spacing-3);
    flex-wrap: wrap;
}

.form-row .form-group {
    margin-bottom: 0;
}

.flex-1 {
    flex: 1;
    min-width: 120px;
}

.flex-2 {
    flex: 2;
    min-width: 200px;
}

.schedule-times-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
    margin-top: var(--spacing-2);
}

.schedule-times-list .schedule-time-row {
    display: flex;
    gap: var(--spacing-2);
    align-items: center;
}

.schedule-times-list .schedule-time-row input {
    flex: 1;
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(78, 205, 196, 0.1);
}

/* ========== Loading Page ========== */
.loading-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    padding: var(--spacing-8);
}

.loading-spinner-large {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(78, 205, 196, 0.2);
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--spacing-4);
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.3);
}

.loading-text {
    color: var(--text-secondary);
    font-size: var(--font-size-lg);
}

/* ========== Loading Overlay ========== */
.confirm-prescription-wrapper {
    position: relative;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-overlay .loading-text {
    color: var(--text-secondary);
    font-size: var(--font-size-lg);
    margin-top: var(--spacing-4);
}

/* ========== Global Mobile Typography Scaling ========== */
@media (max-width: 767px) {

    /* Page Titles */
    .med-page-title,
    .sched-page-title,
    .dash-greeting,
    .section-title {
        font-size: 26px !important;
    }

    /* Section & Profile Titles */
    .dash-section-title,
    .settings-section-title,
    .profile-name,
    .section-subtitle {
        font-size: 20px !important;
    }

    /* Card Titles */
    .med-card-name,
    .sched-item-med,
    .dash-disp-name,
    .dcard-name,
    .history-title,
    .settings-item-label {
        font-size: 16px !important;
    }

    /* Secondary Text */
    .med-card-instructions,
    .sched-item-detail,
    .dcard-meta,
    .history-meta,
    .settings-item-value,
    .dash-schedule-detail,
    .meta-value {
        font-size: 14px !important;
    }

    .meta-label {
        font-size: 11px !important;
    }
}