/*
 * Roster — base theme (light)
 * ------------------------------------------------------------------
 * Design tokens (--color-*, --radius-*, etc.) drive all surfaces.
 * Forms: use .form-stack > .field > .field__label + .input (or textarea.input).
 * Buttons: .btn .btn-primary | .btn-secondary | .btn-danger; .btn-block for full width.
 * Responsive: fluid widths (min/max), safe-area aware overlays, touch-friendly targets.
 *
 * Interaction states (buttons, inputs, links, selectable rows):
 *   Default | :hover | :active | :focus-visible | :disabled / [aria-disabled]
 *   .is-loading / [aria-busy="true"]  |  .is-selected / [aria-selected="true"] / [data-selected]
 *   .is-error / .input--error / [aria-invalid="true"]
 *   Links: :visited in .content; topbar links use --color-nav-link-visited
 */

:root {
    --color-bg-page: #f5f7fa;
    --color-text: #222;
    --color-text-muted: #5c6570;
    --color-surface: #ffffff;
    --color-surface-2: #f3f3f3;
    --color-border: #ccc;
    --color-border-subtle: #ddd;
    --color-accent: #0d2b45;
    --color-accent-hover: #183b4d;
    --color-danger: #e53935;
    --color-danger-hover: #c62828;
    --color-link: #0066cc;
    --color-input-bg: #ffffff;
    --color-input-border: #ccc;
    --color-input-focus-ring: rgba(13, 43, 69, 0.28);
    --color-editable-bg: #fffdf0;
    --color-editable-border: #d6c76f;
    --color-error-border: #e04b4b;
    --color-error-bg: #ffecec;
    --color-success-border: #3ddc97;
    --color-success-ring: rgba(61, 220, 151, 0.2);
    --color-registered-dark: #276749;
    --color-overlay: rgba(0, 0, 0, 0.55);
    --color-user-panel-bg: #f0f4f8;
    --color-user-panel-border: #c5d0dc;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;

    --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.3);
    --shadow-dialog: 0 20px 50px rgba(0, 0, 0, 0.35);

    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-field-gap: 1rem;
    --space-input-y: 0.5rem;
    --space-input-x: 0.75rem;

    --font-label: 0.875rem;
    --font-ui: 1rem;
    --touch-min: 44px;

    --content-max: 1100px;
    --modal-max: 400px;
    --dialog-pad-x: clamp(12px, 4vw, 20px);

    /* Interaction timing & motion */
    --duration-fast: 0.15s;
    --duration-normal: 0.22s;
    --ease-ui: cubic-bezier(0.4, 0, 0.2, 1);

    /* Pressed / darker surfaces */
    --color-accent-active: #0a1f2e;
    --color-danger-active: #b71c1c;
    --color-secondary-active: #dedede;

    /* Links (main content) */
    --color-link-hover: #0052a3;
    --color-link-active: #003d7a;
    --color-link-visited: #551a8b;

    /* Topbar / nav on dark strip — visited still readable */
    --color-nav-link-visited: rgba(255, 255, 255, 0.88);

    --opacity-disabled: 0.5;

    /* Inputs */
    --color-input-bg-hover: #fafbfc;
    --color-input-border-hover: #9aa3ad;

    /* Loading spinners on buttons */
    --color-spinner-track: rgba(255, 255, 255, 0.35);
    --color-spinner-edge: #ffffff;
    --color-spinner-track-muted: rgba(0, 0, 0, 0.12);
    --color-spinner-edge-dark: var(--color-accent);

    /* Selected row / item */
    --color-selected-bg: rgba(13, 43, 69, 0.18);
    --color-selected-border: rgba(13, 43, 69, 0.45);

    /* Tab buttons — distinct teal, separate from primary navy */
    --color-tab:        #2a6a7c;
    --color-tab-hover:  #1f5566;
    --color-tab-active: #184452;
    --color-tab-subtle: #e8f4f6;
}

html, body {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--color-bg-page);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
}

/* ---------- Form layout primitives ---------- */

.form-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-field-gap);
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 0;
}

.field__label {
    font-size: var(--font-label);
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.35;
}

.field__label > span[data-i18n] {
    display: inline-block;
}

.field__hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin: 0;
}

/* Unified text-like controls */
.input,
input.input,
textarea.input,
select.input {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: var(--space-input-y) var(--space-input-x);
    font-size: var(--font-ui);
    line-height: 1.4;
    color: var(--color-text);
    background: var(--color-input-bg);
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    transition:
        border-color var(--duration-fast) var(--ease-ui),
        box-shadow var(--duration-fast) var(--ease-ui),
        background var(--duration-fast) var(--ease-ui),
        opacity var(--duration-fast) var(--ease-ui);
}

textarea.input {
    min-height: 5rem;
    resize: vertical;
}

input.input[type="checkbox"],
input.input[type="radio"] {
    width: auto;
    max-width: none;
    min-height: 1.15rem;
    min-width: 1.15rem;
    padding: 0;
    vertical-align: middle;
    cursor: pointer;
    transition: box-shadow var(--duration-fast) var(--ease-ui), transform var(--duration-fast) var(--ease-ui);
}

input.input[type="checkbox"]:hover:not(:disabled),
input.input[type="radio"]:hover:not(:disabled) {
    box-shadow: 0 0 0 2px var(--color-input-focus-ring);
}

input.input[type="checkbox"]:active:not(:disabled),
input.input[type="radio"]:active:not(:disabled) {
    transform: scale(0.96);
}

input.input[type="checkbox"]:focus-visible,
input.input[type="radio"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-input-focus-ring);
}

input.input[type="checkbox"]:disabled,
input.input[type="radio"]:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
}

.input:not([type="checkbox"]):not([type="radio"]):hover:not(:disabled):not([aria-disabled="true"]):not([aria-busy="true"]):not(.is-loading) {
    border-color: var(--color-input-border-hover);
    background: var(--color-input-bg-hover);
}

.input:active:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--color-accent);
}

.input:focus {
    outline: none;
}

.input:focus-visible {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-input-focus-ring);
}

.input:disabled,
.input[aria-disabled="true"] {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    background: var(--color-surface-2);
}

.input[readonly]:not(.editable):not(:disabled) {
    opacity: 0.9;
    cursor: default;
    background: var(--color-surface-2);
}

.input[aria-busy="true"],
.input.is-loading {
    pointer-events: none;
    cursor: wait;
    background: linear-gradient(
        100deg,
        var(--color-input-bg) 40%,
        var(--color-surface-2) 50%,
        var(--color-input-bg) 60%
    );
    background-size: 200% 100%;
    animation: ui-shimmer 1.1s var(--ease-ui) infinite;
}

.input--error,
.input.is-error,
.input[aria-invalid="true"] {
    border: 2px solid var(--color-error-border);
    background: var(--color-error-bg);
}

.input--error:focus-visible,
.input.is-error:focus-visible,
.input[aria-invalid="true"]:focus-visible {
    box-shadow: 0 0 0 3px rgba(224, 75, 75, 0.35);
}

.field--error .field__label {
    color: var(--color-error-border);
}

.field--row {
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm);
}

.field--row .field__label {
    margin: 0;
    font-weight: 400;
}

.field--check {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--space-sm);
}

.field--check .input[type="checkbox"],
.field--check .input[type="radio"] {
    width: auto;
    margin-top: 0.2rem;
    flex-shrink: 0;
    min-height: 1.15rem;
    min-width: 1.15rem;
}

/* ---------- Buttons ---------- */

.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-warning {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    position: relative;
    min-height: var(--touch-min);
    padding: 0.55rem 1rem;
    font-size: var(--font-ui);
    font-family: inherit;
    font-weight: 500;
    line-height: 1.2;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition:
        background var(--duration-fast) var(--ease-ui),
        border-color var(--duration-fast) var(--ease-ui),
        color var(--duration-fast) var(--ease-ui),
        box-shadow var(--duration-fast) var(--ease-ui),
        transform var(--duration-fast) var(--ease-ui),
        opacity var(--duration-fast) var(--ease-ui);
}

.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-warning:disabled,
.btn[aria-disabled="true"],
.btn-primary[aria-disabled="true"],
.btn-secondary[aria-disabled="true"],
.btn-danger[aria-disabled="true"],
.btn-warning[aria-disabled="true"] {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    pointer-events: none;
}

.btn:focus {
    outline: none;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.btn-warning:focus-visible {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
}

.btn-danger:focus-visible {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-danger);
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.btn-primary:hover:not(:disabled):not([aria-disabled="true"]):not(.is-loading):not([aria-busy="true"]) {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

.btn-primary:active:not(:disabled):not([aria-disabled="true"]):not(.is-loading):not([aria-busy="true"]) {
    background: var(--color-accent-active);
    border-color: var(--color-accent-active);
    transform: translateY(1px);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled):not([aria-disabled="true"]):not(.is-loading):not([aria-busy="true"]) {
    background: var(--color-surface-2);
}

.btn-secondary:active:not(:disabled):not([aria-disabled="true"]):not(.is-loading):not([aria-busy="true"]) {
    background: var(--color-secondary-active);
    transform: translateY(1px);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}

.btn-danger:hover:not(:disabled):not([aria-disabled="true"]):not(.is-loading):not([aria-busy="true"]) {
    background: var(--color-danger-hover);
    border-color: var(--color-danger-hover);
}

.btn-danger:active:not(:disabled):not([aria-disabled="true"]):not(.is-loading):not([aria-busy="true"]) {
    background: var(--color-danger-active);
    border-color: var(--color-danger-active);
    transform: translateY(1px);
}

.btn-warning {
    background: #d4a017;
    color: #1a1a1a;
    border-color: #d4a017;
}

.btn-warning:hover:not(:disabled):not([aria-disabled="true"]):not(.is-loading):not([aria-busy="true"]) {
    background: #b8880f;
    border-color: #b8880f;
}

.btn-warning:active:not(:disabled):not([aria-disabled="true"]):not(.is-loading):not([aria-busy="true"]) {
    background: #9e740c;
    border-color: #9e740c;
    transform: translateY(1px);
}

/* Loading: add class .is-loading or aria-busy="true" on the button */
.btn.is-loading,
.btn-primary.is-loading,
.btn-secondary.is-loading,
.btn-danger.is-loading,
.btn[aria-busy="true"],
.btn-primary[aria-busy="true"],
.btn-secondary[aria-busy="true"],
.btn-danger[aria-busy="true"] {
    pointer-events: none;
    cursor: wait;
    color: transparent !important;
}

.btn-primary.is-loading::after,
.btn-primary[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 1.15em;
    height: 1.15em;
    border: 2px solid var(--color-spinner-track);
    border-top-color: var(--color-spinner-edge);
    border-radius: 50%;
    animation: ui-spin 0.65s linear infinite;
}

.btn-secondary.is-loading::after,
.btn-secondary[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 1.15em;
    height: 1.15em;
    border: 2px solid var(--color-spinner-track-muted);
    border-top-color: var(--color-spinner-edge-dark);
    border-radius: 50%;
    animation: ui-spin 0.65s linear infinite;
}

.btn-danger.is-loading::after,
.btn-danger[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 1.15em;
    height: 1.15em;
    border: 2px solid var(--color-spinner-track);
    border-top-color: var(--color-spinner-edge);
    border-radius: 50%;
    animation: ui-spin 0.65s linear infinite;
}

.btn-block {
    width: 100%;
}

/* ---------- Top bar ---------- */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--dialog-pad-x);
    z-index: 1000;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* notify.js anchors its "top right" corner at top:0, which sits under the
   fixed topbar (56px tall). Push it down just below the topbar instead. */
.notifyjs-corner {
    top: 66px !important;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo img {
    height: 32px;
    width: 32px;
}

.site-name {
    font-weight: 600;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: var(--space-md);
}

.nav-links a {
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease-ui), background var(--duration-fast) var(--ease-ui), opacity var(--duration-fast) var(--ease-ui);
}

.nav-links a:visited {
    color: var(--color-nav-link-visited);
}

.nav-links a:hover {
    text-decoration: underline;
    color: #fff;
}

.nav-links a:active {
    opacity: 0.85;
}

.nav-links a:focus {
    outline: none;
}

.nav-links a:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.nav-links a[aria-current="page"],
.nav-links a.is-selected {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.version {
    font-size: 0.85rem;
    opacity: 0.8;
}

.profile-link {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.35rem;
    margin: -0.2rem -0.35rem;
    transition: opacity var(--duration-fast) var(--ease-ui), text-decoration var(--duration-fast) var(--ease-ui);
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.18);
    border: 1.5px solid rgba(255, 255, 255, 0.38);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    flex-shrink: 0;
    transition:
        background var(--duration-fast) var(--ease-ui),
        border-color var(--duration-fast) var(--ease-ui),
        transform var(--duration-fast) var(--ease-ui);
}

.user-avatar:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.6);
}

