@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
    --bg-primary: #0c0f1a;
    --bg-secondary: #141829;
    --bg-card: #1a1f36;
    --bg-card-hover: #1f2542;
    --bg-input: #0f1225;
    --border: #2a2f4a;
    --border-light: #353b5e;
    --text-primary: #f0f2f5;
    --text-secondary: #8b92b0;
    --text-muted: #5a6178;
    --accent: #6366f1;
    --accent-hover: #5457e5;
    --accent-light: rgba(99,102,241,0.15);
    --success: #22c55e;
    --success-light: rgba(34,197,94,0.15);
    --danger: #ef4444;
    --danger-light: rgba(239,68,68,0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245,158,11,0.15);
    --info: #3b82f6;
    --info-light: rgba(59,130,246,0.15);
    --shadow: 0 4px 24px rgba(0,0,0,0.25);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ========== LOGIN ========== */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    padding: 48px 40px;
    border-radius: var(--radius-lg);
    width: 420px;
    max-width: 100%;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-logo {
    width: 56px;
    height: 56px;
    background: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
}

.login-logo-img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 20px;
    display: block;
    border: 2px solid var(--accent);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.login-box h1 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 0.9rem;
    text-align: center;
}

.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
    border: 1px solid rgba(239,68,68,0.2);
}

/* ========== FORMS ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
}

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

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

/* ========== BUTTONS ========== */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1db954; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-secondary { background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-export { background: var(--info-light); color: var(--info); border: 1px solid rgba(59,130,246,0.2); }
.btn-export:hover { background: rgba(59,130,246,0.25); }

.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 0.95rem; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-icon { padding: 8px; min-width: 34px; justify-content: center; }

/* ========== LAYOUT ========== */
.header {
    background: var(--bg-secondary);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 12px;
}

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

.header-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    color: white;
}

.header-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
}

.header h1 { font-size: 1.1rem; color: var(--text-primary); font-weight: 700; }
.header .subtitle { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }

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

.society-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.society-selector label { font-size: 0.8rem; color: var(--text-muted); }

