/* ============================================================
   USC-PLAN — Components
   ============================================================ */

/* === Conditions table detail cell === */
.cond-detail {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cond-header {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cond-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 1;
}
.cond-label-text {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1;
}
.cond-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-left: 22px;
}
.cond-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
}
/* Per tipo: exclude_station → blu, exclude_slot → rosso, exclude_day → verde, exclude_time_range → arancio */
.cond-tag--station {
    background: #dbeafe;
    color: #1e40af;
}
.cond-tag--slot {
    background: #fee2e2;
    color: #991b1b;
}
.cond-tag--day {
    background: #d1fae5;
    color: #065f46;
}
.cond-tag--time {
    background: #fef3c7;
    color: #92400e;
    border: 1.5px solid #fbbf24;
}
.cond-label-text--station { color: #1e40af; }
.cond-label-text--slot    { color: #991b1b; }
.cond-label-text--day     { color: #065f46; }
.cond-label-text--time    { color: #92400e; }
.cond-detail-cell {
    vertical-align: top;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-secondary {
    background: var(--color-white);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg);
}

.btn-danger {
    background: var(--color-danger);
    color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
    background: #DC2626;
    color: #ffffff;
}

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

.btn-outline-primary {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}
.btn-outline-primary:hover:not(:disabled) {
    background: var(--color-primary);
    color: #ffffff;
}

.btn-white {
    background: var(--color-white);
    color: var(--color-primary);
    border: 2px solid var(--color-white);
}
.btn-white:hover:not(:disabled) {
    background: transparent;
    color: #ffffff;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    padding: 6px 12px;
}
.btn-ghost:hover:not(:disabled) {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.0625rem;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

.btn svg {
    width: 18px;
    height: 18px;
}

/* === Form elements === */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--color-text);
}

.form-label .required {
    color: var(--color-danger);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-white);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}

.form-input::placeholder {
    color: var(--color-text-light);
}

.form-input.error {
    border-color: var(--color-danger);
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

textarea.form-input {
    min-height: 100px;
    resize: vertical;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

input[type="color"].form-input {
    padding: 4px;
    height: 44px;
    cursor: pointer;
}

.form-hint {
    margin-top: 4px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.form-error {
    margin-top: 4px;
    font-size: 0.8125rem;
    color: var(--color-danger);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.duration-toggle-group {
    display: flex;
    gap: 8px;
    background: var(--color-bg);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.duration-toggle-option {
    flex: 1;
    position: relative;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.duration-toggle-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.duration-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
}

.duration-toggle-option input[type="radio"]:checked + .duration-toggle-btn {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(var(--color-primary-rgb), 0.3);
}

[data-theme="dark"] .duration-toggle-group {
    background: #0D1117;
    border-color: #30363D;
}

/* === Summary Box (Riepilogo) === */
.summary-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--color-bg);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.summary-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    color: var(--color-primary);
    flex-shrink: 0;
}

.summary-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.summary-label {
    font-size: 0.78125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.summary-value {
    font-size: 0.95rem;
    color: var(--color-text);
    word-break: break-word;
}

.code-badge {
    display: inline-block;
    font-family: monospace;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    background: rgba(var(--color-primary-rgb), 0.1);
    color: var(--color-primary);
    border: 1px solid rgba(var(--color-primary-rgb), 0.2);
    width: fit-content;
}

[data-theme="dark"] .summary-box {
    background: #0D1117;
    border-color: #30363D;
}

[data-theme="dark"] .summary-item {
    background: #161B22;
    border-color: #30363D;
}

[data-theme="dark"] .summary-icon {
    background: rgba(59, 130, 246, 0.15);
    color: #60A5FA;
}

[data-theme="dark"] .code-badge {
    background: rgba(59, 130, 246, 0.15);
    color: #93C5FD;
    border-color: rgba(59, 130, 246, 0.3);
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group .form-input {
    flex: 1;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.checkbox-group label {
    font-size: 0.9375rem;
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9375rem;
}

.radio-group input[type="radio"] {
    accent-color: var(--color-primary);
    width: 18px;
    height: 18px;
}

.password-toggle {
    position: relative;
}

.password-toggle .form-input {
    padding-right: 44px;
}

.password-toggle-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px;
}

/* === Cards === */
.card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 1.0625rem;
}

.card-body {
    color: var(--color-text);
}

.card-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* Stat cards */
.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.stat-card .progress-bar {
    width: 100%;
    max-width: 150px;
    margin-top: 8px;
    margin-bottom: 4px;
}


/* Highlight card */
.card-highlight {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.card-warning {
    background: var(--color-warning-light);
    border-color: var(--color-warning);
}

.card-success {
    background: var(--color-success-light);
    border-color: var(--color-success);
}

/* Event card */
.event-card {
    cursor: pointer;
    position: relative;
}

.event-card .event-dates {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 12px;
}

.event-card .event-stats {
    display: flex;
    gap: 16px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.6;
}

.badge-primary {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-success {
    background: var(--color-success-light);
    color: #166534;
}

.badge-warning {
    background: var(--color-warning-light);
    color: #92400E;
}

.badge-danger {
    background: var(--color-danger-light);
    color: #991B1B;
}

.badge-info {
    background: var(--color-manual-light);
    color: #1D4ED8;
}

.badge-gray {
    background: #F1F5F9;
    color: var(--color-text-muted);
}

/* Color swatch badge */
.color-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid var(--color-border);
    vertical-align: middle;
}

/* === Modal === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn var(--transition-fast);
}

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

.modal {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp var(--transition-base);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.modal-header h3 {
    font-size: 1.125rem;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* === Toast notifications === */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 420px;
    font-size: 0.9375rem;
    font-weight: 500;
    animation: toastIn 250ms ease forwards;
    cursor: pointer;
}

.toast.dismissing {
    animation: toastOut 150ms ease forwards;
}

.toast-success {
    background: #166534;
    color: #ffffff;
}

.toast-error {
    background: #991B1B;
    color: #ffffff;
}

.toast-info {
    background: #1D4ED8;
    color: #ffffff;
}

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* === Tables === */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-white);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--color-bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9375rem;
    white-space: nowrap;
}

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

tbody tr:hover {
    background: var(--color-primary-light);
}

.table-actions {
    display: flex;
    gap: 4px;
}

/* === Tabs === */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 24px;
    gap: 0;
}

.tab {
    padding: 12px 20px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab:hover {
    color: var(--color-primary);
    background-color: var(--color-bg-hover, rgba(0, 0, 0, 0.04));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* === Progress bar === */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
    transition: width var(--transition-slow);
}

.progress-bar-fill.success { background: var(--color-success); }
.progress-bar-fill.warning { background: var(--color-warning); }

/* === Alerts === */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-info {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border: 1px solid rgba(var(--color-primary-rgb), 0.2);
}

.alert-warning {
    background: var(--color-warning-light);
    color: #92400E;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.alert-danger {
    background: var(--color-danger-light);
    color: #991B1B;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: var(--color-success-light);
    color: #166534;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* === Search === */
.search-box {
    position: relative;
}

.search-box .form-input {
    padding-left: 40px;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-light);
}

/* === Tooltip === */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: var(--color-text);
    color: var(--color-white);
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 50;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* === Drag handle === */
.drag-handle {
    cursor: grab;
    color: var(--color-text-light);
    padding: 4px;
}

.drag-handle:active {
    cursor: grabbing;
}

.sortable-ghost {
    opacity: 0.4;
    background: var(--color-primary-light);
}

/* === Schedule grid cells === */
.schedule-grid {
    width: 100%;
}

.schedule-cell {
    padding: 8px 12px;
    cursor: pointer;
    min-width: 140px;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
}

.schedule-cell:hover {
    filter: brightness(0.95);
}

.schedule-cell .vol-name {
    font-weight: 500;
}

.schedule-cell .shift-type {
    font-size: 0.6875rem;
    opacity: 0.7;
}

/* Availability indicators */
.indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
}

.indicator-available { color: var(--color-success); }
.indicator-conflict { color: var(--color-danger); }
.indicator-gap { color: var(--color-warning); }
.indicator-excluded { color: var(--color-text-light); }

/* === Legend === */
.legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

/* === Empty state === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--color-text-light);
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9375rem;
    margin-bottom: 24px;
}

/* === Dropdown === */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 50;
    padding: 4px;
}

.dropdown-menu label {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    white-space: nowrap;
    color: var(--color-text);
}

.dropdown-menu label:hover {
    background: var(--color-bg);
}

[data-theme="dark"] .dropdown-menu label:hover {
    background: rgba(255, 255, 255, 0.08);
}

.dropdown-menu.active {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    text-align: left;
    font-size: 0.875rem;
    color: var(--color-text);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    font-family: inherit;
}

.dropdown-item:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: 4px 0;
}

/* === Toolbar === */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* === Map === */
.map-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.map-container img {
    display: block;
    max-width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.map-pin {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 10;
    transition: transform var(--transition-fast);
}

.map-pin:hover {
    transform: translate(-50%, -50%) scale(1.15);
}

.map-pin-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid var(--color-white);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-white);
}

