/* ============================================
   MobileCare Gestionale - Modern Dashboard Style
   ============================================ */

:root {
    /* Colori MobileCare: Rosso, Nero, Bianco */
    --primary: #cc0000;
    --primary-light: #e53333;
    --primary-dark: #a00000;
    --secondary: #111111;

    --red: #cc0000;
    --darkred: #a00000;
    --black: #111111;
    --darkgray: #333333;
    --green: #2e7d32;
    --orange: #e65100;
    --yellow: #f9a825;
    --blue: #1565c0;

    /* Gradienti */
    --gradient-1: linear-gradient(135deg, #cc0000, #e53333);
    --gradient-2: linear-gradient(135deg, #111111, #333333);
    --gradient-3: linear-gradient(135deg, #2e7d32, #43a047);
    --gradient-4: linear-gradient(135deg, #e65100, #ff6d00);

    --bg: #f5f5f5;
    --bg-sidebar: #111111;
    --bg-card: #ffffff;

    --text: #111111;
    --text-secondary: #555555;
    --text-muted: #999999;

    --border: #e0e0e0;

    --sidebar-w: 200px;
    --header-h: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.12);

    --transition: all 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

a { text-decoration: none; color: inherit; }
button { border: none; background: none; cursor: pointer; font-family: inherit; }
input { font-family: inherit; border: none; outline: none; }

/* ============================================
   Background Decorations (cerchi sfocati)
   ============================================ */
.bg-decoration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.2;
}

.bg-circle-1 {
    width: 400px;
    height: 400px;
    background: var(--red);
    bottom: -120px;
    left: -100px;
}

.bg-circle-2 {
    width: 350px;
    height: 350px;
    background: var(--darkred);
    bottom: -80px;
    right: 3%;
}

.bg-circle-3 {
    width: 280px;
    height: 280px;
    background: var(--black);
    top: -70px;
    right: 12%;
}

/* ============================================
   Sidebar (stretta, con icone come nello screenshot)
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
    padding: 0;
}

.sidebar-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: #fff;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon img.sidebar-logo-img {
    height: 32px;
    object-fit: contain;
    display: block;
}

/* Linea rossa separatore tra logo bianco e sidebar nera */
.sidebar-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--primary);
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 20px 10px 12px;
    width: 100%;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

.nav-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    width: 100%;
    border-radius: var(--radius-xs);
    color: rgba(255, 255, 255, 0.6);
    transition: var(--transition);
    position: relative;
    text-decoration: none;
    cursor: pointer;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    color: #fff;
    background: var(--primary);
}

.nav-item.active::before {
    display: none;
}

.nav-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: var(--transition);
    flex-shrink: 0;
}

.nav-item.active .nav-icon-wrap {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    box-shadow: none;
}

