* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background-color: #1a7bb3;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

html, body {
    overscroll-behavior-x: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #006caa 0%, #004d7a 100%);
    min-height: 100vh;
    color: #333;
    position: relative;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #006caa 0%, #004d7a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Restart Overlay */
.restart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 77, 122, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.restart-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.restart-content {
    text-align: center;
    color: white;
}

.restart-content .spinner {
    margin: 0 auto 1.5rem auto;
}

.restart-content p {
    font-size: 1.2rem;
    font-weight: 500;
    color: white;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(0, 108, 170, 0.3), transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(232, 80, 29, 0.2), transparent 50%);
    pointer-events: none;
}

/* Login Screen */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.logo-login {
    max-width: 200px;
    height: auto;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: white;
    border-radius: 12px;
}

.login-box h1 {
    font-size: 27px;
    margin-bottom: 0.5rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.login-box p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.login-box input {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s;
    color: white;
}

.login-box input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.login-box input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.login-box button:not(.toggle-pwd-btn) {
    width: 100%;
    padding: 1rem;
    background: #e8501d;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-box button:not(.toggle-pwd-btn):hover {
    transform: translateY(-2px);
}

.login-box button:not(.toggle-pwd-btn):active {
    transform: translateY(0);
}

/* Password input con toggle */
.password-input-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 2.75rem;
    margin-bottom: 0;
}

.toggle-pwd-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    border-radius: 4px;
}

.toggle-pwd-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%);
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* Header compatto */
header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-header {
    height: 40px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.15));
    background: white;
    padding: 0.4rem;
    border-radius: 8px;
}

header h1 {
    font-size: 1.2rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header Status Badge */
.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.header-badge.online {
    background: rgba(16, 185, 129, 0.4);
    color: #d1fae5;
    border: 1px solid rgba(16, 185, 129, 0.6);
}

.header-badge.offline {
    background: rgba(239, 68, 68, 0.4);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.6);
}

.header-badge .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

/* Failover Indicator compatto */
.failover-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: help;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    flex-shrink: 0;
}

.failover-label {
    font-weight: 400;
    opacity: 0.7;
    margin-right: 0.25rem;
}

.failover-system {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

.failover-system.active {
    background: rgba(0, 120, 212, 0.4);
    color: #bfdbfe;
}

.failover-system.standby {
    background: rgba(148, 163, 184, 0.2);
    color: rgba(255, 255, 255, 0.6);
}

.failover-separator {
    opacity: 0.4;
    font-size: 0.7rem;
}

.failover-status {
    font-size: 0.65rem;
    text-transform: uppercase;
    opacity: 0.8;
    letter-spacing: 0.5px;
}

.failover-icon {
    width: 14px;
    height: 14px;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Status Bar compatta */
.status-bar {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.status-metric {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 0;
    flex: 1 1 auto;
}

.metric-icon {
    display: none;
}

.metric-content {
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}

.metric-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: -1;
}

.filters-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.filters-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

.filters-chevron {
    display: inline-block;
    transform: rotate(0deg);
    transition: transform 0.3s ease;
}

.filters-toggle.open .filters-chevron {
    transform: rotate(180deg);
}

.toolbar-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    flex: 1;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 100%;
}

.search-box .search-icon {
    position: absolute;
    left: 0.75rem;
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

.search-box input {
    padding: 0.55rem 0.75rem 0.55rem 2.25rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
    width: 100%;
    transition: all 0.3s;
}

.search-box input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.8);
}

.filter-select, .filter-date {
    padding: 0.55rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-select:focus, .filter-date:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.filter-select option {
    background: #1e3a5f;
    color: white;
}

.filter-date {
    color-scheme: dark;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    position: relative;
}

.filter-date::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.8;
}

.filter-date::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.filter-date::-webkit-datetime-edit,
.filter-date::-webkit-datetime-edit-fields-wrapper,
.filter-date::-webkit-datetime-edit-text,
.filter-date::-webkit-datetime-edit-month-field,
.filter-date::-webkit-datetime-edit-day-field,
.filter-date::-webkit-datetime-edit-year-field {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

/* Custom datepicker container */
.datepicker-wrapper {
    position: relative;
    display: inline-block;
    z-index: 10;
}

/* Desktop: mostra custom, nascondi nativo */
.filter-date-mobile {
    display: none;
}

.filter-date-desktop {
    display: block;
}

.date-display {
    padding: 0.55rem 2.5rem 0.55rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
    min-width: 150px;
    text-align: left;
    pointer-events: none;
}

.date-display:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.date-input-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    cursor: pointer !important;
    z-index: 2 !important;
}

