/* Medical Statistics Gallery Grid Design */
:root {
    --bg-dark: #0a0a0f;
    --bg-card: #1a1a24;
    --primary: #00d4aa;
    --primary-glow: rgba(0, 212, 170, 0.3);
    --text: #e8e8f0;
    --text-muted: #6b6b80;
    --border: #2a2a3a;
    --radius: 12px;
    --gallery-gap: 1.5rem;
}

[data-theme="dark"] {
    --bg-dark: #0a0a0f;
    --bg-card: #1a1a24;
    --primary: #00d4aa;
    --text: #e8e8f0;
    --border: #2a2a3a;
}

[data-theme="light"] {
    --bg-dark: #f8f9fa;
    --bg-card: #ffffff;
    --primary: #00a375;
    --text: #1a1a2e;
    --border: #e0e0e0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    direction: inherit;
    transition: background-color 0.3s ease, color 0.3s ease;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    margin: 0;
}

/* Keep the page behind an open form stationary; the form panel owns scrolling. */
body.form-open {
    overflow: hidden;
    position: fixed;
    left: 0;
    right: 0;
    width: auto;
}

/* Lock background scrolling for the drawer without fixing the body; this avoids
   the mobile Safari/Chrome scroll-to-top jump when the drawer closes. */
body.menu-open {
    overflow: hidden;
    overscroll-behavior: none;
}

html[dir="rtl"] body { direction: rtl; }
html[dir="ltr"] body { direction: ltr; }
html[dir="ltr"] header,
html[dir="ltr"] .main-container,
html[dir="ltr"] .gallery-grid,
html[dir="ltr"] .square {
    direction: ltr;
    text-align: left;
}
/* Keep the header and language switch in the same positions in both languages. */
header,
html[dir="ltr"] header {
    direction: rtl;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex: 0 0 auto;
}
.header-actions .site-notifications { order: 1; }
.header-actions .lang-toggle { order: 2; }
@media (max-width: 600px) {
    .header-actions { gap: .4rem; }
}
html[dir="ltr"] #site-title {
    direction: rtl;
    text-align: right;
}
html[dir="ltr"] .square h3 { text-align: left; }
.kidney-period-label {
    display: inline-block;
    align-self: center;
    margin: 0.15rem 0 0.65rem;
    padding: 0.2rem 0.8rem;
    border: 1px solid rgba(74, 222, 128, 0.75);
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.5;
    animation: kidney-label-pulse 1.5s ease-in-out infinite;
}
@keyframes kidney-label-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 rgba(74, 222, 128, 0); }
    50% { opacity: 0.55; box-shadow: 0 0 12px rgba(74, 222, 128, 0.45); }
}
@media (prefers-reduced-motion: reduce) {
    .kidney-period-label { animation: none; }
}
.department-form-panel[dir="ltr"] { direction: ltr; text-align: left; }
.department-form-panel[dir="ltr"] .form-field,
.department-form-panel[dir="ltr"] .form-field input,
.department-form-panel[dir="ltr"] .form-field select { direction: ltr; text-align: left; }
.department-form-panel[dir="ltr"] .form-close { left: auto; right: 0.8rem; }
.department-form-panel[dir="ltr"] h2 { margin: 0 0 1.25rem 2rem; }
.department-form-panel[dir="ltr"] .form-section-heading {
    border-right: 0;
    border-left: 3px solid var(--primary);
}

header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    line-height: 1.2;
    flex-wrap: nowrap;
}

.theme-toggle,
.lang-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: color 0.3s;
}

.theme-toggle:hover,
.lang-toggle:hover {
    color: var(--primary);
}

/* Gallery Grid Layout */
.main-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    width: 100%;
    max-width: 1200px;
    min-width: 0;
    box-sizing: border-box;
}

/* Responsive gallery: two columns on phones, adapting for larger screens */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: var(--gallery-gap);
    align-items: stretch;
    width: 100%;
    min-width: 0;
    margin-inline: auto;
}

/* Do not expose the gallery before the session check resolves; display:grid overrides the browser's default hidden behavior. */
.gallery-grid[hidden] {
    display: none !important;
}

/* Keep the top-level department tiles compact on desktop; subsection grids keep their own layouts. */
@media (min-width: 901px) {
    .gallery-grid:not(.eye-subsections-grid):not(.newborn-subsections-grid):not(.resistance-subsections-grid) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1.1rem;
    }
    .gallery-grid:not(.eye-subsections-grid):not(.newborn-subsections-grid):not(.resistance-subsections-grid) .home-gallery-tile {
        padding: .9rem;
    }
    .gallery-grid:not(.eye-subsections-grid):not(.newborn-subsections-grid):not(.resistance-subsections-grid) .home-icon-container {
        padding: .45rem .35rem .2rem;
    }
    .gallery-grid:not(.eye-subsections-grid):not(.newborn-subsections-grid):not(.resistance-subsections-grid) .home-inline-icon {
        width: min(68%, 150px);
        max-height: 125px;
    }
}

/* Match ophthalmology card widths to the home gallery on desktop. */
@media (min-width: 601px) {
    .gallery-grid.eye-subsections-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Keep newborn subsection tiles slightly more compact than the eye tiles. */
    .gallery-grid.newborn-subsections-grid {
        max-width: 1000px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.gallery-back-button {
    direction: ltr;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    width: min(100%, 280px);
    min-height: 3.1rem;
    margin: 0 0 1.25rem;
    padding: 0.7rem 1.5rem;
    border: 1px solid rgba(0, 212, 170, 0.4);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.16), rgba(0, 163, 117, 0.07));
    color: var(--primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.14);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.gallery-back-button:hover {
    background: rgba(0, 212, 170, 0.22);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.gallery-back-button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

.gallery-back-button[hidden] {
    display: none;
}

.back-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background: rgba(0, 212, 170, 0.15);
    font-size: 1.2rem;
    line-height: 1;
}

html[dir="rtl"] .gallery-grid { direction: rtl; }
html[dir="ltr"] .gallery-grid { direction: ltr; }

@media (max-width: 600px) {
    .gallery-back-button {
        width: 100%;
        min-height: 3rem;
        margin-bottom: 0.9rem;
    }

    /* Home page: keep the gallery locked to the viewport width on phones. */
    body {
        position: relative;
        overflow-x: hidden;
        overscroll-behavior-x: none;
    }

    header,
    .main-container,
    .gallery-grid {
        max-width: 100%;
        min-width: 0;
        margin-inline: auto;
        box-sizing: border-box;
    }

    header {
        display: flex;
        flex-wrap: nowrap;
    }

    .logo {
        min-width: 0;
        max-width: calc(100% - 4.5rem);
        overflow-wrap: normal;
        flex-shrink: 1;
    }

    .main-container {
        margin: 0.75rem auto;
        padding: 0 0.75rem;
        width: 100%;
        max-width: 100%;
        position: relative;
        left: auto;
        right: auto;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
        align-items: start;
        width: 100%;
        min-width: 0;
        touch-action: pan-y;
    }

    .square {
        min-width: 0;
        padding: 0;
        border-radius: 8px;
        overflow: hidden;
        height: auto;
        align-self: start;
        max-width: 100%;
        transform: none;
        touch-action: pan-y;
    }

    .image-container {
        width: 100%;
        aspect-ratio: 1 / 1;
        margin: 0 0 0.25rem;
        border-radius: 8px 8px 0 0;
    }

    .square h3 {
        font-size: 0.9rem;
        line-height: 1.35;
        margin-bottom: 0;
        text-align: center;
        overflow-wrap: anywhere;
        word-break: normal;
        padding: 0.2rem 0.25rem 0.45rem;
    }

    html[dir="ltr"] .square h3 { text-align: left; }

    header {
        padding: 0.85rem 1rem;
        gap: 0.5rem;
        justify-content: space-between;
    }

    .logo {
        font-size: 0.95rem;
        white-space: nowrap;
        flex-wrap: nowrap;
    }

    .lang-toggle {
        font-size: 0.95rem;
        padding: 0.4rem;
    }

    .form-overlay {
        padding: 0.65rem;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .department-form-panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
}

/* Prevent touch devices from retaining hover transforms that can make the
   mobile gallery appear to shift sideways after tapping a card. */
@media (hover: none), (pointer: coarse) {
    .square:hover {
        transform: none;
        box-shadow: none;
    }

    .square:hover .image-container img {
        transform: none;
    }
}

/* Image container with consistent aspect ratio */
.image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    background: var(--bg-dark);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.3s ease;
}

.square:hover .image-container img {
    transform: scale(1.05);
}

/* Square card */
.square {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    width: 100%;
    color: inherit;
    font: inherit;
    text-align: inherit;
    cursor: pointer;
}

.square:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

/* Icon section */
.icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), #00a375);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Title */
.square h3 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 0.5rem;
    font-weight: 400;
    flex-shrink: 0;
}