.society-selector select,
.controls select, .controls input[type="number"] {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.society-selector select:focus,
.controls select:focus {
    outline: none;
    border-color: var(--accent);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.user-info span { font-size: 0.85rem; color: var(--text-secondary); }

/* ========== TABS ========== */
.tabs {
    display: flex;
    background: var(--bg-secondary);
    padding: 0 28px;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab {
    padding: 14px 20px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ========== CONTENT ========== */
.content { padding: 28px; max-width: 1500px; margin: 0 auto; }

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

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

.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    align-items: center;
    flex-wrap: wrap;
}

.controls label { font-size: 0.8rem; color: var(--text-muted); margin-right: -4px; }

.controls-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ========== CARDS ========== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    padding: 20px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover { border-color: var(--border-light); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.card h3 {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
    font-weight: 600;
}

.card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.card .subvalue {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.card.accent::before { background: var(--accent); }
.card.green::before { background: var(--success); }
.card.green .value { color: var(--success); }
.card.red::before { background: var(--danger); }
.card.red .value { color: var(--danger); }
.card.blue::before { background: var(--info); }
.card.blue .value { color: var(--info); }
.card.warning::before { background: var(--warning); }

/* ========== TABLES ========== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

table { width: 100%; border-collapse: collapse; background: var(--bg-card); }

thead th {
    background: var(--bg-secondary);
    padding: 12px 14px;
    text-align: right;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

thead th:first-child, thead th:nth-child(2) { text-align: left; }

tbody td {
    padding: 8px 14px;
    text-align: right;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(42,47,74,0.5);
    white-space: nowrap;
    color: var(--text-secondary);
}

tbody td:first-child, tbody td:nth-child(2) { text-align: left; color: var(--text-primary); }

tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-card-hover); }

tbody tr.closed-day { background: rgba(34,197,94,0.05); }
tbody tr.closed-day td { color: var(--success); }
tbody tr.closed-day td:first-child::after { content: ' (chiuso)'; font-size: 0.7rem; color: var(--success); }

tbody tr.totals-row {
    background: var(--bg-secondary);
    font-weight: 700;
    position: sticky;
    bottom: 0;
}

tbody tr.totals-row td {
    border-top: 2px solid var(--accent);
    color: var(--text-primary);
    padding: 14px;
    font-size: 0.9rem;
}

/* ========== EDITABLE CELLS ========== */
.editable-cell {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    text-align: right;
    padding: 7px 10px;
    width: 100px;
    font-size: 0.85rem;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    cursor: text;
}

.editable-cell:hover { border-color: var(--border-light); }

.editable-cell:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-card-hover);
}

.calculated {
    color: var(--info) !important;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.negative { color: var(--danger) !important; }
.positive { color: var(--success) !important; }

/* ========== SECTIONS ========== */
.section-title {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--accent);
    border-radius: 2px;
}

.dual-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 1200px) { .dual-tables { grid-template-columns: 1fr; } }

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-category {
    background: var(--accent-light);
    color: var(--accent);
}

.badge-payment {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 480px;
    width: 100%;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: modalIn 0.25s ease;
}

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

.modal h2 {
    color: var(--text-primary);
    margin-bottom: 24px;
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal h2::before {
    content: '+';
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
}

.modal .buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease, toastOut 0.3s ease forwards;
    animation-delay: 0s, 3s;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 380px;
    border: 1px solid;
}

.toast-success { background: var(--success-light); color: var(--success); border-color: rgba(34,197,94,0.2); }
.toast-error { background: var(--danger-light); color: var(--danger); border-color: rgba(239,68,68,0.2); }
.toast-info { background: var(--info-light); color: var(--info); border-color: rgba(59,130,246,0.2); }

@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* ========== DASHBOARD ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

@media (max-width: 1000px) { .dashboard-grid { grid-template-columns: 1fr; } }

.chart-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
}

.chart-container h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
}

.chart-container canvas { max-height: 280px; }

.activity-list {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
}

.activity-list h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(42,47,74,0.5);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-dot.green { background: var(--success); }
.activity-dot.red { background: var(--danger); }
.activity-dot.blue { background: var(--info); }

.activity-text { font-size: 0.82rem; color: var(--text-secondary); flex: 1; }
.activity-value { font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 0.9rem; }

/* ========== DAY NAME ========== */
.day-name { text-transform: capitalize; font-weight: 500; }

/* ========== BUTTON LOADING STATE ========== */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}
.btn.loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 6px;
}

