/* Custom styles for NexioDesk */

:root {
    --primary-color: #0086c9;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
}

body {
    background-color: var(--light-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html, body {
    height: 100%;
}

body:has(.app-layout) {
    overflow: hidden;
}

/* NexioDesk application shell */
.app-layout {
    display: flex;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

.app-sidebar {
    width: 260px;
    background: #0f2347;
    color: #d6deed;
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-logo {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 14px;
    padding: 10px 8px 16px;
}

.sidebar-logo::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 72px;
    transform: translateY(-55%);
    background: radial-gradient(ellipse at 28% 50%, rgba(34, 211, 238, 0.16) 0%, rgba(99, 102, 241, 0.08) 45%, transparent 72%);
    pointer-events: none;
    animation: sidebar-logo-glow 6s ease-in-out infinite;
}

.sidebar-logo::after {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.45), rgba(129, 140, 248, 0.35), transparent);
    opacity: 0.85;
}

.sidebar-logo a {
    position: relative;
    z-index: 1;
    display: inline-flex;
    text-decoration: none;
}

.sidebar-logo .brand-logo--fx svg {
    height: 34px;
    filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.35)) drop-shadow(0 0 22px rgba(99, 102, 241, 0.18));
}

@keyframes sidebar-logo-glow {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 1; }
}

.logo-dot {
    width: 10px;
    height: 10px;
    background: #19d667;
    border-radius: 2px;
    transform: rotate(45deg);
}

.logo-text {
    letter-spacing: 0.2px;
}

/* NexioDesk brand logo */
.brand-logo {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}

.brand-logo svg {
    display: block;
    width: auto;
    height: 28px;
}

.brand-logo--sm svg {
    height: 24px;
}

.brand-logo--md svg {
    height: 28px;
}

.brand-logo--lg svg {
    height: 36px;
}

.brand-logo--xl svg {
    height: 44px;
}

.brand-logo--hero svg {
    height: 64px;
}

.brand-logo--dark {
    color: #1a1a1b;
}

.brand-logo--light {
    color: #ffffff;
}

.brand-logo--fx svg {
    overflow: visible;
    filter: drop-shadow(0 4px 18px rgba(0, 134, 201, 0.28));
}

.brand-logo--fx .logo-icon {
    transform-origin: 18px 18px;
    animation: brand-logo-pulse 4s ease-in-out infinite;
}

@keyframes brand-logo-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.login-brand {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 1.75rem 0 2rem;
    margin-bottom: 0.25rem;
}

.login-brand::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 220px;
    height: 120px;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse at center, rgba(34, 211, 238, 0.22) 0%, rgba(0, 134, 201, 0.12) 40%, transparent 72%);
    pointer-events: none;
    animation: login-brand-glow 5s ease-in-out infinite;
}

.login-brand::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0.5rem;
    width: 140px;
    height: 2px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(0, 134, 201, 0.55), rgba(99, 102, 241, 0.45), transparent);
    border-radius: 999px;
    opacity: 0.7;
}

.login-brand .brand-logo {
    position: relative;
    z-index: 1;
    justify-content: center;
    margin: 0 auto;
}

.login-brand .brand-logo svg {
    margin: 0 auto;
}

@keyframes login-brand-glow {
    0%, 100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

/* ============================================================
   Page loader — card compatta con logo
   ============================================================ */
.page-loader {
    position: fixed;
    top: 18px;
    left: 50%;
    z-index: 9999;
    transform: translateX(-50%) translateY(-12px);
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.page-loader.is-active {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.page-loader__content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1.15rem 0.95rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 134, 201, 0.18);
    border-radius: 14px;
    box-shadow: 0 10px 32px rgba(15, 35, 71, 0.14);
    backdrop-filter: blur(8px);
}

.page-loader__content::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(ellipse at 50% 0%, rgba(34, 211, 238, 0.1) 0%, transparent 65%);
    pointer-events: none;
}

.page-loader__content .brand-logo {
    position: relative;
    z-index: 1;
}

.page-loader__content .brand-logo--md svg {
    height: 26px;
}

.page-loader__track {
    position: relative;
    z-index: 1;
    width: 120px;
    height: 3px;
    border-radius: 999px;
    background: rgba(0, 134, 201, 0.12);
    overflow: hidden;
}

.page-loader__bar {
    width: 45%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22d3ee, #0086c9, #6366f1);
    animation: page-loader-bar 1s ease-in-out infinite;
}

@keyframes page-loader-bar {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(260%); }
}

/* ============================================================
   PWA — banner installazione app
   ============================================================ */
.pwa-install-banner {
    position: fixed;
    left: 50%;
    bottom: 20px;
    z-index: 1080;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    width: min(520px, calc(100vw - 24px));
    padding: 14px 16px;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 134, 201, 0.22);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(15, 35, 71, 0.18);
    backdrop-filter: blur(8px);
    animation: pwa-banner-in 0.28s ease-out;
}

@keyframes pwa-banner-in {
    from { transform: translateX(-50%) translateY(16px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.pwa-install-banner__content {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.pwa-install-banner__icon {
    flex-shrink: 0;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 134, 201, 0.2);
}

.pwa-install-banner__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pwa-install-banner__text strong {
    color: #0f2347;
    font-size: 0.95rem;
}

.pwa-install-banner__text span {
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.35;
}

.pwa-install-banner__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.sidebar-search .input-group-text,
.sidebar-search .form-control {
    border-color: #2a4068;
    background: #1b315d;
    color: #fff;
}

.sidebar-search-icon {
    color: #9ec3ff;
}

.sidebar-search-input::placeholder {
    color: #8fa3c4;
}

.sidebar-search-input:focus {
    background: #243a66;
    border-color: #4a7fc4;
    color: #fff;
    box-shadow: none;
}

.sidebar-search-hint {
    display: block;
    margin-top: 4px;
    padding-left: 2px;
    font-size: 0.72rem;
    color: #7e92b3;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 14px;
}

/* Global search results */
.search-page-form {
    max-width: 720px;
}

.search-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.search-type-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.search-results-list {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 35, 71, 0.08);
}

.search-results-list .list-group-item {
    border-color: #e8ebf0;
}

.sidebar-link {
    color: #d6deed;
    text-decoration: none;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.92rem;
}

.sidebar-link i {
    margin-right: 8px;
}

.sidebar-link:hover {
    background: #1b315d;
    color: #fff;
}

.sidebar-link.active {
    background: #1d3c71;
    color: #fff;
}

.sidebar-user {
    margin-top: auto;
    padding: 10px 8px;
}

.sidebar-user-name {
    color: #fff;
    font-weight: 600;
    margin-bottom: 6px;
}

.sidebar-logout {
    color: #9ec3ff;
    text-decoration: none;
    font-size: 0.9rem;
}

.sidebar-invite {
    padding: 8px 6px 2px;
}

.app-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 56px;
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid #e4e8ef;
    flex-shrink: 0;
    z-index: 100;
}

.app-header-burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #1d3c71;
    font-size: 1.4rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.app-header-burger:hover {
    background: #eef3fa;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 35, 71, 0.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.sidebar-backdrop:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
}

.app-header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.app-header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    color: #4a5d78;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.app-header-link:hover {
    background: #eef3fa;
    color: #1d3c71;
    text-decoration: none;
}

.app-header-link.active {
    background: #e8f0fe;
    color: #1d3c71;
}

.app-header-link--icon {
    padding: 8px 10px;
}

.app-header-link--user {
    max-width: 180px;
}

.app-header-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #1d3c71;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .app-header {
        padding: 0 12px;
        gap: 8px;
    }

    .app-header-nav .app-header-link span {
        display: none;
    }

    .app-header-link {
        padding: 8px 10px;
    }
}

.app-main {
    flex: 1;
    background: #f5f7fb;
    padding: 24px 32px;
    overflow: auto;
    min-height: 0;
}

.app-notifications {
    position: relative;
    pointer-events: auto;
}

.app-notifications-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #4a5d78;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.app-notifications-btn:hover {
    background: #eef3fa;
    color: #1d3c71;
}

.app-notifications-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #dc3545;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.app-notifications-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(380px, calc(100vw - 24px));
    max-height: min(480px, calc(100vh - 80px));
    background: #fff;
    border: 1px solid #e4e8ef;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 35, 71, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 300;
}

.app-notifications-panel[hidden] {
    display: none !important;
}

.app-notifications-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #e4e8ef;
}

.app-notifications-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1a2b44;
    flex-shrink: 0;
}

.app-notifications-header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px 10px;
}

.app-notifications-mark-all {
    border: 0;
    background: transparent;
    color: #1d5bb8;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 0;
    cursor: pointer;
    text-align: right;
    line-height: 1.3;
}

.app-notifications-mark-all:hover {
    text-decoration: underline;
}

.app-notifications-mark-all:disabled {
    opacity: 0.45;
    cursor: default;
    text-decoration: none;
}

.app-notifications-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.app-notifications-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    color: inherit;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.12s;
}

.app-notifications-item-link {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px 12px;
    align-items: start;
    text-decoration: none;
    color: inherit;
}

.app-notifications-item:hover {
    background: #f5f8fc;
}

.app-notifications-mark-one {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-top: 4px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #6b7c93;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.app-notifications-mark-one:hover {
    background: #e8f0fe;
    color: #1d5bb8;
}

.app-notifications-item.is-unread {
    background: #f0f6ff;
}

.app-notifications-item.is-unread:hover {
    background: #e8f0fe;
}