.user-avatar:active {
    transform: scale(0.94);
    background: rgba(255, 255, 255, 0.12);
}

.user-avatar:focus {
    outline: none;
}

.user-avatar:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.profile-link:visited {
    color: var(--color-nav-link-visited);
}

.profile-link:hover {
    text-decoration: underline;
}

.profile-link:active {
    opacity: 0.85;
}

.profile-link:focus {
    outline: none;
}

.profile-link:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

/* Login / Logout links are styled as solid white buttons so they stand
   out against the topbar instead of blending in as plain text. */
#openLogin,
#logout {
    background: #fff;
    color: #000;
    padding: 0.35rem 0.9rem;
    margin: 0;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

#openLogin:visited,
#logout:visited {
    color: #000;
}

#openLogin:hover,
#logout:hover {
    background: #e5e5e5;
    text-decoration: none;
}

#openLogin:active,
#logout:active {
    background: #d4d4d4;
    opacity: 1;
}

#openLogin:focus-visible,
#logout:focus-visible {
    box-shadow: 0 0 0 2px var(--color-accent), 0 0 0 4px #fff;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease-ui), opacity var(--duration-fast) var(--ease-ui), transform var(--duration-fast) var(--ease-ui);
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.menu-toggle:active {
    transform: scale(0.96);
    opacity: 0.9;
}

.menu-toggle:focus {
    outline: none;
}

.menu-toggle:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.menu-toggle:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .nav-links {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--color-accent);
        flex-direction: column;
        gap: 0;
        display: none;
    }

    .nav-links a {
        padding: 12px var(--dialog-pad-x);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        min-height: var(--touch-min);
        display: flex;
        align-items: center;
    }

    .menu-toggle:focus + .logo + .nav-links,
    .nav-links.nav-links--open {
        display: flex;
    }

    .site-name {
        display: none;
    }
}

/* ---------- Page content ---------- */

.banner {
    width: 100%;
    height: 40vh;
    min-height: 220px;
    max-height: 420px;
    background-image: url('../images/banner.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .banner {
        height: 30vh;
        min-height: 180px;
    }
}

@media (min-width: 1200px) {
    .banner {
        height: 45vh;
    }
}

.content {
    flex: 1;
    position: relative;
    min-height: 0;
    margin-top: 56px;
    width: 100%;
    max-width: 100%;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Main copy links — visited / hover / active / focus */
.content a:not(.btn):not(.btn-primary):not(.btn-secondary):not(.btn-danger) {
    color: var(--color-link);
    text-decoration-skip-ink: auto;
    transition: color var(--duration-fast) var(--ease-ui), opacity var(--duration-fast) var(--ease-ui);
}

.content a:not(.btn):visited {
    color: var(--color-link-visited);
}

.content a:not(.btn):hover {
    color: var(--color-link-hover);
    text-decoration: underline;
}

.content a:not(.btn):active {
    color: var(--color-link-active);
}

.content a:not(.btn):focus {
    outline: none;
}

.content a:not(.btn):focus-visible {
    border-radius: 2px;
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-link);
}

/* ---------- Modals (login / forgot) ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    padding: var(--dialog-pad-x);
    padding-bottom: max(var(--dialog-pad-x), env(safe-area-inset-bottom));
    background: var(--color-overlay);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    box-sizing: border-box;
}

.modal {
    background: var(--color-surface);
    color: var(--color-text);
    width: 100%;
    max-width: min(var(--modal-max), 100%);
    padding: var(--space-lg) clamp(1rem, 4vw, 1.75rem);
    border-radius: var(--radius-md);
    position: relative;
    box-shadow: var(--shadow-modal);
}

.modal h2 {
    margin-top: 0;
    margin-bottom: var(--space-md);
    font-size: clamp(1.15rem, 2.5vw, 1.35rem);
}

.modal-close {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    border: none;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease-ui), background var(--duration-fast) var(--ease-ui), transform var(--duration-fast) var(--ease-ui), opacity var(--duration-fast) var(--ease-ui);
}

.modal-close:hover {
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.06);
}

.modal-close:active {
    transform: scale(0.94);
    background: rgba(0, 0, 0, 0.1);
}

.modal-close:focus {
    outline: none;
}

.modal-close:focus-visible {
    color: var(--color-text);
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
}

.modal-close:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    pointer-events: none;
}

#loginModal {
    z-index: 1000;
}

#forgotModal {
    z-index: 1100;
}

.dimmed {
    filter: blur(1px) brightness(0.8);
}

.login-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    margin-bottom: var(--space-sm);
}

.forgot-link {
    text-decoration: none;
    color: var(--color-link);
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.25rem;
    margin: -0.15rem -0.25rem;
    transition: color var(--duration-fast) var(--ease-ui), text-decoration var(--duration-fast) var(--ease-ui);
}

.forgot-link:visited {
    color: var(--color-link-visited);
}

.forgot-link:hover {
    text-decoration: underline;
    color: var(--color-link-hover);
}

.forgot-link:active {
    color: var(--color-link-active);
}

.forgot-link:focus {
    outline: none;
}

.forgot-link:focus-visible {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-link);
}

/* ---------- App dialogs (user admin, grids) ---------- */

.content-dialog {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.15s ease-out;
}

.content-dialog.hidden {
    display: none;
}

/* Layered dialogs: detail sits above list, edit/dirty sit above detail */
#shiftDetailDialog    { z-index: 55; }
#shiftAddDialog       { z-index: 58; }
#shiftEditDialog      { z-index: 60; }
#shiftDirtyDialog     { z-index: 65; }
#shiftsDeleteConfirm  { z-index: 65; }
#shiftDeletePastConfirm { z-index: 65; }
/* User view dialog sits above the patrol-day dialog so clicking a name in
   the shift roster opens the user detail directly, with the day dialog
   visible behind it. */
#userViewDialog       { z-index: 70; }

.dialog-container {
    width: min(var(--content-max), calc(100vw - 2 * var(--dialog-pad-x)));
    height: min(90vh, calc(100dvh - 56px - env(safe-area-inset-bottom)));
    max-height: min(90vh, calc(100dvh - 56px - env(safe-area-inset-bottom)));
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-dialog);
    background: var(--color-surface);
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    gap: var(--space-md);
    padding: 0.75rem clamp(14px, 3vw, 20px);
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-surface-2);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.dialog-header h2,
.dialog-header h3 {
    margin: 0;
    font-size: clamp(1rem, 2.2vw, 1.2rem);
}

.dialog-body {
    background: var(--color-surface);
    color: var(--color-text);
    padding: clamp(12px, 3vw, 20px);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.dialog-footer {
    padding: clamp(12px, 2.5vw, 15px) clamp(14px, 3vw, 20px);
    border-top: 1px solid var(--color-border-subtle);
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-sm);
    flex-shrink: 0;
    background: var(--color-surface);
}

.dialog-footer .btn {
    flex: 1 1 auto;
    min-width: min(140px, 100%);
}

@media (max-width: 480px) {
    .dialog-footer {
        flex-direction: column;
    }

    .dialog-footer .btn {
        width: 100%;
    }
}

button.closeX {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 0 0.75rem;
    font-size: 1.25rem;
    line-height: 1;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--color-accent);
    color: #fff;
    border: 1px solid var(--color-accent);
    transition:
        background var(--duration-fast) var(--ease-ui),
        border-color var(--duration-fast) var(--ease-ui),
        box-shadow var(--duration-fast) var(--ease-ui),
        transform var(--duration-fast) var(--ease-ui),
        opacity var(--duration-fast) var(--ease-ui);
}

button.closeX:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

button.closeX:active {
    background: var(--color-accent-active);
    border-color: var(--color-accent-active);
    transform: scale(0.96);
}

button.closeX:focus {
    outline: none;
}

button.closeX:focus-visible {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
}

button.closeX:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    pointer-events: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#userViewDialog {
    position: fixed;
    inset: 0;
    padding: var(--dialog-pad-x);
    /* Anchored to a fixed distance from the top (matching where the dialog
       sat when it was at its full/max height) instead of vertically centering,
       so switching tabs to shorter content doesn't make the dialog jump.
       Note: .content-dialog (base class) sets flex-direction: column, so here
       the main axis is vertical (justify-content) and the cross axis is
       horizontal (align-items) — the opposite of a row container. */
    padding-top: 5vh;
    background: var(--color-overlay);
    display: none;
    justify-content: flex-start;
    align-items: center;
    z-index: 1000;
    box-sizing: border-box;
}