/* ========== TABLE RESPONSIVE ========== */
.table-wrapper {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .header { padding: 12px 16px; }
    .header h1 { font-size: 0.95rem; }
    .header .subtitle { display: none; }
    .header-logo { width: 36px; height: 36px; }

    .tabs { padding: 0 12px; gap: 0; }
    .tab { padding: 10px 10px; font-size: 0.75rem; }

    .content { padding: 12px; }

    .summary-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
    .card { padding: 12px 14px; }
    .card h3 { font-size: 0.65rem; margin-bottom: 6px; }
    .card .value { font-size: 1.1rem; }
    .card .subvalue { font-size: 0.7rem; }

    .controls { gap: 6px; flex-wrap: wrap; }
    .controls-group { padding: 4px 8px; }
    .controls select { padding: 6px 8px; font-size: 0.8rem; }
    .btn { padding: 8px 14px; font-size: 0.78rem; }
    .btn-sm { padding: 5px 10px; font-size: 0.72rem; }

    .editable-cell { width: 70px; padding: 5px 6px; font-size: 0.78rem; }
    .note-cell { width: 80px; font-size: 0.72rem; }

    .dual-tables { grid-template-columns: 1fr; }
    .modal { padding: 20px; margin: 10px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dash-top-row { grid-template-columns: 1fr; }

    .filter-bar { padding: 10px 12px; gap: 8px; }
    .filter-group { min-width: 120px; }
    .filter-input, .filter-select { padding: 8px 10px; font-size: 0.8rem; }

    .templates-bar { padding: 10px 12px; gap: 6px; }
    .template-pill { padding: 4px 10px; font-size: 0.75rem; }

    .kpi-row { flex-direction: column; }
    .kpi-card { min-width: auto !important; }

    .today-comparison { flex-direction: column; }
    .today-card { min-width: auto !important; }

    .insights-grid { grid-template-columns: 1fr !important; }

    .user-info span { display: none; }
    .society-selector label { display: none; }

    .cost-detail-panel { padding: 16px !important; }

    thead th { padding: 8px 6px; font-size: 0.65rem; }
    tbody td { padding: 6px; font-size: 0.78rem; }
    tbody tr.totals-row td { padding: 10px 6px; font-size: 0.82rem; }
}

@media (max-width: 480px) {
    .summary-cards { grid-template-columns: 1fr; }
    .header-right { width: 100%; justify-content: space-between; }
    .society-selector { flex: 1; }
    .society-selector select { flex: 1; width: 100%; }
    .header-brand { gap: 8px; }
    .header h1 { font-size: 0.85rem; }
    .header-logo { width: 32px; height: 32px; }

    .controls { justify-content: center; }
    .controls-group { flex: 1; min-width: 0; }

    .tab { padding: 10px 8px; font-size: 0.7rem; }

    .modal { max-width: 100%; border-radius: var(--radius); }
    .modal .buttons { flex-direction: column; }
    .modal .buttons .btn { width: 100%; justify-content: center; }

    .goal-ring-container { width: 110px; height: 110px; }
    .goal-pct { font-size: 1.3rem; }

    .dash-summary-cards { grid-template-columns: 1fr 1fr; }
}

/* ========== LOADING SPINNER ========== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

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

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========== DASH TOP ROW ========== */
.dash-top-row {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 900px) { .dash-top-row { grid-template-columns: 1fr; } }

.dash-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ========== GOAL RING ========== */
.goal-ring-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.goal-ring-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--success));
}

.goal-ring-container {
    position: relative;
    width: 130px;
    height: 130px;
}

.goal-ring-svg {
    width: 100%;
    height: 100%;
}

#goalArc { transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1); }

.goal-ring-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.goal-pct {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1;
}

.goal-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.goal-info { text-align: center; }
.goal-info h4 { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.goal-values { font-size: 0.85rem; color: var(--text-primary); font-weight: 500; }
.goal-remaining { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.editable-goal {
    color: var(--accent);
    cursor: pointer;
    border-bottom: 1px dashed var(--accent);
    outline: none;
    padding: 0 2px;
}

.editable-goal:focus {
    background: var(--accent-light);
    border-radius: 4px;
    border-bottom: none;
}

/* ========== INSIGHTS ========== */
.insights-panel {
    margin-bottom: 24px;
}

.insights-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.insights-title::before {
    content: '';
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.insight-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 16px 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: var(--transition);
}

.insight-card:hover { border-color: var(--border-light); transform: translateY(-1px); }

.insight-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.insight-icon.green { background: var(--success-light); }
.insight-icon.red { background: var(--danger-light); }
.insight-icon.blue { background: var(--info-light); }
.insight-icon.purple { background: var(--accent-light); }
.insight-icon.yellow { background: var(--warning-light); }

.insight-text h5 {
    font-size: 0.82rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 3px;
}

.insight-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ========== CELEBRATION ========== */
.confetti-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 3000;
}

/* ========== COUNTER ANIMATION ========== */
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.count-up { animation: countUp 0.6s ease forwards; }

/* ========== COST DETAIL PANELS ========== */
.cost-detail-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px 24px;
}

.supplier-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(42,47,74,0.4);
}

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