/* Center gallery tile titles on desktop without changing the mobile layout. */
@media (min-width: 601px) {
    .square h3 {
        text-align: center;
    }
}

/* Value */
.square .value {
    margin-top: auto;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .square {
        transition: none;
    }
    .square:hover .image-container img {
        transform: none;
    }
}

/* Light theme adjustments */
[data-theme="light"] .square {
    background: var(--bg-card);
}

[data-theme="light"] .icon {
    background: linear-gradient(135deg, var(--primary), #00a375);
}

/* Focus states */
.theme-toggle:focus,
.lang-toggle:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Department input forms */
.form-overlay[hidden],
.success-overlay[hidden] {
    display: none !important;
}

.form-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(5px);
    overflow-y: hidden;
    overflow-x: hidden;
    overscroll-behavior: contain;
    touch-action: auto;
    overscroll-behavior-y: contain;
}

.department-form-panel {
    position: relative;
    width: min(100%, 620px);
    max-height: min(calc(100dvh - 2rem), 850px);
    flex: 0 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
}

.department-form-panel h2 {
    margin: 0 2rem 1.25rem 0;
    color: var(--primary);
    font-size: 1.35rem;
}

.form-close {
    position: absolute;
    top: 0.7rem;
    left: 0.8rem;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 1.6rem;
    cursor: pointer;
}

#department-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

/* Stack newborn statistics fields vertically for easier entry. */
.department-form-panel.newborn-statistics-form #department-form {
    grid-template-columns: minmax(0, 1fr);
}

/* In-site notification dropdown, inspired by the supplied reference. */
.site-notifications { position: relative; flex: 0 0 auto; }
.notification-bell {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 3.1rem; height: 3.1rem; border: 1px solid var(--border); border-radius: 14px;
    background: var(--bg-card); color: var(--text); font: inherit; font-size: 1.65rem; cursor: pointer;
}
.notification-bell-icon { display: inline-flex; width: 1.55rem; height: 1.55rem; align-items: center; justify-content: center; line-height: 1; }
.notification-bell-icon svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notification-bell.has-unread { color: #f2b600; border-color: #f2b600; }
.notification-bell.has-unread .notification-bell-icon svg { filter: drop-shadow(0 0 3px rgba(242, 182, 0, .35)); }
.notification-bell.notification-arrival .notification-bell-icon {
    animation: notification-bell-arrival 850ms ease-in-out infinite;
}
@keyframes notification-bell-arrival {
    0%, 100% { transform: rotate(0) scale(1); }
    15%, 45%, 75% { transform: rotate(-16deg) scale(1.08); }
    30%, 60%, 90% { transform: rotate(16deg) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
    .notification-bell.notification-arrival .notification-bell-icon { animation: none; }
}
.notification-bell:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.notification-count {
    position: absolute; top: -0.45rem; right: -0.35rem; min-width: 1.35rem; height: 1.35rem;
    padding: 0 0.25rem; border-radius: 999px; background: #bd241b; color: #fff;
    font: 700 0.78rem/1.35rem Arial, sans-serif; text-align: center;
}
.notification-count[hidden], .notification-panel[hidden] { display: none !important; }
.notification-panel {
    position: absolute; z-index: 1500; top: calc(100% + 0.7rem); right: auto; left: 0;
    width: min( min(76vw, 480px), calc(100vw - 1.5rem)); max-height: min(68vh, 600px);
    overflow: auto; padding: .75rem; border: 1px solid var(--border); border-radius: 18px;
    background: color-mix(in srgb, var(--bg-card) 92%, transparent); color: var(--text);
    box-shadow: 0 18px 55px rgba(0,0,0,.25); backdrop-filter: blur(18px);
}
.notification-panel[dir="ltr"]:not([hidden]) { animation: notification-enter-ltr 240ms ease-out both; }
.notification-panel[dir="rtl"]:not([hidden]) { animation: notification-enter-rtl 240ms ease-out both; }
@keyframes notification-enter-ltr {
    from { opacity: 0; transform: translateX(-18px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes notification-enter-rtl {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
    .notification-panel[dir="ltr"]:not([hidden]),
    .notification-panel[dir="rtl"]:not([hidden]) { animation: none; }
}
.notification-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .2rem .15rem .6rem; border-bottom: 1px solid var(--border); }
.notification-panel[dir="rtl"], .notification-panel[dir="rtl"] .site-notification-card { direction: rtl; text-align: right; }
.notification-panel[dir="ltr"], .notification-panel[dir="ltr"] .site-notification-card { direction: ltr; text-align: left; }
.notification-panel[dir="rtl"] .site-notification-card,
.notification-panel[dir="ltr"] .site-notification-card { grid-template-columns: minmax(0,1fr); }
.notification-panel[dir="rtl"] .notification-card-read { margin-right: 0; margin-left: auto; }
.notification-panel[dir="ltr"] .notification-card-read { margin-left: 0; margin-right: auto; }
.notification-panel-heading strong { font-size: 1.05rem; }
.notification-panel-heading span { color: var(--text-muted); font-size: .9rem; white-space: nowrap; }
#notification-unread { color: #ff4d4f; font-weight: 700; }
#notification-unread.is-clear { color: #22c55e; }
.notification-items { display: grid; gap: .7rem; padding-top: .75rem; }
.site-notification-card {
    display: grid; grid-template-columns: minmax(0,1fr); align-items: start; gap: .2rem;
    padding: 1rem; border: 1px solid rgba(90,155,175,.35); border-radius: 18px;
    background: linear-gradient(115deg, rgba(42,139,185,.16), rgba(0,212,170,.06));
}
.site-notification-card.is-read { opacity: .72; }
.notification-symbol { display: inline-grid; place-items: center; vertical-align: .08em; width: .42rem; height: .42rem; margin-inline-end: .42rem; border-radius: 2px; background: #b99a95; color: transparent; font-size: 0; font-weight: 700; }
.notification-card-copy { min-width: 0; }
.notification-card-copy h3 { margin: 0 0 .45rem; font-size: 1.03rem; line-height: 1.5; }
.notification-card-copy p { margin: 0 0 .5rem; font-size: .95rem; line-height: 1.8; overflow-wrap: anywhere; }
.notification-card-copy small { color: var(--text-muted); }
.notification-empty { margin: .7rem 0; color: var(--text-muted); text-align: center; }
.notification-mark-read { display: block; margin: .75rem 0 0 auto; padding: .55rem .8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); color: var(--text); font: inherit; cursor: pointer; }
@media (max-width: 600px) {
    .notification-panel { position: fixed; top: 5.2rem; right: .75rem; left: .75rem; width: auto; max-height: calc(100dvh - 6rem); padding: .65rem; border-radius: 16px; }
    .site-notification-card { grid-template-columns: minmax(0,1fr); padding: .8rem; gap: .2rem; }
}

.reminders-overlay[hidden] { display: none !important; }
.reminders-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.74);
    backdrop-filter: blur(5px);
    overflow-y: auto;
}
.reminders-panel {
    position: relative;
    width: min(100%, 620px);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
}
.reminders-panel h2 { margin: 0 2.5rem 0.5rem 0; color: var(--primary); font-size: 1.35rem; }
.reminders-intro { margin-bottom: 1.25rem; color: var(--text-muted); font-size: 0.9rem; }
.reminder-form { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 0.8fr); gap: 0.8rem; align-items: end; }
.reminder-form .form-submit { grid-column: 1 / -1; }
.reminders-panel .form-field input,
.reminders-panel .form-field select {
    width: 100%; min-width: 0; min-height: 2.8rem; padding: 0.65rem 0.75rem;
    border: 1px solid var(--border); border-radius: 9px; background: var(--bg-dark);
    color: var(--text); font: inherit;
}
.reminder-actions { margin-top: 0.8rem; }
.reminder-secondary, .reminder-delete {
    min-height: 2.5rem; padding: 0.45rem 0.8rem; border: 1px solid var(--border);
    border-radius: 8px; background: rgba(0, 212, 170, 0.08); color: var(--primary);
    font: inherit; cursor: pointer;
}
.reminder-status { min-height: 1.5rem; margin-top: 0.6rem; color: var(--primary); font-size: 0.88rem; }
.reminder-list-title { margin: 0.8rem 0; font-size: 1rem; }
.reminder-list { display: grid; gap: 0.6rem; }
.reminder-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 0.8rem; align-items: center; padding: 0.8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-dark); }
.reminder-item-name { font-weight: 700; overflow-wrap: anywhere; }
.reminder-item-detail { color: var(--text-muted); font-size: 0.85rem; }
.reminder-delete { grid-column: 2; grid-row: 1 / span 2; color: #ff8c8c; background: rgba(255, 100, 100, 0.08); }
@media (max-width: 600px) {
    .reminders-overlay { padding: 0.65rem; }
    .reminders-panel { padding: 1.1rem; max-height: calc(100dvh - 1.3rem); border-radius: 14px; }
    .reminder-form { grid-template-columns: minmax(0, 1fr); }
}

.form-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.92rem;
}

