/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    --font-heading: "Segoe UI", "Trebuchet MS", sans-serif;
    --font-body: "Segoe UI", Tahoma, sans-serif;
    --bg: #f4f6f9;
    --bg-soft: #e9edf5;
    --surface: #ffffff;
    --surface-elevated: #fefefe;
    --text: #1f2933;
    --text-muted: #52606d;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --success: #1b8f5a;
    --warning: #b67f00;
    --danger: #b42318;
    --border: #d0d7e2;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
    --login-hero-bg: linear-gradient(135deg, #0f766e 0%, #155e75 52%, #172554 100%);
    --login-stage-border: rgba(255, 255, 255, 0.62);
    --login-form-surface: rgba(255, 255, 255, 0.86);
    --login-stage-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);

    /* Dashboard layout tokens (usabili globalmente) */
    --dashboard-staff-col-width: calc(10rem + 2cm);
    --dashboard-day-cell-width: 0.7cm;
    --dashboard-summary-col-width: 2.50rem;
    --dashboard-summary-dovute-width: 3.00rem;
}

html[data-theme="dark"] {
    --bg: #0f172a;
    --bg-soft: #162338;
    --surface: #1d293b;
    --surface-elevated: #24344a;
    --text: #e5edf5;
    --text-muted: #b5c2d0;
    --accent: #2dd4bf;
    --accent-strong: #14b8a6;
    --success: #45c786;
    --warning: #ffc857;
    --danger: #ff7d66;
    --border: #32475f;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --login-hero-bg: linear-gradient(135deg, #0f766e 0%, #164e63 45%, #0f172a 100%);
    --login-stage-border: rgba(100, 116, 139, 0.32);
    --login-form-surface: rgba(15, 23, 42, 0.82);
    --login-stage-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after { box-sizing: border-box; }

html { font-size: 16px; }

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at 0% 0%, rgba(15, 118, 110, 0.12), transparent 45%),
        radial-gradient(circle at 100% 100%, rgba(17, 94, 89, 0.08), transparent 45%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.45;
    text-rendering: optimizeLegibility;
    transition: background-color 200ms ease, color 200ms ease;
}

a { color: inherit; }

button,
input,
select,
textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent) 65%, #ffffff);
    outline-offset: 2px;
}

/* ============================================================
   SHARED COMPONENT BASES
   ============================================================ */

/* --- Button base ---
   Consolidates: border/background/color/border-radius/cursor
   ripetuti su tutti i pannelli. */
.month-nav button,
.calendar-scope-toggle button,
.view-toggle button,
.modal-footer button,
.retry-button,
.swap-actions button,
.swap-panel-header button,
.nurses-toolbar button,
.pager-row button,
.nurse-actions button,
.editor-actions button,
.dashboard-actions button,
.auth-actions button,
.auth-session-actions button,
.rules-actions button,
.templates-table button,
.users-toolbar button,
.users-table button,
.notification-panel-header button {
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text);
    border-radius: 0.45rem;
    cursor: pointer;
}

/* Padding standard (maggioranza dei bottoni) */
.month-nav button,
.calendar-scope-toggle button,
.view-toggle button,
.modal-footer button,
.retry-button,
.swap-actions button,
.swap-panel-header button,
.nurses-toolbar button,
.pager-row button,
.nurse-actions button,
.editor-actions button,
.rules-actions button,
.templates-table button,
.users-toolbar button,
.users-table button,
.auth-actions button,
.auth-session-actions button {
    padding: 0.45rem 0.7rem;
}

/* Bottoni con min-height esplicita */
.month-nav button,
.calendar-scope-toggle button,
.view-toggle button,
.modal-footer button,
.retry-button,
.swap-actions button,
.swap-panel-header button,
.dashboard-actions button {
    min-height: 2.3rem;
}

/* Notification panel: padding compatto */
.notification-panel-header button { padding: 0.35rem 0.6rem; }

/* Dashboard: padding leggermente più largo */
.dashboard-actions button { padding: 0.45rem 0.75rem; }

/* --- Form control base ---
   Consolidates: border/border-radius/background/color/width
   ripetuti per ogni input/select/textarea. */
.modal-body input,
.modal-body select,
.modal-body textarea,
.auth-input,
.nurse-editor-card input,
.nurse-editor-card select,
.nurses-toolbar input,
.nurses-toolbar select,
.users-toolbar input,
.users-toolbar select,
.rules-grid input[type="number"],
.swap-note-field textarea {
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: var(--surface-elevated);
    color: var(--text);
    width: 100%;
}

/* Padding standard */
.modal-body input,
.modal-body select,
.modal-body textarea,
.auth-input,
.nurse-editor-card input,
.nurse-editor-card select,
.rules-grid input[type="number"] {
    padding: 0.45rem;
}

/* Padding compatto per toolbar */
.nurses-toolbar input,
.nurses-toolbar select,
.users-toolbar input,
.users-toolbar select {
    padding: 0.4rem 0.5rem;
}

.swap-note-field textarea { padding: 0.55rem; resize: vertical; }

/* Inputs inline nella tabella (senza width forzata) */
.templates-table input[type="time"],
.templates-table input[type="color"] {
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: var(--surface-elevated);
    color: var(--text);
    padding: 0.35rem 0.45rem;
}
.templates-table input[type="time"] { width: 100%; }

/* --- Card base ---
   Consolidates: background/border/border-radius/box-shadow/padding
   ripetuti su 10+ componenti. */
.calendar-shell,
.swap-panel,
.nurses-list-card,
.nurse-editor-card,
.leave-summary-card,
.users-card,
.scheduling-note,
.rules-card,
.templates-card,
.warmup-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    box-shadow: var(--shadow);
    padding: 0.8rem;
}