#userViewDialog .dialog-container {
    height: auto;
    max-height: min(90vh, calc(100dvh - 5vh - env(safe-area-inset-bottom)));
}

/* Dialogs that should only be as tall as their content needs, up to the
   usual viewport-relative cap (e.g. the password dialog). */
.dialog-container--auto {
    height: auto;
}

.user-view-header {
    align-items: flex-start;
}

.user-view-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.user-view-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
    cursor: default;
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.user-view-title-text {
    min-width: 0;
}

.user-view-title-text h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-view-role-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.25rem;
}

.user-view-role-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    padding: 0.05rem 0.5rem;
    border-radius: 9999px;
    background: rgba(49, 130, 206, 0.12);
    border: 1px solid rgba(49, 130, 206, 0.5);
    color: #1c5a96;
    white-space: nowrap;
}

/* The shell no longer scrolls as a whole — only .user-view-panels does —
   so the tab strip and footer stay put while long panel content scrolls. */
.user-view-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.user-view-tabs {
    display: flex;
    flex-wrap: wrap;
    flex-shrink: 0;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
}

.user-view-panels {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.user-view-tab__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-view-tab {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--touch-min);
    padding: 0.55rem 1rem;
    border: 1px solid var(--color-tab);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-tab);
    font-family: inherit;
    font-size: var(--font-ui);
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background var(--duration-fast) var(--ease-ui),
        border-color var(--duration-fast) var(--ease-ui),
        color var(--duration-fast) var(--ease-ui),
        box-shadow var(--duration-fast) var(--ease-ui);
}

.user-view-tab:hover:not(.is-active) {
    background: var(--color-tab-subtle);
    border-color: var(--color-tab-hover);
    color: var(--color-tab-hover);
}

.user-view-tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-tab);
}

.user-view-tab:active:not(.is-active) {
    background: var(--color-tab-subtle);
    border-color: var(--color-tab-active);
    color: var(--color-tab-active);
    transform: translateY(1px);
}

.user-view-tab.is-active {
    background: var(--color-tab);
    border-color: var(--color-tab);
    color: #fff;
}

.user-view-tab__indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--color-danger, #c53030);
    color: #fff;
    font-size: 0.72rem;
    line-height: 1;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.user-view-tab__indicator.is-visible {
    opacity: 1;
    transform: scale(1);
}

.user-view-tabpanel {
    min-height: 0;
}

.user-view-panel-card {
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    padding: 1rem;
}

.user-view-panel-card__title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.user-view-panel-card__body {
    min-height: 12rem;
}

.user-view-placeholder {
    margin: 0;
    color: var(--color-text-muted);
}

.password-changed-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 9999px;
    background: rgba(49, 130, 206, 0.12);
    border: 1px solid rgba(49, 130, 206, 0.5);
}

.password-changed-badge__label {
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.password-changed-badge__value {
    font-weight: 600;
    color: #1c5a96;
    font-size: 0.9rem;
}

/* ---------------- History tab ---------------- */

.user-history-overall {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* ---- Season stats panel (Details tab) ---- */
.user-season-stats {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-subtle);
}

.user-season-stats__header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-season-stats__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 8rem;
    text-align: center;
}

.user-season-stats__arrow {
    background: transparent;
    border: 1px solid var(--color-border-subtle);
    border-radius: 4px;
    width: 2rem;
    height: 2rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text);
}

.user-season-stats__arrow:hover:not(:disabled) {
    background: var(--color-surface-hover, rgba(0,0,0,0.05));
}

.user-season-stats__arrow:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.user-season-stats__subhead {
    margin: 0.8rem 0 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.user-season-stats__dept-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.4rem;
}

.user-season-stats__dept-item {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: 4px;
    background: var(--color-surface-1, transparent);
    font-size: 0.9rem;
}

.user-season-stats__dept-count {
    font-weight: 600;
    color: var(--color-text);
}

.user-season-stats__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.user-season-stats__table th,
.user-season-stats__table td {
    padding: 0.3rem 0.55rem;
    border-bottom: 1px solid var(--color-border-subtle);
    text-align: left;
}

.user-season-stats__table th {
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-surface-1, transparent);
}

.user-season-stats__table th.is-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.user-season-stats__table th.is-sortable:hover {
    color: var(--color-text);
}

/* Reserve the caret's width on every sortable header so the columns don't
   shift as the active sort moves between them. */
.user-season-stats__table th.is-sortable::after {
    content: "\2195";
    margin-left: 0.35rem;
    opacity: 0.35;
    font-size: 0.75em;
}

.user-season-stats__table th.is-sorted-asc::after {
    content: "\25B2";
    opacity: 1;
}

.user-season-stats__table th.is-sorted-desc::after {
    content: "\25BC";
    opacity: 1;
}

.user-season-stats__placeholder {
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    padding: 0.3rem 0;
}

.user-history-stat {
    display: flex;
    flex-direction: column;
    min-width: 7rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-surface-1, transparent);
}

.user-history-stat__label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.user-history-stat__value {
    font-size: 1.4rem;
    font-weight: 600;
}

.user-history-subhead {
    margin: 1rem 0 0.5rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.user-history-chart {
    width: 100%;
    overflow-x: auto;
}

.user-history-svg {
    width: 100%;
    height: auto;
    max-width: 640px;
    display: block;
}

.uh-bar {
    fill: var(--color-accent, #3b82f6);
}

.uh-bar:hover {
    fill: var(--color-accent-strong, #1d4ed8);
}

.uh-axis {
    stroke: var(--color-border-subtle, #888);
    stroke-width: 1;
}

.uh-grid {
    stroke: var(--color-border-subtle, #ccc);
    stroke-width: 1;
    stroke-dasharray: 2 3;
    opacity: 0.6;
}

.uh-xtick, .uh-ytick {
    fill: var(--color-text-muted);
    font-size: 10px;
    font-family: inherit;
}

.user-history-season-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.user-history-season-table th,
.user-history-season-table td {
    padding: 0.35rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
}

.user-history-season-table th {
    font-weight: 600;
    color: var(--color-text-muted);
}

/* ---------------- Messages tab ---------------- */

.messages-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.messages-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--color-border-subtle);
    margin-bottom: 0.5rem;
}

.messages-folder-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.messages-expired-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.75rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.messages-expired-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.messages-expired-toggle:hover {
    color: var(--color-text);
}

.messages-folder-tab {
    background: transparent;
    border: 0;
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    color: var(--color-text-muted);
    font: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.messages-folder-tab:hover {
    color: var(--color-text, #111);
}

.messages-folder-tab.is-active {
    color: var(--color-text, #111);
    border-bottom-color: var(--color-accent, #4c9ffe);
    font-weight: 600;
}

.messages-count {
    padding: 0.35rem 0.25rem 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.messages-list {
    position: relative;
    max-height: 22rem;
    overflow-y: auto;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-surface, #fff);
}

/* ---------- Audit table (Actions tab) ---------- */

.audit-status {
    padding: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.audit-table-wrap {
    max-height: 8rem;
    overflow-y: auto;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-surface);
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: var(--color-text);
}

.audit-table thead th {
    position: sticky;
    top: 0;
    background: var(--color-surface-2);
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border-subtle);
    text-align: left;
    padding: 0.4rem 0.6rem;
    font-weight: 600;
    z-index: 1;
    white-space: nowrap;
}

.audit-table tbody td {
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: top;
}

.audit-table tbody tr:last-child td {
    border-bottom: none;
}

.audit-table .audit-meta {
    white-space: nowrap;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.audit-changed {
    background: #fff8d6;
    font-weight: 600;
}

.audit-detail-toolbar {
    margin-bottom: 0.5rem;
}

.audit-detail-wrap {
    max-height: 14rem;
    overflow-y: auto;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-surface);
}

.audit-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: var(--color-text);
    table-layout: fixed;
}

.audit-detail-table thead th {
    position: sticky;
    top: 0;
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border-subtle);
    padding: 0.4rem 0.6rem;
    font-weight: 600;
    z-index: 1;
    vertical-align: bottom;
    word-break: break-word;
}

.audit-detail-label-col {
    width: 9rem;
}

.audit-detail-val-col {
    width: calc((100% - 9rem) / 2);
}

.audit-detail-table tbody td {
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: top;
    word-break: break-word;
}

.audit-detail-table tbody tr:last-child td {
    border-bottom: none;
}

.audit-detail-label {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

#userTabPanel-actions .user-view-panel-card__body {
    min-height: 0;
}

.audit-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.audit-filter-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    user-select: none;
}

/* Same-user dialog content */
.same-user-details {
    margin-bottom: 1rem;
}

.same-user-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.same-user-detail-table td,
.same-user-detail-table th {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--color-border-subtle);
}

.same-user-detail-table td:first-child,
.same-user-detail-table th {
    color: var(--color-text-muted);
    width: 7rem;
    font-size: 0.8rem;
    font-weight: normal;
    text-align: left;
}

.same-user-detail-table tr:last-child td,
.same-user-detail-table tr:last-child th {
    border-bottom: none;
}



.messages-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    color: var(--color-text);
}

.messages-table thead th {
    position: sticky;
    top: 0;
    background: var(--color-surface-2);
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border-subtle);
    text-align: left;
    padding: 0.45rem 0.75rem;
    font-weight: 600;
    z-index: 1;
}

.messages-table tbody td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: top;
}

.messages-table tbody tr:hover {
    background: var(--color-selected-bg, rgba(0,0,0,0.04));
    cursor: pointer;
}

.messages-table .col-from {
    width: 12rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages-table .col-date {
    width: 10rem;
    white-space: nowrap;
    color: var(--color-text-muted);
}

/* Sent folder — sender is always the viewed user, so hide the From column */
.messages-list.is-sent .col-from {
    display: none;
}

.messages-loading,
.messages-empty {
    padding: 0.75rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ---- Admin-wide Messages dialog (top-level menu) ---- */

.dialog-container--messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: min(var(--content-max), calc(100vw - 2 * var(--dialog-pad-x)));
    max-height: min(90vh, calc(100dvh - 56px - env(safe-area-inset-bottom)));
    margin: 0 auto;
    overflow: visible;
}

.messages-admin-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem clamp(14px, 3vw, 20px);
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-surface);
}

.messages-admin-toolbar .messages-expired-toggle {
    margin-left: 0;
}

.messages-list--admin {
    flex: 1;
    min-height: 0;
    max-height: none;
    margin: 0 clamp(14px, 3vw, 20px) clamp(14px, 3vw, 20px);
    border-radius: var(--radius-sm, 4px);
}