.form-section-heading {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0.65rem 0.8rem;
    border-right: 3px solid var(--primary);
    border-radius: 6px;
    background: rgba(0, 212, 170, 0.08);
    color: var(--primary);
    font-size: 1rem;
}

.required-mark {
    color: #ff7373;
}

.optional-mark {
    color: var(--text-muted);
    font-size: 0.82em;
    font-weight: 400;
}

.form-field input,
.form-field select {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 2.8rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
    background: var(--bg-dark);
    color: var(--text);
    font: inherit;
}

.form-field textarea {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 4.5rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
    background: var(--bg-dark);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.numeric-input-wrap {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    width: 100%;
    min-width: 0;
}

.numeric-input-wrap input {
    flex: 1 1 auto;
    min-width: 0;
    direction: ltr;
    text-align: center;
}

.numeric-stepper {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 0 0 2.4rem;
}

.numeric-step {
    flex: 1 1 50%;
    min-height: 1.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0, 212, 170, 0.12);
    color: var(--primary);
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.numeric-step:hover,
.numeric-step:focus-visible {
    background: rgba(0, 212, 170, 0.25);
    border-color: var(--primary);
    outline: none;
}

/* Subtle animated accent around editable fields in Dermatology and Operations forms. */
.form-field input.animated-input-border,
.form-field select.animated-input-border,
.form-field textarea.animated-input-border {
    border: 1px solid transparent;
    background:
        linear-gradient(var(--bg-dark), var(--bg-dark)) padding-box,
        conic-gradient(from var(--field-border-angle, 0deg),
            rgba(0, 212, 170, 0.22),
            rgba(0, 212, 170, 0.85),
            rgba(73, 164, 255, 0.42),
            rgba(0, 212, 170, 0.22)) border-box;
    animation: field-border-drift 7s linear infinite;
}

.form-field input.animated-input-border:focus,
.form-field select.animated-input-border:focus,
.form-field textarea.animated-input-border:focus {
    border-color: transparent;
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.12);
}

@property --field-border-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

@keyframes field-border-drift {
    to { --field-border-angle: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
    .form-field input.animated-input-border,
    .form-field select.animated-input-border,
    .form-field textarea.animated-input-border {
        animation: none;
        border-color: rgba(0, 212, 170, 0.65);
    }
}

.form-field input:focus,
.form-field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.form-submit {
    grid-column: 1 / -1;
    min-height: 3rem;
    margin-top: 0.25rem;
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #06251f;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.form-note {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

.success-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(4px);
}

.success-popup {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: min(100%, 360px);
    padding: 2rem 1.5rem 1.5rem;
    border: 1px solid rgba(34, 197, 94, 0.45);
    border-radius: 18px;
    background: var(--bg-card);
    color: var(--text);
    text-align: center;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.5);
    animation: popup-in 180ms ease-out;
}

.success-popup h2 {
    margin: 0;
    color: #4ade80;
    font-size: 1.2rem;
}

.success-popup .success-check {
    width: 3rem;
    height: 3rem;
    font-size: 1.8rem;
}

.success-popup .form-submit {
    width: 100%;
}

@keyframes popup-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.success-check {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #22c55e;
    color: #062b15;
    font-size: 1.3rem;
    font-weight: 900;
}

@media (max-width: 600px) {
    .department-form-panel {
        padding: 1.1rem;
        border-radius: 14px;
        max-height: calc(100dvh - 1.3rem);
        margin-inline: auto;
        width: 100%;
        flex: 0 1 620px;
    }

    .form-overlay {
        align-items: center;
        justify-content: center;
        padding: 0.65rem;
        overflow: hidden;
        left: 0;
        right: 0;
    }

    #department-form {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.85rem;
    }
}

/* Final mobile overrides: keep images large and cards compact. */
@media (max-width: 600px) {
    .square {
        height: auto;
        padding: 0;
        align-self: start;
    }

    .image-container {
        width: 100%;
        aspect-ratio: 1 / 1;
        height: auto;
        margin: 0 0 0.25rem;
        border-radius: 8px 8px 0 0;
    }
}