/* Card con margine inferiore */
.scheduling-note,
.rules-card,
.templates-card { margin-bottom: 0.8rem; }

/* --- Kicker / eyebrow label ---
   .auth-kicker / .dashboard-eyebrow / .warmup-kicker erano identici. */
.auth-kicker,
.dashboard-eyebrow,
.warmup-kicker {
    margin: 0;
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* --- Icone SVG inline (stroke-only) ---
   .nav-toggle svg / .install-app-icon svg / .theme-toggle-icon svg
   condividevano le stesse proprietà stroke. */
.nav-toggle svg,
.install-app-icon svg,
.theme-toggle-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.app-shell { min-height: 100vh; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.app-main { padding: 0.8rem; }

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav-bar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    overflow: visible;
}

.brand-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.brand-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

/* Nav content: collassata su mobile, espansa via .is-open o ≥768px */
.nav-content {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    overflow: visible;
    min-width: 0;
}
.nav-content.is-open { display: flex; }

.brand-link {
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Hamburger toggle (nascosto a ≥768px) */
.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.nav-toggle svg { width: 1.2rem; height: 1.2rem; }

.connection-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.connection-dot { width: 0.65rem; height: 0.65rem; border-radius: 999px; }
.connection-green  { background: var(--success); }
.connection-yellow { background: var(--warning); }
.connection-red    { background: var(--danger); }

/* Link: impilati verticalmente su mobile */
.nav-links {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    overflow-x: visible;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0;
    min-width: 0;
}
.nav-links > * { flex: 1 1 auto; }

.nav-links a {
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 2.25rem;
    white-space: normal;
}
.nav-links a.active {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.nav-utilities {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    overflow: visible;
    flex-wrap: wrap;
    width: 100%;
}

/* ============================================================
   NOTIFICATION MENU
   ============================================================ */
.notification-menu { position: relative; z-index: 90; overflow: visible; }

.notification-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    position: relative;
    transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.notification-trigger:hover {
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.notification-trigger[aria-expanded="true"] {
    border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    transform: translateY(1px);
}

.notification-trigger-icon {
    display: inline-flex;
    width: 1.35rem;
    height: 1.35rem;
    color: var(--text);
}
.notification-trigger-icon svg { width: 100%; height: 100%; fill: currentColor; }

.notification-count {
    min-width: 1.2rem;
    padding: 0.1rem 0.3rem;
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
    position: absolute;
    top: -0.15rem;
    right: -0.15rem;
    box-shadow: 0 0 0 2px var(--surface-elevated);
}

.notification-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    width: min(24rem, calc(100vw - 2rem));
    max-height: 28rem;
    overflow: auto;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    background: var(--surface);
    box-shadow: var(--shadow);
    z-index: 70;
    transform-origin: top right;
    animation: notification-panel-enter 180ms cubic-bezier(0.22, 1, 0.36, 1);
    overscroll-behavior: contain;
}

.notification-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.8rem;
}
.notification-panel-header p { margin: 0.2rem 0 0; }

.notification-panel-actions { display: flex; gap: 0.45rem; }

.notification-list { display: flex; flex-direction: column; gap: 0.55rem; }

.notification-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.8rem;
}

.notification-filter {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: 0.3rem 0.65rem;
    cursor: pointer;
}
.notification-filter.is-active {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.notification-settings {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--bg-soft);
}
.notification-settings-actions { display: flex; justify-content: flex-end; }

.notification-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
    text-align: left;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    background: var(--surface);
    cursor: pointer;
}
.notification-item.is-unread {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

/* Severity left-border variants */
.notification-item.sev-success { border-left: 0.3rem solid var(--success); }
.notification-item.sev-warning { border-left: 0.3rem solid var(--warning); }
.notification-item.sev-error   { border-left: 0.3rem solid var(--danger); }
.notification-item.sev-info    { border-left: 0.3rem solid var(--accent); }

.notification-title-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.notification-category {
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 12%, transparent);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 600;
}

.notification-message,
.notification-meta { color: var(--text-muted); }
.notification-meta { font-size: 0.82rem; }

.notification-unread-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    background: var(--accent);
    flex-shrink: 0;
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 2.5rem;
    min-width: 2.5rem;
    padding: 0;
    border-radius: 999px;
    cursor: pointer;
    min-height: 2.25rem;
    transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.theme-toggle:hover {
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.theme-toggle:active { transform: translateY(1px); }

.theme-toggle-icon { display: inline-flex; width: 1.1rem; height: 1.1rem; }
/* svg rules incluse nel blocco icone condiviso sopra */

/* ============================================================
   INSTALL APP BUTTON
   ============================================================ */
.install-app-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
    color: var(--accent-strong);
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.install-app-icon { display: inline-flex; width: 1rem; height: 1rem; }
/* svg rules incluse nel blocco icone condiviso sopra */

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.page-title { margin-top: 0; font-family: var(--font-heading); }
.brand-logo { display: block; max-width: 100%; height: auto; }
.text-muted { color: var(--text-muted); }
.link-button {
    border: 0;
    background: transparent;
    color: var(--accent-strong);
    cursor: pointer;
    padding: 0;
    text-align: left;
}
.inline-error   { margin: 0; color: var(--danger); }
.inline-success { margin: 0; color: var(--success); }
.pill-mobile { display: none; }

/* ============================================================
   AUTH / HOME
   ============================================================ */
.home-auth-shell {
    min-height: calc(100dvh - 8rem);
    display: grid;
    place-items: center;
    padding: clamp(1rem, 2vw, 1.75rem) 0 clamp(2rem, 4vw, 3rem);
}
.home-auth-panel {
    width: min(100%, 72rem);
    display: grid;
}
.home-auth-logo { width: min(14rem, 55vw); }

.login-stage {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(22rem, 0.88fr);
    border: 1px solid var(--login-stage-border);
    border-radius: 1.6rem;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.18));
    box-shadow: var(--login-stage-shadow);
    backdrop-filter: blur(18px);
    animation: login-stage-enter 420ms ease both;
}
.login-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.28), transparent 30%),
        radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.22), transparent 34%);
    pointer-events: none;
}

