/* Modern CSS Variables - Light Mode (Default) */
:root,
:root[data-theme="light"] {
    --primary-color: #b1171e;
    --primary-dark: #8b1116;
    --primary-light: #d41f28;
    --secondary-color: #2c3e50;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e1e8ed;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Layout scale (theme-safe) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    /* Container sizing */
    /* App pages: fill available width, keep ~20px side gutter */
    --container-max: 100%;
    --container-max-wide: 100%;
    --container-pad: 20px;
}

@media only screen and (max-width: 420px) {
    :root,
    :root[data-theme="light"],
    :root[data-theme="dark"] {
        --container-pad: 12px;
    }
}

/* Dark Mode Variables - Applied via data-theme="dark" attribute */
:root[data-theme="dark"] {
    --primary-color: #e63946;
    --primary-dark: #d62828;
    --primary-light: #f1495a;
    --secondary-color: #1a1a2e;
    --accent-color: #4dabf7;
    --success-color: #51cf66;
    --warning-color: #ffd43b;
    --danger-color: #ff6b6b;
    --background: #0f0f1e;
    --surface: #1a1a2e;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #2d2d44;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* Apply dark mode when system preference is dark AND no explicit light theme is set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #e63946;
        --primary-dark: #d62828;
        --primary-light: #f1495a;
        --secondary-color: #1a1a2e;
        --accent-color: #4dabf7;
        --success-color: #51cf66;
        --warning-color: #ffd43b;
        --danger-color: #ff6b6b;
        --background: #0f0f1e;
        --surface: #1a1a2e;
        --text-primary: #e9ecef;
        --text-secondary: #adb5bd;
        --border-color: #2d2d44;
        --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
        --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
    }
}

/* Dark mode specific adjustments */
:root[data-theme="dark"] .mobile img {
    filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.1)) brightness(1.2);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .mobile img {
        filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.1)) brightness(1.2);
    }
}

:root[data-theme="dark"] .table-container table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .table-container table tr:nth-child(even) {
        background: rgba(255, 255, 255, 0.03);
    }
}

:root[data-theme="dark"] .nodob {
    background: rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .nodob {
        background: rgba(255, 255, 255, 0.05);
    }
}

:root[data-theme="dark"] .flash {
    background: rgba(255, 243, 205, 0.15);
    border-left-color: var(--warning-color);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .flash {
        background: rgba(255, 243, 205, 0.15);
        border-left-color: var(--warning-color);
    }
}

:root[data-theme="dark"] .invalidaddress {
    background: rgba(255, 107, 107, 0.15);
    border-left-color: var(--danger-color);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .invalidaddress {
        background: rgba(255, 107, 107, 0.15);
        border-left-color: var(--danger-color);
    }
}

:root[data-theme="dark"] .error {
    background: rgba(255, 107, 107, 0.15);
    border-left-color: var(--danger-color);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .error {
        background: rgba(255, 107, 107, 0.15);
        border-left-color: var(--danger-color);
    }
}

:root[data-theme="dark"] #totals_for_year_by_location th {
    background: rgba(255, 255, 255, 0.03) !important;
    color: var(--text-primary) !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) #totals_for_year_by_location th {
        background: rgba(255, 255, 255, 0.03) !important;
        color: var(--text-primary) !important;
    }
}

/* Input fields and selects in dark mode */
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

@media (prefers-color-scheme: dark) {

    :root:not([data-theme="light"]) input,
    :root:not([data-theme="light"]) select,
    :root:not([data-theme="light"]) textarea {
        background-color: var(--surface) !important;
        color: var(--text-primary) !important;
        border-color: var(--border-color) !important;
    }
}

[data-theme="dark"] input,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

@media (prefers-color-scheme: dark) {

    :root:not([data-theme="light"]) input,
    :root:not([data-theme="light"]) select,
    :root:not([data-theme="light"]) textarea {
        background-color: var(--surface) !important;
        color: var(--text-primary) !important;
        border-color: var(--border-color) !important;
    }
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
    color: var(--text-secondary) !important;
}

@media (prefers-color-scheme: dark) {

    :root:not([data-theme="light"]) input::placeholder,
    :root:not([data-theme="light"]) textarea::placeholder {
        color: var(--text-secondary) !important;
    }
}

/* Select dropdown arrows in dark mode */
:root[data-theme="dark"] select:not(.theme-selector) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e63946' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
}

:root[data-theme="dark"] .theme-selector {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e63946' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) select:not(.theme-selector) {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e63946' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 12px center !important;
    }

    :root:not([data-theme="light"]) .theme-selector {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e63946' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    }
}

:root[data-theme="dark"] select:not(.theme-selector):focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e63946' d='M6 3l5 5H1z'/%3E%3C/svg%3E") !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) select:not(.theme-selector):focus {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e63946' d='M6 3l5 5H1z'/%3E%3C/svg%3E") !important;
    }
}

/* ------------------------------------------------------------
   Universal choice controls (checkbox + radios)
   Theme-aware via existing CSS variables.
   ------------------------------------------------------------ */

:root {
    --lh-choice-height: 26px;
    --lh-choice-width: 48px;
    --lh-choice-padding: 3px;
    --lh-choice-thumb: 18px;
    --lh-choice-border: 2px;
}

/* Visually hide inputs but keep them accessible */
.lh-choice__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Checkbox toggle (animated switch) */
.lh-switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Shared: switch-like controls (checkbox + radio switch rows) */
.lh-switch span,
.lh-radio-switch span {
    vertical-align: middle;
}