.app-notifications-item:not(.is-unread) {
    opacity: 0.85;
}

.app-notifications-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e8f0fe;
    color: #1d5bb8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.app-notifications-item-body {
    min-width: 0;
}

.app-notifications-item-title {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: #1a2b44;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-notifications-item-subtitle {
    display: block;
    font-size: 0.78rem;
    color: #6b7c93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-notifications-item-time {
    font-size: 0.72rem;
    color: #8b9cb3;
    white-space: nowrap;
}

.app-notifications-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 0.9rem;
}

.app-notifications-sentinel {
    height: 1px;
    flex-shrink: 0;
}

.app-notifications-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 16px;
    color: #6b7c93;
    font-size: 0.85rem;
}

.app-notifications-footer {
    padding: 10px 16px;
    border-top: 1px solid #e4e8ef;
    text-align: center;
}

.app-notifications-link {
    font-size: 0.85rem;
    color: #1d5bb8;
    text-decoration: none;
}

.app-notifications-link:hover {
    text-decoration: underline;
}

/* Dashboard: layout a pieno schermo con padding interno proprio */
.app-main:has(.inbox-layout) {
    padding: 0;
}

/* Mail client — layout tipo Gmail / Outlook Web */
.mail-client {
    --mail-border: #e4e8ef;
    --mail-bg: #ffffff;
    --mail-sidebar-bg: #f4f6f9;
    --mail-accent: #0086c9;
    --mail-accent-soft: #e8f4fc;
    --mail-text: #1a2b3c;
    --mail-muted: #6b7c8f;
    --mail-hover: #f0f4f8;
    --mail-active: #e3f2fc;
    --mail-toolbar-h: 56px;

    display: grid;
    grid-template-columns: 232px minmax(280px, 400px) minmax(0, 1fr);
    height: 100%;
    max-height: none;
    background: var(--mail-bg);
    overflow: hidden;
}

/* Sidebar cartelle */
.mail-sidebar {
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    background: var(--mail-sidebar-bg);
    border-right: 1px solid var(--mail-border);
    min-height: 0;
}

/* Toggle sidebar e pulsante "Indietro": solo mobile. */
.mail-sidebar-toggle,
.mail-toolbar-btn--back {
    display: none;
}

.mail-sidebar-backdrop {
    display: none;
}

.mail-sidebar-header {
    padding: 0 4px 16px;
}

.mail-compose-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    border-radius: 24px;
    background: var(--mail-accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 134, 201, 0.35);
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.mail-compose-btn:hover {
    background: #0074ad;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 134, 201, 0.4);
    transform: translateY(-1px);
}

.mail-compose-btn--secondary {
    width: auto;
    padding: 10px 22px;
    margin-top: 8px;
}

.mail-folders {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mail-folder-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 0 20px 20px 0;
    color: var(--mail-text);
    text-decoration: none;
    font-size: 0.9rem;
    margin-right: -12px;
}

.mail-folder-icon {
    width: 20px;
    text-align: center;
    color: var(--mail-muted);
    font-size: 1rem;
}

.mail-folder-link:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mail-folder-link.active {
    background: #d3e8f7;
    color: #0d4a73;
    font-weight: 600;
}

.mail-folder-link.active .mail-folder-icon {
    color: var(--mail-accent);
}

.mail-sidebar-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--mail-border);
}

.mail-sidebar-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mail-muted);
    padding: 0 12px 8px;
}

.mail-mailbox-link,
.mail-mailbox-static {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
}

.mail-mailbox-link:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mail-mailbox-link.active {
    background: var(--mail-accent-soft);
}

.mail-mailbox-dot {
    width: 8px;
    height: 8px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--mail-accent);
    flex-shrink: 0;
}

.mail-mailbox-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mail-mailbox-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--mail-text);
}

.mail-mailbox-email {
    font-size: 0.75rem;
    color: var(--mail-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-unified-hint {
    font-size: 0.72rem;
    color: var(--mail-muted);
    margin: 6px 12px 0;
}

.mail-sidebar-footer {
    margin-top: auto;
    padding: 12px 8px 4px;
}

.mail-sidebar-settings {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--mail-muted);
    text-decoration: none;
}

.mail-sidebar-settings:hover {
    color: var(--mail-accent);
}

/* Pannello elenco */
.mail-list-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    border-right: 1px solid var(--mail-border);
    background: var(--mail-bg);
}

.mail-list-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--mail-border);
    flex-shrink: 0;
}

.mail-list-toolbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mail-list-toolbar-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: 0;
}

.mail-list-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--mail-text);
    white-space: nowrap;
}

.mail-list-count {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.5rem;
    padding: 0 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #0d4a73;
    background: #d3e8f7;
    border-radius: 12px;
    line-height: 1;
}

.mail-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f0f3f7;
    border-radius: 20px;
    margin: 0;
}

.mail-search--full {
    width: 100%;
}

.mail-search i {
    color: var(--mail-muted);
    font-size: 0.85rem;
}

.mail-search-input {
    border: 0;
    background: transparent;
    font-size: 0.85rem;
    flex: 1;
    min-width: 0;
    width: 100%;
    outline: none;
    color: var(--mail-text);
}

.mail-search-input::placeholder {
    color: #9aa8b8;
}

.mail-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--mail-muted);
    text-decoration: none;
    border: 0;
    background: transparent;
    transition: background 0.15s;
}

.mail-icon-btn:hover {
    background: var(--mail-hover);
    color: var(--mail-text);
}

.mail-message-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.mail-list-sentinel {
    height: 1px;
    flex-shrink: 0;
}

.mail-list-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--mail-muted, #5f6368);
    font-size: 0.875rem;
}

.mail-message-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px 12px 20px;
    border-bottom: 1px solid #f0f2f5;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
}

.mail-message-item:hover {
    background: var(--mail-hover);
    box-shadow: inset 1px 0 0 #d0d8e0;
}

.mail-message-item.active {
    background: var(--mail-active);
    box-shadow: inset 3px 0 0 var(--mail-accent);
}

.mail-message-item.is-selected {
    background: #fff8e1;
}

.mail-message-item.is-selected:hover {
    background: #ffeebc;
}

.mail-item-select {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-top: 8px;
}

.mail-item-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--mail-accent, #0086c9);
}

.mail-bulk-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff8e1;
    border: 1px solid #f5d97a;
    border-radius: 8px;
}

.mail-bulk-toolbar[hidden] {
    display: none;
}

.mail-bulk-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--mail-text, #1a2b3c);
    white-space: nowrap;
    margin-right: auto;
}

