@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* MemoryCare Caregiver Dashboard Styles */

/* =============================================
   CUSTOM PROPERTIES
   ============================================= */
:root {
    /* ── Palette — MemoryCare Design System ── */
    --bg-page:    #F2ECE4;   /* warm linen page background */
    --bg-card:    #FFFFFF;
    --bg-sidebar: #4A7C6F;   /* sage green header/sidebar */

    --text-dark:   #2D3A32;  /* deep forest — headings, names */
    --text-medium: #7A8C85;  /* supporting / secondary text */
    --text-light:  #FFFFFF;

    /* Sage Green — primary: header, buttons, avatars */
    --accent-blue:       #4A7C6F;   /* primary = sage (variable kept for compatibility) */
    --accent-blue-hover: #3A6359;

    /* Calm Blue — secondary contacts */
    --calm-blue:       #3B6FAD;
    --calm-blue-hover: #2A5490;
    --calm-blue-light: #EAF1FA;

    /* Sage for "done/safe" states */
    --accent-green:       #4A7C6F;
    --accent-green-hover: #3A6359;

    /* Alert Red — emergency ONLY */
    --accent-red:       #D94040;
    --accent-red-hover: #BB3030;

    /* Sunflower Amber — reminders, time-sensitive */
    --accent-yellow: #E8A020;
    --accent-orange: #C87200;

    --border: #D9D0C4;
    --shadow:    0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    --radius-sm:   8px;
    --radius-md:  12px;
    --radius-lg:  16px;
    --radius-full: 50%;

    /* Atkinson Hyperlegible — low-vision optimised typeface */
    --font: 'Atkinson Hyperlegible', 'Helvetica Neue', Arial, sans-serif;
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font);
    color: var(--text-dark);
    background: var(--bg-page);
    line-height: 1.5;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

img { max-width: 100%; display: block; }

/* =============================================
   UTILITIES
   ============================================= */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100dvh; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    transition: background 0.15s ease;
}

.btn-primary {
    background: var(--accent-blue);
    color: var(--text-light);
}
.btn-primary:hover { background: var(--accent-blue-hover); }

.btn-outline {
    background: transparent;
    color: var(--text-dark);
    border: 2px solid var(--border);
}
.btn-outline:hover { background: var(--bg-page); }

/* Buttons inside the dark header get inverted colours */
.cg-header .btn,
.cg-header .btn-outline {
    color: var(--text-light);
    border-color: rgba(255,255,255,0.5);
}
.cg-header .btn-outline:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.75);
}

.btn-danger {
    background: var(--accent-red);
    color: var(--text-light);
}
.btn-danger:hover { background: var(--accent-red-hover); }

.btn-sm { font-size: 13px; padding: 8px 14px; min-height: 36px; }
.btn-full { width: 100%; justify-content: center; }

/* =============================================
   LOGIN SCREEN
   ============================================= */
.login-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 60px 24px;
}

.login-logo {
    text-align: center;
    margin-bottom: 48px;
}

.logo-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-dark);
}

.login-subtitle {
    font-size: 16px;
    color: var(--text-medium);
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-dark);
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    background: var(--bg-card);
}
.login-form input:focus {
    border-color: var(--accent-blue);
    outline: none;
}

.login-demo-note {
    text-align: center;
    font-size: 13px;
    color: var(--text-medium);
    margin-top: 16px;
}

/* =============================================
   CAREGIVER HEADER
   ============================================= */
.cg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-sidebar);
    color: var(--text-light);
    flex-shrink: 0;
    gap: 8px;
}

.cg-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cg-header-left h1 {
    font-size: 22px;
    font-weight: 700;
}

.logo-sm {
    font-size: 28px;
}

.cg-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cg-user-name {
    font-size: 13px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* =============================================
   PATIENT SELECTOR
   ============================================= */
.patient-selector {
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.patient-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    cursor: pointer;
    max-width: 500px;
}
.patient-card.selected {
    border-color: var(--accent-blue);
    background: #E8F4F1;
}

.patient-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    overflow: hidden;
}