:is(.lh-switch__track, .lh-radio-switch__track) {
    width: var(--lh-choice-width);
    height: var(--lh-choice-height);
    border-radius: 999px;
    background: var(--surface);
    border: var(--lh-choice-border) solid var(--border-color);
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    padding: var(--lh-choice-padding);
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

:is(.lh-switch__thumb, .lh-radio-switch__thumb) {
    width: var(--lh-choice-thumb);
    height: var(--lh-choice-thumb);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transform: translateX(0);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

/* Off state contrast tweaks (dark mode) */
:root[data-theme="dark"] .lh-switch > .lh-choice__input:not(:checked) + .lh-switch__track,
:root[data-theme="dark"] .lh-radio-switch .lh-choice__input:not(:checked) ~ .lh-radio-switch__track {
    /* Make "off" clearly visible against dark surfaces */
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(233, 236, 239, 0.22);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .lh-switch > .lh-choice__input:not(:checked) + .lh-switch__track .lh-switch__thumb,
:root[data-theme="dark"] .lh-radio-switch .lh-choice__input:not(:checked) ~ .lh-radio-switch__track .lh-radio-switch__thumb {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .lh-switch > .lh-choice__input:not(:checked) + .lh-switch__track,
    :root:not([data-theme="light"]) .lh-radio-switch .lh-choice__input:not(:checked) ~ .lh-radio-switch__track {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(233, 236, 239, 0.22);
        box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    }

    :root:not([data-theme="light"]) .lh-switch > .lh-choice__input:not(:checked) + .lh-switch__track .lh-switch__thumb,
    :root:not([data-theme="light"]) .lh-radio-switch .lh-choice__input:not(:checked) ~ .lh-radio-switch__track .lh-radio-switch__thumb {
        background: rgba(255, 255, 255, 0.14);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    }
}

/* On state */
.lh-switch > .lh-choice__input:checked + .lh-switch__track {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(177, 23, 30, 0.18);
}

:root[data-theme="dark"] .lh-switch > .lh-choice__input:checked + .lh-switch__track {
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.22);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .lh-switch > .lh-choice__input:checked + .lh-switch__track {
        box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.22);
    }
}

.lh-switch > .lh-choice__input:checked + .lh-switch__track .lh-switch__thumb {
    transform: translateX(calc(var(--lh-choice-width) - (2 * var(--lh-choice-padding)) - var(--lh-choice-thumb) - (2 * var(--lh-choice-border))));
}

/* Focus */
.lh-switch > .lh-choice__input:focus-visible + .lh-switch__track {
    outline: none;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.28);
}

/* Disabled */
.lh-switch > .lh-choice__input:disabled + .lh-switch__track {
    opacity: 0.55;
    cursor: not-allowed;
}

.lh-switch:has(> .lh-choice__input:disabled) {
    cursor: not-allowed;
    opacity: 0.85;
}

/* Label text (optional) */
.lh-switch__text {
    font-weight: 700;
    color: var(--text-secondary);
}

/* Descriptive label (auto-enhanced checkboxes) */
.lh-switch__label {
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    margin-left: 4px !important;
}

/* When both a descriptive label and on/off text exist, keep them readable */
.lh-switch__label + .lh-switch__text,
.lh-switch__text + .lh-switch__label {
    margin-left: 8px;
}

.lh-switch__text::after {
    content: attr(data-off);
}

.lh-switch > .lh-choice__input:checked ~ .lh-switch__text::after {
    content: attr(data-on);
    color: var(--text-primary);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    :is(.lh-switch__track, .lh-radio-switch__track),
    :is(.lh-switch__thumb, .lh-radio-switch__thumb) {
        transition: none !important;
    }
}