/* Report reminder cards: calendar marker and a per-card read action. */
.site-notification-card { grid-template-columns: 3.5rem minmax(0, 1fr); }
.notification-symbol { width: 2.6rem; height: 2.6rem; background: #b99a95; border-radius: 13px; }
.site-notification-card .notification-card-copy p { white-space: pre-line; }
.notification-card-read {
    grid-column: 1 / -1; justify-self: start; max-width: 100%; min-width: 0;
    box-sizing: border-box; white-space: normal; overflow-wrap: anywhere;
    margin-top: .1rem; padding: .2rem .5rem;
    border: 1px solid transparent; border-radius: 999px; background: transparent; color: inherit;
    font: inherit; font-size: .8rem; line-height: 1.35; font-weight: 700; cursor: pointer;
    box-shadow: none;
    transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.notification-card-read:hover,
.notification-card-read:focus-visible {
    background: rgba(22, 163, 106, .08); border-color: transparent;
    box-shadow: none;
    outline: none;
}
.notification-card-read:active { transform: translateY(2px); box-shadow: 0 0 0 #075d38; }
.notification-card-read:disabled {
    border-color: #16a36a; background: #16a36a; color: #fff;
    box-shadow: none; cursor: default; opacity: 1;
}
@media (max-width: 600px) {
    .site-notification-card { grid-template-columns: 2.7rem minmax(0,1fr); }
    .notification-card-read { grid-column: 1 / -1; }
}

/* Clear, dynamic department list inside report reminder cards. */
.site-notification-card .notification-card-copy p {
    white-space: pre-line;
    display: grid;
    gap: .5rem;
    margin-top: .65rem;
}
.site-notification-card .notification-card-copy p {
    line-height: 1.9;
}
.notification-department-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    width: 100%;
    padding: .45rem .65rem;
    border: 1px solid rgba(90, 155, 175, .22);
    border-radius: 10px;
    background: rgba(90, 155, 175, .08);
    color: var(--text);
    font: inherit;
    font-size: .92rem;
    text-align: start;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
    animation: notification-link-border-glow 3.8s ease-in-out infinite;
}
@keyframes notification-link-border-glow {
    0%, 100% { border-color: rgba(90, 155, 175, .22); box-shadow: 0 0 0 0 rgba(90, 155, 175, 0); }
    50% { border-color: rgba(90, 155, 175, .62); box-shadow: 0 0 5px 0 rgba(90, 155, 175, .12); }
}
@media (prefers-reduced-motion: reduce) {
    .notification-department-link { animation: none; }
}
.notification-department-label {
    display: block;
    width: min(100%, 15rem);
    min-height: 2.1rem;
    padding: .3rem .65rem;
    border: 1px solid rgba(90, 155, 175, .16);
    border-radius: 8px;
    color: var(--text);
    font-size: .85rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.notification-department-link::after {
    content: '←';
    color: var(--primary);
    font-size: 1.15rem;
    font-weight: 700;
    flex: 0 0 auto;
}
.notification-department-link:hover,
.notification-department-link:focus-visible {
    background: rgba(0, 212, 170, .14);
    border-color: var(--primary);
    outline: none;
}


/* Globe icon with a language dropdown. */
.language-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-width: 0;
    padding: .35rem .55rem;
    border: 1px solid rgba(0, 212, 170, .55);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(0, 212, 170, .16), rgba(0, 212, 170, .06));
    color: var(--primary);
}
.language-globe { font-size: 1.15rem; line-height: 1; }
.lang-toggle {
    max-width: 8rem;
    padding: .2rem .1rem;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}
.lang-toggle option { background: var(--bg-card); color: var(--text); }
.language-picker:focus-within { box-shadow: 0 0 0 3px rgba(0, 212, 170, .16); border-color: var(--primary); }
.language-options[hidden] { display: none !important; }
.language-options {
    position: absolute;
    z-index: 1600;
    top: calc(100% + .45rem);
    right: 0;
    min-width: 8.5rem;
    display: grid;
    gap: .2rem;
    padding: .35rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}
.language-options button {
    padding: .55rem .7rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.language-options button:hover,
.language-options button:focus-visible { background: rgba(0, 212, 170, .12); outline: none; }
@media (max-width: 600px) {
    .language-picker { gap: .2rem; padding: .3rem .4rem; }
    .language-globe { font-size: 1rem; }
    .lang-toggle { max-width: 6.5rem; font-size: .8rem; }
}

/* Temporary, browser-local entry log */
.record-log-toggle {
    min-height: 2.7rem;
    padding: .45rem .8rem;
    border: 1px solid rgba(0, 212, 170, .55);
    border-radius: 10px;
    background: rgba(0, 212, 170, .1);
    color: var(--primary);
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}
.record-log-toggle[hidden], .side-menu-item[hidden] { display: none !important; }
.record-log-overlay[hidden] { display: none !important; }
.record-log-overlay {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, .74);
    backdrop-filter: blur(5px);
}
.record-log-panel {
    position: relative;
    width: min(100%, 620px);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 20px 70px rgba(0, 0, 0, .45);
}
.record-log-panel h2 { margin: 0 2.5rem .5rem 0; color: var(--primary); font-size: 1.3rem; }
.record-log-intro { margin-bottom: 1rem; color: var(--text-muted); font-size: .9rem; }
.record-log-items { display: grid; gap: .65rem; }
.record-log-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .25rem .75rem;
    align-items: center;
    padding: .85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-dark);
}
.record-log-card strong { overflow-wrap: anywhere; }
.record-log-card p { grid-column: 1; color: var(--text-muted); font-size: .82rem; overflow-wrap: anywhere; }
.record-log-edit {
    grid-column: 2;
    grid-row: 1 / span 2;
    min-height: 2.4rem;
    padding: .35rem .8rem;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: rgba(0, 212, 170, .12);
    color: var(--primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
@media (max-width: 600px) {
    .record-log-toggle { min-height: 2.4rem; padding: .35rem .5rem; font-size: .78rem; }
    /* On mobile, keep the entry-log action inside the navigation drawer only. */
    header .header-actions > .record-log-toggle { display: none !important; }
    .record-log-overlay { padding: .65rem; }
    .record-log-panel { padding: 1.1rem; max-height: calc(100dvh - 1.3rem); border-radius: 14px; }
    .record-log-card { padding: .7rem; }
}

/* Slide-out navigation drawer */
.menu-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.7rem;
    height: 2.7rem;
    flex: 0 0 auto;
    border: 1px solid rgba(0, 212, 170, .45);
    border-radius: 10px;
    background: rgba(0, 212, 170, .09);
    color: var(--primary);
    font-size: 1.35rem;
    cursor: pointer;
}
.header-brand { display: flex; align-items: center; gap: .75rem; min-width: 0; }
html[dir="ltr"] .header-brand { direction: rtl; }
@media (max-width: 600px) {
    .header-brand { gap: .45rem; }
    .menu-toggle { width: 2.35rem; height: 2.35rem; font-size: 1.15rem; }
}
.side-menu-backdrop[hidden] { display: none !important; }
.side-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1400;
    background: rgba(0, 0, 0, .58);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.side-menu {
    position: fixed;
    z-index: 1401;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(84vw, 320px);
    max-height: 100vh;
    max-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 1.1rem;
    background: var(--bg-card);
    color: var(--text);
    border-left: 1px solid var(--border);
    box-shadow: -12px 0 38px rgba(0, 0, 0, .25);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform .22s ease, visibility .22s ease;
}
html[dir="ltr"] .side-menu { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--border); transform: translateX(-105%); box-shadow: 12px 0 38px rgba(0, 0, 0, .25); }
.side-menu.is-open { transform: translateX(0); visibility: visible; }
.side-menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); color: var(--primary); font-size: 1.15rem; }
.side-menu-close { width: 2.25rem; height: 2.25rem; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text); font-size: 1.5rem; cursor: pointer; }
.side-menu-nav { display: grid; gap: .5rem; padding-top: 1rem; }
.side-menu-item { display: flex; align-items: center; gap: .8rem; width: 100%; min-height: 3.2rem; padding: .7rem .85rem; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); font: inherit; text-align: start; cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.side-menu-item > span:first-child { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 7px; background: rgba(0, 212, 170, .12); color: var(--primary); font-size: 1.1rem; }
.side-menu-item#menu-contact > span:first-child,
.side-menu-item#menu-sign-out > span:first-child { color: #4ade80; background: rgba(74, 222, 128, .14); }
.side-menu-item:hover, .side-menu-item:focus-visible { background: rgba(0, 212, 170, .09); border-color: rgba(0, 212, 170, .3); outline: none; }
@media (prefers-reduced-motion: reduce) { .side-menu { transition: none; } }


