:root {
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --accent: #ffd000;
    --accent-hover: #eab308;
    --navy: #0f172a;
    --danger: #dc2626;
    --success: #0d9488;
    --warning: #d97706;
    --border: #e2e8f0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
}

.navbar {
    background-color: #0f172a;
    color: #fff;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
    border-bottom: 2px solid #0d9488;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.badge-role {
    background: #334155;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 500;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-actions a, .btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.btn-primary {
    background-color: #ffd000;
    color: #0f172a !important;
    border-color: #eab308;
    font-weight: 700;
}
.btn-primary:hover {
    background-color: #eab308;
    color: #000000 !important;
}

.btn-outline {
    background-color: transparent;
    border-color: #475569;
    color: #f8fafc;
}
.btn-outline:hover {
    background-color: #1e293b;
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
}

.container {
    max-width: 1440px;
    margin: 1.25rem auto;
    padding: 0 1.25rem;
}

.toolbar {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.kpi-card {
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.kpi-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.main-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.school-budget-item {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}
.school-budget-item:last-child {
    border-bottom: none;
}

.school-tag {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: middle;
}

.progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    margin-top: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
}

.form-group {
    margin-bottom: 0.9rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

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

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 520px;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* Combobox Ricercabile per Codici Attività */
.searchable-select {
    position: relative;
}

.searchable-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
    z-index: 10000;
    display: none;
}

.searchable-dropdown.open {
    display: block;
}

.searchable-group {
    padding: 0.4rem 0.65rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    background: #f8fafc;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-top: 1px solid var(--border);
}

.searchable-group:first-child {
    border-top: none;
}

.searchable-option {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}

.searchable-option:hover,
.searchable-option.selected {
    background-color: #f0fdfa;
    color: #0f766e;
    font-weight: 600;
}

.searchable-empty {
    padding: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.table-responsive {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

table.data-table th, table.data-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
}

.login-wrapper {
    max-width: 400px;
    margin: 5rem auto;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
}

.tab-link {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
}

.tab-link.active {
    background: #ffd000;
    color: #0f172a;
    font-weight: 700;
    border: 1px solid #eab308;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.positive { color: var(--success); }
.negative { color: var(--danger); }
.app-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    vertical-align: middle;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}
.app-logo-lg {
    width: 44px;
    height: 44px;
    object-fit: contain;
    vertical-align: middle;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.18));
}

/* Accordion Monte Ore per Comune nella colonna sinistra */
.mun-accordion-item {
    border: 1px solid var(--border);
    border-radius: 7px;
    margin-bottom: 0.55rem;
    background: #ffffff;
    overflow: hidden;
    transition: border-color 0.15s;
}
.mun-accordion-item:hover {
    border-color: #cbd5e1;
}
.mun-accordion-header {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    user-select: none;
    background: #f8fafc;
    transition: background 0.15s;
}
.mun-accordion-header:hover {
    background: #f1f5f9;
}
.mun-accordion-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: #0f172a;
}
.mun-accordion-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.mun-accordion-arrow {
    display: inline-block;
    font-size: 0.72rem;
    color: #475569;
    width: 14px;
    text-align: center;
    transition: transform 0.15s;
}
.mun-accordion-sub {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    color: #64748b;
    margin-top: 3px;
    padding-left: 1.15rem;
}
.mun-accordion-body {
    display: none;
    padding: 0.35rem 0.75rem 0.55rem 1.35rem;
    border-top: 1px solid var(--border);
    background: #ffffff;
}
.mun-accordion-item.open .mun-accordion-body {
    display: block;
}
.mun-school-subitem {
    padding: 0.42rem 0;
    border-bottom: 1px dashed #e2e8f0;
}
.mun-school-subitem:last-child {
    border-bottom: none;
}

.act-type-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 6px;
    display: inline-block;
}