/* Radio style #1: Two-option segmented toggle (no "off" look) */
.lh-seg-toggle {
    position: relative;
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: center;
    border-radius: 999px;
    border: 2px solid var(--border-color);
    background: var(--surface);
    padding: 2px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.lh-seg-toggle__label {
    position: relative;
    z-index: 1;
    padding: 8px 24px 8px 14px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    text-align: center;
    white-space: nowrap;
}

.lh-seg-toggle__indicator {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    width: calc(50% - 2px);
    border-radius: 999px;
    background: rgba(177, 23, 30, 0.10);
    border: 1px solid rgba(177, 23, 30, 0.30);
    transform: translateX(0);
    transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

:root[data-theme="dark"] .lh-seg-toggle__indicator {
    background: rgba(230, 57, 70, 0.14);
    border-color: rgba(230, 57, 70, 0.35);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .lh-seg-toggle__indicator {
        background: rgba(230, 57, 70, 0.14);
        border-color: rgba(230, 57, 70, 0.35);
    }
}

.lh-seg-toggle .lh-choice__input:checked + .lh-seg-toggle__label {
    color: var(--text-primary);
}

.lh-seg-toggle .lh-choice__input:focus-visible + .lh-seg-toggle__label {
    outline: none;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.28);
    border-radius: 999px;
}

/* Move indicator based on which radio is checked (2 options) */
.lh-seg-toggle--2 .lh-choice__input:nth-of-type(1):checked ~ .lh-seg-toggle__indicator {
    transform: translateX(0);
}

.lh-seg-toggle--2 .lh-choice__input:nth-of-type(2):checked ~ .lh-seg-toggle__indicator {
    transform: translateX(calc(100% + 2px));
}

@media (prefers-reduced-motion: reduce) {
    .lh-seg-toggle__indicator {
        transition: none !important;
    }
}

/* Radio style #2: Radio group displayed as switch rows (only selected looks "on") */
.lh-radio-switches {
    display: grid;
    gap: 4px;
}

.lh-radio-switch {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.lh-radio-switch__label {
    font-weight: 700;
    color: var(--text-primary);
}

.lh-radio-switch:has(.lh-choice__input:focus-visible) {
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.18);
}

.lh-radio-switch .lh-choice__input:checked ~ .lh-radio-switch__track {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.lh-radio-switch .lh-choice__input:checked ~ .lh-radio-switch__track .lh-radio-switch__thumb {
    transform: translateX(calc(var(--lh-choice-width) - (2 * var(--lh-choice-padding)) - var(--lh-choice-thumb) - (2 * var(--lh-choice-border))));
}

/* Reduced motion handled by shared rule above */

/* Form containers with inline styles */
:root[data-theme="dark"] form[style*="background:#f9f9f9"],
:root[data-theme="dark"] form[style*="background: #f9f9f9"],
:root[data-theme="dark"] div[style*="background:#f9f9f9"],
:root[data-theme="dark"] div[style*="background: #f9f9f9"] {
    background: var(--surface) !important;
    border-color: var(--border-color) !important;
}

@media (prefers-color-scheme: dark) {

    :root:not([data-theme="light"]) form[style*="background:#f9f9f9"],
    :root:not([data-theme="light"]) form[style*="background: #f9f9f9"],
    :root:not([data-theme="light"]) div[style*="background:#f9f9f9"],
    :root:not([data-theme="light"]) div[style*="background: #f9f9f9"] {
        background: var(--surface) !important;
        border-color: var(--border-color) !important;
    }
}

:root[data-theme="dark"] #globalFilters {
    background: var(--surface) !important;
    border-color: var(--border-color) !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) #globalFilters {
        background: var(--surface) !important;
        border-color: var(--border-color) !important;
    }
}

:root[data-theme="dark"] #reportPreviewOverlay>div {
    background: var(--surface) !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) #reportPreviewOverlay>div {
        background: var(--surface) !important;
    }
}

#reportPreviewOverlay>div>div:last-child {
    border-top-color: var(--border-color) !important;
}

.grouplist {
    max-width: 1000px;
}

.newpaperworkinstructions {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--accent-color);
}

.footnote {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--accent-color);
}

/* Labels in dark mode */
label {
    color: var(--text-primary) !important;
}

/* Default view - mobile and portrait tablet */

.mobile {
    display: inline;
}