.nav-label {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.3px;
    line-height: 1;
    white-space: nowrap;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* ---- Top Header ---- */
.top-header {
    position: sticky;
    top: 0;
    height: var(--header-h);
    background: rgba(245, 246, 250, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
}

.menu-toggle:hover {
    background: rgba(204, 0, 0, 0.08);
    color: var(--primary);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.breadcrumb-section {
    color: var(--text-muted);
    font-weight: 500;
}

.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 11px;
}

.breadcrumb-page {
    color: var(--text);
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Header links (come Pricing/About nello screenshot) */
.header-links {
    display: flex;
    gap: 20px;
}

.header-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
}

.header-link:hover,
.header-link.active {
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
    position: relative;
    font-size: 15px;
}

.header-btn:hover {
    background: rgba(204, 0, 0, 0.08);
    color: var(--primary);
}

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: var(--primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* User profile chip (come nello screenshot: avatar + nome a destra) */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 14px 5px 5px;
    border-radius: 50px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.user-profile:hover {
    box-shadow: var(--shadow-hover);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.user-role {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================
   Page Content
   ============================================ */
.page-content {
    flex: 1;
    padding: 20px 24px 32px;
}

.page {
    display: none !important;
}

.page.active {
    display: block !important;
    animation: pageIn 0.3s ease;
}

#page-clienti.active,
#page-interventi.active {
    display: flex !important;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Page Title Section (come "Task Management" nello screenshot) ---- */
.page-title-section {
    margin-bottom: 24px;
}

.page-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.page-meta {
    display: flex;
    gap: 18px;
    margin-top: 6px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.meta-dot-blue { background: var(--blue); }
.meta-dot-orange { background: var(--orange); }
.meta-dot-green { background: var(--green); }
.meta-dot-purple { background: var(--purple); }
.meta-dot-red { background: #ef4444; }

/* ---- Nav Badges (come nello screenshot: pallini colorati a destra) ---- */
.nav-badge {
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.nav-badge.visible {
    display: flex;
}

.nav-badge-blue { background: linear-gradient(135deg, #cc0000, #e53333); box-shadow: 0 2px 6px rgba(204, 0, 0, 0.3); }
.nav-badge-red { background: linear-gradient(135deg, #f87171, #ef4444); box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4); }
.nav-badge-green { background: linear-gradient(135deg, #34d399, #22c55e); box-shadow: 0 2px 6px rgba(52, 211, 153, 0.4); }

/* ============================================
   Dashboard Layout (2 colonne come screenshot)
   ============================================ */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

/* ---- Main Card (grande, bianca, bordi arrotondati) ---- */
.main-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.card-inner {
    padding: 28px;
}

/* ---- Side Panel (colonna destra) ---- */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.side-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 20px;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

/* User card nella sidebar destra */
.user-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 20px;
}

.user-card-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gradient-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 10px;
    box-shadow: 0 6px 18px rgba(244, 114, 182, 0.35);
}

.user-card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.user-card-role {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Side card title */
.side-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    letter-spacing: -0.2px;
}

/* Quick stats */
.quick-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.quick-stat:last-child {
    border-bottom: none;
}

.qs-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.qs-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

/* Efficiency rings */
.efficiency-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.eff-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.eff-ring {
    width: 40px;
    height: 40px;
    transform: rotate(-90deg);
}

.eff-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dbeafe, #e0e7ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: var(--primary);
    margin-bottom: 18px;
    box-shadow: 0 4px 14px rgba(204, 0, 0, 0.15);
}

.empty-state h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 300px;
    line-height: 1.6;
}

/* ============================================
   Actions Bar (Clienti page)
   ============================================ */
.actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 10px 18px;
    flex: 1;
    max-width: 380px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.12);
}

.search-box i {
    color: var(--text-muted);
    font-size: 13px;
}

.search-box input {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    background: transparent;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-1);
    color: #fff;
    box-shadow: 0 4px 16px rgba(204, 0, 0, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(204, 0, 0, 0.3);
}

/* Quick Entry Button */
.btn-quick-entry {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #111;
    color: #ffd600;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.btn-quick-entry:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    background: var(--primary);
    color: #fff;
}

/* Quick Entry Modal */
.qe-container {
    max-width: 520px;
    width: 100%;
}
.qe-body {
    padding: 20px;
}
.qe-hint {
    margin: 0 0 10px;
    color: #666;
    font-size: 13px;
    line-height: 1.4;
}
.qe-hint i {
    color: var(--primary);
    margin-right: 4px;
}
.qe-example {
    background: #f9f9f9;
    border: 1px dashed #d0d0d0;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #888;
    line-height: 1.6;
    font-style: italic;
}
.qe-textarea {
    resize: vertical;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100px;
    border-radius: 12px;
    padding: 14px;
}
.qe-preview {
    margin-top: 14px;
}
.qe-preview-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 13px;
    color: #333;
}
.qe-preview-title i {
    color: var(--primary);
    margin-right: 4px;
}
.qe-preview-content {
    background: #f5f5f5;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.8;
}
.qe-preview-content div {
    padding: 2px 0;
}

/* Quick Entry - Mobile full screen */
@media (max-width: 768px) {
    .qe-overlay {
        padding: 0 !important;
        align-items: stretch !important;
    }
    .qe-container {
        max-width: 100% !important;
        width: 100% !important;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }
    .qe-header {
        padding: 16px 16px 12px;
        position: sticky;
        top: 0;
        z-index: 2;
        background: #fff;
    }
    .qe-body {
        flex: 1;
        padding: 16px;
        overflow-y: auto;
    }
    .qe-textarea {
        font-size: 17px;
        min-height: 140px;
        padding: 16px;
        border-radius: 14px;
    }
    .qe-example {
        font-size: 12px;
        padding: 8px 12px;
    }
    .qe-preview-content {
        font-size: 15px;
    }
    .qe-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        background: #fff;
        padding: 12px 16px 16px;
        border-top: 1px solid var(--border);
        gap: 10px;
    }
    .qe-footer .btn {
        flex: 1;
        min-height: 48px;
        font-size: 15px;
        border-radius: 12px;
    }
}

/* ============================================
   CLIENTI - Header, Filters, Table
   ============================================ */
.clienti-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.clienti-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.clienti-filters .search-box {
    max-width: 360px;
}

.filter-select-wrap {
    position: relative;
}

.filter-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 10px 38px 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7194'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.1);
}

.clienti-count {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.card-inner-table {
    padding: 0;
}

/* Clienti Table */
.clienti-table {
    width: 100%;
    border-collapse: collapse;
}

.clienti-table thead th {
    text-align: left;
    padding: 14px 24px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: linear-gradient(180deg, #f8faff, #f0f4ff);
}

.clienti-table thead th:last-child {
    text-align: right;
}

.clienti-table tbody tr {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: var(--transition);
    cursor: pointer;
}

.clienti-table tbody tr:last-child {
    border-bottom: none;
}

.clienti-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(204, 0, 0, 0.03), rgba(17, 17, 17, 0.02));
}

.clienti-table td {
    padding: 16px 24px;
    font-size: 13px;
    vertical-align: middle;
}

.td-cliente {
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

.td-contatto {
    color: var(--text-secondary);
}

.td-dispositivi {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.disp-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.disp-chip i {
    font-size: 11px;
    color: var(--text-muted);
}

.status-badge {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 10px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge-coda {
    background: #f0f0f5;
    color: var(--text-secondary);
}

.status-badge-lavorazione {
    background: #fff3e0;
    color: #e65100;
}

.status-badge-completato {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge-consegnato {
    background: #e3f2fd;
    color: #1565c0;
}

.td-actions {
    text-align: right;
}

.btn-rapporto {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-rapporto:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(204, 0, 0, 0.3);
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(8px);
    z-index: 200;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 780px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.06);
    animation: modalIn 0.25s ease;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-muted);
    background: var(--bg);
    transition: var(--transition);
}

.modal-close:hover {
    background: #e8e8ed;
    color: var(--text);
}

.modal-body {
    padding: 24px 28px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 28px 20px;
    border-top: 1px solid var(--border);
}

.btn-outline {
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: #f8fafc;
    color: var(--primary);
    border-color: var(--primary-light);
}

/* ============================================
   FORM
   ============================================ */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.required {
    color: var(--primary);
}

.form-input,
.form-select {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    color: var(--text);
    background: #fff;
    font-family: inherit;
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.12);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7194'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-center {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

/* ============================================
   DISPOSITIVO CARD (sfondo blu chiaro)
   ============================================ */
.dispositivo-section {
    margin-top: 20px;
}

.dispositivo-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

.dispositivo-section-header i {
    color: var(--primary);
}

.dispositivo-card {
    background: linear-gradient(135deg, #f0f4ff, #e8efff);
    border: 2px dashed #c7d2fe;
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 16px;
    position: relative;
}

.dispositivo-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-remove-disp {
    font-size: 12px;
    color: #ef4444;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-remove-disp:hover {
    background: #fef2f2;
}

/* Cerca dispositivo */
.search-disp {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 10px;
}

.search-disp i {
    font-size: 14px;
}

.search-disp-label {
    font-style: italic;
}

.disp-search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-xs);
    font-size: 13px;
    color: var(--text);
    background: #fff;
    font-family: inherit;
    margin-bottom: 14px;
    transition: var(--transition);
}

.disp-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.12);
}

/* Inner device detail card */
.disp-detail-card {
    background: rgba(255,255,255,0.7);
    border: 1px solid #d4d8f0;
    border-radius: var(--radius-xs);
    padding: 16px;
    margin-bottom: 14px;
}

.disp-detail-card .form-row {
    margin-bottom: 12px;
}

.disp-detail-card .form-row:last-child {
    margin-bottom: 0;
}

/* ============================================
   SEQUENZA SBLOCCO (Tastierino 3x3)
   ============================================ */
.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 180px;
    margin: 8px auto 4px;
}

.pin-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #d4d8f0;
    background: #fff;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.pin-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pin-btn:hover {
    border-color: var(--primary-light);
}

.pin-clear {
    display: block;
    text-align: center;
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    margin-top: 6px;
}

.pin-clear:hover {
    text-decoration: underline;
}

/* ============================================
   PROBLEMI / GUASTI
   ============================================ */
.guasti-section {
    margin-top: 14px;
}

.guasti-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text);
    margin-bottom: 10px;
}

.guasto-row {
    margin-bottom: 10px;
}