.clear-date-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    transition: all 0.2s;
    z-index: 10;
    pointer-events: auto;
}

.clear-date-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.datepicker-wrapper .filter-date {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.datepicker-popup {
    position: fixed;
    margin-top: 0.5rem;
    background: rgba(30, 58, 95, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    min-width: 280px;
    display: none;
}

.datepicker-popup.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.datepicker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.datepicker-title {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
}

.datepicker-nav {
    display: flex;
    gap: 0.5rem;
}

.datepicker-nav button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.8rem;
}

.datepicker-nav button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.datepicker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.datepicker-weekday {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    text-align: center;
    padding: 0.25rem;
    text-transform: uppercase;
}

.datepicker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.datepicker-day {
    background: transparent;
    border: 1px solid transparent;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
}

.datepicker-day:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.datepicker-day.other-month {
    color: rgba(255, 255, 255, 0.3);
}

.datepicker-day.today {
    border-color: rgba(16, 185, 129, 0.5);
    color: #10b981;
}

.datepicker-day.selected {
    background: rgba(16, 185, 129, 0.4);
    border-color: rgba(16, 185, 129, 0.6);
    color: #d1fae5;
}

.datepicker-clear {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
}

.datepicker-clear:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
}

/* Toggle Switch per Notifiche */
.notify-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.notify-toggle-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 22px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #10b981;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Buttons */
button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-primary {
    background: #e8501d;
    color: white;
}

.btn-primary:hover {
    background: #d14518;
    transform: translateY(-2px);
}

.btn-danger {
    background: #e8501d;
    color: white;
}

.btn-danger:hover {
    background: #d14518;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-success:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-2px);
}

.btn-warning:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-icon {
    background: transparent;
    font-size: 1.4rem;
    padding: 0.4rem;
    color: white;
    border-radius: 8px;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-icon.loading {
    animation: spin 1s linear infinite;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Clients Panel */
.clients-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 400px;
    overflow-x: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-title-group {
    display: flex;
    align-items: center;
}

.panel-header h2 {
    color: white;
    font-size: 1.1rem;
    margin: 0;
}

.panel-count {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    margin-left: 0.5rem;
    min-width: 1.4rem;
    text-align: center;
}

.panel-count:empty {
    display: none;
}

.clients-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Client Card */
.client-card {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 0.6rem;
    transition: background 0.2s;
    border-left: 3px solid transparent;
    overflow: hidden;
}

.client-card:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Bordo card basato su stato consegna WhatsApp */
.client-card.delivery-pending {
    border-left-color: rgba(255, 255, 255, 0.5);
}

.client-card.delivery-sent {
    border-left-color: rgba(255, 255, 255, 0.7);
}

.client-card.delivery-delivered {
    border-left-color: #60a5fa;
}

.client-card.delivery-read {
    border-left-color: #10b981;
}

.client-card.delivery-failed {
    border-left-color: #ef4444;
}

/* Fallback per card senza stato consegna */
.client-card.sent:not([class*="delivery-"]) {
    border-left-color: #10b981;
}

.client-card.waiting {
    border-left-color: #f59e0b;
}

.client-card.forwarded:not([class*="delivery-"]) {
    border-left-color: #10b981;
}

/* Card Header (clickable) */
.client-card-header {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    cursor: pointer;
    user-select: none;
}

.client-card-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Chevron indicator */
.card-chevron {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    margin-left: 0.75rem;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.client-card.expanded .card-chevron {
    transform: rotate(90deg);
}

.card-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.btn-delete-placeholder {
    width: 1.8rem;
    flex-shrink: 0;
}

/* Delete conversation button (per card) */
.btn-delete-card {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    flex-shrink: 0;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    width: 1.8rem;
    justify-content: center;
}

.btn-delete-card:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

/* Orders limit select */
.orders-limit-select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    margin-left: auto;
    outline: none;
    transition: background 0.2s, border-color 0.2s;
}
.orders-limit-select:hover,
.orders-limit-select:focus {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}
.orders-limit-select option {
    background: #1a2332;
    color: #fff;
}

/* Orders limit inside toolbar filters - match other filter selects */
.toolbar-filters .orders-limit-select {
    margin-left: 0;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
}

/* Clear all orders button (panel header - red trash icon) */
.btn-clear-orders {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    margin-left: auto;
    margin-right: 0.75rem;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
}

.btn-clear-orders:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
    transform: scale(1.1);
}

/* Card Details (expandable) */
.client-card-details {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid transparent;
}

.client-card.expanded .client-card-details {
    max-height: 800px;
    opacity: 1;
    padding: 1rem;
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* Detail Sections */
.detail-section {
    margin-bottom: 1rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.detail-section h5 {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-weight: 600;
    margin: 0.75rem 0 0.5rem 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, max-content));
    gap: 0.5rem;
    justify-content: center;
}

.detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
}