.mobile img {
    height: 32px;
    width: 32px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.desk {
    display: none;
}

.deskblock {
    display: none;
}

.row-margin {
    margin-bottom: 12px;
}

.push-down {
    margin-top: 12px;
}

/* Mobile-specific enhancements */
@media only screen and (max-width: 768px) {
    body {
        font-size: 3.5vw;
    }

    .topnav {
        border-radius: var(--radius-md);
    }

    .topnav a {
        padding: 14px 12px;
    }

    .button {
        padding: 14px 20px;
        width: 100%;
    }

    .boxed fieldset {
        padding: 16px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Mobile theme selector adjustments */
    .theme-selector-container {
        padding: 6px 10px;
        gap: 6px;
    }

    .theme-selector-label {
        font-size: 0.85em;
    }

    .theme-selector {
        padding: 5px 8px;
        font-size: 0.85em;
    }
}

.button {
    display: inline-block;
    box-sizing: border-box;
    text-decoration: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    font-weight: 640;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    text-align: center;
}

/* Visits page: stack action buttons and keep them the same width */
.visit-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: stretch;
    max-width: 400px;
}

.visit-actions .button {
    flex: 1 1 0;
    width: auto;
    white-space: nowrap;
}

@media only screen and (max-width: 768px) {
    .visit-actions {
        flex-direction: column;
    }

    .visit-actions .button {
        width: 100%;
    }
}

.table-container th.actions-column,
.table-container td.actions-column {
    min-width: 180px;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.buttonsmall {
    text-decoration: none;
    margin-left: 3px;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.buttonsmall:hover {
    opacity: 0.85;
}

.clickable-cell {
    cursor: pointer;
    position: relative;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.clickable-cell:focus,
.clickable-cell:focus-within,
.clickable-cell:hover {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(52, 152, 219, 0.35);
    background: rgba(52, 152, 219, 0.08);
}

.clickable-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent-color);
    font-weight: 600;
    text-decoration: underline;
    letter-spacing: 0.02em;
}

.clickable-label.nodob {
    background: linear-gradient(135deg, rgba(245, 245, 245, 0.8) 0%, rgba(230, 230, 230, 0.9) 100%);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.app-shell .topnav {
    overflow: hidden;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: 20px;

    /* Flex nav (replaces float layout) */
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

.app-shell .topnav a {
    float: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px 24px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95em;
    letter-spacing: 0.05em;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.app-shell .topnav a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: currentColor;
    transition: all var(--transition-base);
    transform: translateX(-50%);
}

.app-shell .topnav a:hover::before {
    width: 80%;
}

.flash {
    background: linear-gradient(135deg, #fff9e6 0%, #FFF5D7 100%);
    border-left: 4px solid var(--warning-color);
    padding: 12px;
    border-radius: var(--radius-sm);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo {
    background-repeat: no-repeat;
    background-size: contain;
    height: 14vw;
    width: 25vw;
    transition: transform var(--transition-base);
}

.logo:hover {
    transform: scale(1.02);
}

/* Theme Selector Styles */
.theme-selector-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

/*
  The header theme picker uses a <label> + <select> pair.
  Our app-wide form rules intentionally stack label+control vertically.
  Override those rules inside the theme selector so the control stays inline.
*/
.theme-selector-container .theme-selector-label {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.theme-selector-container .theme-selector {
    display: inline-block;
    width: auto;
    max-width: none;
    margin: 0;
}

.theme-selector-container:hover {
    box-shadow: var(--shadow-sm);
}

.theme-selector-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9em;
    margin: 0;
}

.theme-selector {
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 30px 6px 10px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b1171e' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

.theme-selector:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(177, 23, 30, 0.1);
}

.theme-selector:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(177, 23, 30, 0.2);
}

.theme-selector option {
    background: var(--background);
    color: var(--text-primary);
}


.boxed fieldset {
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-color);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    padding: 24px 24px 10px 24px;
    transition: all var(--transition-base);
    margin-bottom: 40px;
}

.boxed fieldset:hover {
    box-shadow: var(--shadow-lg);
}

.boxed legend {
    padding: 8px 16px;
    font-style: normal;
    font-weight: 700;
    font-size: 1.2em;
    color: var(--primary-color);
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
}

/* .boxed label {
    display: inline-block;
    width: 25vw;
    min-width: 100px;
    margin-top: 10px;
    font-weight: 500;
    color: var(--text-primary);
} */

.adminlabel {
    line-height: 1.75;
}

div.errorpopup div.ui-widget-header {
    color: white;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 16px;
}

div.messagepopup div.ui-widget-header {
    color: white;
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    border: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 16px;
}

span.warning {
    font-size: smaller;
    font-style: italic;
    width: auto;
    color: var(--warning-color);
    font-weight: 500;
    margin-left: 24px;
}

input,
select,
textarea {
    font-size: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: all var(--transition-base);
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(177, 23, 30, 0.1);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--text-secondary);
}

/* Enhanced select styling */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b1171e' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b1171e' d='M6 3l5 5H1z'/%3E%3C/svg%3E");
}

/* Textarea specific */
textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* Disabled state */
input:disabled,
select:disabled,
textarea:disabled {
    background: var(--background);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Dark mode disabled state override */
@media (prefers-color-scheme: dark) {

    input:disabled,
    select:disabled,
    textarea:disabled {
        background: rgba(255, 255, 255, 0.05) !important;
        color: var(--text-secondary) !important;
    }
}

input[type=checkbox] {
    transform: scale(1.2);
    cursor: pointer;
    accent-color: var(--primary-color);
}

.inputsmall {
    width: 18vw;
    margin-bottom: 1vw;
}

.inputmedium {
    width: 35vw;
    max-width: 325px;
    margin-bottom: 1vw;
}

::placeholder {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.9em;
    opacity: 0.7;
}

.boxed input {
    margin-bottom: 1.5vw;
}

.boxed #newUser {
    text-decoration: none;
    float: right;
}

/* Ensure consistent horizontal spacing and vertical alignment for all member rows (span or div) */
#membersdiv>span[id^="memberspan-"],
#membersdiv>div.member-row {
    display: inline-flex;
    align-items: start;
    align-content: start;
    gap: 8px;
    flex-wrap: nowrap;
    height: auto;
}

/* Apply to every member-row AFTER the first member-row */
#membersdiv > div.member-row ~ div.member-row label,
#membersdiv > div.member-row ~ div.member-row br {
    display: none;
}

#createuser {
    float: left;
}

.clear {
    clear: both;
}

.error {
    padding: 12px 16px;
    font-style: normal;
    text-align: center;
    background: linear-gradient(135deg, #fee 0%, #fdd 100%);
    border-left: 4px solid var(--danger-color);
    border-radius: var(--radius-sm);
    margin: 10px 0;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

ul {
    margin-top: -20px;
}

.notnegative {
    margin-top: -10px;
}

.instructions {
    padding: 3px;
}

li {
    padding: 10px;
}

.instructions li {
    padding: 1px;
}

#dailysummary {
    /*float: left;*/
    background: var(--surface);
    margin: 20px;
    padding-bottom: 16px;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

#noinfo {
    padding: 20px 5vw;
    background: var(--background);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--text-secondary);
}

#summarytotals {
    padding: 20px;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.summarylineamount {
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1em;
}

.summaryfor {
    display: inline-block;
    font-size: 1.4em;
}

.table-container {
    margin: 4px 0 0 0;
}

.table-container table,
.history {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table-container th,
.table-container td {
    text-align: left;
}

.table-container th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 16px;
    font-weight: 600;
    text-transform: uppercase;
    width: auto;
}

.table-container td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.table-container tr:hover td {
    background: var(--background);
}

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

.users th {
    text-align: left;
    padding: 16px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #1a252f 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.05em;
}

.users td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.users tr:hover td {
    background: var(--background);
}

.users h3 {
    text-align: center;
    color: var(--text-primary);
    font-size: 1.8em;
}

.users table {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.history th,
.history td {
    text-align: center;
    padding: 16px;
}

.history th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.05em;
}

.history tr:hover td {
    background: var(--background);
}

.table-container th,
.table-container td {
    vertical-align: middle;
}

#totals_for_year_by_location {
    width: 100%;
    margin: 0 auto;
    /* center the container within the page content area */
    text-align: center;
    /* center the inline table(s) inside */
    display: flex;
    /* lay out year tables in a row */
    flex-wrap: wrap;
    /* allow wrapping to next line on smaller screens */
}