/* Square CSS-only cards for resistance sub-sections. */
.gallery-grid.resistance-subsections-grid {
    width: min(100%, 920px);
    margin-inline: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(.7rem, 2vw, 1.25rem);
}
.gallery-grid.resistance-subsections-grid .square {
    position: relative;
    isolation: isolate;
    aspect-ratio: 1 / 1;
    min-height: 0;
    padding: clamp(.7rem, 1.6vw, 1.2rem);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    border: 1px solid rgba(85, 226, 216, .28);
    border-radius: 22px;
    background: linear-gradient(145deg, #073f50 0%, #087987 52%, #22b7ac 100%);
    color: #fff;
    box-shadow: 0 10px 26px rgba(4, 67, 81, .18), inset 0 1px 0 rgba(255,255,255,.12);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.gallery-grid.resistance-subsections-grid .square::before,
.gallery-grid.resistance-subsections-grid .square::after {
    content: '';
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    pointer-events: none;
}
.gallery-grid.resistance-subsections-grid .square::before {
    width: 115%; aspect-ratio: 1; inset: -42% -38% auto auto;
    background: rgba(91, 238, 220, .12);
}
.gallery-grid.resistance-subsections-grid .square::after {
    width: 90%; aspect-ratio: 1; inset: auto auto -55% -35%;
    border: 1px solid rgba(130, 255, 238, .2);
    box-shadow: 0 0 0 18px rgba(105, 241, 224, .035), 0 0 0 38px rgba(105, 241, 224, .025);
}
.gallery-grid.resistance-subsections-grid .square:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 32px rgba(4, 67, 81, .25), inset 0 1px 0 rgba(255,255,255,.16);
    filter: saturate(1.08);
}
.gallery-grid.resistance-subsections-grid .resistance-card-title {
    display: block;
    position: relative;
    z-index: 1;
    width: 100%;
    color: #fff;
    font-size: clamp(.95rem, 1.55vw, 1.25rem);
    font-weight: 750;
    line-height: 1.65;
    text-align: center;
    overflow-wrap: anywhere;
    text-wrap: balance;
}
.gallery-grid.resistance-subsections-grid .resistance-card-title::after {
    content: ''; display: block; width: 2.8rem; height: 4px;
    margin: .8rem auto 0; border-radius: 999px;
    background: linear-gradient(90deg, #19d8d0, #68f0cb);
}
@media (max-width: 600px) {
    .gallery-grid.resistance-subsections-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
    .gallery-grid.resistance-subsections-grid .square { border-radius: 16px; padding: .65rem; }
    .gallery-grid.resistance-subsections-grid .resistance-card-title { font-size: clamp(.85rem, 3.5vw, 1rem); line-height: 1.55; }
    .gallery-grid.resistance-subsections-grid .resistance-card-title::after { margin-top: .55rem; width: 2.1rem; }
}


/* CSS-only Unicode flag badges for development/revenue cards. */
.gallery-grid.resistance-subsections-grid .development-flags {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(.25rem, .7vw, .55rem);
    margin-bottom: .75rem;
    position: relative;
    z-index: 1;
    direction: ltr;
}
.gallery-grid.resistance-subsections-grid .development-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(1.65rem, 3vw, 2.35rem);
    height: clamp(1.65rem, 3vw, 2.35rem);
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 50%;
    background: rgba(255,255,255,.13);
    box-shadow: 0 3px 9px rgba(0, 24, 40, .14);
    font-size: clamp(1rem, 2vw, 1.45rem);
    line-height: 1;
}
@media (max-width: 600px) {
    .gallery-grid.resistance-subsections-grid .development-flags { gap: .22rem; margin-bottom: .55rem; }
    .gallery-grid.resistance-subsections-grid .development-flag { width: 1.55rem; height: 1.55rem; font-size: 1rem; }
}


/* Reuse the teal CSS tile treatment for newborn subsection cards. */
.gallery-grid.newborn-subsections-grid {
    width: min(100%, 920px);
    margin-inline: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(.7rem, 2vw, 1.25rem);
}
.gallery-grid.newborn-subsections-grid .square {
    position: relative; isolation: isolate; aspect-ratio: 1 / 1; min-height: 0;
    padding: clamp(.7rem, 1.6vw, 1.2rem); display: flex; align-items: center; justify-content: center;
    text-align: center; overflow: hidden; border: 1px solid rgba(85,226,216,.28); border-radius: 22px;
    background: linear-gradient(145deg, #073f50 0%, #087987 52%, #22b7ac 100%); color: #fff;
    box-shadow: 0 10px 26px rgba(4,67,81,.18), inset 0 1px 0 rgba(255,255,255,.12);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.gallery-grid.newborn-subsections-grid .square::before,
.gallery-grid.newborn-subsections-grid .square::after {
    content: ''; position: absolute; z-index: -1; border-radius: 50%; pointer-events: none;
}
.gallery-grid.newborn-subsections-grid .square::before {
    width: 115%; aspect-ratio: 1; inset: -42% -38% auto auto; background: rgba(91,238,220,.12);
}
.gallery-grid.newborn-subsections-grid .square::after {
    width: 90%; aspect-ratio: 1; inset: auto auto -55% -35%; border: 1px solid rgba(130,255,238,.2);
    box-shadow: 0 0 0 18px rgba(105,241,224,.035), 0 0 0 38px rgba(105,241,224,.025);
}
.gallery-grid.newborn-subsections-grid .square:hover {
    transform: translateY(-3px); box-shadow: 0 15px 32px rgba(4,67,81,.25); filter: saturate(1.08);
}
.gallery-grid.newborn-subsections-grid .resistance-card-title {
    display: block; position: relative; z-index: 1; width: 100%; color: #fff;
    font-size: clamp(.95rem, 1.55vw, 1.25rem); font-weight: 750; line-height: 1.65;
    text-align: center; overflow-wrap: anywhere; text-wrap: balance;
}
.gallery-grid.newborn-subsections-grid .resistance-card-title::after {
    content: ''; display: block; width: 2.8rem; height: 4px; margin: .8rem auto 0; border-radius: 999px;
    background: linear-gradient(90deg, #19d8d0, #68f0cb);
}
@media (max-width: 600px) {
    .gallery-grid.newborn-subsections-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
    .gallery-grid.newborn-subsections-grid .square { border-radius: 16px; padding: .65rem; }
    .gallery-grid.newborn-subsections-grid .resistance-card-title { font-size: clamp(.85rem, 3.5vw, 1rem); line-height: 1.55; }
    .gallery-grid.newborn-subsections-grid .resistance-card-title::after { margin-top: .55rem; width: 2.1rem; }
}

/* Reporting cadence badges on revenue and resistance subsection tiles. */
.subsection-period-label {
    margin: 0.7rem 0 0;
    text-align: center;
    max-width: calc(100% - 1rem);
    white-space: normal;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    line-height: 1.35;
    border: 0;
    background: transparent;
    padding: 0;
}
.subsection-period-day {
    display: block;
    font-size: .78em;
    font-weight: 600;
    opacity: .95;
}

/* Keep the original white, blinking style on each individual cadence badge. */
.subsection-period-label > .kidney-period-label {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
    padding: 0.12rem 0.58rem;
    line-height: 1.35;
    animation: subsection-period-blink 1.2s ease-in-out infinite;
}
.subsection-period-label > .subsection-period-day {
    font-size: 0.64rem;
    padding: 0.1rem 0.48rem;
    margin-top: -0.08rem;
}
@keyframes subsection-period-blink {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 rgba(255, 255, 255, 0); }
    50% { opacity: 0.45; box-shadow: 0 0 12px rgba(255, 255, 255, 0.35); }
}
@media (prefers-reduced-motion: reduce) {
    .subsection-period-label > .kidney-period-label { animation: none; }
}


/* Align cadence labels to a consistent bottom edge on each tile. */
.gallery-grid.resistance-subsections-grid .square,
.gallery-grid.newborn-subsections-grid .square {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.gallery-grid.resistance-subsections-grid .subsection-period-label,
.gallery-grid.newborn-subsections-grid .subsection-period-label {
    margin-top: auto;
    position: relative;
    top: .35rem;
}
.gallery-grid.resistance-subsections-grid .resistance-card-title,
.gallery-grid.newborn-subsections-grid .resistance-card-title {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.gallery-grid.resistance-subsections-grid .development-flags { flex: 0 0 auto; }

/* Teal-petrol styling for gallery back navigation. */
.gallery-back-button {
    background: linear-gradient(135deg, #0f766e, #134e4a);
    border-color: #2dd4bf;
    color: #f0fdfa;
}
.gallery-back-button:hover {
    background: linear-gradient(135deg, #14b8a6, #0f766e);
    border-color: #5eead4;
    color: #fff;
}
.gallery-back-button:focus-visible {
    outline-color: #2dd4bf;
}

/* Slightly raise monthly/weekly badges on the revenue and resistance tiles. */
.gallery-grid.resistance-subsections-grid .subsection-period-label {
    top: 0;
    transform: translateY(-0.25rem);
}


/* Place cadence badges directly below the turquoise title underline. */
.gallery-grid.resistance-subsections-grid .resistance-card-title,
.gallery-grid.newborn-subsections-grid .resistance-card-title {
    flex: 0 0 auto;
    display: block;
}
.gallery-grid.resistance-subsections-grid .subsection-period-label,
.gallery-grid.newborn-subsections-grid .subsection-period-label {
    margin: .45rem 0 0;
    position: static;
    top: auto;
    transform: none;
}
.gallery-grid.resistance-subsections-grid .square,
.gallery-grid.newborn-subsections-grid .square {
    justify-content: center;
}

/* Show both monthly and weekly cadence badges on the main revenue card. */
.gallery-grid:not(.eye-subsections-grid):not(.newborn-subsections-grid):not(.resistance-subsections-grid) .square h3 + .kidney-period-label + .kidney-period-label {
    margin-top: -.45rem;
}

/* Per-field zero-fill action beside numeric inputs. */
.numeric-stepper .numeric-fill-zero {
    min-width: 2rem;
    font-weight: 800;
    color: #0f766e;
    border: 1px solid rgba(15, 118, 110, .32);
    background: rgba(45, 212, 191, .12);
    border-radius: 7px;
}
.numeric-stepper .numeric-fill-zero:hover {
    color: #fff;
    background: #0f766e;
}

/* Form actions: submit and zero-fill side by side. */
.form-action-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: stretch;
    gap: .65rem;
    margin-top: .25rem;
}
.form-action-row .form-submit {
    flex: 1 1 auto;
    min-width: 0;
    margin-top: 0;
}
.form-fill-zero {
    flex: 0 0 auto;
    min-height: 3rem;
    padding: .5rem 1rem;
    border: 1px solid rgba(45, 212, 191, .55);
    border-radius: 10px;
    background: linear-gradient(135deg, #0f766e, #134e4a);
    color: #f0fdfa;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.form-fill-zero:hover { background: linear-gradient(135deg, #14b8a6, #0f766e); }
@media (max-width: 420px) {
    .form-action-row { gap: .4rem; }
    .form-fill-zero { padding-inline: .65rem; }
}

/* Text areas in resistance report forms follow the same field styling. */
.form-field textarea {
    width: 100%;
    min-height: 8rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
    background: var(--bg-dark);
    color: var(--text);
    font: inherit;
    resize: vertical;
}
.form-field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Keep diagnosis/reason text areas compact like ordinary form controls. */
.form-field textarea {
    min-height: 3rem;
    height: 3rem;
    resize: vertical;
}

.revenue-period-labels {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    margin: 0.15rem 0 0.65rem;
}
.revenue-period-labels .kidney-period-label {
    margin: 0;
}

/* Mobile form layout: consistent full-width controls and comfortable touch targets. */
@media (max-width: 600px) {
    .form-overlay {
        align-items: flex-start;
        justify-content: center;
        padding: max(.5rem, env(safe-area-inset-top)) .5rem max(.5rem, env(safe-area-inset-bottom));
        overflow: hidden;
    }
    .department-form-panel {
        box-sizing: border-box;
        width: 100%;
        max-width: 34rem;
        max-height: calc(100dvh - max(1rem, env(safe-area-inset-top)) - max(1rem, env(safe-area-inset-bottom)));
        margin: 0 auto;
        padding: 1rem;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }
    /* Phone only: keep the close control floating over the form while fields scroll. */
    .department-form-panel > .form-close {
        position: sticky;
        top: .35rem;
        left: auto;
        right: auto;
        z-index: 20;
        display: flex;
        align-items: center;
        justify-content: center;
        float: left;
        margin: -.25rem 0 .35rem .1rem;
        color: #ffb000;
        box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
    }
    .department-form-panel > h2 {
        clear: both;
    }
    .department-form-panel[dir="ltr"] > .form-close {
        float: right;
        margin: -.25rem .1rem .35rem 0;
    }
    #department-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: .8rem;
        width: 100%;
    }
    #department-form .form-field {
        width: 100%;
        min-width: 0;
        gap: .35rem;
        font-size: .9rem;
        line-height: 1.45;
    }
    #department-form .form-field > span {
        overflow-wrap: anywhere;
    }
    #department-form .form-field input,
    #department-form .form-field select,
    #department-form .form-field textarea {
        box-sizing: border-box;
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 2.9rem;
        padding: .7rem .8rem;
        border-radius: 10px;
        font-size: 16px;
        line-height: 1.35;
    }
    /* Keep native date controls compact on mobile instead of overflowing the form. */
    #department-form .form-field input[type="date"] {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        padding-inline: .45rem;
        font-size: 15px;
        -webkit-appearance: none;
        appearance: none;
    }
    #department-form:has(#field-resistance-yemeni-inpatient-table-4) .form-field input[type="date"],
    #department-form:has(#field-resistance-yemeni-travel-documents-2) .form-field input[type="date"],
    #department-form:has(#field-resistance-yemeni-travel-documents-3) .form-field input[type="date"] {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
    #department-form .form-field textarea {
        min-height: 4.5rem;
        height: 4.5rem;
    }
    #department-form .numeric-input-wrap {
        display: flex;
        width: 100%;
        gap: .4rem;
    }
    #department-form .numeric-input-wrap input {
        flex: 1 1 0;
        width: 0;
        min-width: 0;
    }
    #department-form .numeric-stepper {
        flex: 0 0 2.6rem;
    }
    #department-form .numeric-step {
        min-height: 1.35rem;
        border-radius: 8px;
    }
    #department-form .form-section-heading {
        min-width: 0;
        padding: .65rem .75rem;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }
    #department-form .form-action-row {
        position: sticky;
        bottom: 0;
        z-index: 2;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: .5rem;
        padding: .65rem 0 .2rem;
        background: var(--bg-dark);
    }
    #department-form .form-submit,
    #department-form .form-fill-zero {
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
        min-height: 2.9rem;
        margin: 0;
        padding: .6rem .45rem;
        white-space: normal;
        overflow-wrap: anywhere;
        font-size: .9rem;
    }
    #department-form .form-note {
        margin: 0;
        font-size: .82rem;
        line-height: 1.5;
    }
}