.map-pin-title {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: var(--color-white);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.map-pin:hover .map-pin-title,
.map-pin:active .map-pin-title {
    opacity: 1;
}

.map-placing {
    cursor: crosshair;
}

/* === Two column layout === */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.timeline-wrapper {
    overflow-x: auto;
    max-width: 100%;
    margin-bottom: 24px;
}

.timeline-container {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-white);
    width: max-content;
    min-width: 100%;
}

.timeline-header-row {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--color-bg);
}

.timeline-hours-header {
    width: 60px;
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
}

.timeline-col-header {
    flex: 1;
    min-width: 160px;
    padding: 12px;
    text-align: center;
    font-weight: bold;
    font-size: 0.8125rem;
    color: #fff;
    border-right: 1px solid var(--color-border);
}

.timeline-col-header:last-child {
    border-right: none;
}

.timeline-body-row {
    display: flex;
    position: relative;
}

.timeline-hours {
    width: 60px;
    flex-shrink: 0;
    position: relative;
    border-right: 1px solid var(--color-border);
    background: var(--color-bg);
}

.timeline-hour-label {
    position: absolute;
    width: 100%;
    text-align: right;
    padding-right: 8px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    transform: translateY(-50%);
    font-weight: 500;
}

.timeline-hour-label:first-child {
    transform: none;
    padding-top: 4px;
}