.patient-info h3 {
    font-size: 16px;
    font-weight: 600;
}

.patient-status {
    font-size: 13px;
    color: var(--text-medium);
}

.alert-indicator {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent-red);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 700;
}

.alert-indicator .alert-count[data-count="0"] {
    display: none;
}

/* =============================================
   TAB NAVIGATION
   ============================================= */
.tab-nav {
    display: flex;
    padding: 0 12px;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0;
    flex-shrink: 0;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 14px 12px;
    color: var(--text-medium);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    min-height: 48px;
}
.tab:hover { color: var(--text-dark); }
.tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* =============================================
   TAB CONTENT
   ============================================= */
.tab-content {
    display: none;
    padding: 16px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    flex: 1;
}
.tab-content.active { display: block; }

@media (min-width: 768px) {
    .tab-content { padding: 24px; }
    .cg-header { padding: 12px 24px; }
    .patient-selector { padding: 16px 24px; }
    .tab-nav { padding: 0 24px; }
    .tab { font-size: 14px; padding: 12px 16px; }
    .cg-user-name { max-width: none; font-size: 14px; }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.section-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* =============================================
   TRUSTED PEOPLE LIST
   ============================================= */
.trusted-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 640px) {
    .trusted-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
}

.trusted-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.trusted-card-avatar {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-light);
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.trusted-card-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

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

.trusted-card-info h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}
.badge-emergency {
    background: #FDECEA;
    color: var(--accent-red);
}
.badge-primary {
    background: #E8F4F1;
    color: var(--accent-blue);
}


.trusted-card-meta {
    font-size: 13px;
    color: var(--text-medium);
    margin-top: 4px;
}

/* Trusted card summary truncation/expand */
.trusted-card-summary {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-dark);
    line-height: 1.5;
    word-break: break-word;
}
.trusted-card-summary-truncated .trusted-card-summary-text {
    display: inline;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    vertical-align: bottom;
}
.trusted-card-summary-toggle {
    background: none;
    border: none;
    color: var(--accent-blue);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 8px;
    padding: 0;
    text-decoration: underline;
}
.trusted-card-summary-full {
    display: none;
    white-space: pre-line;
}

@media (max-width: 600px) {
    .trusted-card-summary-truncated .trusted-card-summary-text {
        max-width: 90vw;
        font-size: 13px;
    }
    .trusted-card-summary {
        font-size: 13px;
    }
}

.trusted-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.trusted-card-actions .btn {
    font-size: 12px;
    padding: 4px 12px;
}

/* =============================================
   REMINDERS LIST (Caregiver)
   ============================================= */
.cg-reminders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cg-reminder-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.cg-reminder-card.completed {
    opacity: 0.5;
}