.mail-bulk-select-all input {
    width: 16px;
    height: 16px;
    accent-color: var(--mail-accent, #0086c9);
    flex-shrink: 0;
}

.mail-bulk-count {
    font-weight: 600;
    color: var(--mail-text, #1a2b3c);
    white-space: nowrap;
}

.mail-bulk-count::after {
    content: ' selezionati';
    font-weight: 400;
    color: var(--mail-muted, #6b7c8f);
    margin-left: 2px;
}

.mail-bulk-toolbar .mail-bulk-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--mail-muted, #6b7c8f);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.mail-bulk-toolbar .mail-bulk-action:hover {
    background: #ffeebc;
    color: var(--mail-text, #1a2b3c);
}

.mail-bulk-toolbar .mail-bulk-action--danger {
    color: #c0392b;
    border-color: #f1c0c0;
    background: #fff;
}

.mail-bulk-toolbar .mail-bulk-action--danger:hover {
    background: #fdecec;
    color: #a93226;
    border-color: #e9a9a9;
}

.mail-bulk-toolbar .mail-bulk-action--icon {
    padding: 6px 8px;
}

.mail-icon-btn--danger {
    color: #c0392b;
}

.mail-icon-btn--danger:hover {
    background: #fdecec;
    color: #a93226;
}

.mail-unread-dot {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mail-accent);
}

.mail-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    background: var(--mail-avatar-bg, var(--mail-accent));
}

.mail-avatar--lg {
    width: 44px;
    height: 44px;
    font-size: 1.05rem;
}

.mail-message-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mail-message-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.mail-message-row-end {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mail-message-attachments {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.mail-message-attachment-icon {
    font-size: 0.95rem;
    color: #5f6368;
    line-height: 1;
}

.mail-message-attachment-icon--pdf {
    color: #d93025;
}

.mail-message-attachment-icon--image {
    color: #1a73e8;
}

.mail-thread-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 5px;
    border-radius: 10px;
    background: #e8eaed;
    color: #3c4043;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
}

.mail-thread-count--header {
    margin-left: 8px;
    vertical-align: middle;
    font-size: 0.78rem;
}

.mail-read-content--thread {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.mail-thread-conversation {
    flex: 1;
    min-height: 0;
    padding: 0 0 16px;
}

.mail-thread-message {
    border-bottom: 1px solid var(--mail-border);
}

.mail-thread-message-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.mail-thread-message-header:hover {
    background: var(--mail-hover);
}

.mail-thread-message.is-expanded .mail-thread-message-header {
    background: #f8f9fa;
}

.mail-avatar--sm {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
}

.mail-thread-message-meta {
    flex: 1;
    min-width: 0;
}

.mail-thread-message-from {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--mail-text);
}

.mail-thread-message-snippet {
    display: block;
    font-size: 0.8rem;
    color: var(--mail-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-thread-message-time {
    flex-shrink: 0;
    font-size: 0.72rem;
    color: var(--mail-muted);
}

.mail-thread-message-attachments {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.85rem;
    color: var(--mail-muted);
    line-height: 1;
}

.mail-thread-message-attachments .bi-paperclip {
    transform: rotate(-30deg);
}

.mail-thread-message-attachments-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--mail-text);
}

.mail-thread-message-chevron {
    flex-shrink: 0;
    color: var(--mail-muted);
    transition: transform 0.15s ease;
}

.mail-thread-message.is-expanded .mail-thread-message-chevron {
    transform: rotate(180deg);
}

.mail-thread-message-body {
    padding: 0 16px 16px;
    background: #fff;
}

.mail-read-header--thread {
    margin-bottom: 12px;
    padding-bottom: 0;
    border-bottom: 0;
}

.mail-read-header-row--thread {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px 12px;
}

.mail-read-header-row--thread .mail-read-header-from {
    flex: 1;
    min-width: 0;
}

.mail-read-header-row--thread .mail-read-time {
    margin-left: auto;
}

.mail-read-header-side {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.mail-thread-message-delete {
    display: inline-flex;
    margin: 0;
}

.mail-thread-message-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--mail-muted, #6b7c8f);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mail-thread-message-action:hover {
    background: #f0f4f8;
    color: var(--mail-text, #1a2b3c);
}

.mail-thread-message-action--danger:hover {
    background: #fdecec;
    color: #c0392b;
}

.mail-read-details--thread {
    margin-left: 0;
    margin-top: 10px;
}

.mail-thread-message-body .mail-read-attachments-gmail {
    margin-top: 12px;
}

.mail-message-from {
    font-size: 0.9rem;
    color: var(--mail-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-message-item.unread .mail-message-from,
.mail-message-item.unread .mail-message-subject {
    font-weight: 700;
}

.mail-message-date {
    font-size: 0.72rem;
    color: var(--mail-muted);
    flex-shrink: 0;
}

.mail-message-mailbox {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--mail-accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mail-message-subject {
    font-size: 0.84rem;
    color: #3d4f65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-message-preview {
    font-size: 0.8rem;
    color: var(--mail-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-search-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--mail-muted);
}

/* Pannello lettura */
.mail-read-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: var(--mail-bg);
}

.mail-read-panel--loading {
    opacity: 0.65;
    pointer-events: none;
}

.mail-client--reading .mail-read-panel {
    display: flex;
}

/* toolbar legacy rimossa — azioni in .mail-read-top-actions */

.mail-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--mail-border);
    background: #fff;
    color: var(--mail-text);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.mail-toolbar-btn:hover {
    background: var(--mail-hover);
    border-color: #c8d0da;
    color: var(--mail-text);
}

.mail-toolbar-btn--danger:hover {
    background: #fff5f5;
    border-color: #f5c2c7;
    color: #b02a37;
}

.mail-toolbar-btn--primary {
    background: var(--mail-accent);
    border-color: var(--mail-accent);
    color: #fff;
}

.mail-toolbar-btn--primary:hover {
    background: #0074ad;
    border-color: #0074ad;
    color: #fff;
}

.mail-draft-preview {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--mail-border);
    border-radius: 8px;
    background: #fafbfc;
    max-height: 60vh;
    overflow: auto;
}

.mail-draft-preview-html {
    font-size: 14px;
    line-height: 1.5;
}

.mail-draft-preview-html img {
    max-width: 100%;
    height: auto;
}

.mail-draft-preview-text {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 14px;
}

.mail-read-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 24px 32px;
}

.mail-read-top-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.mail-read-top-actions .mail-toolbar-btn span {
    font-size: 0.8rem;
}

.mail-read-subject {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--mail-text);
    margin: 0 0 16px;
    padding-right: 8px;
}

.mail-read-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--mail-border);
}

.mail-read-header-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: start;
}

.mail-read-header-from {
    min-width: 0;
}

.mail-read-from-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 4px;
}

.mail-read-from-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--mail-text);
}

.mail-read-from-email {
    font-size: 0.82rem;
    color: var(--mail-muted);
    word-break: break-all;
}

.mail-read-recipient-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 0;
    border: 0;
    background: transparent;
    color: var(--mail-muted);
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
}

.mail-read-recipient-toggle:hover {
    color: var(--mail-text);
    background: #f0f3f7;
}

.mail-read-recipient-toggle[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.mail-read-recipient-toggle .bi-chevron-down {
    font-size: 0.7rem;
    transition: transform 0.15s;
}

.mail-read-time {
    font-size: 0.8rem;
    color: var(--mail-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.mail-read-details {
    margin-top: 12px;
    margin-left: 56px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--mail-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(15, 35, 71, 0.08);
}

.mail-read-details[hidden] {
    display: none !important;
}

.mail-read-details-list {
    margin: 0;
    display: grid;
    gap: 8px;
}

.mail-read-details-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    font-size: 0.85rem;
    align-items: start;
}

.mail-read-details-row dt {
    margin: 0;
    font-weight: 500;
    color: var(--mail-muted);
    text-transform: lowercase;
}

.mail-read-details-row dd {
    margin: 0;
    color: var(--mail-text);
    word-break: break-word;
}

.mail-read-details-row dd .bi-lock-fill {
    margin-right: 4px;
}

.mail-read-body {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #2a3544;
}

.mail-read-text {
    white-space: pre-wrap;
    font-family: inherit;
    word-break: break-word;
}

.mail-read-iframe-wrap {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--mail-border);
    border-radius: 8px;
    background: #fff;
}

.mail-read-iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 240px;
    border: 0;
    background: #fff;
    overflow: hidden;
}

/* Allegati in stile Gmail (posta inviata) */
.mail-read-attachments-gmail {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--mail-border);
}

.mail-read-attachments-gmail-label {
    margin: 0 0 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--mail-muted);
}

.mail-read-attachments-gmail-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.mail-read-attachment-card {
    display: flex;
    flex-direction: column;
    width: 168px;
    padding: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #dadce0;
    box-shadow:
        0 1px 2px rgba(60, 64, 67, 0.12),
        1px 1px 0 rgba(60, 64, 67, 0.06);
    transition: box-shadow 0.15s ease;
}

button.mail-read-attachment-card {
    appearance: none;
}

.mail-read-attachment-card:hover {
    box-shadow:
        0 2px 6px rgba(60, 64, 67, 0.18),
        1px 2px 0 rgba(60, 64, 67, 0.08);
}

.mail-read-attachment-card-preview {
    display: block;
    width: 100%;
    height: 118px;
    background: #f1f3f4;
    overflow: hidden;
}

.mail-read-attachment-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.mail-read-attachment-card-file {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 118px;
    background: #f1f3f4;
    color: #5f6368;
    font-size: 2rem;
}

.mail-read-attachment-card-file--pdf {
    background: #fff;
}

.mail-read-attachment-card-file--pdf .bi-file-earmark-pdf {
    font-size: 3.25rem;
    color: #d93025;
}

.mail-read-attachment-card-name {
    display: block;
    padding: 8px 10px;
    font-size: 0.75rem;
    color: #3c4043;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-read-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.mail-read-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--mail-border);
    border-radius: 16px;
    background: #f8f9fa;
    color: var(--mail-text);
    text-decoration: none;
}

.mail-read-attachment img {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 4px;
}

button.mail-read-attachment {
    appearance: none;
    cursor: pointer;
}

.mail-read-attachment--pdf .bi-file-earmark-pdf {
    font-size: 1.25rem;
    color: #d93025;
}

body.mail-lightbox-open {
    overflow: hidden;
}

.mail-attachment-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.mail-attachment-lightbox[hidden] {
    display: none !important;
}

.mail-attachment-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(32, 33, 36, 0.92);
}

.mail-attachment-lightbox-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    color: #e8eaed;
}

.mail-attachment-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    flex-shrink: 0;
}

.mail-attachment-lightbox-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.mail-attachment-lightbox-title-icon {
    color: #f28b82;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.mail-attachment-lightbox-title {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-attachment-lightbox-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.mail-attachment-lightbox-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #e8eaed;
    text-decoration: none;
    font-size: 0.85rem;
    cursor: pointer;
}

.mail-attachment-lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.mail-attachment-lightbox-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 16px 24px 80px;
}

.mail-attachment-lightbox-img {
    max-width: min(100%, 1200px);
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    transition: transform 0.15s ease;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.mail-attachment-lightbox-footer {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: rgba(60, 64, 67, 0.95);
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.mail-attachment-lightbox-zoom-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #e8eaed;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.mail-attachment-lightbox-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.mail-read-empty,
.mail-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 32px;
    height: 100%;
    color: var(--mail-muted);
}

.mail-empty-state h3,
.mail-read-empty h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--mail-text);
    margin: 12px 0 6px;
}

.mail-empty-state p,
.mail-read-empty p {
    font-size: 0.9rem;
    max-width: 280px;
    margin-bottom: 16px;
}

.mail-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f4fc, #d4edda);
    color: var(--mail-accent);
    font-size: 2rem;
}

.mail-empty-icon--muted {
    background: #f0f3f7;
    color: #9aa8b8;
    font-size: 1.75rem;
}

.mail-panel-notice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 12px 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
}

.mail-panel-notice--warning {
    background: #fff8e6;
    border: 1px solid #ffe08a;
    color: #664d03;
}

.mail-panel-notice--danger {
    background: #fff5f5;
    border: 1px solid #f5c2c7;
    color: #842029;
}

/* Composizione nel layout mail */
.mail-compose-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px 40px;
}

.mail-compose-panel .mail-compose-heading {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--mail-text);
}

.mail-compose-form .form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--mail-muted);
}