.guasto-row .form-select,
.guasto-row .form-input {
    padding: 10px 12px;
    font-size: 13px;
}

.btn-remove-guasto {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 13px;
    margin-bottom: 2px;
    transition: var(--transition);
}

.btn-remove-guasto:hover {
    background: #fef2f2;
}

.btn-add-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 2px;
}

.btn-add-link:hover {
    text-decoration: underline;
}

.priorita-row {
    margin-top: 12px;
}

.priorita-row .form-label {
    margin-bottom: 4px;
}

.priorita-row .form-select {
    max-width: 220px;
}

.checkbox-row {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Print label bar */
.print-label-bar {
    background: #fef9e7;
    border-radius: var(--radius-xs);
    padding: 14px 18px;
    margin-top: 18px;
}

.print-label-bar .checkbox-label {
    color: var(--text);
}

/* + Altro Dispositivo */
.btn-altro-disp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid var(--primary);
    background: transparent;
    cursor: pointer;
    margin-top: 8px;
    transition: var(--transition);
}

.btn-altro-disp:hover {
    background: rgba(204, 0, 0, 0.06);
}

/* ============================================
   DETAIL PANEL (Side Panel Dettaglio Cliente)
   ============================================ */
.detail-panel-overlay {
    display: none;
}

/* Clienti page becomes a flex row when panel is open */
#page-clienti {
    display: flex;
    gap: 0;
    align-items: flex-start;
    transition: gap 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#page-clienti.with-detail {
    gap: 24px;
}

.clienti-main {
    flex: 1;
    min-width: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - var(--header-h) - 40px);
    position: sticky;
    top: calc(var(--header-h) + 20px);
    border: 1px solid rgba(0, 0, 0, 0.04);

    /* Collapsed state */
    width: 0;
    min-width: 0;
    opacity: 0;
    transform: translateX(40px);
    pointer-events: none;
    border: 0 solid transparent;
    box-shadow: none;

    transition:
        width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.4s ease,
        border 0.3s ease;
}

.detail-panel.open {
    width: 360px;
    min-width: 360px;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    box-shadow: var(--shadow-card);
}

.detail-panel .detail-panel-header,
.detail-panel .detail-panel-body {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease 0.1s, transform 0.3s ease 0.1s;
}

.detail-panel.open .detail-panel-header,
.detail-panel.open .detail-panel-body {
    opacity: 1;
    transform: translateY(0);
}

.detail-panel.open .detail-panel-body {
    transition-delay: 0.15s;
}

.detail-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, #cc0000, #e53333);
    color: #fff;
    flex-shrink: 0;
}

.detail-panel-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}

.detail-panel-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-panel-btn-delete,
.detail-panel-btn-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.15);
    transition: var(--transition);
}

.detail-panel-btn-delete:hover {
    background: rgba(239, 68, 68, 0.8);
    color: #fff;
}

.detail-panel-btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.detail-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* QR Code Section */
.detail-qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.detail-qr-section canvas {
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.detail-qr-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    font-weight: 500;
}

/* Contact Info */
.detail-info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text);
}

.detail-info-item i {
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.detail-info-item span {
    font-weight: 500;
}

/* Action Buttons */
.detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 28px;
}

.detail-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
    border: none;
    cursor: pointer;
}

.detail-action-btn-chiama {
    background: linear-gradient(135deg, #cc0000, #e53333);
    color: #fff;
    box-shadow: 0 3px 10px rgba(204, 0, 0, 0.2);
}

.detail-action-btn-chiama:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(204, 0, 0, 0.25);
}

.detail-action-btn-whatsapp {
    background: linear-gradient(135deg, #25d366, #34d399);
    color: #fff;
    box-shadow: 0 3px 10px rgba(37, 211, 102, 0.25);
}

.detail-action-btn-whatsapp:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(37, 211, 102, 0.35);
}