/* Linee guida orizzontali in background */
.timeline-grid-lines {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

.timeline-grid-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--color-border);
    opacity: 0.5;
}

.timeline-columns {
    display: flex;
    flex: 1;
    min-width: min-content;
    position: relative;
    z-index: 1;
}

.timeline-col {
    flex: 1;
    min-width: 160px;
    border-right: 1px solid var(--color-border);
    position: relative;
    cursor: pointer;
}

.timeline-empty-gap {
    position: absolute;
    left: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease, border 0.2s ease;
    z-index: 1;
}

.timeline-empty-gap .add-slot-btn {
    display: none;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-white);
    border: 1px solid var(--color-primary);
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    pointer-events: none;
}

.timeline-empty-gap:hover {
    background-color: rgba(59, 130, 246, 0.08);
    border: 1px dashed var(--color-primary);
}

.timeline-empty-gap:hover .add-slot-btn {
    display: inline-flex;
    align-items: center;
}

[data-theme="dark"] .timeline-empty-gap:hover {
    background-color: rgba(59, 130, 246, 0.12);
    border-color: #3b82f6;
}

[data-theme="dark"] .timeline-empty-gap .add-slot-btn {
    background: #1c2128;
    color: #3b82f6;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.timeline-col:last-child {
    border-right: none;
}

.timeline-shift {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    font-size: 0.8125rem;
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    border: 1px solid transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.timeline-shift:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10 !important;
}

.timeline-shift .shift-time {
    font-size: 0.6875rem;
    font-weight: 600;
    opacity: 0.8;
    margin-top: 2px;
}

.timeline-shift .vol-name {
    font-weight: 600;
    white-space: normal;
    word-wrap: break-word;
    overflow: hidden;
    margin-bottom: 4px;
}

.timeline-shift .shift-type {
    font-size: 0.6875rem;
    opacity: 0.7;
    margin-top: auto;
}

.timeline-shift.shift-empty {
    background: var(--color-empty-bg);
    border-color: var(--color-empty);
    color: var(--color-text-muted);
    border-style: dashed;
}

.timeline-shift.shift-auto {
    background: var(--color-success-light);
    border-color: var(--color-success);
    color: #166534;
}

.timeline-shift.shift-manual {
    background: var(--color-manual-light);
    border-color: var(--color-manual);
    color: #1D4ED8;
}