@media (max-width: 360px) {
    .department-form-panel { padding: .8rem; }
    #department-form { gap: .7rem; }
    #department-form .form-action-row { grid-template-columns: minmax(0, 1fr); }
}

/* Keep Resistance forms aligned exactly like the Syrian/Yemeni community form. */
@media (max-width: 600px) {
    #department-form:has(#field-resistance-admissions-0),
    #department-form:has(#field-resistance-deaths-0) {
        grid-template-columns: minmax(0, 1fr);
        gap: .8rem;
    }
    #department-form:has(#field-resistance-admissions-0) .form-field,
    #department-form:has(#field-resistance-deaths-0) .form-field {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 0;
        gap: .35rem;
        font-size: .9rem;
        line-height: 1.45;
    }
    #department-form:has(#field-resistance-admissions-0) .form-field input,
    #department-form:has(#field-resistance-admissions-0) .form-field textarea,
    #department-form:has(#field-resistance-deaths-0) .form-field input,
    #department-form:has(#field-resistance-deaths-0) .form-field textarea {
        display: block;
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 2.9rem;
        height: 2.9rem;
        padding: .7rem .8rem;
        border-radius: 10px;
        font: inherit;
        font-size: 16px;
        line-height: 1.35;
    }
    #department-form:has(#field-resistance-admissions-0) .form-field textarea,
    #department-form:has(#field-resistance-deaths-0) .form-field textarea {
        resize: vertical;
    }
}