/* ---- Message detail dialog ---- */

.message-detail-container {
    max-width: 720px;
    width: 90vw;
}

.message-detail-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message-detail-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
    font-size: 0.9rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-subtle);
}

.message-detail-meta__row {
    display: contents;
}

.message-detail-meta__label {
    color: var(--color-text-muted);
    font-weight: 600;
}

.message-detail-body__content {
    min-height: 8rem;
    max-height: 50vh;
    overflow-y: auto;
    padding: 0.5rem 0.25rem;
    line-height: 1.45;
    color: var(--color-text);
    word-wrap: break-word;
}

.message-detail-body__content a {
    color: var(--color-link, #1d4ed8);
    text-decoration: underline;
}

.message-detail-body__content a:hover {
    color: var(--color-link-hover, #2563eb);
}

/* Users list (grid) — full-height panel, grid scrolls internally */
.dialog-container--users {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: min(var(--content-max), calc(100vw - 2 * var(--dialog-pad-x)));
    max-height: min(90vh, calc(100dvh - 56px - env(safe-area-inset-bottom)));
    margin: 0 auto;
    overflow: visible;
}

.users-dialog-toolbar {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem clamp(14px, 3vw, 20px);
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-surface);
}

.news-admin-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem clamp(14px, 3vw, 20px);
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-surface);
}

.news-admin-actions {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.news-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.news-add-icon {
    font-weight: 700;
    line-height: 1;
}

.news-includeexpired-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.news-includeexpired-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.news-includeexpired-toggle:hover {
    color: var(--color-text);
}

.dialog-container--news {
    min-width: min(900px, 96vw);
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.news-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md, 8px);
    padding: 0.9rem 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: box-shadow var(--duration-fast) var(--ease-ui);
}

.news-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.news-card-content {
    margin-bottom: 0.6rem;
    line-height: 1.45;
    color: var(--color-text);
}

.news-card-meta {
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.5rem;
    row-gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--color-text);
    margin-bottom: 0.75rem;
}

.news-card-meta em {
    font-style: italic;
    color: var(--color-text-muted);
}

.news-card-meta--expired {
    color: var(--color-danger);
}

.news-card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.news-card-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem 0;
}

.user-view-grid .field--full {
    grid-column: 1 / -1;
}

/* News detail dialog: extra bottom padding so the "Saved" toast
   (position:absolute; top:calc(100% + 3px)) has room without triggering a scrollbar */
#newsDetailDialog .dialog-container {
    min-width: min(720px, 96vw);
    min-height: min(560px, 90vh);
}

#newsDetailDialog .dialog-body {
    padding-bottom: clamp(32px, 6vh, 56px);
}

/* Home-page news list */
.home-news {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1.25rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 800px;
}

.home-news-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md, 8px);
    padding: 0.85rem 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: box-shadow 120ms ease, transform 120ms ease;
}

.home-news-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.home-news-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.home-news-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    letter-spacing: 0.01em;
}

.home-news-body {
    color: var(--color-text);
    line-height: 1.45;
}

.home-news-body p:first-child { margin-top: 0; }
.home-news-body p:last-child  { margin-bottom: 0; }

.home-news-empty {
    color: var(--color-text-muted);
    font-style: italic;
    margin: 0.5rem 0;
}

.news-tag {
    display: inline-block;
    padding: 0.08rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.4;
}

.news-tag--new {
    background: #e6f4ea;
    color: #1e7d32;
    border: 1px solid #9fd3ad;
}

.news-tag--updated {
    background: #e7f0ff;
    color: #1f4fb3;
    border: 1px solid #a8c4f0;
}

.users-dialog-toolbar .field {
    margin: 0;
    max-width: min(520px, 100%);
    /* Keep the filter input usable on narrow phones; when the toolbar runs out
       of room the toggle/buttons wrap to a new line instead of crushing this. */
    min-width: 200px;
    flex: 1 1 200px;
}

.users-includeretired-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.users-includeretired-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.users-includeretired-toggle:hover {
    color: var(--color-text);
}

/* Role filter: button + popover of role checkboxes */
.users-rolefilter {
    position: relative;
}
.users-rolefilter__panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 50;
    min-width: 200px;
    padding: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.users-rolefilter__actions {
    display: flex;
    gap: 0.4rem;
    padding-bottom: 0.4rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--color-border-subtle);
}
.users-rolefilter__list {
    display: flex;
    flex-direction: column;
}
.users-rolefilter__item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}
.users-rolefilter__item input[type="checkbox"] {
    margin: 0;
}

/* ---------- Shifts list — full-height panel, grid scrolls internally ---------- */
.dialog-container--shifts {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: min(var(--content-max), calc(100vw - 2 * var(--dialog-pad-x)));
    max-height: min(90vh, calc(100dvh - 56px - env(safe-area-inset-bottom)));
    margin: 0 auto;
    overflow: visible;
}

.shifts-dialog-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem clamp(14px, 3vw, 20px);
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-surface);
}

.shifts-includepast-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.shifts-includepast-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.shifts-includepast-toggle:hover {
    color: var(--color-text);
}

.shifts-grid-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0 clamp(14px, 3vw, 20px) clamp(14px, 3vw, 20px);
}

.shifts-empty,
.shifts-loading {
    text-align: center;
    padding: 2rem 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}

.btn-danger:hover {
    background: var(--color-danger-hover);
    border-color: var(--color-danger-hover);
}

.btn-danger:active {
    background: var(--color-danger-active);
    border-color: var(--color-danger-active);
}

.btn-danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---------- Shift Detail dialog ---------- */
.dialog-container--shift-detail {
    width: min(520px, calc(100vw - 2 * var(--dialog-pad-x)));
}

.shift-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.shift-detail-meta span {
    white-space: nowrap;
}

.shift-detail-actions {
    margin-bottom: 0.75rem;
}

.shift-detail-roster {
    border-top: 1px solid var(--color-border-subtle);
    padding-top: 0.75rem;
}

.shift-detail-group {
    margin-bottom: 0.6rem;
}

.shift-detail-group:last-child {
    margin-bottom: 0;
}

.shift-detail-group-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 0.15rem;
}

.shift-detail-group-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.88rem;
    color: var(--color-text);
}

.shift-detail-group-list li {
    padding: 0.1rem 0;
}

.shift-detail-loading {
    text-align: center;
    padding: 1rem 0;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ---------- Import Users dialog ---------- */

.import-dialog-container {
    width: min(620px, 100%);
}

.import-steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1.5rem;
}

.import-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    flex: 0 0 auto;
}

.import-step__num {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    background: #e2e6ea;
    color: #495057;
    border: 2px solid #9aa5b1;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.import-step__label {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    font-weight: 500;
    transition: color 0.15s;
}

.import-step--active .import-step__num {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.import-step--active .import-step__label {
    color: var(--color-accent);
}

.import-step--done .import-step__num {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
    font-size: 0;
}

.import-step--done .import-step__num::after {
    content: "✓";
    font-size: 0.85rem;
}

.import-step--done .import-step__label {
    color: var(--color-text-muted);
}

.import-step-divider {
    flex: 1;
    height: 2px;
    background: var(--color-border-subtle);
    margin: 0 0.4rem;
    margin-bottom: 1.2rem;
}

.import-dropzone {
    border: 2px dashed var(--color-border-subtle);
    border-radius: var(--radius-md);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    background: var(--color-surface-2);
    cursor: default;
    transition: border-color 0.15s, background 0.15s;
}

.import-dropzone--dragover {
    border-color: var(--color-accent);
    background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface-2));
}