/* === Dark Mode — Component Overrides === */

/* --- Cards --- */
[data-theme="dark"] .card {
    background: #161B22;
    border-color: #30363D;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

[data-theme="dark"] .card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    border-color: #3B82F6;
}

[data-theme="dark"] .card-header {
    border-bottom-color: #30363D;
}

[data-theme="dark"] .card-footer {
    border-top-color: #30363D;
}

[data-theme="dark"] .card-highlight {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.35);
}

[data-theme="dark"] .card-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .card-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

/* Stat cards */
[data-theme="dark"] .stat-card {
    background: #161B22;
    border-color: #30363D;
}

[data-theme="dark"] .stat-card .stat-value {
    color: #3B82F6;
}

[data-theme="dark"] .stat-card .stat-label {
    color: #8B949E;
}

/* --- Form inputs --- */
[data-theme="dark"] .form-input {
    background: #0D1117;
    border-color: #30363D;
    color: #E6EDF3;
    color-scheme: dark;
}

[data-theme="dark"] .form-input::placeholder {
    color: #4D5566;
}

[data-theme="dark"] .form-input:focus {
    border-color: #3B82F6;
    background: #161B22;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B949E' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* Native select options */
[data-theme="dark"] select.form-input option {
    background: #161B22;
    color: #E6EDF3;
}

[data-theme="dark"] select.form-input optgroup {
    background: #161B22;
    color: #58A6FF;
    font-weight: 600;
}


/* Form label */
[data-theme="dark"] .form-label {
    color: #E6EDF3;
}

/* Form hint */
[data-theme="dark"] .form-hint {
    color: #8B949E;
}

/* --- Buttons --- */
[data-theme="dark"] .btn-primary {
    color: #ffffff;
}
[data-theme="dark"] .btn-primary:hover:not(:disabled) {
    color: #ffffff;
}

[data-theme="dark"] .btn-danger {
    color: #ffffff;
}
[data-theme="dark"] .btn-danger:hover:not(:disabled) {
    color: #ffffff;
}

[data-theme="dark"] .btn-success {
    color: #ffffff;
}

[data-theme="dark"] .btn-secondary {
    background: #21262D;
    color: #E6EDF3;
    border-color: #30363D;
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
    background: #2D333B;
    border-color: #8B949E;
}

[data-theme="dark"] .btn-ghost {
    color: #8B949E;
}

[data-theme="dark"] .btn-ghost:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.1);
    color: #E6EDF3;
}

[data-theme="dark"] .btn-outline-primary {
    border-color: #3B82F6;
    color: #3B82F6;
}

[data-theme="dark"] .btn-outline-primary:hover:not(:disabled) {
    background: #3B82F6;
    color: #fff;
}

/* --- Modal --- */
[data-theme="dark"] .modal {
    background: #161B22;
    border: 1px solid #30363D;
    box-shadow: 0 16px 48px rgba(0,0,0,0.7);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #30363D;
    background: #0D1117;
}

[data-theme="dark"] .modal-footer {
    border-top-color: #30363D;
    background: #0D1117;
}

[data-theme="dark"] .modal-close {
    color: #8B949E;
}

[data-theme="dark"] .modal-close:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #E6EDF3;
}

/* --- Tables --- */
[data-theme="dark"] .table-wrapper {
    background: #161B22;
    border-color: #30363D;
}

[data-theme="dark"] thead th {
    background: #0D1117;
    color: #8B949E;
    border-bottom-color: #30363D;
}

[data-theme="dark"] tbody td {
    border-bottom-color: #21262D;
    color: #E6EDF3;
}

[data-theme="dark"] tbody tr:last-child td {
    border-bottom: none;
}

[data-theme="dark"] tbody tr:hover {
    background: rgba(59, 130, 246, 0.07);
}

/* --- Tabs --- */
[data-theme="dark"] .tabs {
    border-bottom-color: #30363D;
}

[data-theme="dark"] .tab {
    color: #8B949E;
}

