:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --planned: #f59e0b; /* Orange */
    --actual: #10b981; /* Green */
    --border: rgba(255,255,255,0.1);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    background-image: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.1), transparent 25%);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 1.5rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--text-main);
}

.container {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    animation: fadeIn 0.5s ease-out;
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.title { font-size: 1.25rem; font-weight: 600; }

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

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 0.5rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 0.75rem;
}

td.proj-name {
    text-align: left;
    font-weight: 600;
}

tr:last-child td { border-bottom: none; }

tr:hover td {
    background: rgba(255,255,255,0.03);
}

/* --- Pivot compatta (Dashboard ore) --- */
table.pivot th,
table.pivot td {
    padding: 0.28rem 0.7rem;
    font-size: 0.82rem;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
table.pivot thead th {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}
table.pivot .row-head { text-align: left; }
table.pivot thead th.row-head { min-width: 220px; }

table.pivot .col-total {
    font-weight: 700;
    border-left: 1px solid var(--border);
    color: var(--text-main);
}

table.pivot .lvl-total > td {
    font-weight: 700;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    color: var(--text-main);
}
table.pivot .lvl-client > td {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer;
}
table.pivot .lvl-client .row-head { padding-left: 1.5rem; }
table.pivot .lvl-proj .row-head {
    padding-left: 3rem;
    font-weight: 400;
    color: var(--text-muted);
}
table.pivot .lvl-total:hover > td,
table.pivot .lvl-client:hover > td { background: rgba(255, 255, 255, 0.08); }

/* Riepilogo capacita' / residuo */
table.capacity .cap-row > td { font-size: 0.82rem; }
table.capacity .cap-row.ooo td,
table.capacity .cap-row.plan td { color: var(--text-muted); }
table.capacity .residuo > td {
    font-weight: 700;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
}
table.capacity .residuo .pos { color: #34d399; }
table.capacity .residuo .neg { color: #f87171; }
table.capacity .residuo .zero { color: var(--text-muted); }

.tw-caret {
    display: inline-block;
    width: 1em;
    margin-right: 0.15rem;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}
.collapsed .tw-caret { transform: rotate(-90deg); }
.hidden { display: none; }

.pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin: 0.15rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    letter-spacing: -0.2px;
}

.pill.planned {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.pill.actual {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.pill.soluto {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.pill.muted {
    opacity: 0.5;
    font-style: italic;
}

.legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.legend-note {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.outlook-sync-panel {
    text-align: center;
    padding: 3rem;
}

.outlook-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    display: inline-block;
    background: linear-gradient(135deg, #0078d4, #005a9e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* --- Flash messages --- */
.flash-area { margin-bottom: 1rem; }
.flash {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: var(--text-main);
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* --- Form tariffe --- */
.tariffa-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}
.tariffa-form .field { display: flex; flex-direction: column; gap: 0.3rem; }
.tariffa-form label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}
.tariffa-form label .opt { text-transform: none; letter-spacing: 0; font-weight: 400; }
.tariffa-form select,
.tariffa-form input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    padding: 0.55rem 0.7rem;
    font-family: inherit;
    font-size: 0.9rem;
    min-width: 150px;
}
.tariffa-form input[type="number"] { min-width: 110px; }
.tariffa-form select:focus,
.tariffa-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}
.hint {
    margin-top: 0.9rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.btn-del {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-del:hover { background: rgba(239, 68, 68, 0.3); }
