/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --secondary: #3b82f6;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-900: #111827;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
    overscroll-behavior: none;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: white;
    position: relative;
    padding-bottom: 80px;
    /* Safe area for notched devices */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Header */
header {
    background: var(--primary);
    color: white;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

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

.icon-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-button:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

.icon-button .icon {
    font-size: 1.25rem;
}

/* Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow);
}

.stat-card {
    text-align: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 0.75rem;
    backdrop-filter: blur(10px);
}

.stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Filter Panel */
.filter-panel {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    transition: all 0.3s ease-in-out;
    max-height: 0;
    overflow: hidden;
}

.filter-panel:not(.hidden) {
    max-height: 400px;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.filter-header h3 {
    font-size: 1.125rem;
    color: var(--gray-900);
}

.filter-content {
    padding: 1.5rem;
}

.filter-group {
    margin-bottom: 1.25rem;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 0.5rem;
    background: white;
    transition: border-color 0.2s;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Main Content */
main {
    padding: 1.5rem;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 3rem 1rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

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

.loading-state p {
    color: var(--gray-600);
    font-size: 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.empty-state h2 {
    font-size: 1.5rem;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-600);
    font-size: 1rem;
}

/* Entries List */
.entries-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.entry-card {
    background: white;
    border: 3px solid var(--gray-200);
    border-radius: 1rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-shadow: var(--shadow);
}

.entry-card.swiping {
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.2);
}

/* Entry Content (swipeable) */
.entry-content {
    background: white;
    position: relative;
    z-index: 1;
    padding: 0.75rem 1rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.entry-card.deleting .entry-content {
    opacity: 0;
    pointer-events: none;
}

/* Entry Header - Compatto v2.3 */
.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.entry-title-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.entry-articolo-nome {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-categoria {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--purple);
    color: white;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    align-self: flex-start;
}

.entry-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.entry-valore {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.entry-timestamp {
    font-size: 0.75rem;
    color: var(--gray-600);
    white-space: nowrap;
}

/* Load More Button */
.load-more-button {
    width: 100%;
    padding: 1rem;
    margin-top: 1.5rem;
    background: var(--gray-100);
    color: var(--gray-900);
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.load-more-button:active {
    background: var(--gray-200);
    transform: scale(0.98);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--gray-900);
}

.modal-body {
    padding: 1.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-200);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.detail-value {
    font-weight: 700;
    color: var(--gray-900);
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* Buttons */
.primary-button,
.secondary-button {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.primary-button {
    background: var(--primary);
    color: white;
}

.primary-button:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.secondary-button {
    background: var(--gray-100);
    color: var(--gray-900);
}

.secondary-button:active {
    background: var(--gray-200);
    transform: scale(0.98);
}

/* Pull to Refresh */
.pull-indicator {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s;
    z-index: 90;
}

.pull-indicator:not(.hidden) {
    transform: translateX(-50%) translateY(0);
}

.pull-icon {
    font-size: 1.5rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: var(--secondary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    box-shadow: var(--shadow-xl);
    text-decoration: none;
    transition: all 0.3s;
    z-index: 99;
}

.fab:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-lg);
}

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

/* Screens Management */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Connection Status Indicator */
.connection-status {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    z-index: 1000;
    box-shadow: 0 0 0 2px white;
}

.connection-status.online {
    background: var(--success);
}

.connection-status.offline {
    background: var(--danger);
}

/* Landing Screen */
.landing-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.landing-header {
    text-align: center;
    color: white;
    margin-bottom: 3rem;
    animation: fadeIn 0.6s ease-out;
}

.landing-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.landing-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 400;
}

.landing-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.landing-button {
    background: white;
    border: none;
    border-radius: 1.25rem;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: slideIn 0.6s ease-out;
}

.landing-button:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.landing-button.primary {
    animation-delay: 0.1s;
}

.landing-button.secondary {
    animation-delay: 0.2s;
}

.landing-button.tertiary {
    animation-delay: 0.3s;
}

.button-icon {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

.button-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.button-subtitle {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 400;
}

/* Quick Stats */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: auto;
    padding-top: 2rem;
    animation: fadeIn 0.8s ease-out 0.4s both;
}

.quick-stat {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 1rem;
    text-align: center;
    color: white;
}

.quick-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.quick-stat-label {
    display: block;
    font-size: 0.75rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Coming Soon Screen */
.stats-content,
.settings-content {
    padding: 2rem 1.5rem;
    min-height: calc(100vh - 70px);
}

/* Settings Sections */
.settings-section {
    margin-bottom: 2rem;
}

.settings-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.settings-item:not(.disabled):hover {
    border-color: var(--primary);
}

.settings-item:not(.disabled):active {
    transform: scale(0.98);
    border-color: var(--primary-dark);
}

.settings-item.disabled {
    cursor: default;
    opacity: 0.7;
}

.settings-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.settings-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.settings-description {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.coming-soon {
    text-align: center;
    padding: 2rem;
}

.coming-soon-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.coming-soon h2 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.coming-soon p {
    color: var(--gray-600);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.coming-soon-subtitle {
    font-size: 0.875rem !important;
    color: var(--gray-500) !important;
    max-width: 300px;
    margin: 0 auto;
}


/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Responsive */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.25rem;
    }
    
    .stats-bar {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .entry-articolo-nome {
        font-size: 1rem;
    }
}

/* Delete Confirmation Dialog */
.delete-confirmation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s;
    padding: 1rem;
}

.delete-confirmation.show {
    opacity: 1;
}

.confirmation-content {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 350px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    transform: scale(0.9);
    transition: transform 0.3s;
}

.delete-confirmation.show .confirmation-content {
    transform: scale(1);
}

.confirmation-content h3 {
    font-size: 1.25rem;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    text-align: center;
}

.confirmation-content p {
    color: var(--gray-600);
    text-align: center;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.confirmation-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn-cancel,
.btn-delete {
    padding: 0.875rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-cancel:active {
    background: var(--gray-200);
    transform: scale(0.97);
}

.btn-delete {
    background: var(--danger);
    color: white;
}

.btn-delete:active {
    background: #dc2626;
    transform: scale(0.97);
}

/* Inline Delete Confirmation (NEW) */
.inline-delete-confirm {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.inline-delete-confirm.show {
    opacity: 1;
    transform: translateX(0);
}

.confirm-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    text-align: center;
}

.confirm-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.confirm-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    z-index: 100;
    -webkit-tap-highlight-color: transparent;
}

.confirm-cancel {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.confirm-cancel:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.96);
}

.confirm-delete {
    background: white;
    color: var(--danger);
}

.confirm-delete:active {
    background: var(--gray-100);
    transform: scale(0.96);
}

/* Dark mode support (future) */
@media (prefers-color-scheme: dark) {
    /* Da implementare se necessario */
}

/* Loading indicator for refresh button */
.icon-button.loading .icon {
    animation: spin 1s linear infinite;
}

/* ========== ANALYTICS / STATISTICS SCREEN ========== */

/* Stats Content Padding Fix for Mobile */
.stats-content {
    padding: 1.5rem;
}

/* Period Selector */
.period-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: 0.75rem;
}

.period-btn {
    padding: 0.75rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.period-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.period-btn:not(.active):active {
    background: var(--gray-200);
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    transition: all 0.2s;
}

.kpi-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.kpi-icon {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1;
}

.kpi-content {
    flex: 1;
    min-width: 0;
}

.kpi-label {
    font-size: 0.6875rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.375rem;
    display: block;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    display: block;
    margin-bottom: 0.25rem;
    line-height: 1;
}

.kpi-change {
    font-size: 0.6875rem;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kpi-change.positive {
    color: var(--primary);
}

.kpi-change.positive::before {
    content: '↑';
}

.kpi-change.negative {
    color: var(--danger);
}

.kpi-change.negative::before {
    content: '↓';
}

/* Charts Section */
.charts-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-100);
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.chart-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 2px solid var(--gray-200);
    border-radius: 0.5rem;
    background: white;
    color: var(--gray-900);
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s;
}

.chart-select:focus {
    outline: none;
    border-color: var(--primary);
}

.chart-container {
    min-height: 250px;
    position: relative;
}

.chart-container canvas {
    max-width: 100%;
}

/* Empty chart state */
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    color: var(--gray-400);
}

.chart-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.chart-empty-text {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Stats Table Section */
.stats-table-section {
    margin-bottom: 2rem;
}

.stats-table-section h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.stats-table-container {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.stats-table thead {
    background: var(--gray-100);
}

.stats-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--gray-200);
}

.stats-table td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-900);
    border-bottom: 1px solid var(--gray-200);
}

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

.stats-table tbody tr:hover {
    background: var(--gray-50);
}

.stats-table .metric-name {
    font-weight: 600;
}

.stats-table .metric-value {
    font-weight: 700;
    color: var(--primary);
}

.stats-table .metric-detail {
    color: var(--gray-600);
    font-size: 0.8125rem;
}

.loading-row {
    text-align: center;
    padding: 2rem !important;
    color: var(--gray-500);
}

/* Export Section */
.export-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--gray-200);
}