.detail-action-btn-etichetta {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.detail-action-btn-etichetta:hover {
    background: #f8fafc;
    border-color: var(--primary-light);
    color: var(--primary);
}

.detail-action-btn-modifica {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.detail-action-btn-modifica:hover {
    background: #f8fafc;
    border-color: var(--primary-light);
    color: var(--primary);
}

/* Detail Section Titles */
.detail-section {
    margin-bottom: 24px;
}

.detail-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
}

/* Detail Device Card */
.detail-disp-card {
    background: linear-gradient(135deg, #f0f4ff, #e8efff);
    border: 1px solid rgba(204, 0, 0, 0.12);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}

.detail-disp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}

.detail-disp-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.detail-disp-type {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.detail-disp-status {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
}

.detail-disp-status-coda {
    background: #f0f0f5;
    color: var(--text-secondary);
}

.detail-disp-status-lavorazione {
    background: #fff3e0;
    color: #e65100;
}

.detail-disp-status-completato {
    background: #e8f5e9;
    color: #2e7d32;
}

.detail-disp-status-consegnato {
    background: #e3f2fd;
    color: #1565c0;
}

/* Pattern lock grid in detail panel */
.detail-pattern-grid {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 10px auto;
}

.detail-pattern-grid svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.detail-pattern-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #c7d0e8;
    transform: translate(-50%, -50%);
}

.detail-pattern-dot.active {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(204, 0, 0, 0.2);
}

.detail-pattern-seq {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-top: 8px;
}

/* Guasti badges */
.detail-guasti {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.detail-guasto-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    background: #fef9e7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Add button in detail panel */
.detail-btn-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    background: transparent;
    border: 2px dashed var(--primary-light);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 10px;
}

.detail-btn-add:hover {
    background: rgba(204, 0, 0, 0.06);
}

/* ============================================
   Sidebar Overlay (Mobile)
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ============================================
   RESPONSIVE - Tablet
   ============================================ */
@media (max-width: 1100px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .side-panel {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .page-content {
        padding: 20px 24px;
    }

    .interventi-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   RESPONSIVE - Mobile (< 768px)
   ============================================ */
@media (max-width: 768px) {
    :root {
        --header-h: 48px;
    }

    /* Bigger base font on mobile */
    html {
        font-size: 16px;
    }

    /* Hide sidebar completely - use bottom nav */
    .sidebar,
    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding-bottom: 72px; /* space for bottom nav */
    }

    .menu-toggle {
        display: none !important;
    }

    /* Simplified app-style header */
    .top-header {
        padding: 0 14px;
        height: var(--header-h);
        background: #fff;
        border-bottom: 1px solid #eee;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .breadcrumb-sep,
    .breadcrumb-page {
        display: none;
    }

    .breadcrumb-section {
        font-size: 18px;
        font-weight: 700;
    }

    .header-links,
    .user-info {
        display: none;
    }

    .user-profile {
        padding: 4px;
    }

    /* Hide bg decorations on mobile */
    .bg-decoration {
        display: none;
    }

    /* Page content */
    .page-content {
        padding: 14px;
        padding-bottom: 16px;
    }

    .page-title {
        font-size: 24px;
        font-weight: 700;
    }

    /* Dashboard */
    .dash-header {
        margin-bottom: 16px;
    }

    .dash-stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    .dash-stat-card {
        padding: 14px;
        border-radius: 14px;
    }

    .dash-stat-card h3 {
        font-size: 12px;
    }

    .dash-stat-val {
        font-size: 26px !important;
        font-weight: 800;
    }

    .dash-stat-card i {
        font-size: 20px;
    }

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

    .side-panel {
        grid-template-columns: 1fr;
    }

    /* Buttons */
    .btn {
        font-size: 14px;
        padding: 10px 16px;
        border-radius: 10px;
    }

    .btn-primary {
        justify-content: center;
        min-height: 44px;
    }

    .actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    /* Search box */
    .search-box {
        max-width: 100%;
    }

    .search-box input {
        font-size: 16px;
        min-height: 44px;
    }

    /* Clienti header */
    .clienti-header {
        gap: 10px;
    }

    /* Tables → Card layout */
    .clienti-table thead,
    .interventi-table thead {
        display: none;
    }

    .clienti-table tbody tr,
    .interventi-table tbody tr {
        display: flex;
        flex-direction: column;
        padding: 16px;
        gap: 8px;
        border-bottom: 1px solid #eee;
        margin-bottom: 8px;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    }

    .clienti-table td,
    .interventi-table td {
        padding: 3px 0;
        font-size: 15px;
    }

    .td-dispositivi {
        flex-direction: column;
        align-items: flex-start;
    }

    .td-actions {
        text-align: left;
        padding-top: 6px;
    }

    /* Clienti filters */
    .clienti-filters,
    .interventi-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .clienti-filters .search-box,
    .interventi-filters .search-box {
        max-width: 100%;
    }

    /* Interventi stat cards */
    .interventi-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
        gap: 10px;
        border-radius: 12px;
    }

    .stat-card-value {
        font-size: 24px;
        font-weight: 700;
    }

    .stat-card-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .lavoro-row {
        flex-direction: column;
        align-items: stretch;
    }

    .lavoro-row .form-group {
        width: 100% !important;
    }

    /* Detail panel → full width overlay on mobile */
    #page-clienti {
        flex-direction: column;
    }

    .detail-panel.open {
        width: 100%;
        min-width: 100%;
        max-height: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 150;
        transform: none;
        border-radius: 0;
        overflow-y: auto;
    }

    /* Modal → full screen on mobile */
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    .modal-container {
        max-width: 100% !important;
        width: 100% !important;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        flex: 1;
        padding: 16px;
        overflow-y: auto;
    }

    .modal-header {
        padding: 14px 16px;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 2;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 2;
        padding: 12px 16px 16px;
        border-top: 1px solid #eee;
    }

    .modal-footer .btn {
        min-height: 44px;
        font-size: 15px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
        min-height: 44px;
        border-radius: 10px;
    }

    .form-label {
        font-size: 13px;
    }

    .guasto-row {
        grid-template-columns: 1fr;
    }

    /* Empty state */
    .empty-state {
        padding: 40px 16px;
    }

    .empty-state i {
        font-size: 48px;
    }

    .empty-state p {
        font-size: 16px;
    }

    /* Promemoria */
    .promemoria-columns {
        grid-template-columns: 1fr !important;
    }

    /* Quick rem buttons */
    .quick-rem-btn {
        font-size: 14px;
        padding: 10px 14px;
    }

    /* ---- GLOBAL MOBILE TEXT FIX ---- */
    /* All inputs/selects/textareas minimum 16px (prevent iOS zoom) */
    input, select, textarea,
    .form-input, .form-select, .form-textarea,
    .disp-search-input,
    .search-box input {
        font-size: 16px !important;
        min-height: 44px;
    }

    /* Nav labels, breadcrumbs */
    .nav-label { font-size: 14px; }

    /* Table cells bigger */
    .clienti-table td,
    .interventi-table td {
        font-size: 15px;
        line-height: 1.5;
    }

    /* Badges and status */
    .status-badge,
    .badge {
        font-size: 12px;
        padding: 4px 10px;
    }

    /* Card sections titles */
    .section-title,
    .detail-section-title,
    .cd-title {
        font-size: 14px !important;
    }

    /* Card values and labels */
    .cd-val {
        font-size: 15px !important;
    }
    .cd-lbl {
        font-size: 11px !important;
    }

    /* Coda lavori cards */
    .coda-c-name {
        font-size: 15px !important;
    }
    .coda-d-wrap {
        font-size: 15px !important;
    }
    .coda-td-prob {
        font-size: 14px !important;
        max-width: none !important;
        white-space: normal !important;
    }

    /* Dispositivo search */
    .search-disp {
        font-size: 14px;
    }
    .disp-search-input {
        padding: 12px 14px;
        border-radius: 10px;
    }

    /* Form groups */
    .form-label {
        font-size: 13px;
        font-weight: 600;
    }
    .form-group {
        margin-bottom: 14px;
    }

    /* Dispositivo cards in modal */
    .dispositivo-card {
        border-radius: 12px;
        padding: 14px;
    }

    /* Guasto entries */
    .guasto-entry {
        font-size: 14px;
    }

    /* Detail panel mobile */
    .detail-panel.open .detail-body {
        padding: 14px;
    }
    .detail-rap-info {
        font-size: 14px !important;
        line-height: 1.6;
    }
    .detail-rap-codice {
        font-size: 15px !important;
    }
    .detail-rap-totale {
        font-size: 15px !important;
    }

    /* Promemoria items */
    .prom-card-text,
    .prom-item-text {
        font-size: 15px;
    }

    /* Interventi stat */
    .stat-card-label {
        font-size: 12px;
    }

    /* Magazzino */
    .mag-prod-name {
        font-size: 15px !important;
    }

    /* Settings */
    .sett-label {
        font-size: 15px;
    }

    /* General font bump for body text */
    p, span, div, td, th, li, label {
        line-height: 1.5;
    }
}

/* ============================================
   BOTTOM NAVIGATION (Mobile App Style)
   ============================================ */
.bottom-nav {
    display: none; /* Hidden on desktop */
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: #fff;
        border-top: 1px solid #e5e5e5;
        z-index: 200;
        align-items: stretch;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
        box-shadow: 0 -2px 16px rgba(0,0,0,0.06);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        color: #999;
        font-size: 10px;
        font-weight: 500;
        position: relative;
        transition: color 0.2s;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        border: none;
        background: none;
        outline: none;
        cursor: pointer;
        font-family: inherit;
        padding: 0;
    }

    .bottom-nav-item i {
        font-size: 20px;
        line-height: 1;
    }

    .bottom-nav-item span {
        line-height: 1;
    }

    .bottom-nav-item.active {
        color: var(--primary);
    }

    .bottom-nav-item.active i {
        transform: scale(1.1);
    }

    .bottom-nav-badge {
        position: absolute;
        top: 6px;
        right: 50%;
        transform: translateX(14px);
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        background: var(--primary);
        color: #fff;
        font-size: 9px;
        font-weight: 700;
        display: none;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        line-height: 1;
    }

    .bottom-nav-badge.visible {
        display: flex;
    }

    /* "Altro" more menu */
    .bottom-nav-more-menu {
        display: none;
        position: absolute;
        bottom: calc(64px + env(safe-area-inset-bottom, 0));
        right: 0;
        background: #fff;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
        padding: 8px 0;
        min-width: 200px;
        z-index: 201;
    }

    .bottom-nav-more-menu.open {
        display: block;
    }

    .bottom-nav-more-item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 20px;
        text-decoration: none;
        color: #333;
        font-size: 15px;
        font-weight: 500;
        transition: background 0.15s;
        border: none;
        background: none;
        outline: none;
        cursor: pointer;
        font-family: inherit;
        width: 100%;
    }

    .bottom-nav-more-item:active {
        background: #f5f5f5;
    }

    .bottom-nav-more-item i {
        font-size: 18px;
        color: #666;
        width: 24px;
        text-align: center;
    }

    .bottom-nav-more-item.active {
        color: var(--primary);
    }
    .bottom-nav-more-item.active i {
        color: var(--primary);
    }

    /* Backdrop for more menu */
    .bottom-nav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 199;
        background: rgba(0,0,0,0.2);
    }
    .bottom-nav-backdrop.open {
        display: block;
    }
}