/* Final exact sizing fix for Resistance forms: no field may exceed its column. */
@media (max-width: 600px) {
    #department-form:has(#field-resistance-admissions-0),
    #department-form:has(#field-resistance-deaths-0) {
        width: 100%;
        min-width: 0;
        grid-template-columns: minmax(0, 1fr);
    }
    #department-form:has(#field-resistance-admissions-0) .form-field,
    #department-form:has(#field-resistance-deaths-0) .form-field {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    #department-form:has(#field-resistance-admissions-0) .form-field input,
    #department-form:has(#field-resistance-admissions-0) .form-field textarea,
    #department-form:has(#field-resistance-deaths-0) .form-field input,
    #department-form:has(#field-resistance-deaths-0) .form-field textarea {
        box-sizing: border-box !important;
        display: block;
        width: 100% !important;
        max-width: 100%;
        min-width: 0;
        height: 2.9rem;
        min-height: 2.9rem;
        margin: 0;
        padding: .7rem .8rem;
        font-size: 16px;
        line-height: 1.35;
    }
    #department-form:has(#field-resistance-admissions-0) .form-action-row,
    #department-form:has(#field-resistance-deaths-0) .form-action-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
        align-items: stretch;
        gap: .5rem;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    #department-form:has(#field-resistance-admissions-0) .form-submit,
    #department-form:has(#field-resistance-admissions-0) .form-fill-zero,
    #department-form:has(#field-resistance-deaths-0) .form-submit,
    #department-form:has(#field-resistance-deaths-0) .form-fill-zero {
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
        min-height: 2.9rem;
        margin: 0;
        padding: .55rem .25rem;
        font-size: .85rem;
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* Phone-only correction for Resistance forms (tablet/desktop remain unchanged). */
@media screen and (max-width: 600px) and (pointer: coarse) {
    .department-form-panel:has(#field-resistance-admissions-0),
    .department-form-panel:has(#field-resistance-deaths-0) {
        width: calc(100vw - 1rem) !important;
        max-width: calc(100vw - 1rem) !important;
        box-sizing: border-box !important;
        padding: .9rem !important;
    }
    #department-form:has(#field-resistance-admissions-0),
    #department-form:has(#field-resistance-deaths-0) {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: .8rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    #department-form:has(#field-resistance-admissions-0) .form-field,
    #department-form:has(#field-resistance-deaths-0) .form-field {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    #department-form:has(#field-resistance-admissions-0) .form-field input,
    #department-form:has(#field-resistance-admissions-0) .form-field textarea,
    #department-form:has(#field-resistance-admissions-0) .form-field input.animated-input-border,
    #department-form:has(#field-resistance-deaths-0) .form-field input,
    #department-form:has(#field-resistance-deaths-0) .form-field textarea,
    #department-form:has(#field-resistance-deaths-0) .form-field input.animated-input-border {
        appearance: none !important;
        -webkit-appearance: none !important;
        display: block !important;
        float: none !important;
        position: relative !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: 2.9rem !important;
        min-height: 2.9rem !important;
        max-height: 2.9rem !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: .7rem .8rem !important;
        border-radius: 9px !important;
        font-size: 16px !important;
        line-height: 1.35 !important;
    }
    #department-form:has(#field-resistance-admissions-0) .form-field textarea,
    #department-form:has(#field-resistance-deaths-0) .form-field textarea {
        resize: vertical !important;
    }
    #department-form:has(#field-resistance-admissions-0) .form-action-row,
    #department-form:has(#field-resistance-deaths-0) .form-action-row {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
        gap: .5rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    #department-form:has(#field-resistance-admissions-0) .form-action-row button,
    #department-form:has(#field-resistance-deaths-0) .form-action-row button {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: .5rem .2rem !important;
        font-size: .82rem !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
    }
}

/* Phone only: keep Submit and Fill with zero side by side at compact widths. */
@media screen and (max-width: 600px) and (pointer: coarse) {
    #department-form:has(#field-resistance-admissions-0) .form-action-row,
    #department-form:has(#field-resistance-deaths-0) .form-action-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        justify-content: center !important;
        gap: .55rem !important;
    }
    #department-form:has(#field-resistance-admissions-0) .form-action-row .form-submit,
    #department-form:has(#field-resistance-deaths-0) .form-action-row .form-submit {
        flex: 0 1 44% !important;
        width: 44% !important;
        max-width: 44% !important;
    }
    #department-form:has(#field-resistance-admissions-0) .form-action-row .form-fill-zero,
    #department-form:has(#field-resistance-deaths-0) .form-action-row .form-fill-zero {
        flex: 0 1 44% !important;
        width: 44% !important;
        max-width: 44% !important;
    }
}

/* Mobile: apply compact action buttons consistently to every department form. */
@media screen and (max-width: 600px) {
    #department-form .form-action-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        justify-content: center !important;
        gap: .55rem !important;
        padding: .35rem 0 .2rem !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    #department-form .form-action-row .form-submit,
    #department-form .form-action-row .form-fill-zero {
        box-sizing: border-box !important;
        flex: 0 1 44% !important;
        width: 44% !important;
        max-width: 44% !important;
        min-width: 0 !important;
        min-height: 2.8rem !important;
        margin: 0 !important;
        padding: .55rem .4rem !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        font-size: .88rem !important;
    }
}

/* Mobile only: allocate 70% to Submit and 30% to Fill with zero. */
@media screen and (max-width: 600px) {
    #department-form .form-action-row .form-submit {
        flex: 0 0 calc(70% - .2rem) !important;
        width: calc(70% - .2rem) !important;
        max-width: calc(70% - .2rem) !important;
    }
    #department-form .form-action-row .form-fill-zero {
        flex: 0 0 calc(30% - .35rem) !important;
        width: calc(30% - .35rem) !important;
        max-width: calc(30% - .35rem) !important;
    }
}

/* Mobile only: 70/30 action-button layout in every form that has these actions. */
@media screen and (max-width: 600px) {
    .form-action-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: .55rem !important;
        padding: .35rem 0 .2rem !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    .form-action-row .form-submit {
        box-sizing: border-box !important;
        flex: 0 0 calc(70% - .2rem) !important;
        width: calc(70% - .2rem) !important;
        max-width: calc(70% - .2rem) !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
    .form-action-row .form-fill-zero {
        box-sizing: border-box !important;
        flex: 0 0 calc(30% - .35rem) !important;
        width: calc(30% - .35rem) !important;
        max-width: calc(30% - .35rem) !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
}

/* Mobile: override the more-specific legacy Resistance rules with the same 70/30 split. */
@media screen and (max-width: 600px) {
    #department-form:has(#field-resistance-admissions-0) .form-action-row .form-submit,
    #department-form:has(#field-resistance-deaths-0) .form-action-row .form-submit {
        flex: 0 0 calc(70% - .2rem) !important;
        width: calc(70% - .2rem) !important;
        max-width: calc(70% - .2rem) !important;
    }
    #department-form:has(#field-resistance-admissions-0) .form-action-row .form-fill-zero,
    #department-form:has(#field-resistance-deaths-0) .form-action-row .form-fill-zero {
        flex: 0 0 calc(30% - .35rem) !important;
        width: calc(30% - .35rem) !important;
        max-width: calc(30% - .35rem) !important;
    }
}

/* Ensure the animated border is visible on every input type in GCC and community forms. */
#department-form:has(#field-gcc-citizens-0) .form-field input.animated-input-border,
#department-form:has(#field-gcc-citizens-0) .form-field select.animated-input-border,
#department-form:has(#field-syrian-yemeni-communities-0) .form-field input.animated-input-border,
#department-form:has(#field-syrian-yemeni-communities-0) .form-field select.animated-input-border {
    border: 1px solid transparent !important;
    background: linear-gradient(var(--bg-dark), var(--bg-dark)) padding-box,
        conic-gradient(from var(--field-border-angle, 0deg), rgba(0, 212, 170, .22), rgba(0, 212, 170, .85), rgba(73, 164, 255, .42), rgba(0, 212, 170, .22)) border-box !important;
    animation: field-border-drift 7s linear infinite !important;
}

/* Signed-in header: distinct brand, account identity and utility controls. */
header {
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) minmax(180px, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem clamp(.85rem, 2vw, 1.5rem);
}
.header-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}
.header-brand .logo {
    white-space: nowrap;
    font-size: clamp(1rem, 1.4vw, 1.3rem);
}
.header-user {
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}
.header-user-label {
    display: block;
    max-width: 100%;
    padding: .55rem .9rem;
    border-inline-start: 2px solid rgba(0, 212, 170, .45);
    color: var(--text-muted);
    font-size: .88rem;
    line-height: 1.6;
    text-align: center;
    overflow-wrap: anywhere;
}
.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: .55rem;
    min-width: 0;
}
.header-actions .record-log-toggle,
.header-actions #sign-out-button {
    min-height: 2.65rem;
    padding: .55rem .85rem;
    white-space: nowrap;
}
.header-actions .site-notifications,
.header-actions .language-picker { flex: 0 0 auto; }
.header-actions .notification-bell {
    width: 2.65rem;
    height: 2.65rem;
}