.login-stage-hero,
.login-form-card {
    position: relative;
    z-index: 1;
}

.login-stage-hero {
    display: grid;
    align-content: space-between;
    gap: clamp(1.25rem, 2vw, 2rem);
    padding: clamp(1.5rem, 3.2vw, 3rem);
    background: var(--login-hero-bg);
    color: #f6fffd;
}
.login-stage-hero::after {
    content: "";
    position: absolute;
    right: -6rem;
    bottom: -6rem;
    width: 18rem;
    height: 18rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.24), transparent 68%);
}

.login-brand-lockup {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.login-brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.95rem 1.1rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(16px);
}
.login-brand-logo {
    width: min(11rem, 42vw);
    filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.14));
}
.login-brand-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-card {
    width: min(95vw, 520px);
    display: grid;
    gap: 0.75rem;
    /* card base applicato sopra */
}
.auth-card h2 { margin: 0; font-family: var(--font-heading); }

.auth-card-login  { width: 100%; padding: 1.25rem; }
.auth-card-header { display: grid; gap: 0.45rem; }

.auth-page-title,
.home-page-title { margin: 0; }

.login-hero-copy {
    display: grid;
    gap: 0.75rem;
    max-width: 32rem;
}
.login-hero-copy .auth-kicker { color: rgba(244, 255, 252, 0.78); }
.login-hero-title {
    font-size: clamp(2.2rem, 4.8vw, 4rem);
    line-height: 0.95;
    max-width: 10ch;
}
.login-hero-text {
    margin: 0;
    color: rgba(244, 255, 252, 0.82);
    font-size: 1rem;
    max-width: 28rem;
}
.login-hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
}
.login-hero-stat {
    display: grid;
    gap: 0.4rem;
    padding: 1rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    animation: login-stat-enter 580ms ease both;
}
.login-hero-stat:nth-child(2) { animation-delay: 80ms; }
.login-hero-stat:nth-child(3) { animation-delay: 160ms; }
.login-hero-stat strong {
    font-size: 0.94rem;
    font-weight: 700;
}
.login-hero-stat span {
    color: rgba(244, 255, 252, 0.78);
    font-size: 0.88rem;
}

.auth-help  { margin: 0; color: var(--text-muted); }
.auth-label { display: block; margin-top: 0.5rem; margin-bottom: 0.2rem; font-size: 0.9rem; }
.auth-input { padding: 0.5rem; /* width:100% e resto dal form-control base */ }

.login-form-card {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: clamp(1.4rem, 3vw, 2.4rem);
    gap: 1.15rem;
    align-content: start;
    background: var(--login-form-surface);
    border: 0;
    border-left: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
    backdrop-filter: blur(20px);
}
.login-form-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.login-form-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 15%, var(--surface));
    color: var(--accent-strong);
    font-weight: 700;
}
.login-form-status {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.login-form-header {
    display: grid;
    gap: 0.55rem;
}
.login-form-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    line-height: 1.02;
}
.login-form-copy { max-width: 28rem; }
.login-form {
    display: grid;
    gap: 1rem;
}
.login-validation-summary {
    margin: 0;
    padding: 0.9rem 1rem 0.9rem 1.15rem;
    border-radius: 1rem;
    border: 1px solid color-mix(in srgb, var(--danger) 28%, var(--border));
    background: color-mix(in srgb, var(--danger) 8%, var(--surface));
    color: var(--danger);
}
.login-validation-summary:empty { display: none; }
.login-validation-summary li + li { margin-top: 0.35rem; }
.login-field-group {
    display: grid;
    gap: 0.45rem;
}
.login-field-label {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.login-input-shell {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.3rem 0.85rem;
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
    border-radius: 1rem;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--surface) 80%, #ffffff),
        color-mix(in srgb, var(--surface-elevated) 92%, var(--surface))
    );
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
    transition: transform 140ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.login-input-shell:focus-within {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}