#totals_for_year_by_location td:nth-child(1) {
    padding-right: 50px;
}

#totals_for_year_by_location table {
    margin: 20px auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#totals_for_year_by_location th {
    border-bottom: 3px solid var(--primary-color);
    padding: 0 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.05em;
    text-align: center;
    height: 60px;
    color: var(--text-primary) !important;
}

#totals_for_year_by_location td {
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
}

#totals_for_year_by_location tr:hover td {
    background: var(--background);
}

#totals_for_year_by_location td:nth-child(2) {
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
}

#totals_for_year_by_location h3 {
    margin-bottom: 5px;
    color: white;
    font-size: 1.6em;
}

#totals_for_year_by_location caption {
    padding: 16px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.footnote {
    margin: 20px;
    font-size: 0.85em;
    font-style: italic;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 8px 12px;
    background: var(--background);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-color);
}

.pickedupby {
    font-style: italic;
    font-size: 3vw;
    color: var(--text-secondary);
}

.nodob {
    font-style: italic;
    background: linear-gradient(135deg, #f5f5f5 0%, #e6e6e6 100%);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

#hchildren:after {
    content: "Ch";
}

#hadults:after {
    content: "Ad";
}

#hseniors:after {
    content: "Sen";
}


.grouptitle {
    padding: 15px 0;
    font-weight: 700;
    font-size: 1.2em;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 12px;
}

.grouplist {
    padding-left: 0 20px 20px 20px;
    padding: 16px 20px;
    margin: 12px 0;
}

.paperworkneeded,
#paperworkprompt {
    color: var(--success-color);
    font-weight: 500;
}

#paperworkprompt label {
    width: 80%;
}

#paperworkprompt div {
    margin-top: 0.5vw;
    margin-bottom: 0.5vw;
}

#paperworkprompt div input {
    margin-bottom: 0vw;
}

.newpaperworkinstructions {
    font-size: 0.9em;
    color: var(--text-secondary);
    background: var(--background);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-color);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    max-width: 100%;
    font-size: 2.6vw;
    color: var(--text-primary);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body>* {
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/*
  App shell (scoped):
  - Normal pages that include include/header.php now render inside .app-shell.
  - Print/ticket/label pages that don't include the shared header/footer remain unaffected.
*/
.app-shell {
    width: 100%;
    min-height: 100dvh;

    /* Avoid horizontal overflow when legacy rules set width:100% plus padding/borders */
    box-sizing: border-box;

    /* Override legacy body>* padding so the shell can manage its own gutters */
    padding-left: 0;
    padding-right: 0;

    /* Move away from vw-based sizing for app UI only */
    font-size: clamp(14px, 1.6vw, 18px);
    line-height: 1.45;
}

/* App-only box sizing reset: prevents "bleeding" past the right edge */
.app-shell *,
.app-shell *::before,
.app-shell *::after {
    box-sizing: border-box;
}

.app-shell .container,
.app-shell .container--wide {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--container-pad);
    padding-right: var(--container-pad);
}

.app-shell .container {
    max-width: var(--container-max);
}

.app-shell .container--wide {
    max-width: var(--container-max-wide);
}

/* Keep sticky nav aligned with the app gutter */
.app-shell .topnav {
    margin-left: var(--container-pad);
    margin-right: var(--container-pad);
}

/*
  Form field standardization (app-only):
  Make labels stack above fields by default.
  (Print/ticket/label pages are unaffected because they don't use .app-shell.)
*/
.app-shell label {
    display: block;
    width: auto;
    margin: 0 0 6px 0;
    font-weight: 600;
    color: var(--text-primary);
}

/* Inline label + help link (e.g., "City (?)") */
.app-shell .label-with-help {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0 8px;
}

.app-shell .label-with-help label {
    display: inline-flex;
    margin: 0;
    width: auto;
}

.app-shell .label-with-help a {
    display: inline-flex;
    font-weight: 600;
    text-decoration: none;
}

.app-shell .label-with-help a:hover {
    text-decoration: underline;
}

/* If a label wraps a control, push the control below the label text */
.app-shell label > input,
.app-shell label > select,
.app-shell label > textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-top: 6px;
}

/* If a label is immediately followed by a control, treat it as a field pair */
.app-shell label + input,
.app-shell label + select,
.app-shell label + textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: var(--space-4);
}

/* Reduce reliance on <br> for vertical spacing in boxed forms */
.app-shell form.boxed br {
    display: none;
}

.app-shell form.boxed fieldset {
    /* Provide consistent vertical rhythm between fields */
    padding-top: 20px;
}

/* Buttons/links inside boxed forms should keep breathing room */
.app-shell form.boxed .button,
.app-shell form.boxed button,
.app-shell form.boxed a {
    margin-top: 4px;
}

/* Exceptions: checkbox/radio should keep inline label patterns */
.app-shell input[type=checkbox],
.app-shell input[type=radio] {
    width: auto;
    display: inline-block;
}

.app-shell input[type=checkbox] + label,
.app-shell input[type=radio] + label {
    display: inline;
    margin: 0 0 0 8px;
    font-weight: 500;
}

.app-shell .checkbox-group label,
.app-shell .checkbox-field label,
.app-shell .radio-group label,
.app-shell .radio label {
    display: inline;
    margin: 0;
    font-weight: 500;
}

.app-shell .stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.app-shell .cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