/* ============================================
   RESPONSIVE - Small Mobile
   ============================================ */
@media (max-width: 480px) {
    .page-meta {
        flex-wrap: wrap;
        gap: 10px;
    }

    .efficiency-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   INTERVENTI - Stat Cards, Filters, Table, Modal
   ============================================ */
.interventi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.interventi-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
}

.stat-card-green {
    background: linear-gradient(135deg, #2e7d32, #43a047);
    color: #fff;
}

.stat-card-blue {
    background: linear-gradient(135deg, #cc0000, #e53333);
    color: #fff;
}

.stat-card-lime {
    background: linear-gradient(135deg, #111111, #333333);
    color: #fff;
}

.stat-card-orange {
    background: linear-gradient(135deg, #e65100, #ff6d00);
    color: #fff;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}

.stat-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    z-index: 1;
}

.stat-card-label {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.85;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
}

.stat-card-euro {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.9;
}

/* Interventi filters */
.interventi-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.interventi-filters .search-box {
    max-width: 360px;
}

/* Interventi table extra */
.td-codice {
    font-weight: 600;
}

.codice-badge {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: var(--primary);
    letter-spacing: 0.5px;
}

.td-disp-int {
    color: var(--text-secondary);
    font-size: 13px;
}

.td-disp-int i {
    color: var(--text-muted);
    margin-right: 4px;
    font-size: 12px;
}

.td-problema {
    color: var(--text-secondary);
    font-size: 13px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-totale {
    font-weight: 700;
    color: var(--green);
    font-size: 14px;
}

.td-data {
    color: var(--text-muted);
    font-size: 12px;
}

/* Action icon buttons */
.btn-action-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-muted);
    transition: var(--transition);
    margin-left: 4px;
}

.btn-action-icon:hover {
    background: rgba(204, 0, 0, 0.08);
    color: var(--primary);
}

.btn-action-danger:hover {
    background: #fef2f2;
    color: #ef4444;
}

/* ---- Intervento Modal Sections ---- */
.modal-intervento {
    max-width: 680px;
}

.intervento-codice-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: #f0f4ff;
    border-radius: var(--radius-xs);
    border: 1px solid #dbe2f5;
}

.intervento-codice-bar .form-label {
    margin: 0;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.intervento-codice-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 1px;
}

.intervento-section-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text);
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

.intervento-section-divider i {
    color: var(--primary);
    font-size: 14px;
}

/* Textarea */
.form-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    line-height: 1.5;
}

/* Lavoro / Ricambio rows */
.lavoro-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 10px;
}

.input-euro-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-euro {
    padding-right: 30px !important;
    width: 100%;
}

.input-euro-symbol {
    position: absolute;
    right: 12px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
}

/* Totale bars */
.intervento-totale-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-radius: var(--radius-xs);
    margin: 12px 0 4px;
    font-size: 14px;
    font-weight: 700;
}

