:root {
    /* Color Palette — STITCH Style */
    --primary: #fccb06;
    --primary-hover: #e6b800;
    --primary-dark: #1f2a3d;
    --background: #f6f7f7;
    --surface: #FFFFFF;
    --text-main: #1f2a3d;
    --text-muted: #6B7280;
    --border: #e5e7eb;
    --success: #10B981;
    --error: #EF4444;
    --sidebar-bg: #1f2a3d;
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-active-bg: #fccb06;
    --sidebar-active-text: #1f2a3d;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Radius */
    --radius: 0.75rem;

    /* Shadow */
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --background: #111827;
    --surface: #1F2937;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --border: #374151;
    --sidebar-bg: #16181c;
    --primary-dark: #F9FAFB;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

/* Layout */
.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.brand {
    margin-bottom: var(--spacing-xl);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 2px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.footer-logo {
    width: 60%;
    max-width: 150px;
    height: auto;
    max-height: 150px;
    /* 50px * 3 */
    object-fit: contain;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    margin-bottom: 0.5rem;
}

.app-version {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    opacity: 0.6;
}

.footer-logo:hover {
    opacity: 1;
}

.theme-toggle {
    width: 100%;
    justify-content: center;
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    padding: 0.7rem var(--spacing-md);
    margin-bottom: 2px;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.nav-links li:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.nav-links li.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

.theme-toggle {
    cursor: pointer;
    padding: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    opacity: 0.6;
    transition: opacity 0.2s;
}

.theme-toggle:hover {
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl);
    background-image:
        linear-gradient(rgba(31, 42, 61, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 42, 61, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Custom Scrollbar */
.main-content::-webkit-scrollbar {
    width: 4px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
}

h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

/* View Management */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.kpi-card {
    background: var(--surface);
    padding: var(--spacing-lg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.kpi-card .label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.kpi-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.kpi-card .value.success {
    color: var(--success);
}

.kpi-card .value.error {
    color: #fff;
}

.kpi-card:has(.value.error) .label {
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-card:has(.value.error) {
    background: var(--primary-dark);
    border-color: rgba(252, 203, 6, 0.3);
    box-shadow: 0 4px 20px rgba(31, 42, 61, 0.3);
}

.kpi-card .sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
    font-weight: 500;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-md);
}

.chart-container {
    background: var(--surface);
    padding: var(--spacing-md);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    height: 220px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chart-container h3 {
    margin-bottom: var(--spacing-md);
    font-size: 1rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    width: 100%;
}

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    background: var(--surface);
    padding: var(--spacing-md);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.date-selector {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-weight: 500;
}

.date-selector button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.date-selector button:hover {
    color: var(--primary);
}

/* Tables */
.table-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

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

.data-table th {
    background-color: rgba(0, 0, 0, 0.02);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
    transition: background-color 0.15s;
}

.data-table td .btn {
    padding: 4px 6px;
    font-size: 0.8rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary-dark);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--primary);
    color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--background);
}

.btn-danger {
    background-color: var(--error);
    color: white;
}

.btn-text {
    background: none;
    color: var(--text-muted);
}

.btn-text:hover {
    color: var(--text-main);
}

.btn-icon-only {
    padding: 0.5rem;
    border-radius: 50%;
}

/* Cards (Clients, etc) */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.client-card {
    background: var(--surface);
    padding: var(--spacing-lg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    transition: transform 0.2s;
}

.client-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.client-card h3 {
    margin-bottom: var(--spacing-xs);
}

.client-card .meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
}

.client-card .actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-xs);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: 0.9rem;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    border-color: var(--primary);
}

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

/* Settings */
.settings-card {
    background: var(--surface);
    padding: var(--spacing-xl);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: var(--spacing-lg);
}

.settings-card h3 {
    margin-bottom: var(--spacing-md);
}

.settings-card p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
}

.danger-zone {
    border: 1px solid var(--error);
}

.danger-zone h3 {
    color: var(--error);
}

/* Filters Bar */
.filters-bar select {
    min-width: 150px;
    background-color: var(--surface);
    cursor: pointer;
}

/* Dashboard Year Filter Highlight */
.dashboard-filter-highlight {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: var(--primary);
    /* Use primary color background */
    color: #333;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dashboard-filter-highlight label {
    margin-bottom: 0;
    font-weight: 600;
    color: #333;
}

.dashboard-filter-highlight select {
    background-color: rgba(255, 255, 255, 0.2);
    /* Semi-transparent white */
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.15);
    font-weight: 600;
    cursor: pointer;
    width: auto;
    min-width: 100px;
}

.dashboard-filter-highlight select option {
    background-color: var(--surface);
    color: var(--text-main);
}

.dashboard-filter-highlight select:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.3);

    border-color: white;
}

/* --- PRODUCT MANAGER STYLES --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.product-card {
    background: var(--surface);
    padding: var(--spacing-lg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 10rem;
    color: #fff;
}

.badge-active {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #F59E0B;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-muted {
    background-color: rgba(107, 114, 128, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(107, 114, 128, 0.2);
}

/* --- MAPPA RELAZIONI — STITCH STYLE (COMPACT) --- */
/* --- MAPPA RELAZIONI (VERTICAL TREE) --- */
.tree-container {
    padding: 1rem;
    min-height: 400px;
    background-color: var(--background);
    border-radius: var(--radius);
}