.login-input-icon {
    flex: 0 0 2.4rem;
    width: 2.4rem;
    height: 2.4rem;
    display: grid;
    place-items: center;
    border-radius: 0.8rem;
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    color: var(--accent-strong);
}
.login-input-icon svg {
    width: 1.1rem;
    height: 1.1rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.login-input {
    border: 0;
    background: transparent;
    padding: 0.8rem 0;
    box-shadow: none;
    min-width: 0;
}
.login-input:focus { outline: none; }
.login-input::placeholder { color: color-mix(in srgb, var(--text-muted) 72%, transparent); }
.login-error-alert {
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    border: 1px solid color-mix(in srgb, var(--danger) 28%, var(--border));
    background: color-mix(in srgb, var(--danger) 9%, var(--surface));
    font-weight: 600;
}

.auth-actions {
    margin-top: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.login-actions {
    margin-top: 0.2rem;
    display: grid;
    gap: 0.75rem;
}
.auth-actions.login-actions button { width: 100%; }
.login-primary-action,
.login-secondary-action {
    min-height: 3.2rem;
    border-radius: 1rem;
    font-weight: 700;
    transition: transform 140ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}
.login-primary-action {
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent-strong) 72%, #082f49));
    color: #f7fffc;
    box-shadow: 0 18px 30px rgba(15, 118, 110, 0.22);
}
.login-primary-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 20px 36px rgba(15, 118, 110, 0.28);
}
.login-secondary-action { background: transparent; }
.login-secondary-action:hover {
    border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
    background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.login-footer-note {
    padding-top: 0.3rem;
    border-top: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
}
.login-form-note {
    margin: 0;
    font-size: 0.92rem;
}
.auth-session-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

/* width:100% su mobile — si resetta a "auto" a ≥480px */
.auth-actions button,
.auth-session-actions button { width: 100%; }

@keyframes login-stage-enter {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes login-stat-enter {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1023px) {
    .login-stage { grid-template-columns: 1fr; }
    .login-form-card {
        border-left: 0;
        border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
    }
    .login-hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 639px) {
    .home-auth-shell {
        min-height: auto;
        place-items: start center;
        padding-top: 0.75rem;
    }
    .login-stage { border-radius: 1.2rem; }
    .login-stage-hero,
    .login-form-card { padding: 1.25rem; }
    .login-brand-lockup {
        flex-direction: column;
        align-items: flex-start;
    }
    .login-brand-logo { width: min(10rem, 58vw); }
    .login-hero-title {
        font-size: clamp(2rem, 12vw, 2.8rem);
        max-width: none;
    }
    .login-hero-stats { grid-template-columns: 1fr; }
    .login-form-topbar { align-items: flex-start; }
}

.home-lead {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 1rem;
}
.home-brand-lockup { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.home-lead-logo    { width: min(11rem, 34vw); flex-shrink: 0; }
.home-lead-copy    { display: grid; gap: 0.35rem; }
.home-lead-copy p  { margin: 0; max-width: 58rem; }

.home-role-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    color: var(--accent-strong);
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ============================================================
   CALENDAR
   ============================================================ */
/* Padding override sulla base card */
.calendar-shell { padding: 0.8rem; }

.calendar-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}
.calendar-toolbar-actions { display: flex; flex-direction: column; gap: 0.6rem; }

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.month-nav h2 { margin: 0; font-size: 1.1rem; text-transform: capitalize; }

.calendar-scope-toggle,
.view-toggle { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.calendar-scope-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.8rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.calendar-scope-banner p { margin: 0.2rem 0 0; }

.view-active {
    background: color-mix(in srgb, var(--accent) 20%, var(--surface-elevated));
    border-color: var(--accent);
}

.shift-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.shift-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.shift-legend i    { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 999px; }

/* Conflict alert */
.conflict-alert {
    border: 1px solid color-mix(in srgb, var(--danger) 50%, var(--border));
    background: color-mix(in srgb, var(--danger) 8%, var(--surface));
    border-radius: 0.6rem;
    margin-bottom: 0.8rem;
}
.conflict-toggle {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 0.7rem;
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}
.conflict-list { margin: 0; padding: 0 0.7rem 0.7rem; list-style: none; }
.conflict-item {
    border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
    padding: 0.6rem 0;
    display: grid;
    gap: 0.35rem;
}

.severity-error   { color: var(--danger); }
.severity-warning { color: var(--warning); }

/* Month grid */
.month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
}
.month-header { text-align: center; font-weight: 700; color: var(--text-muted); font-size: 0.82rem; }
.month-cell {
    min-height: 5.8rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    padding: 0.35rem;
    background: var(--surface-elevated);
    cursor: pointer;
    touch-action: manipulation;
}
.month-cell-muted { opacity: 0.55; }
.day-number { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.25rem; }
.day-shifts { display: flex; flex-direction: column; gap: 0.25rem; }

.shift-pill {
    border: 0;
    color: #fff;
    border-radius: 999px;
    padding: 0.28rem 0.45rem;
    text-align: left;
    font-size: 0.72rem;
    cursor: pointer;
    min-height: 1.35rem;
}
.shift-pill-selected {
    box-shadow:
        0 0 0 2px var(--surface),
        0 0 0 4px color-mix(in srgb, var(--accent) 55%, transparent);
}

/* Leave pills */
.day-leaves {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    margin-bottom: 0.35rem;
}
.day-leaves .leave-pill { width: 100%; }

.leave-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    max-width: 100%;
    border-radius: 999px;
    padding: 0.22rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    border: 1px solid transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leave-pill-vacation  { background: #cd0404; color: #ffffff; border-color: #b00303; }
.leave-pill-sick      { background: #ffe3dd; color: #8a2f20; border-color: #efb0a5; }
.leave-pill-permission{ background: #fff1d2; color: #825700; border-color: #e6c16f; }
.leave-pill-other     { background: #e8edf3; color: #304252; border-color: #c7d2de; }

/* Week / Day views */
.week-view { display: grid; gap: 0.6rem; }
.week-day-card,
.day-view { border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.7rem; }

.calendar-day-section + .calendar-day-section { margin-top: 0.85rem; }
.calendar-section-title { display: block; margin-bottom: 0.4rem; }
.calendar-leave-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.45rem; }
.calendar-leave-item { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.day-view-item { margin-bottom: 0.4rem; list-style: none; }

.week-day-card ul,
.day-view ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.45rem; }

.calendar-shift-row {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text);
    border-radius: 0.55rem;
    padding: 0.55rem 0.7rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 0.6rem;
}
.calendar-shift-row strong { width: 100%; font-size: 0.92rem; }
.calendar-shift-row-selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--surface-elevated));
}

.day-view-dot { width: 0.55rem; height: 0.55rem; border-radius: 999px; }

/* ============================================================
   SWAP
   ============================================================ */
.swap-layout { display: grid; gap: 0.8rem; margin-top: 0.9rem; }
.swap-panel  { display: grid; gap: 0.75rem; /* card base applicato sopra */ }

.swap-panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: start;
    justify-content: space-between;
    gap: 0.6rem;
}
.swap-panel-header h3 { margin: 0 0 0.2rem; font-family: var(--font-heading); }
.swap-panel-header p  { margin: 0; }