[data-theme="dark"] .tab:hover {
    color: #E6EDF3;
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .tab.active {
    color: #3B82F6;
    border-bottom-color: #3B82F6;
}

/* --- Custom Dropdown --- */
[data-theme="dark"] .dropdown-menu {
    background: #1C2333;
    border-color: #30363D;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

[data-theme="dark"] .dropdown-item {
    color: #E6EDF3;
    background: transparent;
}

[data-theme="dark"] .dropdown-item:hover {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #3B82F6;
}

[data-theme="dark"] .dropdown-divider {
    background: #30363D;
}

/* --- Badges --- */
[data-theme="dark"] .badge-gray {
    background: #21262D;
    color: #8B949E;
}

[data-theme="dark"] .badge-primary {
    background: rgba(59, 130, 246, 0.2);
    color: #60A5FA;
}

[data-theme="dark"] .badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ADE80;
}

[data-theme="dark"] .badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #FBBF24;
}

[data-theme="dark"] .badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #F87171;
}

[data-theme="dark"] .badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60A5FA;
}

/* --- Progress --- */
[data-theme="dark"] .progress-bar {
    background: #21262D;
}

/* --- Legend --- */
[data-theme="dark"] .legend {
    background: #161B22;
    border: 1px solid #30363D;
}

/* --- Empty state --- */
[data-theme="dark"] .empty-state {
    color: #8B949E;
}

[data-theme="dark"] .empty-state h3 {
    color: #8B949E;
}

/* --- Alerts --- */
[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.25);
    color: #93C5FD;
}

[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.25);
    color: #FCD34D;
}

[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: #FCA5A5;
}

[data-theme="dark"] .alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.25);
    color: #6EE7B7;
}

/* --- Toast --- */
[data-theme="dark"] .toast-success {
    background: #166534;
}

[data-theme="dark"] .toast-error {
    background: #7F1D1D;
}

[data-theme="dark"] .toast-info {
    background: #1E3A5F;
}

/* --- Color swatch / Map --- */
[data-theme="dark"] .color-swatch {
    border-color: #30363D;
}

[data-theme="dark"] .map-container img {
    border-color: #30363D;
    opacity: 0.92;
}

/* --- Step indicator --- */
[data-theme="dark"] .step-indicator-dot {
    background: #21262D;
    color: #8B949E;
}

[data-theme="dark"] .step-indicator-line {
    background: #30363D;
}

[data-theme="dark"] .step-indicator-label {
    color: #8B949E;
}

/* --- Condition tags (dark) --- */
[data-theme="dark"] .cond-tag--station {
    background: rgba(59, 130, 246, 0.18);
    color: #93C5FD;
}

[data-theme="dark"] .cond-tag--slot {
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
}

[data-theme="dark"] .cond-tag--day {
    background: rgba(34, 197, 94, 0.15);
    color: #6EE7B7;
}

[data-theme="dark"] .cond-tag--time {
    background: rgba(245, 158, 11, 0.15);
    color: #FCD34D;
    border-color: rgba(251, 191, 36, 0.3);
}