.reminder-category-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.cat-medication { background: #FDF3E4; }
.cat-appointment { background: #EAF1FA; }
.cat-task { background: #E8F4F1; }
.cat-other { background: #F0EDE8; }

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

.cg-reminder-info h4 {
    font-size: 15px;
    font-weight: 600;
}

.cg-reminder-info p {
    font-size: 13px;
    color: var(--text-medium);
}

.cg-reminder-info .reminder-datetime {
    font-size: 13px;
    color: var(--accent-yellow);
    font-weight: 600;
}

.cg-reminder-actions {
    display: flex;
    gap: 6px;
}

/* =============================================
   ALERTS LIST
   ============================================= */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    border-left: 4px solid var(--border);
    cursor: pointer;
}

.alert-card.type-location_exit { border-left-color: var(--accent-red); }
.alert-card.type-restricted_zone_entry { border-left-color: var(--accent-red); }
.alert-card.type-emergency_call { border-left-color: var(--accent-red); }
.alert-card.type-face_scan_failed { border-left-color: var(--accent-yellow); }
.alert-card.type-reminder_missed { border-left-color: var(--accent-yellow); }
.alert-card.type-device_inactive { border-left-color: var(--text-medium); }
.alert-card.resolved { opacity: 0.5; }

.alert-type-icon {
    font-size: 28px;
    flex-shrink: 0;
}

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

.alert-info h4 {
    font-size: 15px;
    font-weight: 600;
}

.alert-info p {
    font-size: 13px;
    color: var(--text-medium);
    margin-top: 2px;
}

.alert-time {
    font-size: 12px;
    color: var(--text-medium);
    white-space: nowrap;
}

/* =============================================
   PHOTOS GRID
   ============================================= */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 480px) {
    .photos-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
}

.photo-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.photo-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.photo-card-info {
    padding: 12px;
}

.photo-card-info p {
    font-size: 14px;
    color: var(--text-dark);
}

.photo-card-info .photo-date {
    font-size: 12px;
    color: var(--text-medium);
    margin-top: 4px;
}

.photo-card-actions {
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* =============================================
   INTERACTION LOGS (caregiver tab)
   ============================================= */
.interaction-logs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ilog-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px;
}

.ilog-photo {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: #E8F4F1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.ilog-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ilog-photo-placeholder {
    font-size: 28px;
}

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

.ilog-info h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.ilog-summary {
    font-size: 14px;
    color: var(--text-medium);
    margin-bottom: 4px;
    white-space: pre-wrap;
}

.ilog-time {
    font-size: 12px;
    color: var(--text-medium);
}

.ilog-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

@media (min-width: 480px) {
    .ilog-actions { flex-direction: row; align-items: flex-start; }
}

/* =============================================
   SETTINGS
   ============================================= */
.settings-form {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow);
    max-width: 600px;
}

@media (min-width: 600px) {
    .settings-form { padding: 24px; }
}

.settings-fieldset {
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 24px;
}

.settings-fieldset legend {
    font-weight: 700;
    font-size: 15px;
    color: var(--accent-blue);
    padding: 0 8px;
}

.profile-pic-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.profile-pic-preview {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-page);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 3px solid var(--border);
    flex-shrink: 0;
}

.profile-pic-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.settings-form .form-group {
    margin-bottom: 24px;
}

.settings-form label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

.settings-form input[type="text"],
.settings-form input[type="number"],
.settings-form input[type="email"],
.settings-form input[type="tel"],
.settings-form textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
}
.settings-form input:focus,
.settings-form textarea:focus {
    border-color: var(--accent-blue);
    outline: none;
}

.settings-form input[type="range"] {
    width: 100%;
    margin-top: 8px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-medium);
    margin-top: 4px;
}

.device-info {
    background: var(--bg-page);
    padding: 16px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.device-info code {
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.toggle-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-blue);
}

/* =============================================
   ZONE LEGEND
   ============================================= */