.swap-selection-grid { display: grid; gap: 0.6rem; }

.swap-selection-card {
    border: 1px dashed var(--border);
    border-radius: 0.7rem;
    padding: 0.75rem;
    background: var(--surface-elevated);
    display: grid;
    gap: 0.3rem;
}
.swap-selection-card.is-selected {
    border-style: solid;
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--surface-elevated));
}
.swap-selection-card p,
.swap-selection-card strong,
.swap-request-note { margin: 0; }

.swap-selection-label,
.swap-request-shift-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.swap-note-field { display: grid; gap: 0.25rem; font-size: 0.9rem; }
.swap-actions    { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.swap-request-list { display: grid; gap: 0.65rem; }
.swap-request-card {
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    background: var(--surface-elevated);
    padding: 0.75rem;
    display: grid;
    gap: 0.55rem;
}
.swap-request-top  { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.65rem; }
.swap-request-kind { font-weight: 600; }
.swap-request-body { display: grid; gap: 0.5rem; }
.swap-request-shift{ display: grid; gap: 0.2rem; }
.swap-request-note { color: var(--text-muted); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: grid;
    place-items: center;
    z-index: 80;
}
.modal-card {
    width: min(96vw, 560px);
    max-height: calc(100vh - 1.5rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    padding: 0.8rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}
.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.modal-body {
    display: grid;
    gap: 0.65rem;
    margin: 0.7rem 0;
    overflow-y: auto;
    padding-right: 0.15rem;
}
.modal-body label { display: grid; gap: 0.25rem; font-size: 0.9rem; }

.danger { border-color: var(--danger); color: var(--danger); }

.template-preview { display: flex; align-items: center; gap: 0.45rem; margin: 0; color: var(--text-muted); }
.template-color-dot { width: 0.7rem; height: 0.7rem; border-radius: 999px; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-shell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 0.9rem;
    box-shadow: var(--shadow);
}

.dashboard-header {
    display: flex;
    flex-wrap: wrap;
    align-items: start;
    justify-content: space-between;
    gap: 0.9rem;
    margin-bottom: 0.9rem;
}
.dashboard-header h2 { margin: 0.15rem 0 0.35rem; text-transform: capitalize; }
.dashboard-header p  { margin: 0; }

.dashboard-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }

/* .dashboard-cell-add condivide border/bg/color/border-radius/cursor
   con .dashboard-actions button tramite il button-base sopra — qui solo
   le proprietà specifiche della cella. */
.dashboard-cell-add {
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-weight: 400;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.dashboard-cell:hover .dashboard-cell-add { opacity: 1; }

.dashboard-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 0.7rem;
    margin-bottom: 0.9rem;
}
.dashboard-summary-card {
    display: grid;
    gap: 0.25rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    padding: 0.8rem;
}
.dashboard-summary-card strong { font-size: 1.5rem; line-height: 1; }
.dashboard-summary-label { color: var(--text-muted); font-size: 0.82rem; }

/* Table scroll wrapper */
.dashboard-table-scroll {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: auto;
    max-height: none;
    border: 1px solid #ddd;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.dashboard-table-scroll::-webkit-scrollbar { width: 0; height: 0; }

/* Grid table */
.dashboard-grid { width: max-content; min-width: max-content; border-collapse: collapse; }
.dashboard-grid th,
.dashboard-grid td { border: 1px solid var(--border); padding: 0; text-align: center; }
.dashboard-grid thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-soft);
    font-weight: 700;
}
.dashboard-grid thead th:last-child,
.dashboard-grid tbody td:last-child { border-right: 0; }
.dashboard-grid tbody tr:last-child th,
.dashboard-grid tbody tr:last-child td { border-bottom: 0; }

.dashboard-sticky-col {
    position: sticky;
    left: 0;
    z-index: 4;
    background: var(--surface) !important;
    border-right: 2px solid var(--text) !important;
}
.dashboard-sticky-col-right {
    position: sticky;
    right: 0;
    z-index: 4;
    background: var(--surface) !important;
    border-left: 2px solid var(--text) !important;
}
.dashboard-grid tbody tr:nth-child(even) td {
    background: color-mix(in srgb, var(--bg-soft) 25%, var(--surface-elevated));
}

/* Staff column */
.dashboard-staff-col {
    min-width: var(--dashboard-staff-col-width);
    max-width: var(--dashboard-staff-col-width);
    padding: 0.2rem 0.5rem !important;
    text-align: left !important;
    font-size: 0.85rem;
}
.dashboard-staff-name { display: block; font-weight: 700; white-space: nowrap; }

/* Hours badge */
.dashboard-hours-badge { display: inline-flex; font-size: 0.75rem; font-weight: 700; }
.dashboard-hours-badge.is-ok      { color: var(--success); }
.dashboard-hours-badge.is-warning { color: var(--warning); }
.dashboard-hours-badge.is-limit   { color: var(--danger); }