[data-theme="dark"] .cond-label-text--station { color: #93C5FD; }
[data-theme="dark"] .cond-label-text--slot    { color: #FCA5A5; }
[data-theme="dark"] .cond-label-text--day     { color: #6EE7B7; }
[data-theme="dark"] .cond-label-text--time    { color: #FCD34D; }

/* --- Timeline --- */
[data-theme="dark"] .timeline-container {
    background: #161B22;
    border-color: #30363D;
}

[data-theme="dark"] .timeline-header-row {
    background: #0D1117;
    border-bottom-color: #30363D;
}

[data-theme="dark"] .timeline-hours {
    background: #0D1117;
    border-right-color: #30363D;
}

[data-theme="dark"] .timeline-hour-label {
    color: #8B949E;
}

[data-theme="dark"] .timeline-body-row {
    border-color: #30363D;
}

[data-theme="dark"] .timeline-col {
    border-right-color: #21262D;
}

[data-theme="dark"] .timeline-grid-line {
    border-top-color: #21262D;
}

[data-theme="dark"] .timeline-shift {
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

[data-theme="dark"] .timeline-shift.shift-auto {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.4);
    color: #6EE7B7;
}

[data-theme="dark"] .timeline-shift.shift-manual {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93C5FD;
}

[data-theme="dark"] .timeline-shift.shift-empty {
    background: #1c2128;
    border-color: #444c56;
    color: #adbac7;
}

[data-theme="dark"] .timeline-shift.shift-empty:hover {
    background: #22272e;
    border-color: #539bf5;
    color: #539bf5;
}

/* --- Toolbar --- */
[data-theme="dark"] .toolbar {
    color: #E6EDF3;
}

/* --- Search box --- */
[data-theme="dark"] .search-box svg {
    color: #4D5566;
}

/* --- Sortable ghost --- */
[data-theme="dark"] .sortable-ghost {
    background: rgba(59, 130, 246, 0.12);
    opacity: 0.5;
}

/* --- Password toggle btn --- */
[data-theme="dark"] .password-toggle-btn {
    color: #8B949E;
}

/* Fullscreen Map Styles */
.map-wrapper-container {
    position: relative;
    width: 100%;
}

.map-wrapper-container:fullscreen {
    background: #0d1117;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    padding: 20px;
    box-sizing: border-box;
}

.map-wrapper-container:fullscreen .map-container {
    position: relative;
    display: inline-block;
    width: auto !important;
    max-width: 100%;
    max-height: 100%;
}

.map-wrapper-container:fullscreen .map-container img {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    width: auto;
    height: auto;
    display: block;
    border: none;
}

/* Custom Select Component */
.custom-select-container {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.custom-select-trigger:hover {
    border-color: var(--color-text-muted);
}

.custom-select-container.active .custom-select-trigger {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 350px;
    overflow-y: auto;
    display: none;
}

.custom-select-container.active .custom-select-dropdown {
    display: block;
}

.custom-select-group-title {
    padding: 10px 16px 8px 16px;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    margin-top: 6px;
}

.custom-select-group-title:first-child {
    margin-top: 0;
}

.custom-select-option {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.custom-select-option:has(.option-meta) {
    display: grid;
    grid-template-columns: 165px 1fr;
    gap: 12px;
    align-items: center;
}

.custom-select-option > span:first-child {
    white-space: nowrap;
}

.custom-select-option:has(.option-meta) > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select-option:hover {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.custom-select-option.selected {
    background: var(--color-primary);
    color: var(--color-white);
    font-weight: 600;
}

.custom-select-option .option-meta {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.custom-select-option.selected .option-meta {
    color: rgba(255, 255, 255, 0.8);
}

/* Dark theme overrides */
[data-theme="dark"] .custom-select-trigger {
    background: #0D1117;
    border-color: #30363D;
    color: #E6EDF3;
}

[data-theme="dark"] .custom-select-trigger:hover {
    border-color: #8B949E;
}

[data-theme="dark"] .custom-select-dropdown {
    background: #161B22;
    border-color: #30363D;
}

[data-theme="dark"] .custom-select-group-title {
    background: #0D1117;
    color: #58A6FF;
    border-bottom: 1px solid #30363D;
}

[data-theme="dark"] .custom-select-option {
    color: #E6EDF3;
}

[data-theme="dark"] .custom-select-option:hover {
    background: rgba(56, 139, 253, 0.15);
    color: #58A6FF;
}

[data-theme="dark"] .custom-select-option.selected {
    background: #1F6FEB;
    color: #FFFFFF;
}

[data-theme="dark"] .custom-select-option .option-meta {
    color: #8B949E;
}

[data-theme="dark"] .custom-select-option.selected .option-meta {
    color: rgba(255, 255, 255, 0.8);
}

/* Layout overrides for critical assignment modal */
#modal-assign-critical {
    align-items: flex-start !important;
    padding-top: 5vh;
}

#modal-assign-critical .modal {
    overflow: visible !important;
}

/* === Schedule list view grid === */
.schedule-days-container {
    display: flex;
    gap: 40px;
    align-items: start;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 24px;
}
.schedule-day-column {
    flex: 1;
    min-width: 280px;
}
.schedule-day-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-border);
    color: var(--color-primary);
}
.schedule-grid-mobile {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.schedule-grid-mobile .schedule-row {
    display: block;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px;
}
.schedule-grid-mobile .schedule-row .time-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-primary);
    margin-bottom: 8px;
}
.schedule-grid-mobile .schedule-row .station-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@media (min-width: 768px) {
    .schedule-days-container:has(> .schedule-day-column:only-child) .schedule-day-column {
        max-width: 500px;
    }
}

.legend-text-container {
    display: inline;
}
.modal-title-time {
    display: inline;
    margin-left: 6px;
    font-size: 0.9em;
    font-weight: normal;
}