.zone-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.zone-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.zone-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.zone-legend-item.safe .zone-legend-dot  { background: #66BB6A; }
.zone-legend-item.safe                   { color: #2E7D32; }
.zone-legend-item.restricted .zone-legend-dot { background: #E57373; }
.zone-legend-item.restricted             { color: #C62828; }

/* =============================================
   MAP CONTAINER
   ============================================= */
.map-container {
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.location-map {
    height: 280px;
    border-radius: 12px;
}

@media (min-width: 600px) {
    .location-map { height: 380px; }
}

@media (min-width: 900px) {
    .location-map { height: 420px; }
}

.geofence-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.geofence-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.geofence-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.geofence-card .zone-type {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
}
.zone-type.safe { background: #E8F4F1; color: var(--accent-blue); }
.zone-type.restricted { background: #FDECEA; color: var(--accent-red); }

/* =============================================
   MODALS (Caregiver)
   ============================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.modal .modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    z-index: 1;
}

.modal-sm { max-width: 440px; }

.modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.modal .modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.btn-close {
    font-size: 28px;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-medium);
    border-radius: var(--radius-sm);
}
.btn-close:hover { background: var(--bg-page); }

.modal .modal-body {
    padding: 24px;
}

.modal .form-group {
    margin-bottom: 16px;
}

.modal label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.modal input,
.modal textarea,
.modal select {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
}
.modal input:focus,
.modal textarea:focus,
.modal select:focus {
    border-color: var(--accent-blue);
    outline: none;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.photo-preview-sm {
    position: relative;
    margin-top: 8px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-page);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.photo-preview-sm img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-preview-sm .photo-placeholder {
    font-size: 32px;
    opacity: 0.5;
}

.select-input {
    padding: 10px 14px;
    font-size: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    background: var(--bg-card);
}

.filter-group {
    display: flex;
    gap: 10px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-medium);
    font-size: 16px;
}

.toggle-group {
    display: flex;
    gap: 16px;
}

/* =============================================
   FACE SCAN (TRUSTED PERSON)
   ============================================= */
.face-scan-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hidden-btn {
    display: none !important;
}

.trusted-photo-options {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.trusted-photo-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.camera-wrapper-sm {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 3/4;
    border-radius: 16px;
    overflow: hidden;
    background: #1a1a2e;
    margin: 12px auto;
    box-shadow: var(--shadow);
}

.camera-wrapper-sm video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.face-oval-sm {
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 55%;
    border: 3px dashed rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

.face-scan-body {
    text-align: center;
}

.face-scan-instruction {
    font-size: 15px;
    color: var(--text-medium);
    margin-bottom: 8px;
}

.face-scan-hint {
    font-size: 14px;
    color: var(--text-medium);
    text-align: center;
    margin-top: 8px;
    min-height: 20px;
}

#modal-face-scan .scan-status {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

#modal-face-scan .scan-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: scanBlink 1.2s ease-in-out infinite;
}

#modal-face-scan .scan-dot.success {
    background: var(--accent-green);
    animation: none;
}

@keyframes scanBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* =============================================
   RESPONSIVE (mobile-first — overrides in media queries above)
   ============================================= */
@media (max-width: 640px) {
    .form-row-2col {
        grid-template-columns: 1fr;
    }
    .trusted-card-actions .btn {
        font-size: 13px;
        padding: 8px 10px;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .section-header-actions {
        width: 100%;
    }
}

/* =============================================
   PATIENT SWITCHER (New)
   ============================================= */
.patient-selector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.patient-selector-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
}

.patient-cards {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
}
.patient-cards::-webkit-scrollbar { display: none; }

.patient-card {
    position: relative;
}

.patient-card .patient-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--radius-full);
}

.patient-card .btn-remove-patient {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--accent-red);
    color: white;
    border: 2px solid white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
}
.patient-card:hover .btn-remove-patient {
    opacity: 1;
}

.badge-primary {
    font-size: 11px;
    background: var(--accent-blue);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.tab-nav.hidden {
    display: none;
}

/* =============================================
   SEARCH RESULTS (Add Patient / Add Trusted)
   ============================================= */
.modal-desc {
    font-size: 14px;
    color: var(--text-medium);
    margin-bottom: 16px;
}

.search-results {
    margin-top: 8px;
}

.search-result-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

.search-result-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
}

.search-result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.search-result-info strong {
    display: block;
    font-size: 15px;
}

.search-result-role {
    font-size: 13px;
    color: var(--text-medium);
}

.search-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-medium);
    font-size: 14px;
}

/* =============================================
   FACE SCAN LINK UI (Add Patient by Face)
   ============================================= */

.face-link-scan-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

.face-link-scan-body .camera-wrapper-sm {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 3/4;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
}

.face-link-scan-body .camera-wrapper-sm video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: scaleX(-1);
}

.face-link-scan-body .scan-status {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.face-link-scan-body .scan-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: scanBlink 1.2s ease-in-out infinite;
}

.face-link-scan-body .scan-dot.success {
    background: var(--accent-green);
    animation: none;
}

.face-link-result {
    width: 100%;
    text-align: center;
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

.face-link-result .link-success {
    color: var(--accent-green-hover);
    font-size: 15px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.face-link-result .link-avatar {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 3px solid var(--accent-green);
}

.face-link-result .link-fail {
    color: var(--accent-orange);
    font-size: 14px;
}

/* =============================================
   ADD PATIENT MODAL — TABS & SEARCH
   ============================================= */

.add-patient-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 12px;
}

.add-patient-tab {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-medium);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.add-patient-tab.active {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}

.add-patient-search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.add-patient-search-row input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--bg-card);
    color: var(--text-dark);
}