.export-section .primary-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.export-section .primary-button span {
    font-size: 1.25rem;
}

/* Responsive for Analytics */
@media (max-width: 360px) {
    .period-selector {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .chart-select {
        width: 100%;
    }
}

/* Simple Bar Chart Styles */
.simple-chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.chart-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.chart-bar-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-bar-container {
    position: relative;
    background: var(--gray-100);
    border-radius: 0.5rem;
    height: 32px;
    overflow: hidden;
}

.chart-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 0.5rem;
    transition: width 0.6s ease-out;
    animation: barFillIn 0.6s ease-out;
}

@keyframes barFillIn {
    from {
        width: 0 !important;
    }
}

.chart-bar-value {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--gray-900);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    z-index: 1;
}

/* ========== BATCH CARDS (GROUPED ENTRIES) ========== */

.batch-card {
    background: white;
    border: 3px solid var(--gray-200);
    border-radius: 1rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-shadow: var(--shadow);
}

.batch-card.deleting .batch-content {
    opacity: 0;
    pointer-events: none;
}

.batch-content {
    background: white;
    position: relative;
    z-index: 1;
    padding: 0.75rem 1rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.batch-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.batch-articles-count {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
}

.batch-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.batch-tag {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    background: var(--purple);
    color: white;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.batch-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.batch-valore {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.batch-timestamp {
    font-size: 0.75rem;
    color: var(--gray-600);
    white-space: nowrap;
}

.batch-items-preview {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.batch-item-name {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.batch-item-more {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-style: italic;
}

/* Batch Detail Modal Styles */
.batch-detail-header {
    margin-bottom: 1.5rem;
}

.batch-detail-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.batch-detail-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.batch-detail-stat {
    text-align: center;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 0.75rem;
    border: 2px solid var(--gray-200);
}

.batch-detail-stat .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.batch-detail-stat .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.batch-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.batch-detail-items {
    margin: 1.5rem 0;
}

.batch-detail-items h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.batch-detail-item {
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    border: 2px solid var(--gray-200);
}

.batch-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.batch-item-number {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.875rem;
}

.batch-item-name {
    font-weight: 700;
    color: var(--gray-900);
    font-size: 1rem;
}

.batch-item-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.batch-detail-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--gray-200);
}

/* ========== RESET HISTORY MODAL STYLES ========== */

.confirm-input-group {
    margin-top: 1.5rem;
}

.confirm-input-group label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.confirm-input-group label strong {
    color: var(--danger);
    font-weight: 700;
}

.confirm-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--gray-300);
    border-radius: 0.5rem;
    background: white;
    font-family: inherit;
    transition: all 0.2s;
}

.confirm-input:focus {
    outline: none;
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.confirm-input::placeholder {
    color: var(--gray-400);
}

.danger-button {
    background: var(--danger);
    color: white;
    border: none;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.danger-button:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    opacity: 0.6;
}

.danger-button:not(:disabled):active {
    background: #dc2626;
    transform: scale(0.98);
}

.settings-item.danger {
    border-color: rgba(239, 68, 68, 0.3);
}

.settings-item.danger:not(.disabled):hover {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.settings-item.danger .settings-label {
    color: var(--danger);
}

.settings-item.danger .settings-description {
    color: rgba(239, 68, 68, 0.7);
}