/* Day header + cell: dimensioni condivise */
.dashboard-day-header,
.dashboard-cell {
    width: var(--dashboard-day-cell-width);
    min-width: var(--dashboard-day-cell-width);
}
.dashboard-day-header {
    height: var(--dashboard-day-cell-width);
    padding: 0;
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.1;
}
.dashboard-day-header span  { font-weight: 700; }
.dashboard-day-header small {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.dashboard-hours-header { min-width: 4.5rem; font-size: 0.85rem; vertical-align: middle; }

.dashboard-cell {
    height: var(--dashboard-day-cell-width);
    background: var(--surface-elevated);
    vertical-align: middle;
    cursor: cell;
    transition: background-color 0.1s;
}
.dashboard-cell:hover     { background: color-mix(in srgb, var(--bg-soft) 20%, var(--surface-elevated)); }
.dashboard-cell.weekend   { background: color-mix(in srgb, var(--bg-soft) 45%, var(--surface-elevated)); }
.dashboard-cell.has-shifts{ background: color-mix(in srgb, var(--accent) 4%, var(--surface-elevated)); }
.dashboard-cell.has-leave { background: color-mix(in srgb, var(--warning) 8%, var(--surface-elevated)); }

.dashboard-cell-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    width: 100%;
    height: 100%;
}

.dashboard-shift-chip,
.dashboard-cell-content .leave-pill {
    border: 0;
    color: #ffffff;
    border-radius: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dashboard-shift-chip               { font-size: 0.85rem; }
.dashboard-cell-content .leave-pill { font-size: 0.75rem; }

/* -------------------------------------------------------
   Sticky right summary columns
   Base comune: position/background/z-index/padding/text/border.
   Ogni variante sovrascrive solo right + width.
   ------------------------------------------------------- */
.dashboard-totale-header, .dashboard-totale-cell,
.dashboard-diff-header,   .dashboard-diff-cell,
.dashboard-reso-header,   .dashboard-reso-cell,
.dashboard-dovute-header, .dashboard-dovute-cell {
    position: sticky;
    background: #f8f9fa;
    z-index: 5;
    padding: 0 3px;
    text-align: center;
    font-size: 0.75rem;
    border-left: 1px solid #ddd !important;
}

.dashboard-totale-header, .dashboard-totale-cell {
    right: 0;
    width: var(--dashboard-summary-col-width);
    min-width: var(--dashboard-summary-col-width);
    max-width: var(--dashboard-summary-col-width);
}
.dashboard-diff-header, .dashboard-diff-cell {
    right: var(--dashboard-summary-col-width);
    width: var(--dashboard-summary-col-width);
    min-width: var(--dashboard-summary-col-width);
    max-width: var(--dashboard-summary-col-width);
}
.dashboard-reso-header, .dashboard-reso-cell {
    right: calc(var(--dashboard-summary-col-width) * 2);
    width: var(--dashboard-summary-col-width);
    min-width: var(--dashboard-summary-col-width);
    max-width: var(--dashboard-summary-col-width);
}
.dashboard-dovute-header, .dashboard-dovute-cell {
    right: calc(var(--dashboard-summary-col-width) * 3);
    width: var(--dashboard-summary-dovute-width);
    min-width: var(--dashboard-summary-dovute-width);
    max-width: var(--dashboard-summary-dovute-width);
    padding: 0 2px;
    border-left: 2px solid #ccc !important;
}

/* Thead sticky columns: z-index più alto */
.dashboard-grid thead th.dashboard-totale-header,
.dashboard-grid thead th.dashboard-diff-header,
.dashboard-grid thead th.dashboard-reso-header,
.dashboard-grid thead th.dashboard-dovute-header { z-index: 15; }

/* Dovute: input inline */
.dashboard-dovute-input-cell {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
    padding: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}
.dashboard-dovute-input-cell::-webkit-outer-spin-button,
.dashboard-dovute-input-cell::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dashboard-dovute-input-cell:focus { outline: none; background: var(--surface-elevated); }

/* Dovute toolbar */
.dashboard-dovute-toolbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.9rem;
    width: fit-content;
    max-width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: color-mix(in srgb, var(--surface-elevated) 88%, var(--bg-soft));
}
.dashboard-dovute-toolbar label { font-size: 0.85rem; font-weight: 600; color: var(--text); }

.dashboard-dovute-input {
    width: 4.4rem;
    min-height: 2.25rem;
    padding: 0.2rem 0.45rem;
    border: 1px solid color-mix(in srgb, var(--border) 78%, var(--accent) 22%);
    border-radius: 0.45rem;
    text-align: center;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
    transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}
.dashboard-dovute-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
    outline: none;
}