.import-dropzone__icon {
    width: 2.5rem;
    height: 2.5rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.import-dropzone__hint {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.import-dropzone__filename {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    word-break: break-all;
}

.import-dropzone__filename--set {
    color: var(--color-accent);
}

.import-error {
    color: var(--color-danger, #c0392b);
    font-size: 0.875rem;
    margin: 0.5rem 0 0;
}

/* Step 2 — summary bar & match table */

.import-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm, 6px);
    margin-bottom: 0.85rem;
    font-size: 0.875rem;
}

.import-summary__total {
    font-weight: 600;
    color: var(--color-text);
}

.import-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.import-badge--new      { background: #d4edda; color: #1a5c30; }
.import-badge--resolved { background: #cce5ff; color: #004085; }

/* Same-customer match = amber */
.import-badge--same-customer  { background: #fff3cd; color: #7a5200; }
/* Other-customer match = indigo/blue */
.import-badge--other-customer { background: #e0e7ff; color: #3730a3; }

/* Match table row highlights */
.import-row--volatile { cursor: pointer; }

.import-row--same-customer { background: rgba(255, 193, 7, 0.13); }
.import-row--same-customer:hover { background: rgba(255, 193, 7, 0.24); }

.import-row--other-customer { background: rgba(99, 102, 241, 0.10); }
.import-row--other-customer:hover { background: rgba(99, 102, 241, 0.18); }

.import-row--resolved { background: rgba(40, 167, 69, 0.08); }

.import-match-table-wrap {
    overflow-y: auto;
    max-height: 340px;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm, 6px);
}

.import-match-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.import-match-table th {
    position: sticky;
    top: 0;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.45rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
    z-index: 1;
}

.import-match-table td {
    padding: 0.4rem 0.7rem;
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: middle;
}

.import-match-table tr:last-child td {
    border-bottom: none;
}

.import-match-table tr:hover td {
    background: var(--color-surface-2);
}

.import-match-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-left: 0.3rem;
}

/* Review counter */
.import-review-counter {
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.85rem;
    background: #fff3cd;
    color: #7a5200;
    margin-bottom: 0.6rem;
}

.import-review-counter--done {
    background: #d4edda;
    color: #1a5c30;
}

/* Comparison panel */
.import-compare-notice {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.import-compare-notice--same  { background: #fff3cd; color: #7a5200; }
.import-compare-notice--other { background: #e0e7ff; color: #3730a3; }

.import-compare-grid {
    overflow-y: auto;
    max-height: 340px;
}

.import-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.import-compare-table th {
    position: sticky;
    top: 0;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.4rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
    z-index: 1;
}

.import-compare-table td {
    padding: 0.35rem 0.65rem;
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: middle;
}

.import-compare-table tr:last-child td { border-bottom: none; }

.import-compare-field {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    width: 6rem;
}

/* Highlight rows where values differ */
.import-compare-diff { background: #fff8e1; }
.import-compare-diff .import-compare-field { color: #7a5200; font-weight: 600; }

/* Step 3 — Review & Import */
.import-review-summary {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.import-review-stat {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
}

.import-review-stat--new    { background: #d4edda; color: #155724; }
.import-review-stat--update { background: #fff3cd; color: #7a5200; }
.import-review-stat--link   { background: #e0e7ff; color: #3730a3; }
.import-review-stat--skip   { background: var(--color-surface-2); color: var(--color-text-muted); }

.import-review-list {
    max-height: 380px;
    overflow-y: auto;
}

.import-review-heading {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin: 1rem 0 0.4rem;
}

.import-review-heading:first-child { margin-top: 0; }

.import-review-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.import-review-table th {
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.4rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
}

.import-review-table td {
    padding: 0.35rem 0.65rem;
    border-bottom: 1px solid var(--color-border-subtle);
}

.import-review-table tr:last-child td { border-bottom: none; }

textarea.input[readonly] {
    background: var(--color-surface-2);
    color: var(--color-text-muted);
}

/* User detail grid */
.user-view-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 18px;
    align-content: start;
}

@media (max-width: 768px) {
    .user-view-grid {
        grid-template-columns: 1fr;
    }
}

.user-view-grid .field {
    margin: 0;
}

.user-view-grid textarea.scroll-box {
    overflow-y: auto;
    resize: vertical;
}

/* Empty-field placeholders: show data-label in italics when span has no value */
.user-view-grid span[data-label]:empty::after {
    content: attr(data-label);
    font-style: italic;
    color: var(--color-text-muted);
}

/* Detail panel name — larger, bolder heading */
.detail-name {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Address block — tight single-spaced lines */
.detail-address-block {
    line-height: 1.35;
    margin-bottom: 0.4rem;
}
.detail-address-block div {
    margin: 0;
}

/* Consistent single-spaced rows in the detail field columns */
.user-view-grid .field > div {
    line-height: 1.6;
}

/* ============================================================
   Detail panel: editable-input UX states
   ============================================================ */

/* uv-row: position anchor for the absolute toast */
.uv-row {
    position: relative;
}

/* detail-name: side-by-side name inputs */
.detail-name {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.detail-name .uv-row {
    flex: 1 1 auto;
    min-width: 6rem;
}

/* detail-inline: side-by-side city / province */
.detail-inline {
    display: flex;
    gap: 0.5rem;
}
.detail-inline .uv-row {
    flex: 1 1 auto;
}

/* View mode: inputs look like plain text (no border, no bg) */
input.user-editable:not(.editable),
textarea.user-editable:not(.editable) {
    background:   transparent  !important;
    border-color: transparent  !important;
    box-shadow:   none         !important;
    padding:      0            !important;
    cursor:       default;
    resize:       none;
}

/* View-mode placeholder = italic muted label (mirrors the old ::after trick) */
input.user-editable:not(.editable)::placeholder,
textarea.user-editable:not(.editable)::placeholder {
    font-style: italic;
    color:      var(--color-text-muted);
    opacity:    1;
}

/* Edit mode: rely on .input class for border/bg/padding — add hover emphasis */
input.user-editable.editable:hover,
textarea.user-editable.editable:hover {
    border-color: var(--color-input-border-hover);
    background:   var(--color-input-bg-hover);
}

/* Saving: dim and pulse while the request is in-flight */
.user-editable.is-saving,
.user-editable-group.is-saving {
    opacity:        0.55;
    pointer-events: none;
    animation:      uv-pulse 0.7s ease-in-out infinite alternate;
}
@keyframes uv-pulse {
    to { opacity: 0.85; }
}

/* Error state */
.user-editable.field-error,
.user-editable-group.field-error {
    border-color: var(--color-error-border)        !important;
    box-shadow:   0 0 0 2px rgba(224,75,75,0.22)   !important;
}

/* ---- Checkbox / radio group container ---- */

/* View mode: group hidden, plain-text label shown */
.user-editable-group {
    display: none;
}

/* Edit mode: group visible as a bordered field */
.user-editable-group.editable {
    display:       flex;
    flex-wrap:     wrap;
    gap:           0.35rem 0.75rem;
    align-items:   center;
    border:        1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    background:    var(--color-input-bg);
    padding:       var(--space-input-y) var(--space-input-x);
    transition:
        border-color var(--duration-fast) var(--ease-ui),
        background   var(--duration-fast) var(--ease-ui),
        box-shadow   var(--duration-fast) var(--ease-ui);
}
.user-editable-group.editable:hover {
    border-color: var(--color-input-border-hover);
    background:   var(--color-input-bg-hover);
}

/* Each checkbox/radio option row */
.group-option {
    display:     inline-flex;
    align-items: center;
    gap:         0.3rem;
    cursor:      pointer;
    user-select: none;
}

/* View-mode text label (plain text shown instead of the group) */
.group-view-label {
    display: inline;
}

/* ---- Dark-mode toggle switch ---- */

/* Override group layout for the single-item toggle */
.uv-toggle-group.editable {
    display:     flex;
    flex-wrap:   nowrap;
    align-items: center;
    padding:     0.3rem 0.6rem;
}

/* Label wrapper — horizontal, vertically centred */
.uv-toggle-label-wrap {
    display:     inline-flex;
    align-items: center;
    gap:         0.5rem;
    cursor:      pointer;
    user-select: none;
    line-height: 1;
}

/* Hide the native checkbox — keep it in the accessibility tree */
.uv-toggle-label-wrap input[type="checkbox"] {
    position:       absolute;
    opacity:        0;
    pointer-events: none;
    width:          1px;
    height:         1px;
    margin:         0;
}

/* Pill track */
.uv-toggle-track {
    position:      relative;
    display:       inline-block;
    width:         2.1rem;
    height:        1.15rem;
    border-radius: 999px;
    background:    var(--color-input-border);
    flex-shrink:   0;
    transition:    background var(--duration-fast) var(--ease-ui);
}

/* Sliding knob */
.uv-toggle-thumb {
    position:      absolute;
    top:           0.15rem;
    left:          0.15rem;
    width:         0.85rem;
    height:        0.85rem;
    border-radius: 50%;
    background:    #fff;
    box-shadow:    0 1px 3px rgba(0,0,0,0.25);
    transition:    transform var(--duration-fast) var(--ease-ui);
}

/* Checked state — track on, knob slides right */
.uv-toggle-label-wrap input[type="checkbox"]:checked ~ .uv-toggle-track {
    background: var(--color-accent);
}
.uv-toggle-label-wrap input[type="checkbox"]:checked ~ .uv-toggle-track .uv-toggle-thumb {
    transform: translateX(0.95rem);
}

/* Focus ring for keyboard accessibility */
.uv-toggle-label-wrap input[type="checkbox"]:focus-visible ~ .uv-toggle-track {
    outline:        2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Label text */
.uv-toggle-text {
    font-size: var(--font-ui);
    color:     var(--color-text);
}

/* ---- Inline save toast ---- */
.detail-save-toast {
    position:       absolute;
    z-index:        30;
    top:            calc(100% + 3px);
    left:           0;
    padding:        0.15rem 0.55rem;
    border-radius:  var(--radius-sm);
    font-size:      0.72rem;
    font-weight:    600;
    white-space:    nowrap;
    pointer-events: none;
    animation:      uv-toast-fade 2.2s ease forwards;
}
.detail-save-toast--ok    { background: var(--color-success-border); color: #fff; }
.detail-save-toast--error { background: var(--color-danger);         color: #fff; }

@keyframes uv-toast-fade {
    0%   { opacity: 0; transform: translateY(-3px); }
    12%  { opacity: 1; transform: translateY(0);    }
    72%  { opacity: 1;                               }
    100% { opacity: 0;                               }
}

.top-notification {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-danger);
    color: #fff;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 10000;
    animation: top-notification-in 200ms ease-out;
}

@keyframes top-notification-in {
    from { opacity: 0; transform: translate(-50%, -8px); }
    to   { opacity: 1; transform: translate(-50%, 0);    }
}

/* ============================================================
   Group panels (roles, status) — legacy div.user-editable
   ============================================================ */
div.user-editable:not(.editable) {
    background-color: var(--color-user-panel-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-user-panel-border);
    padding: var(--space-sm);
}

input.editable,
textarea.editable,
div.editable {
    background: var(--color-editable-bg);
    border: 1px solid var(--color-editable-border);
}

.field-saved {
    border-color: var(--color-success-border) !important;
    box-shadow: 0 0 0 2px var(--color-success-ring);
}

.role-checkboxes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm);
}

@media (max-width: 520px) {
    .role-checkboxes {
        grid-template-columns: 1fr;
    }
}

#uv_verified label,
#uv_status label,
#uv_role label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-right: 1rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

/* ---------- jsGrid ---------- */

#usersGrid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.jsgrid-row:nth-child(even),
.jsgrid-alt-row:nth-child(even) {
    background-color: rgba(100, 160, 255, 0.12);
}

.jsgrid-row:hover,
.jsgrid-alt-row:hover {
    background-color: rgba(100, 160, 255, 0.22);
    cursor: pointer;
}

.jsgrid-row.is-selected,
.jsgrid-alt-row.is-selected,
.jsgrid-row[aria-selected="true"],
.jsgrid-alt-row[aria-selected="true"] {
    background-color: var(--color-selected-bg);
    box-shadow: inset 3px 0 0 var(--color-selected-border);
}

.jsgrid-row:active,
.jsgrid-alt-row:active {
    filter: brightness(0.97);
}

/* Deleted users (Include deleted): red tint, muted text. Rgba so it reads on
   both themes; declared after the zebra rule so it wins at equal specificity. */
.jsgrid-row.users-row--deleted,
.jsgrid-alt-row.users-row--deleted {
    background-color: rgba(229, 57, 53, 0.14);
    color: var(--color-text-muted);
    font-style: italic;
}
.jsgrid-row.users-row--deleted:hover,
.jsgrid-alt-row.users-row--deleted:hover {
    background-color: rgba(229, 57, 53, 0.24);
}

.jsgrid-header-row > .jsgrid-header-cell {
    background-color: rgba(255, 165, 0, 0.25);
    color: inherit;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 165, 0, 0.35);
}

.jsgrid-header-cell:hover {
    background-color: rgba(255, 165, 0, 0.35);
}

.jsgrid-filter-row input {
    background-color: var(--color-input-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-input-y) var(--space-input-x);
    min-height: 2.25rem;
}

.jsgrid-pager {
    padding: 6px;
}

.jsgrid-pager-page,
.jsgrid-pager-nav-button,
.jsgrid-pager-current-page {
    margin: 0 3px;
}

.jsgrid-table {
    table-layout: fixed;
}

.jsgrid,
.jsgrid * {
    box-sizing: content-box;
}

/* ---------- Keyframes & accessibility ---------- */

@keyframes ui-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ui-shimmer {
    0% {
        background-position: 100% 0;
    }
    100% {
        background-position: -100% 0;
    }
}

/* Generic selectable / list items */
.is-selected,
[aria-selected="true"],
[data-selected="true"] {
    outline: none;
}

tr.is-selected,
[role="row"].is-selected,
[role="option"].is-selected,
[role="tab"].is-selected {
    background: var(--color-selected-bg);
    box-shadow: inset 3px 0 0 var(--color-selected-border);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .btn.is-loading::after,
    .btn-primary.is-loading::after,
    .btn-secondary.is-loading::after,
    .btn-danger.is-loading::after,
    .btn[aria-busy="true"]::after,
    .input[aria-busy="true"],
    .input.is-loading {
        animation: none !important;
    }
}

/* ---------- Calendar (home page, logged in) ---------- */

.cal {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-page);
    padding: 0.5rem clamp(0.5rem, 1.5vw, 1rem) 0;
    box-sizing: border-box;
}

.cal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    padding: 0.25rem 0 0.5rem 0;
    flex-shrink: 0;
}

.cal-toolbar-left,
.cal-toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cal-select {
    min-height: 2rem;
    padding: 0.25rem 0.5rem;
    min-width: 6rem;
}

.cal-weekday-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--color-border-subtle);
    border: 1px solid var(--color-border-subtle);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    flex-shrink: 0;
}

.cal-weekday-header > div {
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    text-align: center;
    font-size: clamp(0.7rem, calc(0.525rem + 0.875vw), 1.4rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.35rem 0.25rem;
}

.cal-scroller {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* Infinite scroll prepends weeks at the top and manually re-adjusts
       scrollTop to keep the view fixed (see Calendar._initObservers). Browser
       scroll anchoring would ALSO compensate for the inserted content, so the
       two double up and the calendar jerks up/down while scrolling. Disable
       native anchoring and rely solely on the manual compensation. */
    overflow-anchor: none;
    border: 1px solid var(--color-border-subtle);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: var(--color-border-subtle);
    outline: none;
}

.cal-sentinel {
    height: 1px;
}

.cal-weeks {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cal-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.cal-day {
    background: var(--color-surface);
    aspect-ratio: 1 / 1;
    padding: 0.35rem 0.4rem;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-ui),
                box-shadow var(--duration-fast) var(--ease-ui);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
}

.cal-day:hover {
    background: var(--color-input-bg-hover);
}

.cal-day:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--color-input-focus-ring);
}

.cal-day--weekend {
    background: var(--color-surface-2);
}

/* Roster-admin / leader day staffing tints.
   --future: >1 week out, under-staffed
   --ok:     >1 week out, met minRequired
   --short:  <=1 week out, under-staffed */
.cal-day--future { background: #d6e6f5; }
.cal-day--ok     { background: #d6f0d8; }
.cal-day--short  { background: #f3d2d2; }

.cal-day--today {
    box-shadow: inset 0 0 0 2px var(--color-accent);
}

.cal-day--monthstart {
    border-top: 2px solid var(--color-accent);
}

.cal-day-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem;
    line-height: 1.1;
}

.cal-day-num {
    font-size: clamp(0.8rem, calc(0.6rem + 1vw), 1.6rem);
    font-weight: 600;
    color: var(--color-text);
}

.cal-day--today .cal-day-num {
    color: var(--color-accent);
}

.cal-day-month {
    font-size: clamp(0.6rem, calc(0.45rem + 0.75vw), 1.2rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
    text-align: right;
}

.cal-day-body {
    flex: 1;
    min-height: 0;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    overflow: hidden;
}

.cal-empty {
    color: var(--color-text-muted);
    font-style: italic;
    margin: 0;
}

@media (max-width: 600px) {
    .cal-day { padding: 0.2rem 0.25rem; }
}

/* "My Shifts" dialog */
.myshifts-summary {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--color-surface-alt, #f3f3f3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
}
.myshifts-summary-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.myshifts-summary-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    white-space: nowrap;
}
.myshifts-summary-badge-num {
    font-weight: 700;
}
.myshifts-summary-badge--completed {
    color: var(--color-text);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-subtle);
}
.myshifts-summary-badge--upcoming {
    color: #1c5a96;
    background: rgba(49, 130, 206, 0.12);
    border: 1px solid rgba(49, 130, 206, 0.6);
}
.myshifts-summary-badge--unavailable {
    color: #822727;
    background: rgba(197, 48, 48, 0.1);
    border: 1px solid rgba(197, 48, 48, 0.6);
}
.myshifts-group {
    margin-bottom: 1rem;
}
.myshifts-group-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0.75rem 0 0.4rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--color-border);
}
.myshifts-group-count {
    font-weight: 400;
    opacity: 0.7;
    font-size: 0.85rem;
}
.myshifts-card-date {
    font-weight: 600;
    margin-right: 0.4rem;
}
.myshifts-card-name {
    font-weight: 400;
    opacity: 0.9;
}

/* Shift detail cards inside the day dialog */
.day-shift-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--color-surface);
}

.day-shift-card:last-child {
    margin-bottom: 0;
}

.day-shift-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.35rem;
    color: var(--color-text);
}

.day-shift-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.day-shift-filled {
    font-weight: 500;
    color: var(--color-text-muted);
}

.day-shift-spots {
    font-weight: 600;
    color: #1c5a96;
    background: rgba(49, 130, 206, 0.12);
    border: 1px solid rgba(49, 130, 206, 0.6);
    border-radius: 9999px;
    padding: 0.15rem 0.65rem;
    margin-left: auto;
    white-space: nowrap;
}

.day-shift-spots--full {
    color: var(--color-danger, #c53030);
    background: rgba(197, 48, 48, 0.1);
    border-color: rgba(197, 48, 48, 0.6);
    font-weight: 700;
}

.day-shift-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.day-shift-header .day-shift-name {
    margin-bottom: 0;
}

.day-shift-status {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    color: #fff;
    white-space: nowrap;
}

.day-shift-status--rostered {
    background: #38a169;
    border: 2px solid var(--color-registered-dark, #276749);
}

.day-shift-status--available {
    background: #3182ce;
}

.day-shift-status--unavailable {
    background: #c53030;
    border: 2px solid #822727;
}

.day-shift-status--pending {
    background: #b7791f;
    border: 2px solid #8a5a15;
    white-space: normal;
}

.day-shift-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

/* ---- Self-service Register / Unavailable cards ---- */

.day-shift-selfservice {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.day-shift-regcard {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1 1 260px;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
}

.day-shift-regcard--register {
    border: 2px solid var(--color-registered-dark);
}

.day-shift-regcard--unavailable {
    border: 1px solid var(--color-border-subtle);
}

.day-shift-regcard--pending {
    border: 2px solid #b7791f;
}

.day-shift-regcard--full {
    flex-basis: 100%;
}

/* A shift whose hours clash with one the viewer is already on. The register
   button is disabled; the card reads as unavailable rather than actionable. */
.day-shift-regcard--conflict {
    border: 1px dashed var(--color-border-subtle);
    opacity: 0.75;
}

.day-shift-regcard--conflict .day-shift-regcard-text {
    color: var(--color-text-muted);
    font-style: italic;
}

.day-shift-action[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.day-shift-regcard-text {
    color: var(--color-text);
    margin-right: auto;
    text-align: left;
}

.day-shift-regcard-state {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    width: 100%;
}

.day-shift-regcard-state.hidden {
    display: none;
}

.day-shift-regcard-icon {
    flex-shrink: 0;
    display: inline-flex;
}

.day-shift-regcard-icon--check {
    color: var(--color-registered-dark);
}

.day-shift-regcard-icon--warn {
    color: #b7791f;
}

.day-shift-regcard-confirm-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1 1 auto;
    min-width: 12rem;
}

.day-shift-regcard-confirm-text strong {
    color: var(--color-text);
}

.day-shift-regcard-confirm-text em {
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.day-shift-regcard-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    margin-left: auto;
}

/* ---- Admin / hill-leader editing actions ---- */

.day-shift-adminactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    min-height: unset;
    border-radius: var(--radius-sm, 4px);
}

.day-shift-header-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.day-shift-expand {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.1rem 0.35rem;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm, 4px);
}

.day-shift-expand:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}

/* --- Add Patroller popup --- */
.add-patroller-popup {
    position: fixed;
    z-index: 1100;
    min-width: 260px;
    max-width: 340px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border);
    border-radius: var(--radius, 6px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

.add-patroller-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border-subtle, var(--color-border));
}

.add-patroller-search {
    flex: 1;
    min-width: 200px;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
}

.add-patroller-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0 0.3rem;
    line-height: 1;
}

.add-patroller-close:hover {
    color: var(--color-text);
}

.add-patroller-list {
    max-height: 220px;
    overflow-y: auto;
}

.add-patroller-results {
    list-style: none;
    margin: 0;
    padding: 0;
}

.add-patroller-item {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--color-text);
}