/* Utility: keep clustered items on one line when desired (used for GNAP options in check-in) */
.app-shell .cluster.cluster--nowrap {
    flex-wrap: nowrap;
}

.app-shell .grid {
    display: grid;
    gap: var(--space-4);
}

.app-shell .grid--auto {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.app-shell .card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}

.app-header {
    display: block;
}

.app-header__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding-top: var(--space-4);
    padding-bottom: var(--space-3);
}

.app-header__logoLink {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.app-header__controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.app-welcome {
    color: var(--text-secondary);
    font-weight: 500;
    padding: var(--space-2) var(--space-3);
}

.app-welcome__name {
    color: var(--primary-color);
}

.app-main {
    padding-top: var(--space-4);
    padding-bottom: var(--space-6);
}

/* Modern heading styles */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
}

h1 {
    font-size: 2.5em;
    color: var(--primary-color);
}

h2 {
    font-size: 2em;
    color: var(--primary-color);
}

h3 {
    font-size: 1.6em;
}

h4 {
    font-size: 1.3em;
}

h5 {
    font-size: 1.1em;
}

h6 {
    font-size: 1em;
    font-weight: 600;
}

/* Caption styling for tables */
caption {
    font-size: 1.3em;
    font-weight: 700;
    padding: 12px;
    color: var(--text-primary);
    text-align: left;
}

footer {
    text-align: center;
    font-size: 2.25vw;
    font-style: italic;
    color: var(--text-secondary);
    padding: 30px 0;
    margin-top: 40px;
    border-top: 2px solid var(--border-color);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all var(--transition-fast);
}

footer a:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

footer hr {
    display: none;
}

.printview {
    display: none;
}

/* Page container with better spacing */
body>div {
    animation: fadeIn 0.4s ease;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Form improvements */
form.boxed {
    margin: 20px auto;
}

form.boxed br {
    display: block;
    margin: 8px 0;
}

/* Better link styling */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: all var(--transition-fast);
}

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

/* Improved list styling */
ul {
    margin-top: 0;
    padding-left: 24px;
}

li {
    padding: 8px 0;
    line-height: 1;
}

.instructions li {
    padding: 4px 0;
}

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

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

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

/* Landscape tablet and desktop tweaks */
@media only screen and (min-width: 1200px) {

    body {
        font-size: 1.1rem;
        padding: 0 20px;
    }

    .mobile {
        display: none;
    }

    .desk {
        display: inline;
    }

    .deskblock {
        display: block;
    }

    .button {
        padding: 12px 28px;
        font-size: 1rem;
    }

    .logo {
        height: 7vw;
        width: 14vw;
    }

    .boxed label {
        width: 15vw;
    }

    input[type=checkbox] {
        transform: scale(1.5);
    }

    .inputsmall {
        width: 5vw;
    }

    .inputmedium {
        width: 20vw;
    }

    #hchildren:after {
        content: "Children";
    }

    #hadults:after {
        content: "Adults";
    }

    #hseniors:after {
        content: "Seniors";
    }

    .pickedupby {
        font-size: 0.95vw;
    }

    footer {
        font-size: 0.95rem;
    }

    .summaryfor {
        margin-top: 2vw;
        margin-bottom: 2vw;
    }

    /* Enhanced hover effects for desktop */
    .button,
    .buttonsmall {
        cursor: pointer;
    }

    a {
        transition: all var(--transition-fast);
    }

    a:hover {
        opacity: 0.85;
    }

}

@media print {
    .topnav {
        display: none;
    }

    footer {
        display: none;
    }

    .table-container td,
    .history td {
        padding-bottom: 0;
    }

    .table-container table,
    .history {
        border-spacing: 0;
    }

    .logo {
        display: none;
    }

    .printview {
        display: inline;
    }

    select {
        display: none;
    }

    #dailysummary {
        padding-left: 0;
    }

    .summaryfor {
        display: inline-block;
        font-size: larger;
    }

    .pickedupby {
        display: inline;
    }
}

.form-info-inline-card {    
    display: inline-flex;
    flex-direction: row;
    gap: 57px;
}

/* Optional modifier: allow the inline info card to wrap (useful for summaries with many columns). */
.form-info-inline-card.form-info-inline-card--wrap {
    flex-wrap: wrap;
    gap: 14px 26px;
}

/* Form Grid Layout for Guest Information - Desktop only */
.form-info-card {
    border: 1px solid var(--border-color, #e0e0e0);
    background: var(--surface, #f9f9f9);
    border-radius: var(--radius-md, 10px);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.06));
    width: 93%;
}

.form-info-card .info-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}

.form-info-card .info-label {
    font-weight: 600;
    color: var(--text-secondary, #5f6368);
    letter-spacing: 0.01em;
}

.form-info-card .info-value {
    font-weight: 700;
    color: var(--text-primary, #1f1f1f);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px 24px;
    align-items: start;
    width: 100%;
    max-width: 1000px;
}

/* ------------------------------------------------------------
   Client page: Check-In call-to-action (ticket preview button)
   ------------------------------------------------------------ */

/* Let this specific grid use more horizontal room on desktop */
.form-grid.form-grid--checkin {
    max-width: 1400px;
}

/* Keep special blocks from stealing the right column */
.form-grid.form-grid--checkin > .error,
.form-grid.form-grid--checkin > #paperworkprompt {
    grid-column: 1 / -1;
}

/* The check-in row is one logical unit: controls on the left, preview CTA on the right */
.lh-checkin-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(520px, 1fr);
    gap: 18px;
    align-items: stretch;
}

