:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1c1f24;
    --text-muted: #626873;
    --accent: #2453ff;
    --accent-dark: #1a3fc7;
    --danger: #c0392b;
    --success: #1e8e5a;
    --radius: 8px;
    --brand: #000f89;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
    background: var(--brand);
    border-bottom: 1px solid var(--brand);
    padding: 0.9rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header.topbar .brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
}

header.topbar nav a { margin-left: 1rem; font-size: 0.9rem; color: rgba(255, 255, 255, 0.82); }
header.topbar nav a:hover { color: #fff; }

header.topbar nav a.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-weight: 700;
    font-size: 0.82rem;
    vertical-align: middle;
}
header.topbar nav a.avatar:hover { background: rgba(255, 255, 255, 0.3); text-decoration: none; }

main.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

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

h1 { font-size: 1.6rem; margin-top: 0; }
h2 { font-size: 1.2rem; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

th, td {
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border);
}

th { color: var(--text-muted); font-weight: 600; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge.on { background: #e4f7ee; color: var(--success); }
.badge.off { background: #fbe9e7; color: var(--danger); }

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
}

.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }

form.inline { display: inline; }

input[type=text], input[type=email], input[type=password], select, textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
}

label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; }

.field { margin-bottom: 1rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    background: #eef2ff;
    color: var(--accent-dark);
    font-size: 0.9rem;
}
.messages li.error { background: #fbe9e7; color: var(--danger); }

.muted { color: var(--text-muted); font-size: 0.88rem; }

.controls-box {
    background: #fafbfc;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.controls-box .row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.dashboard-grid {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.dashboard-main { flex: 1; min-width: 0; }

.dashboard-sidebar {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 1rem;
}

@media (max-width: 860px) {
    .dashboard-grid { flex-direction: column; }
    .dashboard-sidebar { width: 100%; position: static; }
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: 0.9rem;
}

.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.kpi-label { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.25rem; }
.kpi-value.warn { color: var(--danger); }

details.collapsible summary {
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0.2rem 0;
    list-style: none;
}
details.collapsible summary::-webkit-details-marker { display: none; }
details.collapsible summary::before {
    content: "\25B8";
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.15s ease;
}
details.collapsible[open] summary::before { transform: rotate(90deg); }
details.collapsible .collapsible-body { margin-top: 1rem; }

.corso-manage-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.corso-manage-row.inactive { opacity: 0.55; }
.corso-manage-row .meta { font-size: 0.82rem; color: var(--text-muted); }

.competenza-review {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.competenza-review .promote-form {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-top: 0.75rem;
}
.competenza-review .promote-form .field { margin-bottom: 0; min-width: 140px; }

.report-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}
.report-index-grid a.card { display: block; color: var(--text); }
.report-index-grid a.card:hover { border-color: var(--brand); text-decoration: none; }
.report-index-grid .tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--brand);
    margin-bottom: 0.4rem;
}

.confidential-banner {
    background: #fff4e5;
    border: 1px solid #f0c36d;
    color: #7a5300;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.report-status { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.report-status .dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; display: inline-block; }
.report-status.done .dot { background: var(--success); }
.report-status.todo .dot { background: var(--danger); }

.report-section { max-width: 860px; }
.report-section h2 { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }
.report-section h2:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

@media print {
    header.topbar, .no-print { display: none !important; }
    main.container { max-width: 100%; padding: 0; }
    .card { border: none; padding: 0; }
    a { color: var(--text) !important; text-decoration: none !important; }
}