.detail-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

.detail-value {
    font-size: 0.85rem;
    color: white;
    word-break: break-word;
}

.detail-value.mono {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
}

.detail-value.status-sent { color: rgba(255, 255, 255, 0.7); }
.detail-value.status-delivered { color: #86efac; }
.detail-value.status-read { color: #34d399; }
.detail-value.status-failed { color: #f87171; }

/* Risposte cliente */
.detail-responses {
    margin-top: 0.75rem;
    padding: 0.75rem 0.5rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.detail-responses h5 {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    text-align: center;
    font-weight: 400;
}

.response-item {
    display: inline-block;
    max-width: 85%;
    padding: 0.4rem 0.6rem 0.2rem;
    background: #005c4b;
    border-radius: 8px 8px 0 8px;
    margin-bottom: 0.3rem;
    position: relative;
    float: right;
    clear: both;
}

.response-item:last-child {
    margin-bottom: 0;
}

.response-item::after {
    content: '';
    display: table;
    clear: both;
}

.detail-responses::after {
    content: '';
    display: table;
    clear: both;
}

.response-time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    float: right;
    margin-left: 0.5rem;
    margin-top: 0.2rem;
}

.response-text {
    font-size: 0.85rem;
    color: #e9edef;
    word-break: break-word;
    line-height: 1.4;
}
.response-text a {
    color: #60a5fa;
    text-decoration: none;
}
.response-text a:hover {
    text-decoration: underline;
}
.response-media-preview {
    display: block;
    max-width: 250px;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 6px;
    cursor: pointer;
}
.response-audio-player {
    display: block;
    margin-top: 6px;
    max-width: 280px;
    height: 36px;
}
.response-video-player {
    display: block;
    max-width: 280px;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 6px;
}

.no-details {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    text-align: center;
    margin: 0;
}

.client-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    margin-right: 0.85rem;
    flex-shrink: 0;
}

.client-info {
    flex: 1;
    min-width: 0;
}

.client-name {
    font-weight: 600;
    color: white;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.client-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.client-meta span {
    white-space: nowrap;
}

.client-phone {
    font-family: 'Monaco', 'Menlo', monospace;
    white-space: nowrap;
}

.client-status-badge {
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.client-status-badge.sent {
    background: rgba(16, 185, 129, 0.5);
    color: #ffffff;
    border: 1px solid rgba(16, 185, 129, 0.6);
}

.client-status-badge.waiting {
    background: rgba(245, 158, 11, 0.35);
    color: #fef3c7;
    border: 1px solid rgba(245, 158, 11, 0.5);
}

.client-status-badge.duplicate {
    background: rgba(156, 163, 175, 0.3);
    color: #d1d5db;
    border: 1px solid rgba(156, 163, 175, 0.4);
}

.client-status-badge.failed {
    background: rgba(239, 68, 68, 0.35);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.client-status-badge.forwarded {
    background: rgba(59, 130, 246, 0.35);
    color: #bfdbfe;
    border: 1px solid rgba(59, 130, 246, 0.5);
}

.allegato-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 500;
}

.allegato-badge.pdf-missing {
    background: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.template-badge {
    display: inline-block;
    background: rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid rgba(99, 102, 241, 0.4);
}

/* Testo notifica Francesco */
.notified-text {
    display: block;
    color: rgba(251, 191, 36, 0.9);
    font-size: 0.7rem;
    font-weight: 500;
    margin-top: 2px;
}

/* Pulsante notifica per ordine */
.notify-action {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-notify {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-notify:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-notify:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-notify.notified {
    background: rgba(251, 191, 36, 0.4);
    border-color: rgba(251, 191, 36, 0.6);
    color: #fef3c7;
}

/* Stato consegna messaggio WhatsApp */
.delivery-status {
    display: inline-block;
    font-size: 0.7rem;
    margin-left: 8px;
    font-weight: 600;
    vertical-align: middle;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.delivery-status.pending {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.delivery-status.sent {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.delivery-status.delivered {
    background: rgba(59, 130, 246, 0.4);
    color: #ffffff;
}

.delivery-status.read {
    background: rgba(16, 185, 129, 0.5);
    color: #ffffff;
}

.delivery-status.failed {
    background: rgba(239, 68, 68, 0.5);
    color: #ffffff;
}

.delivery-status.unknown {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

/* Numeri di telefono censurati */
.phone-toggle {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.phone-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

.phone-toggle.censored {
    color: rgba(255, 255, 255, 0.7);
}

.phone-toggle.revealed {
    color: rgba(255, 255, 255, 0.7);
}

.phone-icon {
    font-size: 0.7rem;
    opacity: 0.7;
}

.phone-toggle:hover .phone-icon {
    opacity: 1;
}

.empty-state {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 3rem;
}

/* Empty State Container */
.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    margin: 1rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state-title {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.empty-state-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    margin: 0;
}

/* Log Panel */
.log-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    overflow: hidden;
}

.log-panel.collapsed .log-content {
    max-height: 0;
    opacity: 0;
}

.log-panel.collapsed .log-chevron {
    transform: rotate(-90deg);
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    user-select: none;
    transition: background 0.2s;
}

.log-header:hover {
    background: rgba(255, 255, 255, 0.1);
}

.log-header h3 {
    margin: 0;
    color: white;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.log-chevron {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.3s ease;
    transform: rotate(0deg);
}

.log-content {
    max-height: 250px;
    overflow: hidden;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.log-container {
    height: 250px;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.2);
}

.log-entry {
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 0.75rem;
}

.log-time {
    color: rgba(255, 255, 255, 0.5);
    min-width: 65px;
    flex-shrink: 0;
}

.log-message {
    color: rgba(255, 255, 255, 0.9);
    word-break: break-word;
}

.log-entry.log-info .log-message {
    color: #7dd3fc;
}

.log-entry.log-success .log-message {
    color: #86efac;
}

.log-entry.log-warning .log-message {
    color: #fcd34d;
}

.log-entry.log-error .log-message {
    color: #fca5a5;
}

.log-empty {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 2rem;
    margin: 0;
}

.log-resume-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: auto;
    margin-right: 1rem;
    animation: pulse 1.5s infinite;
}

.log-resume-btn:hover {
    background: #218838;
    animation: none;
}

/* Scrollbar */
.clients-list::-webkit-scrollbar,
.log-container::-webkit-scrollbar {
    width: 6px;
}

.clients-list::-webkit-scrollbar-track,
.log-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.clients-list::-webkit-scrollbar-thumb,
.log-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.clients-list::-webkit-scrollbar-thumb:hover,
.log-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

footer p {
    margin: 0.25rem 0;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Fade Out Animation */
@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-error {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.toast-success {
    background: rgba(16, 185, 129, 0.9);
    color: white;
}

.error {
    background: rgba(239, 68, 68, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(239, 68, 68, 0.9);
    color: #ffffff;
    font-weight: 600;
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    text-align: center;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal.closing {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.modal.closing .modal-content {
    transform: scale(0.95) translateY(10px);
    transition: transform 0.5s ease-out;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 0;
    min-width: 350px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(1);
    transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
    transform: scale(0.9);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    color: white;
    font-size: 1.1rem;
}

.modal-body {
    padding: 1.25rem 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.alert-modal-content {
    min-width: 320px;
    max-width: 420px;
}

.alert-modal-content .modal-body p {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    white-space: pre-line;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.modal-footer button {
    min-width: 90px;
}

/* Prompt Input */
.prompt-input-wrapper {
    position: relative;
    margin-top: 1rem;
}

.prompt-input-wrapper input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.prompt-input-wrapper input:focus {
    outline: none;
    border-color: #006caa;
    background: rgba(255, 255, 255, 0.15);
}

.prompt-input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.prompt-input-wrapper .toggle-pwd-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prompt-input-wrapper .toggle-pwd-btn:hover {
    color: white;
}

.prompt-error {
    color: #ffffff;
    background: rgba(239, 68, 68, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-align: center;
}

/* FTP Steps */
.ftp-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 100px;
    position: relative;
}

.ftp-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.ftp-step.fading {
    opacity: 0.35;
    transform: scale(0.95);
}

.ftp-step.exiting {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
    position: absolute;
    width: calc(100% - 2rem);
}

.ftp-step.success {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

.ftp-step.error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

.ftp-step.info {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

.step-icon {
    font-size: 1.1rem;
    min-width: 28px;
    text-align: center;
}

.step-text {
    color: white;
    font-size: 0.9rem;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive */
@media (max-width: 1024px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 1.5rem; /* Reset symmetric padding */
    }

    .toolbar-filters {
        order: 1;
        justify-content: center;
    }

    .toolbar-actions {
        position: static;
        order: 0;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    /* Login responsive */
    .login-box {
        padding: 2rem 1.5rem;
        max-width: 350px;
    }

    .logo-login {
        max-width: 160px;
        padding: 0.5rem;
    }

    .login-box h1 {
        font-size: 22px;
    }

    .login-box p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .login-box input {
        padding: 0.85rem;
        font-size: 0.95rem;
    }

    .login-box button:not(.toggle-pwd-btn) {
        padding: 0.85rem;
        font-size: 0.95rem;
    }

    header {
        padding: 0.6rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .header-left {
        flex-wrap: wrap;
        justify-content: center;
    }

    .logo-header {
        height: 32px;
    }

    header h1 {
        font-size: 1rem;
    }

    .header-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    .failover-indicator {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .header-actions {
        display: none;
    }

    .status-bar {
        padding: 0.6rem 1rem;
        gap: 0.5rem;
    }

    .status-metric {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 0;
        padding: 0.4rem 0.75rem;
        justify-content: center;
    }

    .metric-content {
        align-items: center;
        text-align: center;
    }

    .metric-value {
        font-size: 0.9rem;
    }

    .toolbar {
        padding: 0.6rem 1rem;
        flex-direction: column;
    }

    .filters-toggle {
        display: flex;
        order: 1;
    }

    .toolbar-filters {
        flex-direction: column;
        width: 100%;
        order: 2;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
        margin-top: 0;
    }

    .toolbar-filters.open {
        max-height: 400px;
        opacity: 1;
        margin-top: 0.75rem;
    }

    .toolbar-actions {
        position: static;
        order: 0;
        margin-bottom: 0.5rem;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
        min-width: unset;
    }

    .filter-select, .filter-date {
        width: 100%;
    }

    .datepicker-wrapper {
        width: 100%;
        z-index: 10002;
    }

    .datepicker-wrapper .filter-date {
        width: 100%;
        min-height: 44px;
        touch-action: manipulation;
    }

    .datepicker-popup {
        position: absolute !important;
        top: calc(100% + 0.5rem) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        margin-top: 0 !important;
        width: 95vw !important;
        max-width: 340px !important;
        max-height: 70vh !important;
        animation: none !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 1rem 0.75rem !important;
    }
    
    .datepicker-wrapper {
        position: relative !important;
        overflow: visible !important;
        width: 100%;
    }
    
    /* Mobile: mostra nativo, nascondi custom */
    .filter-date-mobile {
        display: block !important;
    }
    
    .filter-date-desktop {
        display: none !important;
    }
    
    .datepicker-popup {
        display: none !important;
    }
    
    .date-display {
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .datepicker-header {
        margin-bottom: 0.75rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    .datepicker-title {
        font-size: 1rem !important;
    }
    
    .datepicker-nav button {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.1rem !important;
    }
    
    .datepicker-weekdays {
        margin-bottom: 0.4rem !important;
    }
    
    .datepicker-weekday {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.2rem !important;
    }
    
    .datepicker-days {
        gap: 0.35rem !important;
    }
    
    .datepicker-day {
        width: 40px !important;
        height: 40px !important;
        font-size: 0.95rem !important;
        border-radius: 6px !important;
    }
    
    .datepicker-clear {
        margin-top: 0.75rem !important;
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
        border-radius: 8px !important;
    }

    .toolbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .btn-action {
        flex: 1;
        justify-content: center;
        min-width: calc(33% - 0.5rem);
    }

    .main-content {
        padding: 1rem;
    }

    .client-card {
        align-items: flex-start;
    }

    .client-status-badge {
        flex-shrink: 0;
    }
    
    .delivery-status {
        font-size: 0.65rem !important;
        padding: 2px 6px !important;
        margin-left: 6px !important;
        letter-spacing: 0.3px !important;
        white-space: nowrap !important;
    }
}

@media (max-width: 480px) {
    /* Login 480px */
    .login-box {
        padding: 1.5rem 1.25rem;
        max-width: 100%;
        width: 95%;
        border-radius: 12px;
    }

    .logo-login {
        max-width: 140px;
        padding: 0.4rem;
        margin-bottom: 1rem;
    }

    .login-box h1 {
        font-size: 20px;
    }

    .login-box p {
        font-size: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .login-box input {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .login-box button:not(.toggle-pwd-btn) {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Dashboard 480px */
    .status-metric {
        flex: 1 1 100%;
        min-width: 0;
        justify-content: center;
    }

    .metric-content {
        align-items: center;
        text-align: center;
    }

    .btn-action {
        min-width: 100%;
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }

    .client-meta {
        flex-direction: column;
        gap: 0.25rem;
    }

    .client-card-header {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .client-info {
        flex: 1 1 100%;
        min-width: 0;
    }
    
    .client-name {
        overflow: visible !important;
        white-space: normal !important;
        flex-wrap: wrap !important;
    }

    .client-status-badge {
        order: 4;
        margin-left: 0;
        flex: 0 0 auto;
    }

    .card-chevron {
        order: 5;
        margin-left: auto;
    }

    .client-card.expanded .client-card-details {
        padding: 0.75rem;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .client-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }

    .client-name {
        font-size: 0.9rem;
    }

    .panel-header h2 {
        font-size: 1rem;
    }

    /* Modals 480px */
    .modal-content,
    .alert-modal-content {
        min-width: unset;
        width: 95%;
        max-width: 95%;
        margin: 1rem;
        border-radius: 16px;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer button {
        width: 100%;
    }

    /* Log panel 480px */
    .log-container {
        height: 200px;
        font-size: 0.75rem;
    }
}

@media (max-width: 360px) {
    .login-box {
        padding: 1.25rem 1rem;
    }

    .logo-login {
        max-width: 120px;
    }

    .login-box h1 {
        font-size: 18px;
    }

    .login-box p {
        font-size: 0.8rem;
    }

    .failover-indicator {
        padding: 0.25rem 0.5rem;
        font-size: 0.65rem;
        gap: 0.25rem;
    }

    .failover-label {
        display: none;
    }

    .failover-separator {
        display: none;
    }

    .failover-system {
        padding: 0.15rem 0.35rem;
        gap: 0.2rem;
    }

    .failover-system span:not(.failover-status) {
        display: none;
    }

    .failover-icon {
        width: 12px;
        height: 12px;
    }

    .failover-status {
        font-size: 0.55rem;
    }

    .toolbar-actions {
        gap: 0.25rem;
    }

    .btn-action {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 200px) {
    .login-box {
        padding: 1rem 0.75rem;
    }

    .logo-login {
        max-width: 80px;
        padding: 0.25rem;
        margin-bottom: 0.75rem;
    }

    .login-box h1 {
        font-size: 14px;
    }

    .login-box p {
        font-size: 0.7rem;
        margin-bottom: 1rem;
    }

    .login-box input {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .login-box button:not(.toggle-pwd-btn) {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .toggle-pwd-btn {
        padding: 0.2rem;
    }

    .toggle-pwd-btn svg {
        width: 14px;
        height: 14px;
    }

    header {
        padding: 0.4rem 0.5rem;
    }

    .logo-header {
        height: 24px;
    }

    header h1 {
        font-size: 0.8rem;
    }

    .header-badge {
        display: none;
    }

    .status-bar {
        padding: 0.4rem 0.5rem;
        gap: 0.25rem;
    }

    .status-metric {
        padding: 0.3rem 0.5rem;
    }

    .metric-value {
        font-size: 0.75rem;
    }

    .metric-label {
        font-size: 0.6rem;
    }

    .toolbar {
        padding: 0.4rem 0.5rem;
    }

    .btn-action {
        padding: 0.4rem 0.5rem;
        font-size: 0.65rem;
    }

    .main-content {
        padding: 0.5rem;
    }

    .panel-header {
        padding: 0.5rem;
    }

    .panel-header h2 {
        font-size: 0.85rem;
    }

    .clients-list {
        padding: 0.5rem;
    }

    .client-card-header {
        padding: 0.5rem;
    }

    .client-card.expanded .client-card-details {
        padding: 0.5rem;
    }

    .card-chevron {
        font-size: 0.6rem;
        margin-left: 0.5rem;
    }

    .client-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
        margin-right: 0.5rem;
    }

    .client-name {
        font-size: 0.8rem;
    }

    .client-meta {
        font-size: 0.7rem;
    }

    .client-status-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }

    .detail-section h4 {
        font-size: 0.75rem;
    }

    .detail-item {
        padding: 0.35rem 0.5rem;
    }

    .detail-label {
        font-size: 0.6rem;
    }

    .detail-value {
        font-size: 0.75rem;
    }
}

/* ============================================= */
/* MOBILE FIX - Card overflow & responsive fixes */
/* ============================================= */

/* Force all containers to respect viewport width */
.dashboard, .main-content, .clients-panel, .clients-list,
.toolbar, .status-bar, header, footer {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Card header: proper wrapping on mobile */
.client-card {
    max-width: 100%;
    word-break: break-word;
}

.client-card-header {
    max-width: 100%;
    overflow: hidden;
}

/* Ensure client-info shrinks properly */
.client-info {
    overflow: hidden;
}

/* Client name: allow wrapping on all screens */
.client-name {
    flex-wrap: wrap;
    overflow: hidden;
    word-break: break-word;
}

/* Delivery status badge: never truncate */
.delivery-status {
    flex-shrink: 0;
}

/* Phone number: truncate if too long */
.client-phone {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Card actions: shrink properly */
.card-actions {
    flex-wrap: nowrap;
    overflow: hidden;
}

/* Status bar metrics: don't overflow */
.metric-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Response media: respect container */
.response-media-preview {
    max-width: 100%;
    height: auto;
}

.response-audio-player,
.response-video-player {
    max-width: 100%;
}

/* Detail grid: single column on small screens */
@media (max-width: 600px) {
    .detail-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Fix: toolbar actions buttons overflow */
@media (max-width: 768px) {
    .toolbar-actions {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .btn-action {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Panel header: stack on mobile */
    .panel-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .notify-toggle-wrapper {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }

    .notify-toggle-label {
        white-space: normal;
        font-size: 0.7rem;
    }

    /* Failover: more compact */
    .failover-indicator {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    /* Card: full stack layout */
    .client-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .card-actions {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
    }

    .card-chevron {
        position: absolute;
        right: 0.75rem;
        top: 0.75rem;
    }

    .client-card-header {
        position: relative;
        padding-right: 2rem;
    }

    /* Badge containers: wrap */
    .client-name {
        font-size: 0.85rem;
        gap: 0.3rem;
    }

    .allegato-badge,
    .template-badge {
        font-size: 0.6rem;
        padding: 1px 4px;
    }

    /* Smaller delete buttons */
    .btn-delete-card {
        width: 1.5rem;
        padding: 0.15rem 0.3rem;
        font-size: 0.9rem;
    }

    .btn-delete-placeholder {
        width: 1.5rem;
    }

    /* Status metric: 2 columns */
    .status-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }

    .status-metric {
        flex: unset;
    }

    .metric-content {
        text-align: left;
    }

    /* Clients list: tighter padding */
    .clients-list {
        padding: 0.5rem;
    }

    .client-card {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 360px) {
    /* Extra small: even more compact */
    .client-name {
        font-size: 0.8rem;
    }

    .client-meta {
        font-size: 0.7rem;
        gap: 0.2rem;
    }

    .client-status-badge {
        font-size: 0.6rem;
        padding: 0.15rem 0.4rem;
    }

    .status-bar {
        grid-template-columns: 1fr 1fr;
        padding: 0.4rem;
    }
}

/* FIX: risposte cliente troncate in card espansa (mobile) */
.client-card.expanded .client-card-details {
    max-height: none;
    overflow: visible;
}

.client-card.expanded {
    overflow: visible;
}

.detail-responses {
    overflow: hidden; /* clearfix per float */
}

.response-item {
    box-sizing: border-box;
}