.lh-checkin-left {
    grid-column: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lh-checkin-right {
    grid-column: 2;
    min-width: 0;
}

.lh-checkin-ticketRow {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ------------------------------------------------------------
   Inline validation labels (theme-aware)
   ------------------------------------------------------------ */

.lh-validation-label--error {
    /* Must override the global `label { color: ... !important; }` rule */
    color: var(--danger-color) !important;
    font-weight: 700;
}

/* Keep the ticket row compact even though generic .form-grid input rules want width:95% */
.form-grid.form-grid--checkin .lh-checkin-ticketRow input#ticket {
    width: 8.5ch;
    min-width: 8.5ch;
    max-width: 8.5ch;
    flex: 0 0 auto;
    margin-bottom: 0;
    text-align: center;
    padding-left: 10px;
    padding-right: 10px;
}

.lh-checkin-ticketRow .button {
    width: auto;
    margin-top: 0;
    white-space: nowrap;
}

/* Match textarea sizing to other form-grid controls */
.form-grid .form-field textarea {
    width: 95%;
    max-width: 650px;
    box-sizing: border-box;
}

.lh-checkin-fieldsSection {
    min-width: 0;
}

.lh-checkin-ctaSection {
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    min-width: 0;
}

.lh-checkin-btn {
    width: 100%;
    max-width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    box-shadow: none;
    transform: none;
    height: auto;
    max-height: 520px;
}

.lh-checkin-btnFrame {
    width: 100%;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Padding around the ticket so it clearly sits inside a clickable button */
.lh-checkin-btnFrame > .lh-ticket-previewTicket {
    margin: 16px;
    width: auto;
    height: auto;
    flex: 1 1 auto;
}

.lh-checkin-btnLip {
    flex: 0 0 auto;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-align: center;
    padding: 14px 14px 22px 14px;
    font-size: clamp(24px, 2.2vw, 32px);
}

.lh-checkin-btn:hover {
    box-shadow: none;
    transform: none;
}

.lh-checkin-btn:active {
    box-shadow: none;
    transform: none;
}

.lh-checkin-btn:hover .lh-checkin-btnFrame {
    box-shadow: 0 24px 58px rgba(0, 0, 0, 0.30);
}

.lh-checkin-btn:active .lh-checkin-btnFrame {
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
}

/* Ticket-faithful preview (intentionally theme-agnostic) */
.lh-ticket-previewTicket {
    width: 100%;
    height: 100%;
    min-height: 340px;
    border-radius: 12px;
    background: #ffffff;
    color: #000000;
    padding: 16px;
    box-sizing: border-box;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
    border: 2px solid rgba(0, 0, 0, 0.55);
    font-family: "Arial Narrow", Arial, sans-serif;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

/* Ticket watermark (preview only) */
.lh-ticket-previewTicket::before {
    content: attr(data-watermark);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 900;
    letter-spacing: 0.18em;
    font-size: clamp(42px, 6vw, 96px);
    color: rgba(0, 0, 0, 0.10);
    transform: rotate(-18deg);
    pointer-events: none;
    user-select: none;
}

.lh-ticket-previewTicket > * {
    position: relative;
    z-index: 1;
}

.lh-ticket-previewTicket__table {
    width: 100%;
    border-collapse: collapse;
}

.lh-ticket-previewTicket__table td {
    vertical-align: top;
    padding: 0;
}

.lh-ticket-previewTicket__ticketnumber {
    width: 28%;
    border: 4px solid #000;
    text-align: center;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.02em;
    padding: 10px 8px;
    font-size: clamp(56px, 5.2vw, 96px);
}

.lh-ticket-previewTicket__nameCell {
    padding-left: 14px !important;
}

.lh-ticket-previewTicket__name {
    font-size: clamp(26px, 2.4vw, 54px);
    font-weight: 900;
    line-height: 1.05;
    word-break: break-word;
}

.lh-ticket-previewTicket__pickedupby {
    font-style: italic;
    font-weight: 700;
    margin-top: 6px;
    font-size: clamp(12px, 1.1vw, 18px);
}

.lh-ticket-previewTicket__program {
    border: 3px dashed #000;
    padding: 8px;
    font-weight: 900;
    text-align: center;
    font-size: clamp(22px, 2vw, 44px);
    line-height: 1.2;
}

.lh-ticket-previewTicket__kids {
    padding-left: 14px !important;
    font-size: clamp(16px, 1.5vw, 28px);
    font-weight: 800;
    line-height: 1.4;
}

.lh-ticket-previewTicket__count {
    font-weight: 900;
    font-size: clamp(22px, 2vw, 40px);
    line-height: 1.1;
}

.lh-ticket-previewTicket__message {
    padding-top: 10px !important;
    font-style: italic;
    font-weight: 700;
    font-size: clamp(16px, 1.45vw, 26px);
    line-height: 1.35;
    min-height: 2.2em;
}

.lh-ticket-previewTicket__disclaimer {
    border: 2px solid #000;
    padding: 10px !important;
    font-size: clamp(11px, 0.95vw, 16px);
    line-height: 1.2;
    font-weight: 700;
}


@media only screen and (max-width: 980px) {
    .lh-checkin-row {
        grid-template-columns: 1fr;
    }

    .lh-checkin-right {
        grid-column: 1;
    }

    .lh-checkin-btn {
        width: 100%;
        max-width: 720px;
        margin-left: auto;
        margin-right: auto;
    }

    .lh-ticket-previewTicket {
        min-height: 320px;
        max-width: 560px;
        margin-left: auto;
        margin-right: auto;
    }

    .lh-checkin-btnFrame {
        min-height: 480px;
    }

    .lh-checkin-btnFrame > .lh-ticket-previewTicket {
        margin: 14px;
    }
}

.householdfield {
    max-width: 200px;
}

.edit-cell {
    display: flex !important;
    flex-direction: column !important;
}

.edit-cell label {
    margin-left: 4px;
    width: auto !important;
}

.deletememberbtn {
    margin: 0;
}

@media (prefers-color-scheme: dark) {
    .form-info-card {
        background: var(--background, #181818);
        border-color: var(--border-color, #2e2e2e);
        box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.4));
    }
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 24px;
    }

    .form-info-card {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }

    .form-grid .form-section {
        display: contents;
    }

    .form-grid .form-section-title {
        grid-column: 1 / -1;
        font-weight: bold;
        font-size: 1.3em;
        margin: 16px 0 8px 0;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
        color: var(--text-primary);
    }

    .form-grid .form-section-title:first-child {
        border-top: none;
        padding-top: 0;
    }


    .form-grid .form-field {
        display: flex;
        flex-direction: column;
    }

    .form-grid .form-field-inline {
        flex-direction: row;
        align-items: stretch;
        gap: 16px;
    }

    .form-grid .form-field-inline .inline-input {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
    }

    .form-grid .form-field-inline .inline-input input,
    .form-grid .form-field-inline .inline-input select {
        width: 100%;
        max-width: 400px;
        box-sizing: border-box;
    }

    .half-width {
        width: 45%;
    }

    .half-width-step {
        width: 45%;
        margin-right: 4%;
    }

    .form-grid .form-field label {
        max-width: 650px;
        text-align: left;
        font-weight: 500;
    }

    .form-grid .form-field input,
    .form-grid .form-field select {
        width: 95%;
        max-width: 650px;
        box-sizing: border-box;
    }

    /* Keep inline datetime picker elements from stretching full width */
    .form-grid .datetime-control select,
    .form-grid .datetime-control .dtc-calendar-btn {
        width: auto;
        max-width: none;
        flex: 0 0 auto;
    }

    /* Checkbox group - multiple checkboxes inline */
    .checkbox-group {
        flex-direction: row;
        flex-wrap: wrap;
        display: flex;
        width: auto;
        height: auto;
        align-items: center;
        gap: 16px;
    }

    .checkbox-group .checkbox-field {
        display: inline-flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        width: auto;
        height: auto;
        gap: var(--space-2);
    }

    .checkbox-group .checkbox-field input {
        width: auto;
        margin: 0;
    }

    .checkbox-field label {
        width: auto;
        margin: 0;
        color: var(--text-secondary) !important;
    }

    /* If .checkbox-field input is checked label font color will be bold and white */
    .checkbox-field input:checked+label {
        color: var(--text-primary) !important;
        font-weight: 600;
    }

}

/* GNAP Options: animate collapse/expand instead of display:none */
.gnap-options {
    overflow: hidden;
    transform-origin: top;
    opacity: 1;
    transform: translateY(0);
    max-height: 260px; /* enough for label + 3 checkboxes */
}

/* Only animate after JS marks it ready to prevent initial page-load jank */
.gnap-options.is-anim-ready {
    transition:
        max-height var(--transition-slow),
        opacity var(--transition-base),
        transform var(--transition-base);
    will-change: max-height, opacity, transform;
}

.gnap-options.is-hidden {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0 !important;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .gnap-options.is-anim-ready {
        transition: none !important;
    }
}

/* Collapsible address fields (Homeless toggle) */
.address-fields-collapsible {
    overflow: hidden;
    transform-origin: top;
    opacity: 1;
    transform: translateY(0);
    max-height: none;
    width: 100%;
}

/* Only animate after JS marks it ready to prevent initial page-load jank */
.address-fields-collapsible.is-anim-ready {
    transition:
        max-height var(--transition-slow),
        opacity var(--transition-base),
        transform var(--transition-base);
    will-change: max-height, opacity, transform;
}

.address-fields-collapsible.is-collapsed {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0 !important;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .address-fields-collapsible.is-anim-ready {
        transition: none !important;
    }
}

.radio-group {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.radio-group .radio {
    display: flex;
    flex-direction: row;
    gap: 4px;
    height: auto;
}

.radio-group .radio input {
    width: auto;
    margin-top: 6px;
}

.radio-group .radio label {
    width: auto;
    height: auto;
}

/* Shared pager bar (reusable include: include/pagerbar.php) */
.lh-pagerbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin: 6px 0 12px 0;
}

.lh-pagerbar--compact {
    justify-content: flex-start;
}

.lh-pagerbar--nomargin {
    margin: 0;
}

.lh-pagerbar__status {
    margin-right: auto;
}

.lh-pager {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}

.lh-pager select {
    padding: 8px 10px;
    width: 80px !important;
    margin: 0 !important;
}

.lh-pager .muted {
    white-space: nowrap;
    margin: 0 !important;
}

/* jQuery UI dialogs (e.g., confirm/delete popups) */
.ui-dialog {
    box-sizing: border-box;
    max-width: calc(100vw - (2 * var(--container-pad, 20px))) !important;
}

@media only screen and (max-width: 768px) {
    .ui-dialog {
        width: calc(100vw - (2 * var(--container-pad, 20px))) !important;
        left: var(--container-pad, 20px) !important;
        right: var(--container-pad, 20px) !important;
    }
}