.mail-compose-form .form-control,
.mail-compose-form .form-select {
    border-radius: 8px;
    border-color: var(--mail-border);
}

.mail-compose-form .form-control:focus,
.mail-compose-form .form-select:focus {
    border-color: var(--mail-accent);
    box-shadow: 0 0 0 3px rgba(0, 134, 201, 0.15);
}

.app-main:has(.mail-client) {
    padding: 0;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.app-main:has(.mail-client) .alert {
    position: absolute;
    top: 8px;
    right: 16px;
    left: 276px;
    z-index: 20;
    margin: 0;
    max-width: 480px;
}

.mail-client--compose {
    grid-template-columns: 232px minmax(0, 1fr);
}

.mail-client--compose .mail-list-panel--placeholder {
    display: none;
}

.app-main:has(.mail-client--compose) {
    padding: 0;
    overflow: hidden;
}

/* Dashboard/homepage style (legacy) */
.inbox-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    min-height: 100vh;
}

.inbox-panel {
    background: #fff;
    border-right: 1px solid #e8ebf0;
}

.inbox-header {
    padding: 14px 16px 8px;
    border-bottom: 1px solid #e8ebf0;
}

.inbox-title {
    font-size: 1.75rem;
    margin: 0;
    color: #1b1f24;
}

.inbox-tabs {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 16px;
    border-bottom: 1px solid #e8ebf0;
}

.tab-link {
    color: #7e8794;
    text-decoration: none;
    font-size: 0.92rem;
    padding-bottom: 8px;
    border-bottom: 2px solid transparent;
}

.tab-link.active {
    color: #243a5e;
    border-bottom-color: #18bf7b;
}

.inbox-empty {
    padding: 80px 18px;
    text-align: center;
    color: #7b8794;
}

.empty-icon-wrap {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: #f0f3f8;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
}

.empty-icon-wrap i {
    font-size: 2rem;
    color: #19d667;
}

.inbox-empty h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: #667792;
}

.inbox-empty p {
    margin-bottom: 8px;
}

.empty-link {
    text-decoration: none;
    font-size: 0.9rem;
}

.assignee-picker .form-label {
    font-weight: 600;
}

.assignee-selected-list {
    min-height: 42px;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.assignee-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eaf3ff;
    color: #24508b;
    font-size: 0.85rem;
}

.chip-remove {
    border: 0;
    background: transparent;
    color: #24508b;
    padding: 0;
    line-height: 1;
}

.assignee-search-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #e7eaf0;
    border-radius: 8px;
    padding: 6px;
}

.assignee-option {
    display: flex;
    align-items: flex-start;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.assignee-option:hover {
    background: #f6f8fc;
}

.assignee-option input[type="checkbox"] {
    flex-shrink: 0;
    margin-top: 3px;
}

.assignee-option__body {
    flex: 1;
    min-width: 0;
}

.assignee-option__name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-weight: 500;
}

.assignee-option__email {
    margin-top: 1px;
    word-break: break-all;
}

.assignee-chip__label {
    font-weight: 500;
}

/* Variante inline del company tag per usi dentro chip/option (riduce il bordo sx) */
.user-company-tag--inline {
    font-size: 0.65rem;
    padding: 0 6px 0 7px;
    border-left-width: 2px;
}

.assignee-option:hover {
    background: #f5f8fc;
}

.inbox-side {
    background: #f5f7fb;
    padding: 16px;
}

.right-panel-card {
    background: #fff;
    border: 1px solid #e8ebf0;
    border-radius: 10px;
    padding: 14px;
}

.app-main .alert {
    margin: 0 0 16px;
}

.app-main:has(.inbox-layout) .alert {
    margin: 14px 16px 0;
}

.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    border-radius: 8px;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.project-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,.15);
}

/* Project folders (griglia + sottoprogetti collassabili) */
.project-folder-col {
    position: relative;
}

.project-folder-col:has(.dropdown.show) {
    z-index: 1050;
}

.project-folder-card {
    border: 1px solid #e8ebf0;
    box-shadow: 0 1px 3px rgba(15, 35, 71, 0.06);
    transition: box-shadow 0.2s;
    overflow: visible;
}

.project-folder-card .card-body {
    overflow: visible;
}

.project-folder-card:hover {
    box-shadow: 0 4px 12px rgba(15, 35, 71, 0.1);
}

.project-folder-card__header {
    position: relative;
    z-index: 2;
}

.project-folder-card__menu {
    flex-shrink: 0;
}

.project-folder-card__menu .dropdown-menu {
    z-index: 1060;
}

.project-folder-card__footer {
    position: relative;
    z-index: 1;
}

.project-folder-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 0;
}

.project-subproject-list {
    border: 1px solid #e8ebf0;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.project-subproject-list .list-group-item {
    background: #f8fafc;
    border-color: #eef2f6;
}

.project-subproject-list .list-group-item + .list-group-item {
    border-top-width: 1px;
}

.task-item {
    background-color: #fff;
    transition: background-color 0.2s;
    position: relative;
    overflow: visible;
}

.task-item:hover {
    background-color: #f8f9fa;
}

.task-item:has(.dropdown.show) {
    z-index: 1050;
}

.task-item__menu .dropdown-menu {
    z-index: 1060;
    min-width: 11rem;
}

.comment-item {
    background-color: #f8f9fa;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #006ba3;
    border-color: #006ba3;
}

.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 134, 201, 0.25);
}

.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1rem;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--secondary-color);
}

/* Status badges */
.badge.bg-success {
    background-color: var(--success-color) !important;
}

.badge.bg-warning {
    background-color: var(--warning-color) !important;
    color: #000;
}

.badge.bg-secondary {
    background-color: var(--secondary-color) !important;
}

/* Progress bar */
.progress {
    height: 8px;
    border-radius: 4px;
    background-color: #e9ecef;
}

.progress-bar {
    background-color: var(--primary-color);
    border-radius: 4px;
}

/* Task list styling */
.task-list {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: clip;
    padding-right: 4px;
}