.supplier-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.supplier-rank {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.supplier-rank.gold { background: rgba(245,158,11,0.2); color: #f59e0b; }
.supplier-rank.silver { background: rgba(139,146,176,0.2); color: #8b92b0; }
.supplier-rank.bronze { background: rgba(180,130,80,0.2); color: #b48250; }
.supplier-rank.normal { background: var(--bg-input); color: var(--text-muted); }

.supplier-name { font-size: 0.85rem; color: var(--text-primary); font-weight: 500; }
.supplier-count { font-size: 0.72rem; color: var(--text-muted); }
.supplier-value { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.cat-breakdown-row {
    padding: 12px 0;
    border-bottom: 1px solid rgba(42,47,74,0.4);
}

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

.cat-breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.cat-breakdown-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cat-breakdown-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.cat-breakdown-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.cat-breakdown-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
}

.cat-breakdown-pct {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* Food cost KPI */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 18px 22px;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.kpi-card.green::before { background: var(--success); }
.kpi-card.red::before { background: var(--danger); }
.kpi-card.blue::before { background: var(--info); }
.kpi-card.yellow::before { background: var(--warning); }
.kpi-card.purple::before { background: var(--accent); }

.kpi-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.kpi-subtext {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.kpi-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    margin-left: 6px;
}

.kpi-badge.ok { background: var(--success-light); color: var(--success); }
.kpi-badge.warn { background: var(--warning-light); color: var(--warning); }
.kpi-badge.alert { background: var(--danger-light); color: var(--danger); }

/* ========== PROGRESS BAR ========== */
.progress-bar-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-bar-container .progress-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 140px;
}

.progress-bar-container .progress-label strong {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.progress-track {
    flex: 1;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease;
    background: linear-gradient(90deg, var(--accent), var(--success));
}

.progress-fill.over { background: linear-gradient(90deg, var(--success), #10b981); }
.progress-fill.under { background: linear-gradient(90deg, var(--warning), var(--danger)); }

.progress-bar-container .progress-percent {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 50px;
    text-align: right;
}

/* ========== CLOSED DAY TOGGLE ========== */
.closed-toggle {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: transparent;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: transparent;
    padding: 0;
}

.closed-toggle:hover { border-color: var(--success); }
.closed-toggle.active {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* ========== TODAY COMPARISON ========== */
.today-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) { .today-comparison { grid-template-columns: 1fr; } }

.today-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
}

.today-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.today-card.today::before { background: var(--accent); }
.today-card.lastweek::before { background: var(--text-muted); }

.today-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.today-card-header h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 600;
}

.today-card-header .trend {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
}

.trend.up { background: var(--success-light); color: var(--success); }
.trend.down { background: var(--danger-light); color: var(--danger); }
.trend.neutral { background: var(--bg-input); color: var(--text-muted); }

.today-card .big-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.today-card .detail {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ========== ANIMATE NUMBERS ========== */
.animate-value {
    transition: all 0.5s ease;
}

/* ========== WELCOME SCREEN ========== */
#welcomeOverlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #0c0f1a 0%, #141836 30%, #1a1050 60%, #0c0f1a 100%);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: welcomeFadeIn 0.5s ease;
    overflow: hidden;
}

#welcomeOverlay.welcome-exit {
    animation: welcomeFadeOut 0.6s ease forwards;
}

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

@keyframes welcomeFadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(1.05); }
}

.welcome-particles {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
}

.welcome-particle {
    position: absolute;
    background: rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0% { transform: translateY(0) scale(1); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-120px) scale(0.3); opacity: 0; }
}

.welcome-content {
    text-align: center;
    z-index: 1;
    animation: welcomeContentIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

@keyframes welcomeContentIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    animation: welcomeIconBounce 1s ease 0.3s;
}

@keyframes welcomeIconBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.welcome-greeting {
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-date {
    font-size: 0.95rem;
    color: rgba(139, 146, 176, 0.9);
    font-weight: 400;
}

.welcome-divider {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #22c55e);
    margin: 28px auto;
    border-radius: 2px;
}

.welcome-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 28px;
}

.welcome-logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.welcome-logo-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(99, 102, 241, 0.6);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.welcome-brand h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    text-align: left;
    margin: 0;
}