.tree-root {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

details.tree-node {
    margin-bottom: 0.25rem;
    width: 100%;
}

summary.tree-summary {
    list-style: none;
    /* Hide default arrow */
    cursor: pointer;
    background: var(--surface);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    user-select: none;
    position: relative;
    padding-left: 2rem;
    /* Space for arrow */
}

summary.tree-summary::-webkit-details-marker {
    display: none;
}

/* Custom Arrow */
summary.tree-summary::before {
    content: '\f0da';
    /* fa-caret-right */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

details[open]>summary.tree-summary::before {
    transform: rotate(90deg);
}

summary.tree-summary:hover {
    background-color: #f9fafb;
    border-color: var(--primary);
}

/* Indentation and Lines */
.tree-children {
    margin-left: 1.5rem;
    padding-left: 1rem;
    border-left: 1px solid rgba(31, 42, 61, 0.1);
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Level Specifics */
/* Client */
.tree-node.client>summary {
    background: #fff;
    border-left: 4px solid var(--primary-dark, #1f2a3d);
}

.tree-label-main {
    font-weight: 700;
    color: var(--primary-dark, #1f2a3d);
    font-size: 1rem;
}

.tree-badge {
    background: rgba(31, 42, 61, 0.05);
    padding: 0.1rem 0.5rem;
    border-radius: 99px;
    font-size: 0.7rem;
    color: #6B7280;
}

/* Project */
.tree-node.project>summary {
    border-left: 4px solid var(--primary);
}

.tree-status {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 700;
    margin-left: auto;
    /* Push to right */
}

.tree-status.active {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.tree-status.dev {
    background: rgba(234, 179, 8, 0.1);
    color: #D97706;
}

.tree-status.completed {
    background: rgba(107, 114, 128, 0.1);
    color: #6B7280;
}

.tree-cost {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
    min-width: 60px;
    text-align: right;
}

/* Variant */
.tree-node.variant>summary {
    border: 1px dashed var(--border);
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

.tree-icon {
    width: 24px;
    text-align: center;
    color: var(--text-muted);
}

.tree-icon.folder {
    color: #F59E0B;
}

.tree-icon.client {
    color: var(--primary-dark, #1f2a3d);
}

/* Component Leaf */
.tree-leaf-component {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 0.75rem;
    /* No arrow space needed */
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid transparent;
    border-radius: 0.5rem;
    margin-left: 2rem;
    /* Match summary text alignment */
    font-size: 0.85rem;
}

.tree-leaf-component:hover {
    background: #fff;
    border-color: var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.comp-icon {
    color: var(--success);
    width: 20px;
    text-align: center;
}

.comp-name {
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.comp-meta {
    font-family: monospace;
    color: #6B7280;
    font-size: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.comp-supplier {
    color: #4B5563;
    font-style: italic;
}

.map-empty {
    padding: 3rem;
    text-align: center;
    color: #9CA3AF;
}

.map-wrapper {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 1rem;
    padding-bottom: 2rem;
}

.map-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 300px;
    /* Ensure visual separation */
}

/* Vertical divider between clients */
.map-divider-v {
    width: 2px;
    background-color: var(--primary-dark, #1f2a3d);
    /* Dark strong line as per image */
    align-self: stretch;
    margin: 0 2rem;
    opacity: 1;
}

/* Old .map-flow is replaced by .map-column logic generally, keeping for compatibility if needed */
.map-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* Connector line between levels */
.map-connector {
    width: 1px;
    height: 1rem;
    /* Reduced from 1.5rem */
    background-color: rgba(31, 42, 61, 0.2);
    flex-shrink: 0;
}

.map-connector-h {
    height: 1px;
    background-color: rgba(31, 42, 61, 0.2);
    flex-shrink: 0;
    align-self: stretch;
}

/* Level row — horizontal children */
.map-level {
    display: flex;
    justify-content: center;
    gap: 1rem;
    /* Reduced from 1.5rem */
    position: relative;
}

/* Client card */
.map-card-client {
    background: var(--surface);
    border-left: 4px solid var(--primary-dark, #1f2a3d);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    /* Compact padding */
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: box-shadow 0.2s;
    cursor: pointer;
}

.map-card-client:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.map-card-client .map-icon {
    width: 40px;
    /* Reduced from 48px */
    height: 40px;
    border-radius: 0.5rem;
    background: rgba(31, 42, 61, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark, #1f2a3d);
    font-size: 1.25rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.map-card-client:hover .map-icon {
    background: var(--primary-dark, #1f2a3d);
    color: #fff;
}

.map-card-client .map-type-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.map-card-client .map-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark, #1f2a3d);
}

.map-card-client .map-meta {
    font-size: 0.75rem;
    color: #9CA3AF;
}

/* Project card */
.map-card-project {
    background: var(--surface);
    border-left: 4px solid var(--primary);
    border-radius: 0.75rem;
    padding: 0.75rem;
    width: 220px;
    /* Reduced from 280px */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
    cursor: pointer;
}

.map-card-project:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.map-card-project.completed {
    opacity: 0.5;
    filter: grayscale(0.5);
    transition: all 0.3s;
}

.map-card-project.completed:hover {
    opacity: 1;
    filter: grayscale(0);
}

.map-project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.map-badge-status {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.map-badge-status.active {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.map-badge-status.dev {
    background: rgba(234, 179, 8, 0.1);
    color: #D97706;
}

.map-badge-status.completed {
    background: rgba(107, 114, 128, 0.1);
    color: #6B7280;
}

.map-project-cost {
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

.map-project-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark, #1f2a3d);
    margin-bottom: 0.15rem;
}

.map-project-desc {
    font-size: 0.7rem;
    color: #9CA3AF;
}

/* Folder / Version card */
.map-card-folder {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.4rem 0.6rem;
    /* Reduced padding */
    min-width: 140px;
    /* Reduced width */
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.map-card-folder:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.map-card-folder .folder-icon {
    color: var(--primary);
    font-size: 1.1rem;
}

.map-card-folder .folder-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-dark, #1f2a3d);
}

/* Component card */
.map-card-component {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.35rem 0.5rem;
    /* Reduced padding */
    width: 100%;
    /* Adapts to grid */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 70px;
}

.map-card-component:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(252, 203, 6, 0.1);
}

.map-comp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.15rem;
}

.map-comp-name {
    font-size: 0.7rem;
    /* Reduced */
    font-weight: 700;
    color: var(--primary-dark, #1f2a3d);
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.map-comp-qty {
    font-size: 0.55rem;
    background: rgba(0, 0, 0, 0.04);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: monospace;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.map-comp-ref {
    font-size: 0.55rem;
    /* Reduced */
    color: #9CA3AF;
    margin-bottom: 0.15rem;
}

.map-comp-price {
    font-size: 0.7rem;
    /* Reduced */
    font-weight: 700;
    color: var(--primary);
    margin-top: auto;
}

.map-comp-price .unit {
    font-size: 0.55rem;
    color: #9CA3AF;
    font-weight: 400;
}

/* Vertical flow column */
.map-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* GRID LAYOUT for Components (Optimized Space) */
.map-branch-children {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    /* Reduced from 220px */
    gap: 0.25rem;
    /* Reduced gap */
    width: 100%;
    min-width: 340px;
    /* Reduced min width */
    max-width: 900px;
    justify-items: center;
    background: transparent;
    /* Changed from rgba(31, 42, 61, 0.02) */
    padding: 0.5rem;
    /* Reduced padding */
    border-radius: 0.75rem;
    border: 1px dashed rgba(31, 42, 61, 0.1);
}

/* Unassigned section */
.map-card-unassigned {
    background: var(--surface);
    border-left: 4px solid var(--error);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    min-width: 240px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
}

.map-card-unassigned .map-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--error);
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Footer bar */
.map-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-top: 1rem;
}

.map-footer-stat .stat-label {
    font-size: 0.6rem;
    color: #9CA3AF;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.map-footer-stat .stat-value {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--primary-dark, #1f2a3d);
}

.map-footer-stat .stat-value.success {
    color: var(--success);
}

.map-empty {
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.map-empty i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* --- STAR RATING --- */
.star-rating {
    display: inline-flex;
    gap: 0.35rem;
    font-size: 1.2rem;
}

.star-rating .star.fa-regular {
    color: var(--border);
    opacity: 0.6;
}

.star-rating .star {
    position: relative;
    display: inline-block;
}

.star-rating .star.filled {
    color: var(--primary);
    /* Gold per le stelle accese */
}

/* Star Rating Input (Modale) */
.star-rating-input {
    display: inline-flex;
    gap: 0.4rem;
    font-size: 1.5rem;
    color: var(--border);
    cursor: pointer;
    margin-top: 0.2rem;
}

.star-rating-input i {
    transition: transform 0.1s, color 0.2s;
}

.star-rating-input i:hover {
    transform: scale(1.1);
}

.star-rating-input i.active {
    color: var(--primary);
}

/* --- ROADMAP STYLES --- */

.roadmap-timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.roadmap-phase {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.roadmap-phase-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.roadmap-phase-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.roadmap-phase-color {
    width: 4px;
    align-self: stretch;
    border-radius: 2px;
    flex-shrink: 0;
}

.roadmap-phase-body {
    padding: 1rem;
}

.roadmap-task-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.roadmap-task {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-main);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.roadmap-task:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.status-dot {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    border: 2px solid;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}

.status-dot:hover {
    transform: scale(1.2);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
}

.roadmap-task-info {
    flex: 1;
    min-width: 0;
}

.roadmap-task-info .task-name {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.15rem;
}

.roadmap-task-info .task-dates {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.task-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.task-actions .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
}

.roadmap-add-task-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem;
    margin-top: 0.75rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.roadmap-add-task-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-secondary);
}

.roadmap-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 1rem;
}