@media (max-width: 900px) {
    header {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: .75rem;
    }
    .header-brand { grid-column: 1; grid-row: 1; }
    .header-user { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
    .header-user-label { padding: .25rem .65rem; text-align: start; }
    .header-actions { grid-column: 2; grid-row: 1; max-width: 58vw; }
}
/* Desktop: bring the signed-in identity closer to the site title. */
@media (min-width: 901px) {
    body:not(.auth-page) > header {
        grid-template-columns: max-content minmax(0, 1fr) auto;
        column-gap: .25rem;
    }
    body:not(.auth-page) > header .header-user {
        justify-content: flex-start;
    }
    body:not(.auth-page) > header .header-user-label {
        text-align: start;
        padding-inline-start: .35rem;
        color: #ffffff;
    }
}
@media (max-width: 600px) {
    header {
        padding: .75rem;
        grid-template-columns: minmax(0, 1fr);
        gap: .6rem;
    }
    .header-brand { grid-column: 1; grid-row: 1; }
    .header-brand .logo { font-size: 1rem; white-space: normal; }
    .header-user { grid-column: 1; grid-row: 2; justify-content: flex-start; }
    .header-user-label { padding: .15rem .5rem; font-size: .8rem; }
    .header-actions {
        grid-column: 1;
        grid-row: 3;
        max-width: 100%;
        justify-content: flex-start;
        gap: .45rem;
    }
    .header-actions .record-log-toggle,
    .header-actions #sign-out-button,
    .header-actions .lang-toggle {
        min-height: 2.4rem;
        padding: .4rem .65rem;
        font-size: .85rem;
    }
    .header-actions .notification-bell { width: 2.4rem; height: 2.4rem; }
}

/* Mobile header polish: compact two-row layout with no oversized controls. */
@media screen and (max-width: 600px) {
    body:not(.auth-page) > header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "brand" "user" "actions";
        align-items: center;
        justify-content: stretch;
        gap: .65rem;
        padding: .85rem .9rem .9rem;
    }
    body:not(.auth-page) .header-brand {
        grid-area: brand;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: .7rem;
        width: 100%;
    }
    body:not(.auth-page) .header-brand .logo {
        flex: 1 1 auto;
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
        font-size: clamp(1.05rem, 4.8vw, 1.35rem);
        line-height: 1.4;
    }
    body:not(.auth-page) .header-brand .menu-toggle {
        flex: 0 0 3rem;
        width: 3rem;
        height: 3rem;
        min-width: 3rem;
        padding: 0;
        border-radius: 14px;
        font-size: 1.35rem;
    }
    body:not(.auth-page) .header-user {
        grid-area: user;
        width: 100%;
        justify-content: flex-start;
        min-width: 0;
    }
    body:not(.auth-page) .header-user-label {
        width: 100%;
        max-width: 100%;
        padding: .15rem .6rem;
        border-inline-start-width: 2px;
        text-align: start;
        font-size: .82rem;
        line-height: 1.6;
    }
    body:not(.auth-page) .header-actions {
        grid-area: actions;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: .5rem;
        width: 100%;
        max-width: 100%;
    }
    body:not(.auth-page) .header-actions .record-log-toggle,
    body:not(.auth-page) .header-actions #sign-out-button {
        min-height: 2.55rem;
        padding: .4rem .65rem;
        border-radius: 11px;
        font-size: .82rem;
        line-height: 1.35;
    }
    /* In RTL, push language and notifications to the opposite (left) edge. */
    body:not(.auth-page) .header-actions .site-notifications { order: 10; margin-inline-start: auto; }
    body:not(.auth-page) .header-actions .language-picker { order: 11; }
    body:not(.auth-page) .header-actions .notification-bell {
        width: 2.55rem;
        height: 2.55rem;
        min-width: 2.55rem;
        border-radius: 11px;
    }
    body:not(.auth-page) .header-actions .lang-toggle {
        min-height: 2.55rem;
        padding: .35rem .55rem;
        font-size: .82rem;
    }
    body:not(.auth-page) .header-actions .language-globe { font-size: 1rem; }
}




/* Home-page department tiles use an inline SVG icon; subsection tiles remain unchanged. */
.home-gallery-tile .home-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(circle at 50% 45%, rgba(30, 151, 255, .17), rgba(9, 23, 46, .08) 66%, transparent 72%);
}
.home-gallery-tile .home-inline-icon {
    display: block;
    width: min(76%, 220px);
    height: auto;
    max-height: 190px;
    filter: drop-shadow(0 5px 12px rgba(0, 105, 210, .16));
    transition: transform .25s ease;
}
.home-gallery-tile:hover .home-inline-icon,
.home-gallery-tile:focus-visible .home-inline-icon { transform: translateY(-3px) scale(1.025); }
@media (prefers-reduced-motion: reduce) { .home-gallery-tile .home-inline-icon { transition: none; } }

/* Embed each department name directly under the icon within the home tile artwork. */
.home-gallery-tile .home-icon-container {
    flex-direction: column;
    gap: .15rem;
    padding: .7rem .5rem .25rem;
}
.home-gallery-tile .home-inline-icon {
    width: min(68%, 190px);
    max-height: 155px;
    flex: 0 1 auto;
}
.home-gallery-tile .home-icon-title {
    display: block;
    max-width: 100%;
    color: #eaf5ff;
    font-size: clamp(.82rem, 1.5vw, 1.05rem);
    font-weight: 800;
    line-height: 1.45;
    text-align: center;
    text-wrap: balance;
    text-shadow: 0 2px 8px rgba(0, 90, 180, .35);
}
.home-gallery-tile .home-accessible-title {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Slightly larger icon and department label on top-level home tiles. */
.home-gallery-tile .home-inline-icon {
    width: min(78%, 220px);
    max-height: 180px;
}
.home-gallery-tile .home-icon-title {
    font-size: clamp(.95rem, 1.7vw, 1.18rem);
    line-height: 1.5;
}

/* Custom warning dialog for the Syrian and Yemeni communities form. */
.warning-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(7, 15, 30, .66);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}
.warning-overlay[hidden] { display: none; }
.warning-popup {
    width: min(100%, 390px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .85rem;
    padding: 1.8rem 1.5rem 1.4rem;
    border: 1px solid rgba(245, 158, 11, .48);
    border-radius: 22px;
    background: var(--bg-card, #fff);
    color: var(--text, #172033);
    text-align: center;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
    animation: popup-in 200ms ease-out;
}
.warning-icon {
    display: grid;
    place-items: center;
    width: 3.6rem;
    height: 3.6rem;
    border-radius: 50%;
    background: rgba(245, 158, 11, .13);
    border: 2px solid #f59e0b;
    color: #d97706;
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
}
.warning-popup h2 { margin: .1rem 0 0; font-size: 1.25rem; }
.warning-popup p { margin: 0; font-size: 1rem; line-height: 1.9; }
.warning-confirm {
    width: 100%;
    min-height: 2.8rem;
    margin-top: .3rem;
    border: 0;
    border-radius: 12px;
    background: #d97706;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.warning-confirm:hover { background: #b45309; }
.warning-confirm:focus-visible { outline: 3px solid rgba(245, 158, 11, .4); outline-offset: 3px; }

/* Force the Contact and Sign out icons to stay green in the mobile side menu. */
@media screen and (max-width: 600px) {
    body:not(.auth-page) #side-menu .side-menu-item#menu-contact > span:first-child,
    body:not(.auth-page) #side-menu .side-menu-item#menu-sign-out > span:first-child {
        color: #4ade80 !important;
        background: rgba(74, 222, 128, .14) !important;
    }
}

/* My Records: compact two-choice navigation, optimized for small screens. */
.my-records-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.65rem; margin:1rem 0; }
.my-records-option { display:flex; flex-direction:column; justify-content:center; gap:.45rem; min-width:0; min-height:76px; padding:.8rem; border:1px solid var(--border); border-radius:12px; background:var(--bg-dark); color:var(--text); font:inherit; cursor:pointer; }
.my-records-option[aria-pressed="true"] { border-color:var(--primary); background:rgba(0,212,170,.1); }
.my-records-option strong { color:var(--primary); font-size:1.15rem; overflow-wrap:anywhere; }
#record-log-items[hidden] { display:none !important; }
@media(max-width:600px) { .record-log-overlay { align-items:flex-start; overflow-y:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; } .record-log-panel { width:100%; margin:auto 0; max-height:none; overflow:visible; } .my-records-options { gap:.45rem; } .my-records-option { padding:.65rem; font-size:.88rem; } }