.welcome-brand p {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: left;
    margin: 2px 0 0;
}

.welcome-quote {
    max-width: 400px;
    margin: 0 auto 32px;
    min-height: 60px;
    animation: welcomeQuoteIn 0.8s ease 0.6s forwards;
    opacity: 0;
}

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

.welcome-quote p {
    font-size: 0.88rem;
    color: rgba(199, 210, 254, 0.7);
    font-style: italic;
    line-height: 1.5;
    margin: 0 0 6px;
}

.welcome-quote span {
    font-size: 0.75rem;
    color: rgba(139, 146, 176, 0.6);
}

.welcome-loader {
    width: 200px;
    height: 3px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 2px;
    margin: 0 auto 12px;
    overflow: hidden;
}

.welcome-loader-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #22c55e);
    border-radius: 2px;
    animation: welcomeLoaderFill 3s ease forwards;
}

@keyframes welcomeLoaderFill {
    0% { width: 0%; }
    30% { width: 40%; }
    60% { width: 70%; }
    80% { width: 85%; }
    100% { width: 100%; }
}

.welcome-loading-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

@media (max-width: 480px) {
    .welcome-greeting { font-size: 1.5rem; }
    .welcome-brand { flex-direction: column; }
    .welcome-brand h2, .welcome-brand p { text-align: center; }
}

/* ========== LOADING SKELETONS ========== */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-card {
    height: 90px;
    border-radius: var(--radius);
}

.skeleton-table {
    height: 300px;
    margin-top: 16px;
    border-radius: var(--radius);
}

.skeleton-row {
    height: 38px;
    margin: 4px 0;
    border-radius: 4px;
}

.skeleton-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.skeleton-wrapper .skeleton-table {
    grid-column: 1 / -1;
}

/* ========== PDF STYLES ========== */
/* ========== FILTER BAR ========== */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.filter-group { flex: 1; min-width: 150px; }

.filter-input, .filter-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    transition: var(--transition);
}

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

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

/* ========== NOTE CELL ========== */
.note-cell {
    width: 100px;
    font-size: 0.78rem;
    border: 1px dashed var(--border);
    background: transparent;
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: inherit;
    transition: var(--transition);
}
.note-cell:focus {
    border-color: var(--accent);
    background: var(--bg-card);
    color: var(--text-primary);
}
.note-cell::placeholder { color: var(--text-muted); font-size: 0.75rem; }

/* ========== COST TEMPLATES ========== */
.templates-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    min-height: 48px;
}
.templates-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 4px;
}
.templates-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}
.template-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: var(--transition);
}
.template-pill:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}
.template-pill-name { font-weight: 600; }
.template-pill-cat {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 1px 6px;
    background: var(--bg-input);
    border-radius: 10px;
}
.template-pill-delete {
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    transition: var(--transition);
}
.template-pill-delete:hover { color: var(--danger); }

.btn-template {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid rgba(245,158,11,0.3);
}
.btn-template:hover { background: rgba(245,158,11,0.25); }

/* ========== PASSWORD SUCCESS ========== */
.password-success {
    background: var(--success-light);
    color: var(--success);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
    border: 1px solid rgba(34,197,94,0.2);
}

@media print {
    body { background: white !important; color: black !important; }
    .header, .tabs, .controls, .btn, .toast-container, .modal-overlay { display: none !important; }
    .tab-content { display: block !important; }
    .card { border: 1px solid #ddd !important; background: #f9f9f9 !important; }
    table { background: white !important; }
    thead th { background: #f0f0f0 !important; color: #333 !important; }
    tbody td { color: #333 !important; }
    .editable-cell { border: none !important; background: transparent !important; color: #333 !important; }
}