html[data-theme="dark"] .dashboard-dovute-toolbar {
    background: color-mix(in srgb, var(--surface-elevated) 92%, var(--bg));
}
html[data-theme="dark"] .dashboard-dovute-input {
    background: color-mix(in srgb, var(--surface) 82%, #08111f);
    border-color: color-mix(in srgb, var(--border) 62%, var(--accent) 38%);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Dashboard flex layout: colonna su mobile, riga a ≥1280px */
.dashboard-flex-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-top: 1rem;
    overflow: hidden;
    max-height: none;
}

/* Presence grid */
.dashboard-presence-shell {
    min-width: max-content;
    margin-top: 0;
    border-top: 1px solid #8fbc8f;
    background: #eef7df;
}
.dashboard-presence-grid {
    width: max-content;
    min-width: max-content;
    border-collapse: collapse;
    color: #16361f;
    font-size: 0.82rem;
}
.dashboard-presence-grid th,
.dashboard-presence-grid td { border: 1px solid #8fbc8f; padding: 0.2rem 0.35rem; text-align: center; }

.dashboard-presence-label {
    min-width: var(--dashboard-staff-col-width);
    max-width: var(--dashboard-staff-col-width);
    background: #cfe8bd;
    font-family: var(--font-body);
    font-weight: 700;
    text-align: left;
    white-space: normal;
    line-height: 1.15;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem !important;
}
.dashboard-presence-value {
    width: var(--dashboard-day-cell-width);
    min-width: var(--dashboard-day-cell-width);
    background: #f8fff1;
    font-weight: 700;
}
.dashboard-presence-value.weekend { background: #edf6e0; }

/* Legend side panel */
.dashboard-legend-side {
    flex-shrink: 0;
    align-self: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: none;
    z-index: 20;
    background: var(--surface);
    box-shadow: none;
}

.excel-legend {
    position: sticky;
    top: 0;
    border-collapse: collapse;
    background-color: #fbefcc;
    font-size: 0.82rem;
    color: #000;
    width: 210px;
}
.excel-legend th,
.excel-legend td { border: 1px solid #f6b26b; padding: 2px 6px; }
.excel-legend thead th {
    background-color: #fbefcc;
    text-align: center;
    padding: 10px 0;
    font-size: 1.1rem;
    font-weight: 700;
}
.excel-legend .code { font-weight: 700; text-align: center; width: 45px; }
.excel-legend tbody tr td:last-child { text-align: left; }
.excel-legend .legend-section-row td { background: #f7deb1; font-weight: 700; text-align: left; }
.excel-legend .legend-note-row td   { background: #fff7e6; font-size: 0.75rem; line-height: 1.35; }

/* ============================================================
   NURSES / STAFF
   ============================================================ */
.nurses-toolbar,
.users-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}
.nurses-toolbar label,
.users-toolbar label { display: grid; gap: 0.25rem; font-size: 0.9rem; }

.nurses-grid { display: grid; gap: 0.8rem; }

/* card base applicato sopra per .nurses-list-card, .nurse-editor-card */

.nurses-table,
.users-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.nurses-table th, .nurses-table td,
.users-table th,  .users-table td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 0.45rem;
}
.users-table th, .users-table td { vertical-align: top; }

.nurse-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.pager-row {
    margin-top: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.nurse-editor-card h2 { margin-top: 0; font-family: var(--font-heading); }
.nurse-editor-card form  { display: grid; gap: 0.6rem; }
.nurse-editor-card label { display: grid; gap: 0.2rem; }

.nurse-editor-modal { width: min(96vw, 620px); }
.editor-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ============================================================
   USERS / ROLES / STATUS
   ============================================================ */
.roles-grid { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; }
.roles-grid legend { width: 100%; font-weight: 600; margin-bottom: 0.25rem; }
.role-option { font-size: 0.85rem; }

.status-badge { display: inline-block; padding: 0.2rem 0.45rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.status-success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.status-warning { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.status-danger  { background: color-mix(in srgb, var(--danger) 15%, transparent);  color: var(--danger); }

.user-editor-modal { width: min(96vw, 620px); }
.user-editor-modal fieldset { border: 1px solid var(--border); border-radius: 0.45rem; padding: 0.55rem; margin: 0; }

/* ============================================================
   SETTINGS — RULES & TEMPLATES
   ============================================================ */
.scheduling-note h2,
.rules-card h2,
.templates-card h2 { margin-top: 0; font-family: var(--font-heading); }
.scheduling-note p { margin: 0; color: var(--text-muted); }

.rules-grid { display: grid; gap: 0.6rem; }
.rules-grid label { display: grid; gap: 0.25rem; font-size: 0.9rem; }
.rules-actions { margin-top: 0.7rem; }

.templates-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.templates-table th,
.templates-table td { border-bottom: 1px solid var(--border); text-align: left; padding: 0.45rem; vertical-align: top; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.responsive-table td[data-label]::before { content: none; }

/* ============================================================
   LEAVE SUMMARY
   ============================================================ */
.leave-summary-grid { display: grid; gap: 0.8rem; margin-bottom: 0.8rem; }
/* .leave-summary-card: card base applicato sopra */
.leave-summary-card { display: grid; gap: 0.35rem; }
.leave-summary-card strong { font-size: 1.6rem; line-height: 1; }
.leave-summary-card p { margin: 0; color: var(--text-muted); }
.leave-period { display: grid; gap: 0.15rem; }

/* ============================================================
   CHECKBOX
   ============================================================ */
.checkbox-row { display: inline-flex; align-items: center; gap: 0.35rem; }

/* ============================================================
   WARMUP SCREEN
   ============================================================ */
.warmup-screen { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
/* .warmup-card: card base applicato sopra, solo override */
.warmup-card { display: grid; gap: 0.85rem; width: min(94vw, 520px); padding: 1.2rem; }
.warmup-card h1 { margin: 0; font-family: var(--font-heading); }
.warmup-logo { width: min(11rem, 48vw); }
.warmup-lead, .warmup-support, .warmup-retry-note { margin: 0; }
.warmup-support { color: var(--text-muted); }

.warmup-progress {
    width: 100%;
    background: var(--bg-soft);
    border-radius: 999px;
    overflow: hidden;
    height: 0.65rem;
}
.warmup-status { display: grid; gap: 0.35rem; }
.warmup-status-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.32rem 0.65rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border));
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 700;
}
.warmup-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    animation: pulse 1.2s infinite ease-in-out;
    transition: width 200ms ease;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes notification-panel-enter {
    from { opacity: 0; transform: translateY(-0.4rem) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulse {
    0%   { filter: brightness(0.85); }
    50%  { filter: brightness(1.15); }
    100% { filter: brightness(0.85); }
}

/* ============================================================
   RESPONSIVE — mobile-first defaults (fuori da media query)
   ============================================================ */
.nurses-toolbar > label,
.users-toolbar > label,
.nurses-toolbar > button,
.users-toolbar > button,
.rules-actions > button { width: 100%; }

.view-toggle button { flex: 1 1 calc(33.33% - 0.3rem); }

/* ============================================================
   RESPONSIVE — max-width: 767px
   ============================================================ */
@media (max-width: 767px) {
    .home-lead         { flex-direction: column; align-items: stretch; }
    .home-brand-lockup { flex-direction: column; align-items: flex-start; }
    .home-lead-logo    { width: min(10rem, 52vw); }

    .auth-session-actions { width: 100%; }
    .home-role-pill { justify-content: center; width: 100%; }

    .dashboard-header,
    .dashboard-actions { width: 100%; }
    .dashboard-actions button { flex: 1 1 calc(33.33% - 0.3rem); }

    .dashboard-shell {
        --dashboard-staff-col-width: calc(11rem + 2cm);
        --dashboard-day-cell-width: 4.1rem;
    }

    .calendar-toolbar         { gap: 0.65rem; }
    .calendar-toolbar-actions { width: 100%; }
    .month-nav h2   { font-size: 1rem; }
    .month-nav button { min-width: 3.2rem; }
    .day-view-item  { grid-template-columns: auto 1fr; }

    .modal-footer {
        border-top: 1px solid var(--border);
        padding-top: 0.6rem;
        flex-wrap: wrap;
    }
    .modal-footer button { flex: 1 1 100%; }

    /* Responsive table → card layout */
    .responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td,
    .responsive-table th { display: block; width: 100%; }
    .responsive-table thead { display: none; }
    .responsive-table tr {
        border: 1px solid var(--border);
        border-radius: 0.65rem;
        padding: 0.6rem;
        margin-bottom: 0.65rem;
        background: var(--surface-elevated);
    }
    .responsive-table td {
        border: 0;
        padding: 0.25rem 0;
        display: grid;
        grid-template-columns: minmax(7.2rem, 42%) minmax(0, 1fr);
        gap: 0.5rem;
        align-items: start;
    }
    .responsive-table td[data-label]::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-weight: 600;
        font-size: 0.82rem;
        line-height: 1.35;
    }
    .responsive-table td.cell-actions { grid-template-columns: 1fr; gap: 0.35rem; }
    .responsive-table td.cell-actions::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-weight: 600;
        font-size: 0.82rem;
    }

    .nurse-actions { width: 100%; }
    .nurse-actions button,
    .users-table button,
    .templates-table button { width: 100%; }
    .pager-row { justify-content: center; }
}

/* ============================================================
   RESPONSIVE — max-width: 479px
   ============================================================ */
@media (max-width: 479px) {
    .notification-panel {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 5.35rem);
        right: 0.75rem;
        left: 0.75rem;
        width: auto;
        max-height: calc(100dvh - 6.1rem);
        transform-origin: top center;
    }
    .notification-panel-header { flex-direction: column; align-items: stretch; }
    .notification-panel-actions { width: 100%; flex-direction: column; }
    .notification-panel-header button { width: 100%; }
    .notification-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.2rem; scrollbar-width: thin; }
    .notification-filter  { flex: 0 0 auto; }

    .dashboard-shell { padding: 0.7rem; }
    .dashboard-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-summary-card strong { font-size: 1.25rem; }

    .month-grid   { gap: 0.2rem; }
    .month-header { font-size: 0.72rem; }
    .month-cell   { min-height: 4.8rem; padding: 0.2rem; }
    .day-number   { font-size: 0.76rem; margin-bottom: 0.18rem; }
    .shift-pill   { width: 0.7rem; height: 0.7rem; border-radius: 999px; padding: 0; min-height: 0; }
    .pill-desktop { display: none; }
    .pill-mobile  { display: inline-block; }
    .link-button  { font-size: 0.72rem; }
}

/* ============================================================
   RESPONSIVE — sm ≥ 480px
   ============================================================ */
@media (min-width: 480px) {
    /* Toolbar labels/buttons: ripristino larghezza auto */
    .nurses-toolbar > label,
    .users-toolbar > label,
    .nurses-toolbar > button,
    .users-toolbar > button,
    .rules-actions > button,
    .auth-actions button,
    .auth-session-actions button { width: auto; }

    .calendar-shell { padding: 1rem; }
}

/* ============================================================
   RESPONSIVE — md ≥ 768px
   ============================================================ */
@media (min-width: 768px) {
    .app-main { padding: 1.25rem; }

    /* Nav: hamburger → barra orizzontale */
    .nav-toggle   { display: none; }
    .nav-content  { display: flex; }

    .nav-links {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.2rem;
        scrollbar-width: thin;
    }
    .nav-links > * { flex: 0 0 auto; }
    .nav-links a   { justify-content: center; white-space: nowrap; }

    .nav-utilities { justify-content: flex-end; width: auto; }

    .calendar-toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
    .calendar-toolbar-actions { flex-direction: row; align-items: center; justify-content: flex-end; }
    .month-cell { min-height: 7rem; }

    .swap-selection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .swap-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }

    .nurses-grid { grid-template-columns: minmax(0, 1fr); align-items: start; }

    .users-table th:nth-child(1),
    .users-table td:nth-child(1) { min-width: 220px; }

    .rules-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .leave-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ============================================================
   RESPONSIVE — lg ≥ 1024px
   ============================================================ */
@media (min-width: 1024px) {
    .app-main { max-width: 100%; margin: 0; padding: 1rem; }
}

/* ============================================================
   RESPONSIVE — xl ≥ 1280px
   ============================================================ */
@media (min-width: 1280px) {
    .app-main { max-width: 100%; }

    /* Dashboard flex: colonna → riga */
    .dashboard-flex-layout {
        flex-direction: row;
        max-height: 75vh;
    }
    .dashboard-table-scroll,
    .dashboard-legend-side { max-height: 100%; }
    .dashboard-legend-side { box-shadow: -2px 0 5px rgba(0, 0, 0, 0.05); }
}

/* ============================================================
   ACCESSIBILITY — reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .login-stage,
    .login-hero-stat,
    .notification-trigger,
    .notification-panel { transition: none; animation: none; }
}