.totale-lavori {
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.totale-ricambi {
    background: #fff5f5;
    color: #a00000;
    border: 1px solid #fca5a5;
}

.totale-generale {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 16px;
    margin-top: 16px;
    box-shadow: 0 4px 16px rgba(204, 0, 0, 0.25);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateX(40px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    max-width: 350px;
}

.toast-show { opacity: 1; transform: translateX(0); }
.toast-hide { opacity: 0; transform: translateX(40px); }

.toast-ok { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.toast-er { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast-info { background: #fff5f5; color: #a00000; border: 1px solid #fca5a5; }

.toast i { font-size: 16px; flex-shrink: 0; }

/* ============================================
   Dashboard
   ============================================ */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.dash-date {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.dash-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.dash-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 22px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.dash-stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.dash-stat-card h3 {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.dash-stat-val {
    font-size: 30px;
    font-weight: 800;
    color: #fff;
}

.dash-stat-card > i {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 24px;
    opacity: 0.25;
    color: #fff;
}

.dash-stat-blue {
    background: linear-gradient(135deg, #cc0000, #e53333);
    box-shadow: 0 6px 20px rgba(204, 0, 0, 0.25);
}
.dash-stat-blue .dash-stat-val { color: #fff; }
.dash-stat-orange {
    background: linear-gradient(135deg, #fb923c, #f472b6);
    box-shadow: 0 6px 20px rgba(251, 146, 60, 0.3);
}
.dash-stat-orange .dash-stat-val { color: #fff; }
.dash-stat-green {
    background: linear-gradient(135deg, #34d399, #22d3ee);
    box-shadow: 0 6px 20px rgba(52, 211, 153, 0.3);
}
.dash-stat-green .dash-stat-val { color: #fff; }
.dash-stat-purple {
    background: linear-gradient(135deg, #111111, #333333);
    box-shadow: 0 6px 20px rgba(17, 17, 17, 0.2);
}
.dash-stat-purple .dash-stat-val { color: #fff; }

.dash-income-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.dash-income-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.dash-income-val {
    font-size: 24px;
    font-weight: 700;
}

.dash-income-green { color: var(--green); }
.dash-income-blue { color: var(--blue); }
.dash-income-purple { color: var(--purple); }

.dash-bottom-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.dash-recent-table {
    width: 100%;
    border-collapse: collapse;
}

.dash-recent-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.dash-recent-table td:first-child { font-weight: 600; }

.dash-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}

.dash-status-ok { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }
.dash-status-lav { background: linear-gradient(135deg, #dbeafe, #fca5a5); color: #a00000; }
.dash-status-att { background: linear-gradient(135deg, #ffedd5, #fed7aa); color: #9a3412; }
.dash-status-ko { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; }

.dash-low-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.dash-low-qty {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: #fef2f2;
    color: #991b1b;
}

/* ============================================
   Coda Lavori
   ============================================ */
.coda-main { flex: 1; min-width: 0; }

.coda-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.coda-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.coda-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.coda-filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.coda-filter-btn.active { background: var(--gradient-1); color: #fff; border-color: transparent; box-shadow: 0 3px 10px rgba(204, 0, 0, 0.25); }
.coda-filter-urgent.active { background: linear-gradient(135deg, #f87171, #ef4444); border-color: transparent; box-shadow: 0 3px 10px rgba(239, 68, 68, 0.3); }
.coda-filter-parts.active { background: linear-gradient(135deg, #fb923c, #f97316); border-color: transparent; box-shadow: 0 3px 10px rgba(251, 146, 60, 0.3); }
.coda-filter-ready.active { background: linear-gradient(135deg, #34d399, #22c55e); border-color: transparent; box-shadow: 0 3px 10px rgba(52, 211, 153, 0.3); }

#page-coda-lavori.active {
    display: block !important;
    position: relative;
}

#page-coda-lavori .coda-main {
    width: 100%;
}

/* Detail panel coda: overlay fisso a destra */
#page-coda-lavori .detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    border-radius: 0;
    z-index: 150;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    max-width: none;
}
#page-coda-lavori .detail-panel.open {
    width: 400px;
    min-width: 400px;
}

#page-coda-lavori .detail-panel-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 140;
}
#page-coda-lavori .detail-panel-overlay.visible {
    display: block;
}

.coda-row-urgent { background: #fef2f2 !important; }
.coda-row-ready { background: #f0fdf4 !important; }

.coda-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}

.coda-status-urgente { background: #fef2f2; color: #dc2626; }
.coda-status-normale { background: #f0f9ff; color: #0369a1; }
.coda-status-pronto { background: #ecfdf5; color: #166534; }

.coda-mini-stepper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.coda-mini-check {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

.coda-mini-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

/* Coda detail panel progress stepper */
.coda-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    padding: 16px;
    background: var(--bg);
    border-radius: 12px;
    margin: 16px 0;
}

.coda-stepper-line {
    position: absolute;
    top: 50%;
    left: 14%;
    right: 14%;
    height: 3px;
    background: #e2e8f0;
    transform: translateY(-50%);
    z-index: 0;
}

.coda-stepper-progress {
    position: absolute;
    top: 50%;
    left: 14%;
    height: 3px;
    background: var(--primary);
    transform: translateY(-50%);
    z-index: 1;
    transition: width 0.3s;
}

.coda-stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    cursor: pointer;
}

.coda-stepper-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.coda-stepper-circle.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.coda-stepper-circle.done {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.coda-stepper-label {
    font-size: 10px;
    margin-top: 6px;
    font-weight: 500;
    color: var(--text-muted);
}

.coda-stepper-label.active { color: var(--primary); font-weight: 600; }
.coda-stepper-label.done { color: var(--green); font-weight: 600; }

.coda-priority-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 0;
}

.coda-priority-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.coda-priority-dot.urgente { background: #ef4444; }
.coda-priority-dot.normale { background: #e2e8f0; }
.coda-priority-dot i { font-size: 12px; }

.coda-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    background: #25D366;
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
}

.coda-wa-btn:hover { background: #20bd5a; }

/* ============================================
   Promemoria
   ============================================ */
.promemoria-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.quick-rem-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.quick-rem-title i { color: var(--orange); margin-right: 6px; }

.quick-rem-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-rem-btn {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.quick-rem-btn:hover { border-color: var(--primary); color: var(--primary); }
.quick-rem-btn.active { background: var(--gradient-1); color: #fff; border-color: transparent; box-shadow: 0 3px 10px rgba(204, 0, 0, 0.2); }
.quick-rem-btn-custom { background: #f0f4ff; border-color: var(--primary); color: var(--primary); }

.quick-rem-extra-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

.quick-rem-extra-bar .form-input { flex: 1; }

.promemoria-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.prom-col-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.prom-col-title i { margin-right: 6px; }

.prom-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.prom-item input[type="checkbox"] {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.prom-item-body { flex: 1; min-width: 0; }

.prom-item-text {
    font-weight: 500;
    font-size: 13px;
    line-height: 1.4;
}

.prom-text-completed {
    text-decoration: line-through;
    opacity: 0.6;
}

.prom-item-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.prom-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.prom-priority-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 4px;
}

.prom-priority-urgente { background: #fef2f2; color: #dc2626; }
.prom-priority-alta { background: #fff7ed; color: #9a3412; }

.prom-item-urgent { background: #fef2f2; }
.prom-item-alta { background: #fff7ed; }
.prom-overdue { color: #dc2626 !important; font-weight: 600; }

/* ============================================
   Magazzino
   ============================================ */
.magazzino-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.magazzino-header-actions {
    display: flex;
    gap: 8px;
}

.magazzino-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #9a3412;
}

.magazzino-alert i { color: var(--orange); }

.magazzino-filters {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.magazzino-filters .search-box { flex: 1; max-width: 400px; }

.mag-qty-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.mag-qty-ok { background: #ecfdf5; color: #166534; }
.mag-qty-low { background: #fef2f2; color: #dc2626; }

.mag-row-low { background: #fff7ed !important; }

/* ============================================
   Impostazioni
   ============================================ */
.impostazioni-header {
    margin-bottom: 20px;
}

.impostazioni-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.settings-section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.settings-section-title i {
    margin-right: 8px;
    color: var(--primary);
}

.settings-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.settings-hint code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.settings-backup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.settings-backup-row:last-child { border-bottom: none; }
.settings-backup-row div { display: flex; gap: 6px; }

.settings-log-list {
    max-height: 250px;
    overflow-y: auto;
}

.settings-log-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.settings-log-time {
    color: var(--text-muted);
    min-width: 120px;
    font-size: 11px;
}

.settings-log-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

.log-badge-add { background: #ecfdf5; color: #166534; }
.log-badge-edit { background: #fff5f5; color: #a00000; }
.log-badge-delete { background: #fef2f2; color: #991b1b; }
.log-badge-info { background: var(--bg); color: var(--text-secondary); }

.settings-log-msg { flex: 1; color: var(--text); }

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

::selection {
    background: rgba(204, 0, 0, 0.15);
    color: var(--primary-dark);
}

@media print {
    .sidebar, .top-header, .menu-toggle, .bg-decoration { display: none !important; }
    .main-content { margin-left: 0 !important; }
}

/* ============================================
   Responsive - New sections
   ============================================ */
@media (max-width: 1024px) {
    .dash-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-bottom-grid { grid-template-columns: 1fr; }
    .impostazioni-grid { grid-template-columns: 1fr; }
    .promemoria-columns { grid-template-columns: 1fr; }

}

@media (max-width: 768px) {
    .dash-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-income-grid { grid-template-columns: 1fr; }
    .coda-filters { gap: 6px; }
    .coda-filter-btn { padding: 6px 12px; font-size: 11px; }
    .magazzino-header-actions { flex-wrap: wrap; }

    #page-coda-lavori .detail-panel.open {
        width: 90%;
        min-width: 90%;
        max-width: 400px;
        z-index: 200;
    }
}

/* ============================================
   INTERVENTI IMPROVEMENTS
   ============================================ */

/* Codice + Stato bar */
.intervento-codice-stato-bar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
}
.intervento-codice-stato-bar .intervento-codice-bar {
    margin-bottom: 0;
}

/* Stato badges in table */
.int-stato-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.stato-ricevuto { background: linear-gradient(135deg, #dbeafe, #fca5a5); color: #a00000; }
.stato-lavorazione { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.stato-attesa { background: linear-gradient(135deg, #fed7aa, #fdba74); color: #9a3412; }
.stato-pronto { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }
.stato-consegnato { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); color: #3730a3; }
.stato-annullato { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; }

/* Suggestions chips */
.suggestions-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px dashed #cbd5e1;
}
.suggestions-label {
    width: 100%;
    font-size: 12px;
    color: #475569;
    font-weight: 700;
    margin-bottom: 6px;
}
.suggestions-label i {
    color: #f59e0b;
    margin-right: 6px;
}
.suggestion-chip {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.suggestion-chip:hover {
    background: #fff5f5;
    border-color: #fca5a5;
    color: #a00000;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(59,130,246,0.15);
}
.suggestion-chip.chip-active {
    background: #cc0000;
    border-color: #cc0000;
    color: #fff;
    box-shadow: 0 2px 6px rgba(59,130,246,0.3);
}
.suggestion-chip-work {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}
.suggestion-chip-work:hover {
    background: #dcfce7;
    border-color: #4ade80;
    color: #15803d;
}
.suggestion-chip-work.chip-active {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

/* Modal footer layout */
.modal-footer-left {
    display: flex;
    gap: 8px;
}
.modal-footer-right {
    display: flex;
    gap: 8px;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Interventi table row actions */
.interventi-table .td-actions {
    display: flex;
    gap: 4px;
}
.interventi-table tr {
    transition: background 0.15s;
}
.interventi-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(204, 0, 0, 0.03), rgba(17, 17, 17, 0.02));
}

/* Period filter responsive */
@media (max-width: 768px) {
    .intervento-codice-stato-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .interventi-filters {
        flex-wrap: wrap;
    }
    .suggestions-chips {
        gap: 4px;
    }
    .suggestion-chip {
        font-size: 11px;
        padding: 4px 10px;
    }
    .modal-footer-left {
        flex-wrap: wrap;
    }
}

/* ============================================
   DEVICE AUTOCOMPLETE DROPDOWN
   ============================================ */
.autocomplete-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-top: 2px solid #cc0000;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
    max-height: 260px;
    overflow-y: auto;
    z-index: 99999;
}
.autocomplete-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
}
.autocomplete-item:last-child {
    border-bottom: none;
}
.autocomplete-item:hover,
.autocomplete-item.ac-active {
    background: #fff5f5;
}
.ac-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}
.ac-type {
    font-size: 10px;
    color: #64748b;
    background: #f1f5f9;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ============================================
   QR CODE - Bigger
   ============================================ */
.detail-qr-section {
    text-align: center;
    padding: 20px 0;
}
#detailQrCode {
    display: inline-block;
    padding: 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
#detailQrCode img,
#detailQrCode canvas {
    display: block;
    border-radius: 4px;
}

/* ============================================
   GUASTO ROW - layout with suggestions
   ============================================ */
.guasto-row {
    margin-bottom: 10px;
}
.guasto-row-top {
    display: flex;
    gap: 8px;
    align-items: center;
}
.guasto-row-top .form-select {
    width: 180px;
    flex-shrink: 0;
}
.guasto-row-top .form-input {
    flex: 1;
}
.guasto-suggestions {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 4px;
}
.sug-chip {
    background: #fff5f5;
    border: 1px solid #fca5a5;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #a00000;
    cursor: pointer;
    transition: all 0.15s;
}
.sug-chip:hover {
    background: #dbeafe;
    border-color: #60a5fa;
    transform: translateY(-1px);
}
.sug-chip.chip-active {
    background: #cc0000;
    border-color: #cc0000;
    color: #fff;
}

@media (max-width: 600px) {
    .guasto-row-top {
        flex-wrap: wrap;
    }
    .guasto-row-top .form-select {
        width: 100%;
    }
}

/* ============================================
   INTERVENTI - Detail Panel layout
   ============================================ */
#page-interventi {
    display: block;
    position: relative;
}
#page-interventi.with-detail {
    /* no gap needed - panel is overlay */
}
.interventi-main {
    width: 100%;
    min-width: 0;
    transition: all 0.3s ease;
}

/* Detail panel interventi: overlay fisso a destra */
#page-interventi .detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    border-radius: 0;
    z-index: 150;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}
#page-interventi .detail-panel.open {
    width: 400px;
    min-width: 400px;
}

/* Overlay scuro dietro il panel */
#page-interventi .detail-panel-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 140;
}
#page-interventi .detail-panel-overlay.visible {
    display: block;
}

/* Detail panel info rows */
.int-detail-section {
    margin-bottom: 18px;
}
.int-detail-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}
.int-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 7px 0;
    gap: 12px;
}
.int-detail-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
}
.int-detail-value {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    text-align: right;
    word-break: break-word;
}
.int-detail-desc {
    font-size: 13px;
    color: #334155;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-top: 4px;
    line-height: 1.5;
}
.int-detail-lavoro-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #e2e8f0;
    gap: 8px;
}
.int-detail-lavoro-item:last-child {
    border-bottom: none;
}
.int-detail-lavoro-desc {
    font-size: 13px;
    color: #334155;
    flex: 1;
}
.int-detail-lavoro-costo {
    font-size: 13px;
    font-weight: 700;
    color: #059669;
    white-space: nowrap;
}
.int-detail-totale {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #cc0000, #e53333);
    border-radius: 10px;
    margin-top: 12px;
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.2);
}
.int-detail-totale-label {
    font-size: 14px;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.int-detail-totale-value {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
}
.int-detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.int-detail-actions .btn {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    padding: 8px 6px;
}
.int-detail-stato-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Selected row highlight */
.interventi-table tr.row-selected {
    background: linear-gradient(90deg, rgba(204, 0, 0, 0.04), rgba(17, 17, 17, 0.02)) !important;
    box-shadow: inset 3px 0 0 var(--primary);
}

@media (max-width: 768px) {
    #page-interventi .detail-panel.open {
        width: 90%;
        min-width: 90%;
        max-width: 400px;
    }
}

/* ============================================
   CODA LAVORI v3 - Clean
   ============================================ */
/* Table rows */
.coda-tr { transition: background 0.12s; }
.coda-tr:hover { background: #f8fafc; }
.coda-tr.row-selected { background: #fff5f5 !important; box-shadow: inset 3px 0 0 var(--primary); }

.coda-c-name { font-weight: 600; font-size: 13px; color: #1e293b; }
.coda-d-wrap { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #1e293b; }
.coda-d-icon { color: #94a3b8; font-size: 14px; }
.coda-urg { color: #ef4444; font-size: 11px; background: #fef2f2; border-radius: 4px; padding: 2px 5px; margin-left: 4px; }
.coda-td-prob { font-size: 12px; color: #64748b; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Stato badge (cliccabile, cicla al click) */
.coda-stato {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; border-radius: 20px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
    cursor: pointer; border: 1.5px solid; white-space: nowrap;
    transition: all 0.15s;
}
.coda-stato:hover { filter: brightness(0.92); transform: scale(1.05); }
.coda-stato:active { transform: scale(0.97); }

/* Ricambi badges */
.coda-ric { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 14px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.coda-ric-ok { color: #16a34a; background: #f0fdf4; border: 1px solid #bbf7d0; }
.coda-ric-wait { color: #ea580c; background: #fff7ed; border: 1px solid #fed7aa; }
.coda-ric-no { color: #64748b; background: #f1f5f9; border: 1px solid #e2e8f0; }
.coda-ric-na { color: #cbd5e1; font-size: 12px; }

/* ---- Detail panel content ---- */
.cd-stato-bar { text-align: center; margin-bottom: 10px; }
.cd-stato-current {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 18px; border-radius: 20px;
    font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.cd-stato-btns {
    display: flex; justify-content: center; gap: 4px;
    margin-bottom: 18px; flex-wrap: wrap;
}
.cd-sb {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--sb); background: var(--sb);
    color: var(--sc); font-size: 12px; cursor: pointer;
    transition: all 0.15s; opacity: 0.5;
}
.cd-sb:hover { opacity: 0.8; transform: scale(1.15); }
.cd-sb.cd-sb-active { opacity: 1; box-shadow: 0 0 0 3px rgba(79,110,247,0.2); transform: scale(1.1); }

.cd-section { margin-bottom: 16px; }
.cd-title {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.8px; color: #94a3b8;
    margin-bottom: 8px; padding-bottom: 5px;
    border-bottom: 1px solid #f1f5f9;
    display: flex; align-items: center; gap: 6px;
}
.cd-title i { font-size: 11px; }
.cd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.cd-item { display: flex; flex-direction: column; gap: 1px; }
.cd-lbl { font-size: 10px; color: #94a3b8; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }
.cd-val { font-size: 13px; font-weight: 600; color: #1e293b; word-break: break-word; }

.cd-prob-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 6px 10px; background: #f8fafc; border-radius: 8px;
    border: 1px solid #f1f5f9; margin-bottom: 6px;
}
.cd-prob-tipo { font-size: 11px; font-weight: 700; color: #ef4444; text-transform: uppercase; }
.cd-prob-desc { font-size: 13px; color: #334155; line-height: 1.4; }

.cd-wa-ctx {
    display: flex; align-items: center; gap: 8px; justify-content: center;
    padding: 10px 16px; border-radius: 10px;
    font-size: 13px; font-weight: 600; text-decoration: none;
    margin-bottom: 8px; transition: all 0.15s;
}
.cd-wa-ctx:hover { filter: brightness(0.92); }
.cd-wa-pronto { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.cd-wa-ricambio { background: #fff5f5; color: #cc0000; border: 1px solid #fca5a5; }

.cd-actions {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px; margin-top: 12px;
}
.cd-act-btn {
    display: flex; align-items: center; justify-content: center; gap: 5px;
    padding: 8px 6px; border-radius: 8px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    border: 1px solid #e2e8f0; background: #fff; color: #334155;
    text-decoration: none; transition: all 0.12s; text-align: center;
}
.cd-act-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.cd-act-wa { background: #25d366 !important; color: #fff !important; border-color: #25d366 !important; }
.cd-act-primary { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }
.cd-remove-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 8px; margin-top: 8px;
    border-radius: 8px; border: 1px solid #fecaca;
    background: #fef2f2; color: #ef4444;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all 0.12s;
}
.cd-remove-btn:hover { background: #fee2e2; }

/* ── Rapporto cards in Clienti detail ── */
.detail-rapporto-card {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 12px; margin-bottom: 8px; cursor: pointer; transition: all 0.15s;
}
.detail-rapporto-card:hover { background: #eef2ff; border-color: #c7d2fe; }
.detail-rap-top {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.detail-rap-codice { font-weight: 700; font-size: 13px; color: #1e293b; }
.detail-rap-stato {
    font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 20px; border: 1px solid; background: #fff;
}
.detail-rap-info { font-size: 12px; color: #64748b; margin-bottom: 6px; line-height: 1.5; }
.detail-rap-bottom {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12px; color: #94a3b8;
}
.detail-rap-data { font-weight: 500; }
.detail-rap-totale { font-weight: 700; color: #1e293b; font-size: 13px; }
