@import 'Variables.css';

* {
    box-sizing: border-box;
}

:root {
    --color-background: #0f172a;
    --color-surface: rgba(15, 23, 42, 0.88);
    --color-surface-soft: rgba(30, 41, 59, 0.92);
    --color-primary: #14b8a6;
    --color-primary-dark: #0f766e;
    --color-accent: #22c55e;
    --color-success: #16a34a;
    --color-error: #ef4444;
    --color-white: #ffffff;
    --color-text: #cbd5e1;
    --color-text-light: #e2e8f0;
    --color-muted: #94a3b8;
    --color-gray-100: #1e293b;
    --color-gray-200: #334155;
    --color-gray-300: #475569;
    --panel-2: rgba(15, 23, 42, 0.72);
    --card-border: rgba(148, 163, 184, 0.14);
    --shadow-md: 0 18px 50px rgba(2, 6, 23, 0.35);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 28px;
    --spacing-1: 0.5rem;
    --spacing-2: 1rem;
    --spacing-3: 1.5rem;
    --accent: var(--color-primary);
}

html, body {
    min-height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background:
        radial-gradient(circle at top, rgba(20, 184, 166, 0.10), transparent 36%),
        linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: var(--color-text-light);
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    overscroll-behavior-y: none;
}

#app {
    min-height: 100dvh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--color-white);
    margin-top: 0;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-primary-dark);
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--color-background);
    color: var(--color-text-light);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #1e293b;
    border-bottom-color: var(--color-primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.login-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    z-index: 100;
}

.login-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #020617 100%);
}

.gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(20, 184, 166, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
}

.login-container {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    min-height: 100vh;
    padding: 2rem;
    z-index: 1;
}

.login-hero-logo {
    width: min(92vw, 820px);
    display: flex;
    justify-content: center;
}

.login-hero-image {
    width: 100%;
    max-width: 360px;
    height: auto;
    display: block;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
}