.patient-search-results {
    margin-top: 4px;
    max-height: 280px;
    overflow-y: auto;
}

.patient-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--bg-card);
}

.patient-search-result-info {
    flex: 1;
    min-width: 0;
}

.patient-search-result-info strong {
    display: block;
    font-size: 15px;
}

.drawing-banner {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 62, 80, 0.97);
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 15px;
    min-width: 320px;
    max-width: 90vw;
    pointer-events: all;
}
.drawing-banner.hidden { display: none; }
#drawing-banner-text { flex: 1; }
#btn-undo-point, #btn-cancel-drawing, #btn-save-zone {
    font-size: 14px;
    padding: 6px 14px;
    flex-shrink: 0;
    white-space: nowrap;
}
#btn-save-zone {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}
#btn-save-zone:hover {
    background: var(--accent-blue-hover);
}
#btn-undo-point {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 8px;
    cursor: pointer;
}
#btn-cancel-drawing {
    background: rgba(229,115,115,0.85);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.map-container { position: relative; isolation: isolate; }

/* =============================================
   PEOPLE TAB
   ============================================= */
.people-tab-desc {
    font-size: 14px;
    color: var(--text-medium);
    margin-bottom: 16px;
    line-height: 1.5;
}

.people-filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.people-filter-btn {
    padding: 7px 18px;
    border-radius: 20px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-medium);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.people-filter-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}
.people-filter-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

.people-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
@media (min-width: 640px) {
    .people-list { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
}

.person-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border-left: 4px solid var(--border);
    transition: border-color 0.2s;
}
.person-card.trusted { border-left-color: var(--accent-blue); }
.person-card.untrusted { border-left-color: var(--accent-yellow); }

.person-card-avatar {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}
.person-card-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.person-card-body {
    flex: 1;
    min-width: 0;
}
.person-card-body h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.person-card-summary {
    font-size: 13px;
    color: var(--text-medium);
    margin-bottom: 8px;
}
.person-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Inline trusted toggle on card */
.person-trust-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}
.person-trust-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* Person search in modal */
.person-search-row {
    margin-bottom: 8px;
}
.person-search-row input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    background: var(--bg-card);
}
.person-search-row input:focus {
    border-color: var(--accent-blue);
    outline: none;
}

.person-search-results {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 4px;
}

.person-search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 6px;
    background: var(--bg-card);
    cursor: pointer;
    transition: background 0.12s;
}
.person-search-result-item:hover {
    background: #E8F4F1;
    border-color: var(--accent-blue);
}

.person-search-result-item .psri-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}
.person-search-result-item .psri-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.person-search-result-item .psri-info strong {
    font-size: 14px;
}
.person-search-result-item .psri-source {
    font-size: 12px;
    color: var(--text-medium);
}

.or-divider {
    text-align: center;
    font-size: 13px;
    color: var(--text-medium);
    margin: 12px 0;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.badge-trusted {
    background: #E8F4F1;
    color: var(--accent-blue);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}
.badge-seen {
    background: #FDF3E4;
    color: var(--accent-orange);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}