.add-patroller-item:hover {
    background: var(--color-primary, #3182ce);
    color: #fff;
}

.add-patroller-empty,
.add-patroller-loading {
    padding: 0.75rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-align: center;
}

.day-shift-detail {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border-subtle, var(--color-border));
}

.day-shift-detail.hidden {
    display: none;
}

.day-shift-detail-group {
    margin-bottom: 0.4rem;
}

.day-shift-detail-group:last-child {
    margin-bottom: 0;
}

.day-shift-detail-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.35rem;
}

.day-shift-detail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
    color: var(--color-text);
}

.day-shift-detail-list li {
    padding: 0.1rem 0;
}

.day-shift-detail-loading,
.day-shift-detail-empty {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.day-shift-detail-person {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    flex-wrap: wrap;
    border: 1px solid var(--color-border-subtle, #ddd);
    border-radius: var(--radius-sm, 6px);
    padding: 0.35rem 0.9rem 0.35rem 0.6rem;
    margin-bottom: 0.3rem;
    background: var(--color-surface);
}

.day-shift-detail-list li:last-child {
    margin-bottom: 0;
}

/* Highlights the viewing user's own row in the roster list. */
.day-shift-detail-person--me {
    border-color: var(--color-registered-dark);
}

.day-shift-detail-person--me .day-shift-detail-name {
    font-weight: 700;
}

/* Flags a patroller with an outstanding "Unregister Requested" (type 6). */
.day-shift-detail-person--pending {
    border-color: #b7791f;
}

.day-shift-detail-pending-note {
    margin-left: 0.5rem;
    font-size: 0.75rem;
    font-style: italic;
    color: #b7791f;
}

.day-shift-detail-tally {
    flex-basis: 100%;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    padding-left: 0.5rem;
    font-style: italic;
}

.day-shift-detail-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 0.15rem 0 0.35rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px dashed var(--color-border-subtle, #ddd);
}

.day-shift-detail-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    color: var(--color-text-muted);
}

.day-shift-detail-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.day-shift-detail-name {
    flex: 1;
    min-width: 0;
    padding-left: 0.5rem;
}

.day-shift-detail-actions {
    display: flex;
    gap: 0.15rem;
    flex-shrink: 0;
}

.day-shift-detail-dept {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    min-width: 8rem;
    text-align: right;
    justify-content: flex-end;
}

.day-shift-detail-deptname {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.1rem 0.6rem;
    border-radius: 9999px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-subtle);
    color: var(--color-text);
}