.login-card {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title {
    color: #ffffff;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.4rem 0;
    background: linear-gradient(135deg, #14b8a6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #94a3b8;
    font-size: 0.95rem;
    margin: 0;
}

.login-form {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    color: #ffffff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

.form-input::placeholder {
    color: #64748b;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    color: #fca5a5;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.error-icon {
    font-size: 1.2rem;
}

.btn-login {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    border: none;
    border-radius: 12px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-login:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(20, 184, 166, 0.3);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.login-footer {
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    padding-top: 1.5rem;
}

.hint {
    color: #94a3b8;
    font-size: 0.75rem;
    text-align: center;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.test-users {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.test-user-btn {
    flex: 1;
    min-width: 120px;
    padding: 0.625rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.test-user-btn:hover {
    background: rgba(20, 184, 166, 0.1);
    border-color: rgba(20, 184, 166, 0.3);
    color: #14b8a6;
}

.test-user-icon {
    width: 16px;
    height: 16px;
    fill: #cbd5e1;
    margin-right: 0.5rem;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(18px);
    background: rgba(15, 23, 42, 0.76);
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.app-main {
    flex: 1;
    padding: 1rem 1rem 6.6rem;
}

.content-panel {
    max-width: 720px;
    margin: 0 auto;
}

.nav-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-white);
}

.nav-links {
    display: flex;
    gap: 0.75rem;
    font-weight: 600;
}

.nav-links a.active {
    color: var(--color-primary);
}

.auth-screen {
    min-height: calc(100vh - 80px);
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-card,
.hero-panel,
.action-panel {
    width: 100%;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.92) 0%, rgba(15, 23, 42, 0.80) 100%);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    padding: 1.25rem;
}

.auth-card {
    max-width: 420px;
}

.brand-mark {
    width: 3.5rem;
    height: 3.5rem;
    display: grid;
    place-items: center;
    border-radius: 1.2rem;
    background: linear-gradient(135deg, var(--color-primary), #0ea5a1);
    color: #062c2a;
    font-weight: 900;
    font-size: 1.7rem;
    margin-bottom: 1rem;
}

.auth-card h1 {
    margin-bottom: 0.4rem;
}

.auth-card p,
.hero-copy p,
.eyebrow,
.action-panel h2,
.field-group label,
.session-box span {
    color: var(--color-muted);
}

.field-group {
    margin-top: 1rem;
}

.btn,
.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-primary,
.btn-hero {
    color: var(--color-white);
    background: linear-gradient(135deg, var(--color-primary) 0%, #0ea5a1 100%);
    border: none;
}

.btn-primary:hover,
.btn-hero:hover {
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, #0d9488 100%);
}

.btn-hero {
    padding: 0.95rem 1rem;
    border-radius: 18px;
    font-weight: 700;
    color: #ffffff;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(20, 184, 166, 0.22);
}

.form-control {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius-sm);
    background-color: rgba(15, 23, 42, 0.92);
    color: var(--color-text-light);
}

.form-control::placeholder {
    color: var(--color-muted);
}

.home-shell {
    display: grid;
    gap: 1rem;
}

.empty-page-shell {
    min-height: calc(100vh - 170px);
    display: grid;
    place-items: center;
}

.empty-page-card {
    width: 100%;
    max-width: 620px;
    border: 1px dashed rgba(148, 163, 184, 0.35);
    border-radius: 22px;
    background: rgba(15, 23, 42, 0.5);
    padding: 2rem;
    text-align: center;
}

.empty-page-card h1 {
    margin-bottom: 0.6rem;
}

.empty-page-card p {
    color: var(--color-muted);
    margin-bottom: 1.4rem;
}

.detail-page-shell {
    min-height: calc(100vh - 130px);
    width: 100%;
    display: block;
    padding: 0.25rem 0 0;
}

.detail-card {
    position: relative;
    width: 100%;
    max-width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    padding: 0;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.detail-kicker {
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.detail-header p {
    color: var(--color-muted);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1.5px solid rgba(239, 68, 68, 0.4);
    color: var(--color-error);
    font-size: 0.95rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.12s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: var(--color-error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.logout-btn:active {
    transform: scale(0.88);
    box-shadow: none;
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 8px;
    background: transparent;
    border: 1.5px solid rgba(148, 163, 184, 0.28);
    color: var(--color-muted);
    font-size: 0.95rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s, transform 0.12s;
}

.refresh-btn:hover:not(:disabled) {
    background: rgba(20, 184, 166, 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.refresh-btn:active:not(:disabled) {
    transform: scale(0.88);
    box-shadow: none;
}

.refresh-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.refresh-btn.spinning {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.refresh-btn.spinning i {
    display: inline-block;
    animation: spin-cw 0.75s linear infinite;
}

@keyframes spin-cw {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.detail-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--color-primary) 40%,
        var(--color-primary-dark) 60%,
        transparent 100%);
    background-size: 200% 100%;
    background-position: 200% 0;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.detail-card.refreshing::after {
    opacity: 1;
    animation: progress-shimmer 1.2s linear infinite;
}

@keyframes progress-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.status-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.info-tile {
    border-radius: 18px;
    background: rgba(30, 41, 59, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.10);
    padding: 0.95rem;
    display: grid;
    gap: 0.25rem;
}

.info-tile span,
.detail-meta-line span,
.commessa-row-subtitle {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.tile-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.tile-icon {
    font-size: 0.95rem;
}

.shipped-icon {
    color: #22c55e;
}

.pending-icon {
    color: #facc15;
}

.info-tile strong,
.detail-meta-line strong,
.commessa-row-title {
    color: var(--color-white);
}

.detail-meta-panel {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.48);
    border: 1px solid rgba(148, 163, 184, 0.10);
    margin-bottom: 1rem;
}

.detail-meta-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.detail-field-group {
    margin-top: 0;
}

.detail-input {
    width: 100%;
    padding: 0.95rem 1rem;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    color: var(--color-white);
}

.detail-input:focus {
    outline: none;
    border-color: rgba(20, 184, 166, 0.8);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

select.detail-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-color: rgba(15, 23, 42, 0.72);
    padding-right: 2.75rem;
    cursor: pointer;
}

select.detail-input:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%2314b8a6' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}

select.detail-input option {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 0.5rem 1rem;
}

select.detail-input option:checked,
select.detail-input option:focus {
    background-color: #0f766e;
    color: #ffffff;
}

/* ── CustomSelect ─────────────────────────────────────────────────────── */

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.95rem 1rem;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    color: var(--color-white);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.custom-select-trigger:focus {
    outline: none;
    border-color: rgba(20, 184, 166, 0.8);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.cs-open .custom-select-trigger {
    border-color: rgba(20, 184, 166, 0.8);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.cs-disabled .custom-select-trigger {
    opacity: 0.5;
    cursor: not-allowed;
}

.custom-select-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-placeholder {
    color: var(--color-muted);
}

.custom-select-arrow {
    flex-shrink: 0;
    color: var(--color-muted);
    font-size: 0.85rem;
    transition: transform 0.2s ease;
}

.cs-open .custom-select-arrow {
    transform: rotate(180deg);
    color: var(--color-primary);
}

.custom-select-backdrop {
    position: fixed;
    inset: 0;
    z-index: 198;
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 199;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    overflow: hidden;
    overflow-y: auto;
    max-height: 260px;
    box-shadow: 0 16px 40px rgba(2, 6, 23, 0.55);
}

.custom-select-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
    color: var(--color-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    border-bottom: 1px solid rgba(148, 163, 184, 0.07);
}

.custom-select-option:last-child {
    border-bottom: none;
}

.custom-select-option:hover {
    background: rgba(20, 184, 166, 0.1);
    color: var(--color-white);
}

.custom-select-option.cs-selected {
    background: rgba(20, 184, 166, 0.15);
    color: var(--color-primary);
    font-weight: 600;
}

.custom-select-option.cs-option-placeholder {
    color: var(--color-muted);
    font-style: italic;
}

.cs-check {
    color: var(--color-primary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* ── UbicazionePicker ─────────────────────────────────────────────────── */

.ub-picker {
    display: grid;
    gap: 0.55rem;
}

.ub-picker-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.12);
    min-height: 2.4rem;
}

.ub-bc-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.55rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--color-muted);
    font-size: 0.83rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.14s, color 0.14s;
    line-height: 1.3;
}

.ub-bc-item:hover {
    background: rgba(20, 184, 166, 0.1);
    color: var(--color-primary);
}

.ub-bc-item.ub-bc-current {
    color: var(--color-white);
    font-weight: 600;
    pointer-events: none;
}

.ub-bc-sep {
    color: rgba(148, 163, 184, 0.35);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.ub-picker-list {
    display: grid;
    gap: 0.35rem;
    max-height: var(--ub-list-max-height, 340px);
    overflow-y: auto;
    padding-right: 2px;
}

.ub-picker-empty {
    padding: 0.8rem 1rem;
    color: var(--color-muted);
    font-size: 0.9rem;
    text-align: center;
}

.ub-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.10);
    background: rgba(30, 41, 59, 0.65);
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s;
    user-select: none;
}

.ub-picker-item:hover {
    background: rgba(30, 41, 59, 0.92);
    border-color: rgba(148, 163, 184, 0.22);
}

.ub-picker-item.ub-branch {
    border-left: 2px solid rgba(20, 184, 166, 0.25);
}

.ub-picker-item.ub-branch:hover {
    border-left-color: var(--color-primary);
}

.ub-picker-item.ub-selected {
    background: rgba(20, 184, 166, 0.12);
    border-color: rgba(20, 184, 166, 0.35);
}

.ub-item-label {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    color: var(--color-text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ub-picker-item.ub-selected .ub-item-label {
    color: var(--color-primary);
    font-weight: 600;
}

.ub-item-right {
    flex-shrink: 0;
    color: var(--color-muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
}

.ub-item-check {
    color: var(--color-primary);
    font-size: 1rem;
}

.ub-item-arrow {
    color: rgba(148, 163, 184, 0.45);
    font-size: 0.75rem;
}

.ub-picker-selection {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    background: rgba(20, 184, 166, 0.08);
    border: 1px solid rgba(20, 184, 166, 0.2);
    color: var(--color-primary);
    font-size: 0.82rem;
    font-weight: 500;
    word-break: break-word;
}

/* ── End UbicazionePicker ─────────────────────────────────────────────── */

.detail-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    position: relative;
    z-index: 90;
}

.scan-helper {
    color: var(--color-muted);
    margin: 0 0 0.9rem;
}

.qr-reader {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.72);
}

.qr-reader video {
    border-radius: 12px;
}

.scan-manual-panel {
    margin-top: 1rem;
    padding: 0.95rem;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.45);
}

.scan-manual-title {
    color: var(--color-muted);
    margin-bottom: 0.65rem;
    font-size: 0.9rem;
}

.scan-manual-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem;
    align-items: center;
}


.detail-state {
    padding: 0.95rem 1rem;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.12);
    color: var(--color-text-light);
}

.detail-state-error {
    border-color: rgba(239, 68, 68, 0.28);
    background: rgba(127, 29, 29, 0.28);
    color: #fecaca;
    margin-top: 0.75rem;
}

.detail-state-ok {
    border-color: rgba(34, 197, 94, 0.28);
    background: rgba(20, 83, 45, 0.24);
    color: #bbf7d0;
    margin-top: 0.75rem;
}

.flash-message {
    position: fixed;
    top: 0.9rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 140;
    width: min(92vw, 560px);
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(20, 184, 166, 0.35);
    background: rgba(20, 83, 45, 0.22);
    color: #ccfbf1;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.45);
    backdrop-filter: blur(8px);
    pointer-events: none;
}

.commessa-list {
    display: grid;
    gap: 0.75rem;
}

.ubicazioni-count-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
}

.ubicazioni-count-row strong {
    color: var(--color-text-light);
    font-size: 0.88rem;
}

.commessa-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-radius: 18px;
    background: rgba(30, 41, 59, 0.76);
    border: 1px solid rgba(148, 163, 184, 0.10);
}

.commessa-row-main {
    display: grid;
    gap: 0.15rem;
    width: 100%;
    min-width: 0;
}

.commessa-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.commessa-ubicazione-row {
    margin-top: 0.4rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.55rem;
    align-items: stretch;
}

.commessa-ubicazione-label {
    align-self: center;
    color: var(--color-muted);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.ubicazione-readonly-input {
    height: 42px;
    padding: 0.65rem 0.85rem;
    color: var(--color-text-light);
    border-color: rgba(148, 163, 184, 0.24);
}

.ubicazione-readonly-input[readonly] {
    opacity: 0.95;
}

.row-edit-btn {
    height: 42px;
    width: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border-radius: 12px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(3px);
    display: grid;
    place-items: center;
    padding: 1rem;
}

.modal-card {
    width: min(560px, 100%);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.55);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.modal-card:has(.ub-dialog-body) {
    height: min(560px, 88dvh);
}

/* Dialog body: picker fills available space, list scrolls, breadcrumb stays fixed */
.ub-dialog-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ub-dialog-body .ub-picker {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ub-dialog-body .ub-picker-breadcrumb {
    flex-shrink: 0;
}

.ub-dialog-body .ub-picker-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    align-content: start;
}

/* Ubicazioni page: extra bottom padding so last item clears the nav bar */
.ub-picker-page-wrap .ub-picker-list {
    padding-bottom: 4rem;
}

.modal-card h2 {
    margin: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.status-badge {
    flex-shrink: 0;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.status-shipped {
    background: rgba(20, 184, 166, 0.14);
    color: #6ee7d8;
    border: 1px solid rgba(20, 184, 166, 0.24);
}

.status-pending {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.22);
}

/* Collo stati */
.status-pronto {
    background: rgba(100, 116, 139, 0.18);
    color: #cbd5e1;
    border: 1px solid rgba(100, 116, 139, 0.28);
}

.status-etichettato {
    background: rgba(234, 179, 8, 0.14);
    color: #fde047;
    border: 1px solid rgba(234, 179, 8, 0.26);
}

.status-picking {
    background: rgba(249, 115, 22, 0.14);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.26);
}

.status-caricato {
    background: rgba(6, 182, 212, 0.14);
    color: #67e8f9;
    border: 1px solid rgba(6, 182, 212, 0.26);
}

.status-carico-finito {
    background: rgba(34, 197, 94, 0.14);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.24);
}

.status-cantiere {
    background: rgba(139, 92, 246, 0.14);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.26);
}

/* Picking stati */
.status-returned {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.26);
}

.picking-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.picking-actions .btn-hero,
.picking-actions .ghost-btn {
    flex: 1;
}

.scanner-dialog-card {
    max-width: min(480px, 96vw);
}

.commessa-row-clickable {
    cursor: pointer;
}

.commessa-row-clickable:hover {
    color: var(--color-primary);
}

.ghost-btn {
    border: 1px solid rgba(20, 184, 166, 0.45);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    background: rgba(20, 184, 166, 0.08);
    color: #9be7dd;
    font-weight: 600;
}

.ghost-btn:hover {
    background: rgba(20, 184, 166, 0.15);
}

.hero-panel {
    padding: 1.5rem;
}

.hero-copy h1 {
    margin: 0.25rem 0 0.75rem;
    font-size: clamp(2rem, 8vw, 3rem);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.summary-grid article,
.session-box,
.action-card {
    border-radius: 20px;
    background: rgba(30, 41, 59, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.10);
}

.summary-grid article {
    padding: 0.9rem;
    display: grid;
    gap: 0.15rem;
}

.summary-grid strong {
    font-size: 1.15rem;
    color: var(--color-white);
}

.action-panel h2 {
    margin-top: 0;
}

.action-list {
    display: grid;
    gap: 0.75rem;
}

.action-card {
    border: 0;
    color: var(--color-text-light);
    padding: 1rem;
    text-align: left;
}

.session-box {
    margin-top: 1rem;
    padding: 1rem;
    display: grid;
    gap: 1rem;
}

.session-box strong {
    display: block;
    margin-top: 0.25rem;
    word-break: break-all;
    color: var(--color-white);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid var(--color-error);
}

.validation-message {
    color: #fca5a5;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1100;
    background: rgba(15, 23, 42, 0.92);
    color: var(--color-text-light);
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
    font-size: 0.9rem;
    align-items: center;
    gap: 0.5rem;
}

#blazor-error-ui a.reload {
    color: var(--color-primary);
    text-decoration: underline;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    margin-left: 0.6rem;
    cursor: pointer;
}

.spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin-small 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin-small {
    to {
        transform: rotate(360deg);
    }
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%);
    border-radius: 8px;
    border: 2px solid rgba(11, 17, 28, 0.6);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #0d9488 0%, #0ea5a1 100%);
}

* {
    scrollbar-width: thin;
    scrollbar-color: #14b8a6 rgba(15, 23, 42, 0.2);
}

@media (max-width: 640px) {
    .nav-wrap {
        flex-direction: column;
        align-items: flex-start;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .auth-card,
    .hero-panel,
    .action-panel {
        border-radius: 22px;
    }

    .commessa-row {
        flex-direction: column;
        align-items: stretch;
    }

    .commessa-row-top,
    .modal-actions {
        justify-content: stretch;
    }

    .commessa-ubicazione-row {
        grid-template-columns: auto 1fr auto;
    }

    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .detail-actions {
        justify-content: stretch;
    }

    .detail-save-btn {
        width: 100%;
        min-width: 190px;
        color: #ffffff;
    }
}