.project-tasks-card,
.project-tasks-card .card-body {
    overflow: visible;
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .app-header-burger {
        display: inline-flex;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 250;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
    }

    .app-layout.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-shell {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .app-main:not(:has(.inbox-layout)) {
        padding: 16px 20px;
    }

    .mail-client,
    .mail-client--compose {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: 100%;
        min-height: 0;
        position: relative;
    }

    /* Sidebar diventa un drawer laterale: nascosta di default. */
    .mail-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.18);
        border-right: 1px solid var(--mail-border, #e4e8ef);
        border-bottom: 0;
        overflow-y: auto;
    }

    .mail-client.mail-sidebar-open .mail-sidebar {
        transform: translateX(0);
    }

    .mail-sidebar-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(15, 35, 71, 0.4);
        z-index: 55;
    }

    .mail-client.mail-sidebar-open .mail-sidebar-backdrop[hidden] {
        display: block;
    }

    .mail-list-panel {
        border-right: 0;
        min-height: 0;
        height: 100%;
        grid-column: 1;
        grid-row: 1;
    }

    /* Pulsante per aprire la sidebar nel toolbar della lista. */
    .mail-sidebar-toggle {
        display: inline-flex;
    }

    .mail-read-panel {
        display: none;
        grid-column: 1;
        grid-row: 1;
        background: var(--mail-bg);
        height: 100%;
        min-height: 0;
        z-index: 5;
    }

    .mail-client:has(.mail-message-item.active) .mail-list-panel {
        display: none;
    }

    .mail-client:has(.mail-message-item.active) .mail-read-panel {
        display: flex;
        min-height: 0;
    }

    .mail-toolbar-btn--back {
        display: inline-flex;
    }

    .mail-list-toolbar {
        padding: 10px 12px;
    }

    .mail-list-toolbar-top {
        flex-wrap: wrap;
        gap: 8px;
    }

    .mail-list-title {
        font-size: 1rem;
    }

    .mail-search {
        width: 100%;
    }

    /* Drawer dell'app (esterno): chiudibile anche cliccando su un link. */
    .app-sidebar a {
        white-space: normal;
    }

    /* Più aria nei form Bootstrap standard. */
    .container,
    .container-fluid,
    main > .row {
        padding-left: 12px;
        padding-right: 12px;
    }

    h1 {
        font-size: 1.4rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    .btn {
        white-space: normal;
    }

    .table-responsive {
        overflow-x: auto;
    }

    .mail-read-details {
        margin-left: 0;
    }

    .mail-read-details-row {
        grid-template-columns: 88px 1fr;
    }

    .app-main:has(.mail-client) .alert {
        left: 16px;
        right: 16px;
    }

    .inbox-layout {
        grid-template-columns: 1fr;
    }

    .inbox-side {
        padding-top: 0;
    }

    .card-body {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* User settings */
.settings-page-header h2 {
    font-weight: 600;
}

.settings-page {
    max-width: 1180px;
    margin: 0 auto;
}

.settings-account-card {
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.settings-account-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.75rem 1.25rem;
    gap: 0.75rem;
}

.settings-account-info {
    width: 100%;
}

.settings-account-info p,
.settings-account-info h5 {
    text-align: center;
}

.settings-account-badges {
    justify-content: center;
}

.settings-avatar {
    display: flex;
    justify-content: center;
}

.settings-avatar-img,
.settings-avatar-initials {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
}

@media (max-width: 991.98px) {
    .settings-account-card-body {
        flex-direction: row;
        align-items: center;
        text-align: left;
        gap: 1rem;
        padding: 1rem 1.1rem;
    }

    .settings-account-info p,
    .settings-account-info h5 {
        text-align: left;
    }

    .settings-account-badges {
        justify-content: flex-start;
    }

    .settings-avatar-img,
    .settings-avatar-initials {
        width: 64px;
        height: 64px;
        font-size: 1.5rem;
    }

    .settings-account-info h5 {
        font-size: 1.05rem;
    }
}

.settings-avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0086c9, #0f2347);
    color: #fff;
    font-size: 2rem;
    font-weight: 600;
}

.settings-meta dt {
    color: #6c757d;
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.settings-meta dd {
    margin-bottom: 0.75rem;
}

.sidebar-user-name:hover {
    color: #fff;
}

.settings-form .form-label {
    font-weight: 500;
}

.settings-email-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.settings-email-item {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fafbfc;
}

.settings-email-item-main {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

.settings-email-item-main i {
    font-size: 1.25rem;
    margin-top: 0.15rem;
}

.settings-email-item-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.settings-mailbox-item {
    align-items: flex-start;
}

.mailbox-view-mode-options .form-check {
    margin-bottom: 0.5rem;
}

.mailbox-config-form h6 {
    letter-spacing: 0.04em;
}

.settings-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: 1px solid var(--border-color);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.settings-tabs::-webkit-scrollbar {
    height: 4px;
}

.settings-tabs::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.settings-tabs .nav-item {
    flex-shrink: 0;
}

.settings-tabs .nav-link {
    color: #4b5563;
    border: 1px solid transparent;
    border-bottom: none;
    padding: 0.6rem 1rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.settings-tabs .nav-link:hover {
    color: var(--primary-color, #0d6efd);
    background: rgba(13, 110, 253, 0.05);
}

.settings-tabs .nav-link.active {
    color: var(--primary-color, #0d6efd);
    background: #fff;
    border-color: var(--border-color) var(--border-color) #fff;
}

.settings-tabs .nav-link i {
    font-size: 1rem;
}

.settings-tab-content {
    background: transparent;
}

.settings-totp-input {
    letter-spacing: 0.5em;
    font-size: 1.6rem;
    font-weight: 600;
    text-indent: 0.5em;
}

.settings-secret-key code {
    display: inline-block;
    padding: 0.5rem 0.85rem;
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    font-size: 1.05rem;
    letter-spacing: 0.15em;
    color: #1f2937;
    word-break: break-all;
}

.settings-2fa-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    border-radius: 50%;
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

/* ============================================================
   Recipient role badge (To / Cc / Bcc)
   ============================================================ */
.mail-recipient-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    padding: 1px 7px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
    vertical-align: middle;
}

.mail-recipient-badge--to {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.mail-recipient-badge--cc {
    background: rgba(255, 159, 28, 0.18);
    color: #b56a00;
}

.mail-recipient-badge--bcc {
    background: rgba(108, 117, 125, 0.18);
    color: #475569;
}

/* ============================================================
   Calendar invitation card (Outlook/Gmail style)
   ============================================================ */
.mail-calendar-card {
    display: flex;
    gap: 14px;
    margin: 12px 16px 16px;
    padding: 16px 18px;
    border: 1px solid #d6e2f1;
    border-left: 4px solid #4f6df5;
    border-radius: 10px;
    background: linear-gradient(180deg, #f4f8ff 0%, #ffffff 100%);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.mail-calendar-card--cancelled {
    border-color: #f8d7da;
    border-left-color: #dc3545;
    background: linear-gradient(180deg, #fff5f5 0%, #ffffff 100%);
}

.mail-calendar-card--reply {
    border-color: #d4edda;
    border-left-color: #28a745;
    background: linear-gradient(180deg, #f4fff7 0%, #ffffff 100%);
}

.mail-calendar-card-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: #4f6df5;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.mail-calendar-card--cancelled .mail-calendar-card-icon {
    background: #dc3545;
}

.mail-calendar-card--reply .mail-calendar-card-icon {
    background: #28a745;
}

.mail-calendar-card-body {
    flex: 1;
    min-width: 0;
}

.mail-calendar-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.mail-calendar-card-tag {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(79, 109, 245, 0.12);
    color: #4f6df5;
}

.mail-calendar-card-tag--danger {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

.mail-calendar-card-tag--info {
    background: rgba(40, 167, 69, 0.12);
    color: #28a745;
}

.mail-calendar-card-provider {
    font-size: 0.78rem;
    color: #6b7280;
    font-weight: 500;
}

.mail-calendar-card-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
    word-break: break-word;
}

.mail-calendar-card-meta {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mail-calendar-card-meta li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.92rem;
    color: #374151;
    line-height: 1.45;
}

.mail-calendar-card-meta li i {
    flex-shrink: 0;
    margin-top: 2px;
    color: #6b7280;
}

.mail-calendar-card-meta li span {
    min-width: 0;
    word-break: break-word;
}

.mail-calendar-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.mail-calendar-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.mail-calendar-card-btn--primary {
    background: #4f6df5;
    color: #fff;
}

.mail-calendar-card-btn--primary:hover {
    background: #3d5be0;
    color: #fff;
}

@media (max-width: 600px) {
    .mail-calendar-card {
        margin: 10px 10px 14px;
        padding: 12px 14px;
        gap: 10px;
    }
    .mail-calendar-card-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    .mail-calendar-card-title {
        font-size: 0.98rem;
    }
}

@media (max-width: 575.98px) {
    .settings-tabs .nav-link {
        padding: 0.5rem 0.7rem;
        font-size: 0.9rem;
    }

    .settings-tabs .settings-tab-label {
        display: none;
    }

    .settings-tabs .nav-link i {
        font-size: 1.15rem;
    }
}

/* ============================================================
   MbsModal — modali di conferma grafiche
   ============================================================ */
.mbs-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(15, 35, 71, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.mbs-modal-backdrop:not([hidden]) {
    display: flex;
}

.mbs-modal-backdrop.is-open {
    opacity: 1;
}

body.mbs-modal-open {
    overflow: hidden;
}

.mbs-modal {
    width: min(440px, 100%);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 35, 71, 0.25);
    overflow: hidden;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.18s ease;
    outline: none;
}

.mbs-modal-backdrop.is-open .mbs-modal {
    transform: translateY(0) scale(1);
}

.mbs-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px 8px;
}

.mbs-modal-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.35rem;
}

.mbs-modal-icon--primary {
    background: #e8f0fe;
    color: #1d5bb8;
}

.mbs-modal-icon--danger {
    background: #fdecec;
    color: #c0392b;
}

.mbs-modal-icon--warning {
    background: #fff7e1;
    color: #b9770e;
}

.mbs-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1a2b44;
    line-height: 1.3;
}

.mbs-modal-body {
    padding: 4px 20px 20px;
    color: #4a5d78;
    font-size: 0.92rem;
    line-height: 1.5;
}

.mbs-modal-body p {
    margin: 0;
}

.mbs-modal-body[hidden] {
    display: none;
}

.mbs-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 18px;
    background: #f7f9fc;
    border-top: 1px solid #eef1f5;
}

.mbs-modal-btn {
    padding: 8px 16px;
    border: 0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, color 0.15s;
}

.mbs-modal-btn:focus-visible {
    outline: 2px solid #1d5bb8;
    outline-offset: 2px;
}

.mbs-modal-btn--secondary {
    background: #fff;
    color: #4a5d78;
    border: 1px solid #d4dae3;
}

.mbs-modal-btn--secondary:hover {
    background: #f0f4f8;
}

.mbs-modal-btn--primary {
    background: #1d5bb8;
    color: #fff;
}

.mbs-modal-btn--primary:hover {
    background: #154a9a;
}

.mbs-modal-btn--danger {
    background: #c0392b;
    color: #fff;
}

.mbs-modal-btn--danger:hover {
    background: #a93226;
}

.mbs-modal-btn--warning {
    background: #d4900e;
    color: #fff;
}

.mbs-modal-btn--warning:hover {
    background: #b9770e;
}

/* ============================================================
   MbsToast — notifiche flottanti
   ============================================================ */
.mbs-toast-container {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 1400;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.mbs-toast {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: start;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 35, 71, 0.18);
    color: #1a2b44;
    pointer-events: auto;
    transform: translateX(20px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    border-left: 4px solid #1d5bb8;
}

.mbs-toast.is-visible {
    transform: translateX(0);
    opacity: 1;
}

.mbs-toast.is-leaving {
    transform: translateX(20px);
    opacity: 0;
}

.mbs-toast--success {
    border-left-color: #2e8b57;
}

.mbs-toast--warning {
    border-left-color: #d4900e;
}

.mbs-toast--danger {
    border-left-color: #c0392b;
}

.mbs-toast-icon {
    font-size: 1.15rem;
    line-height: 1.1;
    margin-top: 1px;
}

.mbs-toast--info .mbs-toast-icon { color: #1d5bb8; }
.mbs-toast--success .mbs-toast-icon { color: #2e8b57; }
.mbs-toast--warning .mbs-toast-icon { color: #b9770e; }
.mbs-toast--danger .mbs-toast-icon { color: #c0392b; }

.mbs-toast-body {
    min-width: 0;
    font-size: 0.88rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.mbs-toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.mbs-toast-close {
    background: transparent;
    border: 0;
    padding: 2px;
    color: #8b9cb3;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    border-radius: 4px;
}

.mbs-toast-close:hover {
    background: #f0f2f5;
    color: #1a2b44;
}

@media (max-width: 575px) {
    .mbs-toast-container {
        top: 64px;
        left: 12px;
        right: 12px;
        max-width: none;
    }
}

/* ============================================================
   MbsLoader — overlay caricamento operazioni
   ============================================================ */
.mbs-loader-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1600;
    background: rgba(15, 35, 71, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.mbs-loader-backdrop.is-visible {
    opacity: 1;
}

body.mbs-loader-open {
    overflow: hidden;
}

.mbs-loader {
    background: #fff;
    border-radius: 14px;
    padding: 26px 32px;
    min-width: 240px;
    max-width: 360px;
    box-shadow: 0 24px 60px rgba(15, 35, 71, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    transform: translateY(8px) scale(0.97);
    transition: transform 0.18s ease;
}

.mbs-loader-backdrop.is-visible .mbs-loader {
    transform: translateY(0) scale(1);
}

.mbs-loader-spinner {
    width: 48px;
    height: 48px;
    position: relative;
}

.mbs-loader-spinner-ring {
    display: block;
    width: 100%;
    height: 100%;
    border: 4px solid #e4e8ef;
    border-top-color: #1d5bb8;
    border-radius: 50%;
    animation: mbs-loader-spin 0.85s linear infinite;
}

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

.mbs-loader-message {
    text-align: center;
    color: #1a2b44;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

/* ============================================================
   Lista utenti — riga account corrente
   ============================================================ */
.user-row--self {
    background: linear-gradient(90deg, rgba(0, 134, 201, 0.1), rgba(99, 102, 241, 0.06));
    box-shadow: inset 3px 0 0 #0086c9;
}

.user-row--self:hover {
    background: linear-gradient(90deg, rgba(0, 134, 201, 0.14), rgba(99, 102, 241, 0.09));
}

.user-row__self-badge {
    background: linear-gradient(135deg, #0086c9, #6366f1);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* ============================================================
   Bulk toolbar (lista utenti, ecc.)
   ============================================================ */
.bulk-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: linear-gradient(90deg, rgba(13, 110, 253, 0.06), rgba(13, 110, 253, 0.03));
    border: 1px solid rgba(13, 110, 253, 0.18);
    border-radius: 10px;
    position: sticky;
    top: 0;
    z-index: 5;
    animation: bulk-toolbar-slide-in 0.18s ease-out;
}

@keyframes bulk-toolbar-slide-in {
    from { transform: translateY(-6px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.bulk-toolbar__info {
    color: #0d3a82;
    font-size: 0.9rem;
}

.bulk-toolbar__info i {
    margin-right: 4px;
}

.bulk-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================
   User chip + company tag (riutilizzabile in tutta la UI)
   ============================================================ */
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.25;
    max-width: 100%;
    vertical-align: middle;
}

.user-chip__name {
    font-weight: 500;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-company-tag {
    --company-color: #0d6efd;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px 1px 8px;
    background: color-mix(in srgb, var(--company-color) 12%, transparent);
    color: color-mix(in srgb, var(--company-color) 85%, #000 15%);
    border-left: 3px solid var(--company-color);
    border-radius: 4px 999px 999px 4px;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-decoration: none;
}

.user-company-tag:hover {
    background: color-mix(in srgb, var(--company-color) 18%, transparent);
    color: color-mix(in srgb, var(--company-color) 95%, #000 5%);
}

.user-company-tag i {
    font-size: 0.72rem;
    flex-shrink: 0;
}

.user-company-tag__name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-company-dot {
    --company-color: #0d6efd;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: color-mix(in srgb, var(--company-color) 16%, transparent);
    color: var(--company-color);
    border-radius: 50%;
    font-size: 0.65rem;
    margin-left: 4px;
    cursor: help;
    vertical-align: middle;
}

/* Variante "soft" su sfondi colorati (es. assignee chip già stilizzata) */
.assignee-chip .user-company-tag,
.dashboard-task-row .user-company-tag {
    background: rgba(13, 110, 253, 0.14);
}

@media (max-width: 575.98px) {
    .user-company-tag {
        max-width: 100px;
    }
    .user-company-tag__name {
        font-size: 0.65rem;
    }
}

/* Riepilogo "Aziende coinvolte" nel progetto */
.project-companies-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.project-company-pill {
    --company-color: #0d6efd;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    background: color-mix(in srgb, var(--company-color) 8%, #fff 92%);
    border: 1px solid color-mix(in srgb, var(--company-color) 25%, #fff 75%);
    border-left: 4px solid var(--company-color);
    border-radius: 4px 999px 999px 4px;
    font-size: 0.82rem;
    color: color-mix(in srgb, var(--company-color) 80%, #000 20%);
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
    cursor: pointer;
}

.project-company-pill:hover {
    background: color-mix(in srgb, var(--company-color) 16%, #fff 84%);
    border-color: color-mix(in srgb, var(--company-color) 45%, #fff 55%);
    color: color-mix(in srgb, var(--company-color) 95%, #000 5%);
    transform: translateY(-1px);
}

.project-company-pill.is-active {
    background: var(--company-color);
    color: #fff;
    border-color: var(--company-color);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--company-color) 35%, transparent);
}

.project-company-pill.is-active .project-company-pill__count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border-color: transparent;
}

.project-company-pill__count {
    background: #fff;
    border: 1px solid #dde3ee;
    border-radius: 999px;
    font-size: 0.7rem;
    padding: 1px 7px;
    font-weight: 600;
    color: #6c7891;
}

.project-company-pill--none {
    background: transparent;
    border: 1px dashed #ced4da;
    color: #adb5bd;
    cursor: default;
}

/* ============================================================
   Dashboard (overview) — KPI, cards, task rows
   ============================================================ */
.dashboard-page {
    padding: 16px 4px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashboard-page__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-page__title {
    font-size: 1.65rem;
    font-weight: 700;
    color: #1a2b44;
    margin: 0 0 4px;
}

.dashboard-page__subtitle {
    font-size: 0.92rem;
}

.dashboard-page__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Layout personalizzabile -------------------------------------- */
.dashboard-layout-hint {
    padding: 8px 12px;
    background: #f0f4ff;
    border-radius: 8px;
    border: 1px dashed #b8c9e8;
}

.dashboard-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    align-items: start;
}

@media (min-width: 1200px) {
    .dashboard-layout-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-widget--kpi {
        grid-column: span 1;
    }
}

.dashboard-widget {
    position: relative;
    min-width: 0;
}

.dashboard-widget--kpi .kpi-card {
    height: 100%;
}

.dashboard-widget--panel .dashboard-card {
    height: 100%;
}

.dashboard-widget__handle {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #d0d7e2;
    border-radius: 8px;
    background: #fff;
    color: #6c7891;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    box-shadow: 0 1px 4px rgba(20, 30, 60, 0.08);
}

.dashboard-widget__handle:active {
    cursor: grabbing;
}

.dashboard-page.is-dashboard-customizing .dashboard-widget {
    outline: 2px dashed #b8c9e8;
    outline-offset: 2px;
    border-radius: 12px;
}

.dashboard-widget--ghost {
    opacity: 0.45;
}

.dashboard-widget--chosen {
    outline-color: #0d6efd;
}

.dashboard-widget--drag {
    box-shadow: 0 12px 28px rgba(20, 30, 60, 0.12);
}

/* KPI cards ---------------------------------------------------- */
.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}

.kpi-card {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e6e9f0;
    box-shadow: 0 1px 3px rgba(20, 30, 60, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(20, 30, 60, 0.06);
}

.kpi-card__icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    background: #6c757d;
}

.kpi-card--primary .kpi-card__icon { background: linear-gradient(135deg, #1d5bb8, #0d6efd); }
.kpi-card--danger  .kpi-card__icon { background: linear-gradient(135deg, #c92a2a, #e03131); }
.kpi-card--warning .kpi-card__icon { background: linear-gradient(135deg, #d97706, #f59f00); }
.kpi-card--success .kpi-card__icon { background: linear-gradient(135deg, #198754, #2fb344); }
.kpi-card--info    .kpi-card__icon { background: linear-gradient(135deg, #0891b2, #06aed4); }

.kpi-card.is-alert {
    border-color: rgba(224, 49, 49, 0.35);
    background: #fff5f5;
}

.kpi-card__body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    flex: 1;
}

.kpi-card__label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c7891;
    font-weight: 600;
    margin-bottom: 2px;
}

.kpi-card__value {
    font-size: 1.7rem;
    font-weight: 700;
    color: #1a2b44;
    line-height: 1.1;
}

.kpi-card__sub {
    font-size: 0.78rem;
    color: #6c7891;
    margin-top: 4px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.kpi-card__sub i {
    margin-right: 2px;
}

/* Grid sezioni ------------------------------------------------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.dashboard-grid--two {
    grid-template-columns: 1fr;
}

@media (min-width: 992px) {
    .dashboard-grid--two {
        grid-template-columns: 1fr 1fr;
    }
}

.dashboard-card {
    background: #fff;
    border: 1px solid #e6e9f0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(20, 30, 60, 0.04);
}

.dashboard-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #eef0f5;
    background: #fafbfd;
}

.dashboard-card__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a2b44;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-card__count {
    background: #eef0f5;
    color: #6c7891;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
}

.dashboard-card__link {
    font-size: 0.82rem;
    color: #0d6efd;
    text-decoration: none;
}
.dashboard-card__link:hover { text-decoration: underline; }

.dashboard-card__body {
    padding: 8px;
    min-height: 100px;
}

/* Task rows --------------------------------------------------- */
.dashboard-task-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-task-row {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.dashboard-task-row:hover {
    background: #f6f8fc;
    border-color: #e6e9f0;
}

.dashboard-task-row.is-overdue {
    background: #fff8f8;
    border-color: rgba(224, 49, 49, 0.18);
}

.dashboard-task-row__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-task-row__title {
    font-weight: 600;
    color: #1a2b44;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #adb5bd;
}
.status-dot--new        { background: #6c757d; }
.status-dot--in_progress{ background: #f59f00; }
.status-dot--completed  { background: #2fb344; }
.status-dot--cancelled  { background: #ced4da; }

.dashboard-task-row__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.78rem;
    color: #6c7891;
}

.dashboard-task-row__person {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.dashboard-task-row__company-icon {
    color: #0d6efd;
    font-size: 0.7rem;
    margin-left: 2px;
    opacity: 0.85;
}

.dashboard-task-row__meta i {
    margin-right: 3px;
}

.dashboard-task-row__progress {
    height: 5px;
    margin-top: 4px;
    background: #eef0f5;
}

.dashboard-task-row__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
    min-width: 130px;
}

.dashboard-task-row__due {
    font-size: 0.78rem;
    color: #6c7891;
    text-align: right;
    line-height: 1.25;
}

.dashboard-task-row__due small {
    display: block;
    font-size: 0.7rem;
    opacity: 0.85;
}

.dashboard-task-row__due.is-overdue {
    color: #c92a2a;
    font-weight: 600;
}

.dashboard-task-row__due.is-soon {
    color: #d97706;
    font-weight: 600;
}

.dashboard-task-row__due.is-none {
    color: #adb5bd;
    font-style: italic;
}

/* Project grid ----------------------------------------------- */
.dashboard-project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 6px;
}

.dashboard-project-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #e6e9f0;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    position: relative;
    overflow: hidden;
}

.dashboard-project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(20, 30, 60, 0.07);
    border-color: #d4dbe6;
}

.dashboard-project-card__color {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.dashboard-project-card__title {
    font-weight: 600;
    color: #1a2b44;
    padding-left: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-project-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.74rem;
    color: #6c7891;
    padding-left: 4px;
}

.dashboard-project-card__meta i {
    margin-right: 2px;
}

/* Empty state ------------------------------------------------ */
.dashboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    color: #adb5bd;
    font-size: 0.88rem;
    text-align: center;
    gap: 4px;
}

.dashboard-empty i {
    font-size: 1.6rem;
    opacity: 0.6;
}

.dashboard-card--invitations {
    border-color: rgba(245, 159, 0, 0.35);
}

/* Mobile tweaks --------------------------------------------- */
@media (max-width: 767.98px) {
    .dashboard-page {
        padding: 8px 0 24px;
        gap: 14px;
    }
    .dashboard-page__title {
        font-size: 1.35rem;
    }
    .kpi-card__value {
        font-size: 1.4rem;
    }
    .dashboard-task-row {
        flex-direction: column;
        gap: 6px;
    }
    .dashboard-task-row__side {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        min-width: 0;
        width: 100%;
    }
    .dashboard-task-row__due {
        text-align: left;
    }
    .dashboard-task-row__title {
        white-space: normal;
    }
}

/* ========================================================================
   TICKET MANAGEMENT
   ======================================================================== */
.ticket-page { color: #1f2937; }

.ticket-kpis .kpi-card { transition: transform .15s ease, box-shadow .15s ease; }
.ticket-kpis .kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.08); }

.ticket-table tbody tr { cursor: pointer; }
.ticket-table tbody tr.ticket-row--overdue { background: rgba(220, 53, 69, .04); }
.ticket-table tbody tr.ticket-row--overdue:hover { background: rgba(220, 53, 69, .08); }

.ticket-code-link {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: .85rem;
    color: #0d6efd;
    text-decoration: none;
    font-weight: 600;
}
.ticket-code-link:hover { text-decoration: underline; }

.ticket-code-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    background: #eef2f7;
    color: #1f2937;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .02em;
}

/* Pills generiche */
.ticket-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    background: rgba(0,0,0,.04);
    white-space: nowrap;
}
.ticket-pill .bi { font-size: .85em; }

/* Stati */
.ticket-pill--status.ticket-pill--open          { background:#e7f1ff; color:#0a58ca; border-color:#cfe2ff; }
.ticket-pill--status.ticket-pill--in_progress   { background:#fff4d9; color:#9a6700; border-color:#ffe69c; }
.ticket-pill--status.ticket-pill--waiting       { background:#e0f3fa; color:#055160; border-color:#b6effb; }
.ticket-pill--status.ticket-pill--resolved      { background:#d8f5e3; color:#0f5132; border-color:#b3ecc7; }
.ticket-pill--status.ticket-pill--closed        { background:#e9ecef; color:#495057; border-color:#dee2e6; }
.ticket-pill--status.ticket-pill--cancelled     { background:#1f2937; color:#fff; border-color:#1f2937; }

/* Priorità: usa --ticket-color */
.ticket-pill--priority {
    background: color-mix(in srgb, var(--ticket-color, #0d6efd) 14%, #fff);
    color: var(--ticket-color, #0d6efd);
    border-color: color-mix(in srgb, var(--ticket-color, #0d6efd) 28%, #fff);
}
.ticket-pill--p-urgent { animation: ticket-urgent-pulse 1.8s ease-in-out infinite; }
@keyframes ticket-urgent-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, .35); }
    50%      { box-shadow: 0 0 0 5px rgba(220, 53, 69, 0); }
}

/* Tipologia */
.ticket-pill--type {
    background: color-mix(in srgb, var(--ticket-color, #0d6efd) 10%, #fff);
    color: var(--ticket-color, #0d6efd);
    border-color: color-mix(in srgb, var(--ticket-color, #0d6efd) 22%, #fff);
}

/* Scadenza */
.ticket-due {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .78rem;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}
.ticket-due--soon { color: #b45309; font-weight: 600; }
.ticket-due--overdue { color: #b42318; font-weight: 700; }

/* Header del singolo ticket */
.ticket-header h1 { line-height: 1.25; }
.ticket-description-card .ticket-description {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.55;
    color: #1f2937;
}

/* Thread di conversazione */
.ticket-thread { display: flex; flex-direction: column; gap: 14px; max-height: 600px; overflow-y: auto; }

.ticket-comment {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
}
.ticket-comment--internal {
    background: #fff8e1;
    border-color: #ffe082;
}
.ticket-comment--customer {
    background: #f0fdf4;
    border-color: #bbf7d0;
    border-left: 4px solid #16a34a;
}
.ticket-comment--new {
    animation: ticket-comment-highlight 1.2s ease-out;
}
.ticket-thread--pulse {
    box-shadow: inset 0 0 0 2px rgba(22, 163, 74, 0.45);
    transition: box-shadow 0.3s ease;
}

@keyframes ticket-comment-highlight {
    from { filter: brightness(0.95); box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.5); }
    to { filter: none; box-shadow: none; }
}

.ticket-screen-share-video-wrap {
    position: relative;
    overflow: hidden;
}

.ticket-screen-share-video-inner {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background: #000;
}

.ticket-screen-share-audio {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.ticket-screen-share-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.ticket-screen-share-notice {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.88);
    color: #f8fafc;
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    padding: 1.5rem;
}

.ticket-screen-share-notice[hidden] {
    display: none !important;
}

.ticket-screen-share-notice i {
    font-size: 2.5rem;
    opacity: 0.9;
}

.ticket-screen-share-video-controls {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    display: flex;
    gap: 6px;
}

.ticket-screen-share-fs-stage {
    position: relative;
    width: 100%;
}

.ticket-screen-share-video-wrap.is-pseudo-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    margin: 0;
    border-radius: 0;
}

.ticket-screen-share-video-wrap:fullscreen,
.ticket-screen-share-video-wrap.is-pseudo-fullscreen {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    background: #0b0f14;
    overflow: hidden;
}

.ticket-screen-share-video-wrap:fullscreen .ticket-screen-share-fs-stage,
.ticket-screen-share-video-wrap.is-pseudo-fullscreen .ticket-screen-share-fs-stage {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    height: 100vh;
    min-height: 0;
}

.ticket-screen-share-video-wrap:fullscreen .ticket-screen-share-video-inner,
.ticket-screen-share-video-wrap.is-pseudo-fullscreen .ticket-screen-share-video-inner {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    height: 100%;
    padding-top: 0;
    min-height: 0;
}

.ticket-screen-share-video-wrap[hidden] {
    display: none !important;
}

.ticket-screen-share-fs-drawer {
    display: none;
    flex-direction: column;
    background: #f8fafc;
    color: #1e293b;
    border-left: 1px solid #e2e8f0;
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
}

.ticket-screen-share-fs-drawer[hidden] {
    display: none !important;
}

.ticket-screen-share-video-wrap:fullscreen.is-fs-chat-open .ticket-screen-share-fs-drawer:not([hidden]),
.ticket-screen-share-video-wrap.is-pseudo-fullscreen.is-fs-chat-open .ticket-screen-share-fs-drawer:not([hidden]) {
    display: flex;
    flex: 0 0 min(400px, 34vw);
    width: min(400px, 34vw);
    max-width: 100%;
    height: 100%;
    min-height: 0;
}

.ticket-screen-share-fs-drawer__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.ticket-screen-share-fs-drawer__title {
    display: block;
    font-size: 1rem;
    color: #0f172a;
}

.ticket-screen-share-fs-drawer__subtitle {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.ticket-screen-share-fs-thread {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 1rem;
    min-height: 0;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ticket-screen-share-fs-thread .ticket-comment {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    margin: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ticket-screen-share-fs-thread .ticket-comment--customer {
    background: #f0fdf4;
    border-color: #bbf7d0;
    border-left: 4px solid #16a34a;
}

.ticket-screen-share-fs-thread .ticket-comment--internal {
    background: #fffbeb;
    border-color: #fde68a;
}

.ticket-screen-share-fs-thread .ticket-comment__head {
    flex-wrap: wrap;
    gap: 0.35rem;
}

.ticket-screen-share-fs-thread .ticket-comment__author,
.ticket-screen-share-fs-thread .ticket-comment__body {
    color: #334155;
}

.ticket-screen-share-fs-thread .ticket-comment__body {
    font-size: 0.9rem;
    line-height: 1.45;
}

.ticket-screen-share-fs-thread .text-muted,
.ticket-screen-share-fs-thread .ticket-comment__date {
    color: #64748b !important;
}

.ticket-screen-share-fs-thread .ticket-event {
    font-size: 0.8rem;
    color: #64748b;
    padding: 0.35rem 0.5rem;
    background: #fff;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
}

.ticket-screen-share-fs-thread .ticket-thread-empty {
    color: #64748b;
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem 0.5rem;
}

.ticket-screen-share-fs-thread .attachment-grid {
    display: none;
}

.ticket-screen-share-fs-compose {
    flex-shrink: 0;
    padding: 0.85rem 1rem 1rem;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.ticket-screen-share-fs-compose textarea {
    resize: none;
    min-height: 4.5rem;
    max-height: 10rem;
    font-size: 0.95rem;
}

.ticket-screen-share-fs-hint {
    margin-top: 0.35rem;
}

.ticket-screen-share-fs-fab {
    position: absolute;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 5;
    border-radius: 999px;
    padding: 0.5rem 1.1rem;
    white-space: nowrap;
}

.ticket-screen-share-video-wrap:fullscreen .ticket-screen-share-video-controls,
.ticket-screen-share-video-wrap.is-pseudo-fullscreen .ticket-screen-share-video-controls {
    top: 12px;
    right: 12px;
    bottom: auto;
    z-index: 6;
}

.ticket-screen-share-video-wrap:fullscreen.is-fs-chat-open .ticket-screen-share-video-controls,
.ticket-screen-share-video-wrap.is-pseudo-fullscreen.is-fs-chat-open .ticket-screen-share-video-controls {
    right: calc(min(400px, 34vw) + 12px);
}

.ticket-screen-share-video-controls [data-screen-share-mic-mute].is-muted,
.ticket-screen-share-video-controls [data-screen-share-remote-mute].is-muted {
    background: #fff5f5;
    border-color: #dc3545;
    color: #dc3545;
}

.ticket-screen-share-video-controls [data-screen-share-fs-chat-toggle].is-active {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

@media (max-width: 900px) {
    .ticket-screen-share-video-wrap:fullscreen.is-fs-chat-open .ticket-screen-share-fs-stage,
    .ticket-screen-share-video-wrap.is-pseudo-fullscreen.is-fs-chat-open .ticket-screen-share-fs-stage {
        flex-direction: column;
    }

    .ticket-screen-share-video-wrap:fullscreen.is-fs-chat-open .ticket-screen-share-fs-drawer:not([hidden]),
    .ticket-screen-share-video-wrap.is-pseudo-fullscreen.is-fs-chat-open .ticket-screen-share-fs-drawer:not([hidden]) {
        flex: 0 0 42vh;
        width: 100%;
        height: 42vh;
        border-left: none;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
    }

    .ticket-screen-share-video-wrap:fullscreen.is-fs-chat-open .ticket-screen-share-video-inner,
    .ticket-screen-share-video-wrap.is-pseudo-fullscreen.is-fs-chat-open .ticket-screen-share-video-inner {
        flex: 1 1 58vh;
        height: 58vh;
        max-height: 58vh;
    }

    .ticket-screen-share-video-wrap:fullscreen.is-fs-chat-open .ticket-screen-share-video-controls,
    .ticket-screen-share-video-wrap.is-pseudo-fullscreen.is-fs-chat-open .ticket-screen-share-video-controls {
        right: 12px;
    }
}

.ticket-screen-share-timing dt {
    font-weight: 500;
}

.ticket-screen-share-history table th {
    font-weight: 600;
    white-space: nowrap;
}

.ticket-customer-card .card-body {
    background: linear-gradient(180deg, #f0f9ff 0%, #fff 60%);
}
.ticket-customer-card #portalLinkInput {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: .75rem;
}

/* Allegati */
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}
.attachment-grid--inline {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.attachment-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: background-color .15s ease, border-color .15s ease;
}
.attachment-card:hover { background: #f3f4f6; border-color: #d1d5db; }
.attachment-card__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.attachment-card__icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.attachment-card__icon-link {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #0086c9;
    font-size: 1.45rem;
}
.attachment-card__body {
    flex-grow: 1;
    min-width: 0;
}
.attachment-card__name {
    font-size: .82rem;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attachment-card__meta {
    font-size: .7rem;
    color: #6b7280;
    display: flex;
    gap: 4px;
    margin-top: 2px;
}
.attachment-card__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.attachment-card__actions .btn {
    padding: 2px 8px;
    line-height: 1;
}

.ticket-upload-form {
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px dashed #d1d5db;
}

/* Form ticket - blocco cliente con tab */
.ticket-customer-fieldset {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
.ticket-customer-fieldset__head {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 14px;
    font-size: .92rem;
    display: flex;
    align-items: center;
    color: #374151;
}
.ticket-customer-tabs {
    padding: 0 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
.ticket-customer-tabs .nav-link {
    border-radius: 0;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6b7280;
    font-weight: 500;
    padding: 8px 14px;
    background: transparent;
}
.ticket-customer-tabs .nav-link:hover {
    color: #0086c9;
    background: #fff;
}
.ticket-customer-tabs .nav-link.active {
    color: #0086c9;
    background: #fff;
    border-bottom-color: #0086c9;
    font-weight: 600;
}
.ticket-customer-tabcontent {
    padding: 14px;
}
.ticket-customer-tabcontent .form-label {
    font-weight: 500;
    color: #374151;
}

/* Multi-select assegnatari - altezza più consistente */
.ticket-assignees-select {
    min-height: 130px;
    background-image: none !important;
}
.ticket-assignees-select option {
    padding: 4px 8px;
}

/* Fieldset allegati uniforme */
.ticket-attachments-fieldset {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    padding: 14px;
    margin: 0;
}
.ticket-attachments-fieldset__legend {
    float: none;
    width: auto;
    padding: 0 8px;
    font-size: .95rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

/* Bottoni azione form */
.ticket-form-actions {
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

/* Mobile: tab stacked */
@media (max-width: 575.98px) {
    .ticket-customer-tabs .nav-link {
        padding: 8px 10px;
        font-size: .85rem;
    }
}

/* Customer - banner "Cliente di" */
.customer-service-banner {
    background: color-mix(in srgb, var(--company-color, #0086c9) 10%, #fff);
    border: 1px solid color-mix(in srgb, var(--company-color, #0086c9) 30%, #fff);
    border-left: 4px solid var(--company-color, #0086c9);
    color: #1f2937;
    padding: 10px 14px;
    border-radius: 8px;
}
.customer-service-banner .bi-building-check { color: var(--company-color, #0086c9); }
.customer-service-banner a { color: var(--company-color, #0086c9); }
.customer-service-banner a:hover { text-decoration: underline; }

/* Customer fieldset */
.customer-fieldset {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    padding: 14px;
}
.customer-fieldset__legend {
    float: none;
    width: auto;
    padding: 0 8px;
    font-size: .95rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.customer-fieldset__hint {
    font-size: .8rem;
    color: #6b7280;
    padding: 6px 10px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}
.customer-fieldset--service {
    background: linear-gradient(180deg, #f0f9ff 0%, #fff 50%);
    border-color: #bae6fd;
}
.customer-fieldset--service .customer-fieldset__legend { color: #0086c9; }

.customer-form-actions {
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}
.ticket-comment__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: .85rem;
}
.ticket-comment__author { font-weight: 600; color: #1f2937; }
.ticket-comment__body { color: #374151; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

.ticket-event {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .82rem;
    color: #6b7280;
    padding: 4px 10px;
    border-left: 2px solid #d1d5db;
    margin-left: 6px;
}
.ticket-event .bi { color: #9ca3af; }
.ticket-event__date { margin-left: auto; color: #9ca3af; font-size: .75rem; }

/* Form commento */
.ticket-comment-form textarea {
    resize: vertical;
    min-height: 70px;
}

/* Lista assegnatari nel picker */
.ticket-assignee-row {
    border-radius: 6px;
    padding: 4px 8px;
    margin: 0;
    cursor: pointer;
}
.ticket-assignee-row:hover { background: #f3f4f6; }
.ticket-assignee-row input[type="checkbox"] { flex-shrink: 0; }

/* Form ticket */
.ticket-form .form-label { font-weight: 500; color: #374151; font-size: .9rem; }

/* Responsive */
@media (max-width: 767.98px) {
    .ticket-table th, .ticket-table td { font-size: .8rem; padding: .5rem .35rem; }
    .ticket-code-badge { font-size: .8rem; padding: 3px 7px; }
    .ticket-thread { max-height: none; }
}
