:root {
    --page-bg: #f5efe6;
    --page-gradient-start: #fdfbf8;
    --page-gradient-end: #f1e3d4;
    --wood: #d1b894;
    --wood-dark: #b99560;
    --text: #3f2c1e;
    --card: rgba(255, 255, 255, 0.9);
    --card-highlight: rgba(255, 255, 255, 0.55);
    --shadow: 0 24px 60px rgba(51, 36, 26, 0.08);
    --shadow-strong: 0 35px 80px rgba(77, 51, 31, 0.15);
    --muted: #7a6654;
    --accent: #c06c2b;
    --accent-2: #f0d8c0;
    --alert-yellow: #fff3cd;
    --alert-red: #fbe5e5;
    --border-soft: #f1e6da;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(145deg, var(--page-gradient-start), var(--page-gradient-end));
    color: var(--text);
    font-family: 'Poppins', 'Inter', system-ui, -apple-system, sans-serif;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.45), transparent 35%),
        radial-gradient(circle at 90% 10%, rgba(255, 255, 255, 0.35), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(209, 184, 148, 0.35), transparent 35%);
    pointer-events: none;
    z-index: 0;
}

main,
body > *:not(.modal):not(.modal-backdrop) {
    position: relative;
    z-index: 1;
}

.login-page {
    background: repeating-linear-gradient(
            -45deg,
            #dcbf96 0,
            #dcbf96 20px,
            #c9ad8a 20px,
            #c9ad8a 40px
    );
    background-size: 200% 200%;
    animation: parquetMove 80s linear infinite;
    position: relative;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.25), transparent 30%),
    rgba(0, 0, 0, 0.12);
    pointer-events: none;
}

.login-container {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(420px, 100%);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(4px);
}

.login-panel .logo-mark {
    letter-spacing: 0.18em;
    font-weight: 700;
    font-size: 13px;
}

@keyframes parquetMove {
    0% { background-position: 0 0; }
    100% { background-position: 200% 200%; }
}

.navbar {
    background: linear-gradient(120deg, var(--wood), var(--wood-dark));
    border: none;
    height: 72px;
    box-shadow: var(--shadow);
    border-radius: 0 0 24px 24px;
    padding: 0 12px;
}

.navbar-brand {
    color: var(--text) !important;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
}

.navbar-brand img {
    height: 42px;
}

.nav-link {
    color: var(--text) !important;
    font-weight: 600;
    position: relative;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 4px;
    width: 0;
    height: 2px;
    background: var(--text);
    transition: width 0.2s ease;
}

.nav-link:hover::after,
.nav-link:focus::after,
.nav-link.active::after {
    width: 100%;
}

.nav-link:hover,
.nav-link:focus,
.nav-link.active {
    background: rgba(255, 255, 255, 0.35);
}

.dashboard-container {
    max-width: 1200px;
    margin: 32px auto 64px;
    padding-bottom: 32px;
}

.section-title {
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 10px;
}

.card {
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    background: var(--card);
    box-shadow: var(--shadow-strong);
    overflow: hidden;
}

.card-header {
    background: linear-gradient(120deg, rgba(209, 184, 148, 0.35), rgba(240, 216, 192, 0.6));
    color: var(--text);
    font-weight: 700;
    border: none;
    padding: 18px 22px;
    font-size: 15px;
}

.card-body {
    padding: 26px;
}

.hero {
    background: linear-gradient(135deg, var(--card), var(--card-highlight));
    border-radius: 24px;
    padding: 24px 28px;
    box-shadow: var(--shadow-strong);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.hero h3 {
    margin: 0 0 6px;
    font-weight: 700;
}

.hero .muted {
    margin-bottom: 12px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow);
}

.status-pill .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #61b963;
    box-shadow: 0 0 0 6px rgba(97, 185, 99, 0.15);
}

.status-alert {
    background: #f7d3c8;
}

.status-alert .dot {
    background: #d9534f;
    box-shadow: 0 0 0 6px rgba(217, 83, 79, 0.18);
}

.alert-wood {
    background: rgba(255, 243, 205, 0.9);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 20px 24px;
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.alert-danger,
.alert-success {
    background: rgba(251, 229, 229, 0.85);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 16px 18px;
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.alert-success {
    background: rgba(223, 243, 227, 0.9);
}

.muted {
    color: var(--muted);
}

.table {
    color: var(--text);
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.table thead th {
    background: transparent;
    border: none;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 13px;
    color: var(--muted);
}

.table tbody td,
.table tbody th {
    border: none;
    vertical-align: middle;
}

tbody tr {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: rgba(255, 255, 255, 0.7);
}

.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: rgba(240, 231, 221, 0.9);
}

.table-bordered > :not(caption) > * {
    border-color: #f0e8de;
}

.table-budget tbody tr.table-danger {
    background: #fbe5e5;
}

.badge {
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
    border: none;
}

.badge-mode {
    background: #f3ebe1;
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.badge-mode.mode-bonifico { background: #d7e7ff; color: #1a4b8b; }
.badge-mode.mode-carta { background: #ffe2d1; color: #b34a1f; }
.badge-mode.mode-contanti { background: #dff3e3; color: #2f6b3c; }
.badge-mode.mode-riba { background: #f1e3ff; color: #5a2f91; }
.badge-mode.mode-anticipato { background: #e0f3ff; color: #0b5975; }
.badge-mode.mode-riba-30 { background: #fff1e0; color: #a65b00; }
.badge-mode.mode-riba-60 { background: #e8f5e9; color: #1f6b3a; }
.badge-mode.mode-riba-90 { background: #f2e6ff; color: #5a2f91; }
.badge-mode.mode-riba-30-60 { background: #ffe6fb; color: #5a2f91; }
.badge-mode.mode-riba-30-60-90 { background: #ffe9d9; color: #8b4b11; }

.badge-date {
    background: linear-gradient(120deg, #0d6efd, #5e9dff);
    color: #fff;
    letter-spacing: 0.04em;
    box-shadow: 0 8px 18px rgba(13, 110, 253, 0.25);
}

.attachment-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(243, 237, 230, 0.85);
    color: var(--text);
    border-radius: 16px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
    font-weight: 600;
    box-shadow: var(--shadow);
}

.attachment-pill:hover {
    background: #f1e5d6;
    transform: translateY(-1px);
}

.table-responsive {
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 8px;
    background: rgba(255, 255, 255, 0.6);
}

.form-control,
.form-select,
.form-control:focus,
.form-select:focus {
    border-radius: 14px;
    border: 1px solid var(--border-soft);
    box-shadow: none;
    background-color: rgba(255, 255, 255, 0.9);
}

.btn-primary {
    border-radius: 999px;
    padding: 0.6rem 1.6rem;
    border: none;
    background: linear-gradient(120deg, var(--accent), #d98a53);
    box-shadow: 0 15px 25px rgba(192, 108, 43, 0.25);
}

.btn-outline-secondary,
.btn-outline-secondary:hover {
    border-radius: 999px;
}

.modal-content {
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-strong);
}

@media (max-width: 768px) {
    .navbar {
        height: auto;
        border-radius: 0;
    }

    .dashboard-container {
        padding: 0 16px 32px;
    }
}