a.day-shift-detail-namelink {
    color: var(--color-link, #1462a8);
    text-decoration: none;
}

a.day-shift-detail-namelink:hover {
    text-decoration: underline;
    color: var(--color-link-hover, #0d4a82);
}

a.day-shift-detail-deptname.is-editable {
    color: var(--color-link, #1462a8);
    text-decoration: none;
    cursor: pointer;
    background: rgba(20, 98, 168, 0.08);
    border-color: rgba(20, 98, 168, 0.4);
}

a.day-shift-detail-deptname.is-editable:hover {
    color: var(--color-link-hover, #0d4a82);
    background: rgba(20, 98, 168, 0.14);
    border-color: rgba(20, 98, 168, 0.6);
}

a.day-shift-detail-commenttext.is-editable {
    color: var(--color-link, #1462a8);
    text-decoration: underline;
    cursor: pointer;
}

a.day-shift-detail-commenttext.is-editable:hover {
    color: var(--color-link-hover, #0d4a82);
}

.day-shift-detail-comment {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    min-width: 8rem;
    max-width: 14rem;
    text-align: right;
    justify-content: flex-end;
    padding-right: 0.6rem;
}

.day-shift-detail-commenttext {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.day-shift-detail-commentedit {
    position: fixed;
    z-index: 9999;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border-subtle, #ccc);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    padding: 0.4rem;
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.day-shift-detail-commentinput {
    flex: 1;
    min-width: 12rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--color-border-subtle, #ccc);
    border-radius: 4px;
    font-size: 0.9rem;
    background: var(--color-surface, #fff);
    color: var(--color-text, inherit);
}


.day-shift-saved-flash {
    display: block;
    font-size: 0.7rem;
    color: var(--color-success, #2a7a2a);
    opacity: 1;
    transition: opacity 0.4s ease;
    pointer-events: none;
    text-align: right;
}

.day-shift-saved-flash.is-fading {
    opacity: 0;
}

.day-shift-detail-deptpicker {
    position: fixed;
    z-index: 9999;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border-subtle, #ccc);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    min-width: 160px;
    max-height: 260px;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.day-shift-detail-deptopt {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: inherit;
}

.day-shift-detail-deptopt:hover,
.day-shift-detail-deptopt:focus {
    background: var(--color-hover, rgba(49,130,206,0.1));
}

.day-shift-detail-deptopt.is-selected {
    font-weight: 600;
}

.btn-link-sm {
    background: none;
    border: none;
    font-size: 0.75rem;
    padding: 0.1rem 0.35rem;
    cursor: pointer;
    color: var(--color-primary, #3182ce);
    border-radius: var(--radius-sm, 4px);
    white-space: nowrap;
}

.btn-link-sm:hover {
    background: rgba(0, 0, 0, 0.06);
    text-decoration: underline;
}

.btn-link-danger {
    color: var(--color-danger, #c53030);
}

.btn-link-danger:hover {
    background: rgba(197, 48, 48, 0.08);
}

.cal-day-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cal-day-actions .btn {
    padding: 0.35rem 0.75rem;
    min-height: 2rem;
}

/* Date navigation bar — sits between the title bar and the body */
.day-nav-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.day-nav-arrow {
    flex-shrink: 0;
    font-size: 1.75rem;
    line-height: 1;
    padding: 0.2rem 0.65rem;
    min-height: 2.4rem;
}

.day-nav-title-wrap {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
}

/* Clickable date text — styled to look like a heading, hint of interactivity */
.day-nav-title-btn {
    background: none;
    border: none;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm, 4px);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    white-space: nowrap;
}

.day-nav-title-btn:hover {
    opacity: 0.75;
}

.myshifts-season-icon {
    display: inline-flex;
    vertical-align: -2px;
    margin-right: 0.35rem;
    color: var(--color-text-muted);
}

/* Hidden date input — positioned near the title so the picker anchors there */
.day-date-picker-hidden {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    top: 100%;
    left: 50%;
    pointer-events: none;
}

/* Add Shift dialog form */
.shift-day-label {
    margin: 0 0 1rem 0;
    font-weight: 600;
    color: var(--color-text-muted);
}

.shift-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-field-gap);
}

/* Department permission grid inside Add/Edit Shift dialogs */
.shift-dept-field {
    margin-bottom: var(--space-field-gap);
}

.dept-grid {
    border: 1px solid var(--color-border-subtle);
    border-radius: 6px;
    max-height: 220px;
    overflow-y: auto;
    background: var(--color-surface, transparent);
}

.dept-grid table {
    width: 100%;
    border-collapse: collapse;
}

.dept-grid th,
.dept-grid td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
}

.dept-grid thead th {
    position: sticky;
    top: 0;
    background: var(--color-surface, #f6f6f6);
    font-weight: 600;
    font-size: 0.9rem;
}

.dept-grid tbody tr:last-child td {
    border-bottom: none;
}

.dept-grid .dept-grid-check {
    text-align: center;
    width: 110px;
}

.dept-grid .dept-grid-empty {
    padding: 12px;
    color: var(--color-text-muted);
    font-style: italic;
}

@media (max-width: 520px) {
    .shift-form-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Repeat weekly / Create daily series ---------- */
.replicate-section {
    margin-top: 0.5rem;
    border-top: 1px solid var(--color-border-subtle);
    padding-top: 0.5rem;
}

.replicate-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    padding: 0.35rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.replicate-toggle:hover {
    color: var(--color-text);
}

.replicate-toggle-arrow {
    display: inline-block;
    font-size: 0.65rem;
    transition: transform 0.15s ease;
}

.replicate-toggle.is-open .replicate-toggle-arrow {
    transform: rotate(90deg);
}

.replicate-body {
    padding: 0.5rem 0 0.25rem;
}

/* One-line teaser under the collapsed toggle; hidden while the panel is open. */
.replicate-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    padding: 0 0 0.35rem 1.1rem;
}

.replicate-intro {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0 0 0.6rem;
}

.replicate-control {
    margin-bottom: 0.75rem;
}

.replicate-preview-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.15rem;
}

.replicate-tally {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}

.replicate-until-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    display: block;
    margin-bottom: 0.25rem;
}

.replicate-date-input {
    max-width: 140px;
}

.shift-date-picker {
    max-width: 180px;
}

.replicate-date-list {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    max-height: 160px;
    overflow-y: auto;
    line-height: 1.6;
}

.replicate-date-list .replicate-date-item {
    padding: 0.1rem 0;
}

.replicate-date-item.is-base {
    font-weight: 600;
    color: var(--color-text);
}

.replicate-date-none {
    font-style: italic;
}

.replicate-conflict-btn {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.05rem 0.4rem;
    margin-left: 0.3rem;
    border-radius: 3px;
    border: 1px solid var(--color-danger, #dc3545);
    background: var(--color-danger, #dc3545);
    color: #fff;
    cursor: pointer;
    vertical-align: middle;
    line-height: 1.4;
}

.replicate-conflict-btn:hover {
    opacity: 0.85;
}

.replicate-conflict-btn.is-omitted {
    background: var(--color-text-muted, #6c757d);
    border-color: var(--color-text-muted, #6c757d);
    text-decoration: line-through;
}

.replicate-range-dates {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
    max-width: 340px;
}
.replicate-range-dates .field {
    flex: 1 1 140px;
    min-width: 0;
}

/* Dirty-field highlight for shift edit form — unsaved change indicator */
.shift-form .input.is-field-dirty {
    border-color: var(--color-accent, #3b82f6);
    box-shadow: inset 0 0 0 1px var(--color-accent, #3b82f6);
    background-color: rgba(59, 130, 246, 0.08);
}

/* Shift chips inside calendar day cells */
.cal-shift-chip {
    display: block;
    font-size: clamp(0.65rem, calc(0.49rem + 0.81vw), 1.3rem);
    line-height: 1.3;
    background: #1a73e8;
    color: #fff;
    border-radius: 3px;
    padding: 1px 4px;
    margin-top: 2px;
    overflow: hidden;
}

.cal-shift-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-shift-chip-count {
    font-size: 0.65em;
    line-height: 1.1;
    opacity: 0.92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 0.25em;
}

/* When the calendar gets narrow, the small per-shift count lines crowd
   out the shift name and badly squeeze each cell. Hide them at narrow
   viewports so the shift names themselves stay legible. */
@media (max-width: 900px) {
    .cal-shift-chip-count { display: none; }
}

.cal-shift-chip--rostered {
    background: #38a169;
}

.cal-shift-chip--unavailable {
    background: #c53030;
}

/* Compact confirm dialogs (dirty-check, etc.) */
.dialog-container--sm {
    max-width: 420px;
    width: 90vw;
    height: auto;
}

/* ---------- Updates dialog ---------- */
#updatesDialog .dialog-container {
    width: min(620px, calc(100vw - 2 * var(--dialog-pad-x)));
}

.updates-intro {
    margin: 0 0 0.9rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.updates-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border-subtle);
    margin-bottom: 0.9rem;
}

.updates-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font-family: inherit;
    font-size: var(--font-ui);
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
}

.updates-tab:hover { color: var(--color-text); }

.updates-tab.is-active {
    color: var(--color-text);
    border-bottom-color: var(--color-accent);
}

.updates-tab-badge {
    display: inline-block;
    min-width: 1.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: var(--color-border-subtle);
    color: var(--color-text);
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
}

.updates-tab.is-active .updates-tab-badge {
    background: var(--color-accent);
    color: #fff;
}

.updates-toolbar {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 0.9rem;
}

.updates-search {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.updates-search-icon {
    position: absolute;
    top: 50%;
    left: 0.6rem;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

/* Element-qualified to outrank the `input.input` / `select.input` base rules */
input.updates-search-input {
    width: 100%;
    padding-left: 2.2rem;
}

select.updates-filter {
    flex: 0 0 auto;
    width: auto;
    min-width: 8rem;
}

.updates-section-title {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
}

.updates-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.updates-empty {
    margin: 0;
    font-style: italic;
    color: var(--color-text-muted);
}

.update-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    cursor: pointer;
}

.update-card:hover { border-color: var(--color-input-border-hover); }

/* Unread items get an accent rule down the leading edge */
.update-card.is-unread {
    border-left: 3px solid var(--color-accent);
}

.update-card__main {
    flex: 1 1 auto;
    min-width: 0;
}

.update-card__title {
    font-weight: 700;
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.update-card__preview {
    margin-top: 0.15rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
}

.update-card__time {
    flex: 0 0 auto;
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.update-card__body {
    flex: 1 1 100%;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--color-border-subtle);
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--color-text);
    overflow-wrap: anywhere;
}

/* ---------- Settings dialog ---------- */
#settingsDialog .dialog-container {
    width: min(520px, calc(100vw - 2 * var(--dialog-pad-x)));
    height: auto;
}

.settings-intro {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-form .field {
    margin: 0;
}

.settings-input {
    max-width: 320px;
}

.settings-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    align-items: center;
}

.settings-radio-group--stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.settings-switch-row {
    display: flex;
    align-items: center;
    padding: 0.15rem 0;
}

/* ---------- Confirm dialog (icon + centred message) ---------- */
#settingsDirtyDialog {
    z-index: 65;
    background: var(--color-overlay);
    padding-top: 8vh;
}

.confirm-dialog__body {
    text-align: center;
    padding: clamp(20px, 4vw, 28px) clamp(18px, 4vw, 26px) clamp(12px, 3vw, 18px);
}

.confirm-dialog__icon {
    color: var(--color-danger);
    line-height: 0;
    margin-bottom: 0.75rem;
}

.confirm-dialog__title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
}

.confirm-dialog__text {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--color-text-muted);
}


/* ---- Attendance dialog ---- */
.attendance-shift-label {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.dialog-container--wide {
    max-width: 820px;
    width: 95vw;
}

.att-table-wrap {
    overflow-x: auto;
}

.att-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.att-add-panel {
    margin-bottom: 0.75rem;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border);
    border-radius: var(--radius, 6px);
}

.att-add-note {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.add-patroller-item:hover .att-add-note {
    color: inherit;
}

.att-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.att-th {
    padding: 0.35rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.att-th--name {
    text-align: left;
    min-width: 140px;
}

.att-row:nth-child(even) {
    background: var(--color-surface-2);
}

.att-td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--color-border-subtle);
    text-align: center;
}

.att-td--name {
    text-align: left;
    font-weight: 500;
}

.att-td--radio {
    width: 80px;
}

.att-td--area {
    text-align: left;
}

.att-area {
    min-width: 120px;
    font-size: 0.85rem;
    padding: 0.25rem 0.4rem;
}

.att-radio-label {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    min-height: var(--touch-min, 44px);
}

.att-check {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
    accent-color: var(--color-primary, #1a56a0);
}

.template-toolbar {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}
.template-fmt-btn {
    min-width: 2.2rem;
    padding: 0.25rem 0.6rem;
}
.template-editor {
    min-height: 14rem;
    max-height: 28rem;
    overflow-y: auto;
    padding: 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #111;
    white-space: pre-wrap;
}
.template-editor:focus {
    outline: 2px solid var(--color-primary, #1a56a0);
    outline-offset: -2px;
}
/* ---- Templates list: one rounded strip per template type ---- */
.templates-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
}

.template-card__name {
    font-weight: 600;
    color: var(--color-text);
}

/* Push the action button to the right edge of the strip */
.template-card__btn {
    margin-left: auto;
    min-width: 6rem;
    padding: 0.35rem 0.9rem;
    min-height: 0;
}

.template-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.template-badge--active  { background: #d4edda; color: #1a5c30; }
.template-badge--missing { background: #f8d7da; color: #842029; }

/* ---- Template editor: back arrow beside the title ---- */
.dialog-header__lead {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.dialog-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 0;
}

.dialog-back:hover {
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.06);
}

.dialog-back:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Disabled for editing, but the value is the point — keep it legible */
.template-subject {
    width: 100%;
}

.template-subject:disabled {
    opacity: 1;
    color: var(--color-text);
}

.template-note {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.5rem;
    font-style: italic;
}

/* Call to Roster dialog */
.ctr-recipients-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}
.ctr-recipients-toolbar label {
    cursor: pointer;
    user-select: none;
}
.ctr-count {
    color: #666;
    font-size: 0.9rem;
}
.ctr-recipients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.25rem 1rem;
    max-height: 16rem;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fafafa;
}
.ctr-recipient {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    padding: 0.15rem 0;
}
.ctr-recipient input:disabled + * {
    color: #999;
}
.ctr-recipient-flag {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
}
.ctr-ok   { color: #1f8a3a; font-weight: 600; }
.ctr-fail { color: #c0392b; font-weight: 600; }
.ctr-skip { color: #888;    font-style: italic; }

/* Magic-link bail-out replacement dialog */
.linkaction-shift {
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.linkaction-prompt {
    margin-bottom: 0.5rem;
}
.linkaction-already,
.linkaction-result {
    font-weight: 600;
    margin: 0.5rem 0;
}
.linkaction-already { color: #b26a00; }
.linkaction-result  { color: #1f8a3a; }

/* Bail-out button when a replacement request is already outstanding (cancelAction 2) */
.day-shift-action--bailsent,
.day-shift-action--bailsent:hover {
    background-color: #b26a00 !important;
    border-color: #b26a00 !important;
    color: #fff !important;
}

/* In-app bail-out replacement notice */
.bailnotice-from {
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.bailnotice-shift {
    color: #555;
    margin-bottom: 0.75rem;
}
.bailnotice-body {
    margin-bottom: 0.75rem;
    line-height: 1.4;
}
.bailnotice-prompt {
    font-weight: 600;
    margin-top: 0.5rem;
}

/* ---------- Reports dashboard ---------- */
#reportsDialog .dialog-container {
    max-width: 1100px;
    width: 96vw;
}
.reports-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--space-md) 0;
}
.report-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}
.report-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}
.report-card-title {
    margin: 0;
    font-size: 1.05rem;
}
.report-card-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.report-season-nav {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.report-season-label {
    min-width: 56px;
    text-align: center;
    font-weight: 600;
}
.report-area-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem;
    margin-bottom: var(--space-sm);
    padding: 0.4rem 0.2rem;
    border-bottom: 1px dashed var(--color-border-subtle);
}
.report-area-cb-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
}
.report-area-swatch {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
    flex: 0 0 auto;
}
.report-chart {
    width: 100%;
    overflow-x: auto;
}
.report-card-foot {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}
.report-grid {
    margin-top: var(--space-sm);
    overflow-x: auto;
}
.report-grid.hidden {
    display: none;
}
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.report-table th,
.report-table td {
    border: 1px solid var(--color-border-subtle);
    padding: 0.3rem 0.5rem;
    text-align: left;
    white-space: nowrap;
}
.report-table th {
    background: var(--color-surface-2);
    font-weight: 600;
}
.report-grid-subtitle {
    margin: var(--space-md) 0 var(--space-xs);
    font-size: 0.9rem;
    font-weight: 600;
}
.report-grid-subtitle:first-child {
    margin-top: 0;
}
.reports-empty {
    color: var(--color-text-muted);
    text-align: center;
    padding: var(--space-lg) var(--space-md);
    margin: 0;
}

/* ---- Areas (departments) admin: draggable badge list ---- */

.dept-badge-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dept-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 0.5rem 0.75rem;
    cursor: grab;
}

.dept-badge:active {
    cursor: grabbing;
}

.dept-badge--dragging {
    opacity: 0.4;
}

.dept-badge-handle {
    display: inline-flex;
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.dept-badge-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    color: var(--color-text);
}

.dept-badge-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* Tag filter: shown when no user in the list has a tag yet */
.users-rolefilter__empty {
    padding: 0.25rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* ---------- Import / Export dialog ---------- */
.data-tabs {
    margin: 0.75rem clamp(14px, 3vw, 20px) 0;
}
.data-fieldset {
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.9rem 0.8rem;
    margin: 0;
}
.data-fieldset legend {
    padding: 0 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.data-option {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-right: 1.25rem;
    cursor: pointer;
}
.data-season-actions {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}
.data-season-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.35rem 0.75rem;
}
.data-season {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}
.data-status {
    margin-left: 0.75rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}
.data-status--error {
    color: var(--color-danger);
}

/* Import tab */
.data-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.data-import-pick {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.data-import-pick .data-status {
    margin-left: 0;
}
.data-import-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-size: 0.9rem;
}
.data-import-questions {
    border: 1px solid var(--color-border-subtle);
    border-left: 4px solid #e57c04;
    border-radius: var(--radius-md);
    padding: 0.6rem 0.9rem;
}
.data-import-qtitle {
    margin: 0 0 0.5rem;
    font-weight: 600;
}
.data-import-qlist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.data-import-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}
.data-import-actions .data-status {
    margin-left: 0;
}
.data-import-table {
    max-height: 55vh;
    overflow: auto;
}
.data-import-details {
    white-space: normal !important;
    min-width: 240px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
.data-badge {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.data-badge--new  { background: rgba(58, 167, 87, 0.18);  color: #2e8a47; }
.data-badge--upd  { background: rgba(47, 126, 216, 0.18); color: #2f7ed8; }
.data-badge--same { background: rgba(127, 127, 127, 0.15); color: var(--color-text-muted); }
.data-badge--warn { background: rgba(229, 124, 4, 0.18);  color: #c06800; }
.data-badge--err  { background: rgba(229, 57, 53, 0.16);  color: var(--color-danger); }
.data-badge--done { background: rgba(58, 167, 87, 0.30);  color: #23703a; }

/* Edit Shift: Unregister override radio group, dirty highlight like the inputs */
#shiftEdit_cancelGrp {
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0.25rem 0.4rem;
}
#shiftEdit_cancelGrp.is-field-dirty {
    border-color: var(--color-accent, #3b82f6);
    background-color: rgba(59, 130, 246, 0.08);
}

/* Updates: news previews keep their line breaks (point-form items); the
   preview is hidden while a card is open since the full body repeats it. */
.update-card__preview {
    white-space: pre-line;
}
.update-card.is-open .update-card__preview {
    display: none;
}

/* Settings > General: home page welcome text */
.settings-hometext {
    width: 100%;
    min-height: 10rem;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.85rem;
}
.settings-hint {
    margin: 0.3rem 0 0;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}
