.app-body, body {
    font-family: 'Inter', sans-serif;
}
:root {
    --bg: #fafaf8; /* stone-50 */
    --text: #374151; /* gray-700 */
    --primary: #0C9488; /* AgriWine, lettera W */
    --primary-hover: #09756c;
    --amber-100: #fef3c7;
    --accent: #f59e0b; /* amber-500 */
    --muted: #e5e7eb; /* gray-200 */
    --vasca-border: #a0a0a0;
    --chat-bg: #f9fafb;
}
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}
.card {
    background-color: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); /* shadow-lg */
    padding: 2rem;
    margin-bottom: 1.5rem;
}
.form-input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    margin-top: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(245,158,11,0.12); /* subtle amber */
}
.input-field {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(245,158,11,0.12);
}
select.input-field,
select.form-input {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vigneto-search-wrap {
    position: relative;
}
.vigneto-search-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(17, 24, 39, 0.18);
    pointer-events: none; /* non blocca la casella di ricerca */
}
.vigneto-search-backdrop.is-open {
    display: block;
}
.vigneto-search-dropdown {
    display: none;
    position: fixed;
    z-index: 100001;
    box-sizing: border-box;
    min-width: 300px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border: 1px solid #9ca3af;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.35);
    pointer-events: auto;
}
.vigneto-search-dropdown.is-open {
    display: block;
}
.vigneto-search-option {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    padding: 0.28rem 0.55rem;
    border: 0;
    border-bottom: 1px solid #f3f4f6;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1.25;
}
.vigneto-search-option:last-child {
    border-bottom: none;
}
.vigneto-search-option:hover,
.vigneto-search-option:focus {
    background: #fef3c7;
    outline: none;
}
.vigneto-search-option .v-nome {
    font-weight: 600;
    color: #1f2937;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.vigneto-search-option .v-varieta {
    color: #6b7280;
    flex-shrink: 0;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.vigneto-search-empty {
    padding: 0.55rem 0.65rem;
    font-size: 0.75rem;
    color: #6b7280;
}
.vigneto-search-count {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.3rem 0.55rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #6b7280;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

/* Vinificazione — schede compatte */
.ferm-card {
    border-radius: 0.75rem;
    border-width: 1px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 0.7rem 0.85rem;
}
.ferm-card-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.9rem;
    margin-bottom: 0.4rem;
    font-size: 0.68rem;
    color: #374151;
}
.ferm-card-dates strong {
    font-weight: 700;
    margin-right: 0.25rem;
}
.ferm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}
.ferm-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}
.ferm-card-chips span {
    font-size: 0.65rem;
    font-weight: 600;
    color: #4b5563;
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
}
.ferm-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 999px;
    padding: 0.1rem 0.4rem;
}
.ferm-badge-attiva {
    background: #dcfce7;
    color: #166534;
}
.ferm-badge-svinata {
    background: #e5e7eb;
    color: #374151;
}
.ferm-card-details {
    margin-top: 0.45rem;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 0.5rem;
    background: rgba(255,255,255,0.55);
}
.ferm-card-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.35rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #374151;
    user-select: none;
}
.ferm-card-summary::-webkit-details-marker {
    display: none;
}
.ferm-card-summary::before {
    content: '▸ ';
    color: #6b7280;
}
.ferm-card-details[open] > .ferm-card-summary::before {
    content: '▾ ';
}
.ferm-card-details[open] > .ferm-card-summary {
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.ferm-card-details-body {
    padding: 0.45rem 0.55rem 0.55rem;
    max-height: 14rem;
    overflow-y: auto;
}
.ferm-mini-block {
    margin-bottom: 0.45rem;
    padding: 0.35rem 0.45rem;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 0.35rem;
    background: rgba(255,255,255,0.65);
}
.ferm-mini-block h5,
.ferm-mini-grid h5 {
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: #1f2937;
}
.ferm-mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
@media (max-width: 640px) {
    .ferm-mini-grid {
        grid-template-columns: 1fr;
    }
}
.ferm-dose-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.15rem 0;
    font-size: 0.7rem;
    color: #374151;
}
.ferm-dose-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ferm-dose-meta {
    color: #6b7280;
    font-size: 0.65rem;
}
.ferm-edit-btn {
    background: none;
    border: none;
    color: #1d4ed8;
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    white-space: nowrap;
}
.ferm-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 0.85rem;
    margin-top: 0.45rem;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(0,0,0,0.06);
}
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
}
.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}
.text-brand {
    color: var(--primary);
}
.bg-brand {
    background-color: var(--primary);
}
.brand-check {
    accent-color: var(--primary);
}
#menu-button:focus {
    --tw-ring-color: var(--primary);
}
.btn-secondary {
    background-color: var(--muted);
    color: #1f2937;
}
.btn-secondary:hover {
    background-color: #d1d5db;
    transform: translateY(-2px);
}
.tab-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
    background-color: transparent;
    color: #4b5563; /* gray-600 */
    border: none;
    border-radius: 0; /* No radius for individual items */
}

#menu-scrim {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 50;
}
#menu-scrim.hidden {
    display: none;
}
#dropdown-menu.app-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(24rem, 88vw);
    max-height: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 0 1rem 1rem 0;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.18);
    z-index: 60;
    overflow: hidden;
}
#dropdown-menu.app-menu.hidden {
    display: none;
}
.app-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}
.app-menu-head strong {
    font-size: 1.05rem;
    color: #111827;
}
.app-menu-scroll {
    overflow-y: auto;
    padding-bottom: 1.25rem;
}
.app-menu-label,
.app-menu-group {
    margin: 0;
    padding: 0.85rem 1rem 0.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6b7280;
}
.app-menu-group {
    color: #374151;
    padding-top: 0.7rem;
}
#dropdown-menu button {
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
    line-height: 1.3;
    font-size: 1rem;
    min-height: 3rem;
}
#dropdown-menu #submenu-bottaia .tab-btn,
#dropdown-menu #submenu-manutenzione .tab-btn {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    padding-left: 1.6rem;
    font-size: 0.98rem;
    min-height: 2.85rem;
    font-weight: 600;
}

@media (pointer: coarse) {
    #dropdown-menu button {
        min-height: 2.75rem;
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
    }
}

.tab-btn:hover {
    background-color: #f3f4f6; /* gray-100 */
}

.tab-btn.active {
    background-color: var(--amber-100);
    color: var(--primary);
    font-weight: 700;
}

.tab-btn-ordini {
    position: relative;
    padding-right: 2.25rem;
}

.ordini-alert-badge {
    position: absolute;
    top: 0.55rem;
    right: 0.65rem;
    color: #b91c1c;
    font-size: 0.95rem;
    line-height: 1;
    pointer-events: none;
    animation: ordini-alert-pulse 1.6s ease-in-out infinite;
}

.ordini-menu-dot {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 9999px;
    background-color: #dc2626;
    box-shadow: 0 0 0 2px #fff;
    animation: ordini-alert-pulse 1.6s ease-in-out infinite;
}

@keyframes ordini-alert-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(1.12); }
}
.error-message {
    color: #ef4444;
    margin-top: 0.5rem;
}
.vasca-icon-container {
    width: 80px;
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
}
/* Il liquido ora è relativo al corpo della vasca, non al container */
.vasca-liquid {
    width: 100%;
    transition: height 0.5s ease-in-out;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 1;
}
.vasca-body {
    width: 65px;
    height: 85px;
    border: 2px solid var(--vasca-border);
    border-top: none;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    background-color: #f0f0f0;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    overflow: hidden; /* Fondamentale per non far uscire il liquido */
    position: absolute; /* Mantiene il posizionamento */
}
.vasca-top {
    width: 70px;
    height: 15px;
    border: 2px solid var(--vasca-border);
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: #f0f0f0;
    z-index: 2; /* Sopra il corpo */
}

/* Stile specifico per Semprepieno */
.vasca-semprepieno .vasca-body {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    background: linear-gradient(to right, #e0e0e0, #f8f8f8, #e0e0e0); /* Effetto metallico */
}
.vasca-semprepieno .vasca-top {
    border-radius: 50%; /* Ovale più schiacciato o diverso se necessario */
    background: linear-gradient(to right, #e0e0e0, #f8f8f8, #e0e0e0);
}

/* Coperchio galleggiante per semprepieno */
.vasca-lid {
    width: 100%;
    height: 4px;
    background-color: #555;
    border-top: 1px solid #888;
    border-bottom: 1px solid #333;
    position: absolute;
    left: 0;
    z-index: 10;
    transition: bottom 0.5s ease-in-out;
}
.cantina-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2rem;
    justify-items: center;
}
.cantina-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.cantina-item:hover {
    transform: translateY(-5px);
    transition: transform 0.2s ease-in-out;
    cursor: pointer;
}
.cantina-item.search-focus {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
    border-radius: 0.5rem;
}
.cantina-search-hit {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #fff;
    font-size: 0.75rem;
    color: #374151;
    text-align: left;
    cursor: pointer;
}
.cantina-search-hit:hover,
.cantina-search-hit.search-focus {
    border-color: var(--primary);
    background: #f0fdfa;
}
.cantina-search-hit strong {
    color: #111827;
}

/* --- Pianta cantina --- */
.cantina-pianta-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.cantina-pianta-stage {
    position: relative;
    width: min(920px, 100%);
    aspect-ratio: 1652.4 / 2304.6;
    background:
        linear-gradient(180deg, #f7f5f1 0%, #efebe3 100%);
    border: 1px solid #d6d3d1;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 8px 28px rgba(0,0,0,0.08);
    --tank-scale: 0.55;
}
.cantina-pianta-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}
.cantina-pianta-tanks {
    position: absolute;
    inset: 0;
}
.cantina-map-tank {
    position: absolute;
    transform: translate(-50%, -50%) scale(var(--tank-scale));
    transform-origin: center center;
    width: 48px;
    z-index: 2;
    cursor: pointer;
    user-select: none;
    touch-action: none;
}
.cantina-map-tank.search-dim {
    opacity: 0.22;
}
.cantina-map-tank.search-hit {
    z-index: 6;
}
.cantina-map-tank.search-focus {
    z-index: 8;
    filter: drop-shadow(0 0 6px rgba(153, 27, 27, 0.65));
}
.cantina-map-tank.dragging {
    z-index: 20;
    opacity: 0.92;
    cursor: grabbing;
}
.cantina-pianta-stage.edit-mode .cantina-map-tank {
    cursor: grab;
}
.cantina-map-tank .vasca-icon-container {
    width: 48px;
    height: 62px;
}
.cantina-map-tank .vasca-body {
    width: 40px;
    height: 52px;
    border-width: 1.5px;
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
}
.cantina-map-tank .vasca-top {
    width: 44px;
    height: 10px;
    border-width: 1.5px;
}
.cantina-map-tank .vasca-inner-info {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.12rem;
    text-align: center;
    pointer-events: none;
    line-height: 1.1;
}
.cantina-map-tank .vasca-inner-info .num {
    font-size: 0.62rem;
    font-weight: 800;
    color: #111;
    text-shadow: 0 0 2px rgba(255,255,255,0.85);
}
.cantina-map-tank .detail-chip {
    margin-top: 0.06rem;
    max-width: 100%;
    font-size: 0.46rem;
    line-height: 1.12;
    color: #111;
    text-shadow: 0 0 2px rgba(255,255,255,0.8);
}
.cantina-map-tank .detail-chip .den {
    font-weight: 700;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.cantina-map-tank .detail-chip .meta {
    margin-top: 0.04rem;
    font-weight: 600;
}
.cantina-pianta-stage.hide-details .detail-chip {
    display: none;
}
.cantina-map-tank.has-dark-fill .vasca-inner-info .num,
.cantina-map-tank.has-dark-fill .detail-chip {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.55);
}
.barrel-map {
    width: auto;
}
.barrel-icon-wrap {
    position: relative;
    display: flex;
    justify-content: center;
}
.barrel-icon-wrap .vasca-inner-info {
    position: absolute;
    left: 12%;
    right: 12%;
    top: 16%;
    bottom: 28%;
}
.barrel-face,
.tank-shape {
    display: block;
}
.tank-map {
    width: auto;
}
.tank-icon-wrap {
    position: relative;
    display: flex;
    justify-content: center;
}
.tank-icon-wrap .vasca-inner-info {
    position: absolute;
    left: 18%;
    right: 18%;
    top: 26%;
    bottom: 16%;
}
.tank-cemento .tank-icon-wrap .vasca-inner-info {
    left: 12%;
    right: 30%;
    top: 30%;
    bottom: 16%;
}

/* Stili per la chat AI */
#chat-window {
    height: 400px;
    overflow-y: auto;
    border: 1px solid var(--muted);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: var(--chat-bg);
}
.chat-message {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    max-width: 80%;
    line-height: 1.5;
}
.user-message {
    background-color: var(--amber-100);
    color: #78350f; /* amber-900 */
    align-self: flex-end;
    margin-left: auto;
}
.ai-message {
    background-color: #f3f4f6; /* gray-100 */
    color: #1f2937; /* gray-800 */
    align-self: flex-start;
}
.loading-spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Logo sizing */
#logo-img {
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
}
#auth-logo {
    display: block;
    margin: 0 auto 0.75rem;
    max-width: 88px;
    max-height: 88px;
    object-fit: contain;
}
#auth-logo.auth-logo-wide {
    max-width: 280px;
    max-height: 84px;
}
.tenant-banner {
    background: #fef3c7;
    color: #09756c;
    border: 1px solid #f59e0b;
    border-radius: 0.75rem;
    padding: 0.65rem 0.9rem;
    margin: -0.5rem 0 1rem;
    font-size: 0.875rem;
}
body.tenant-wide-logo #app-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background: transparent;
    background-image: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0.35rem 0 0.85rem;
}
body.tenant-wide-logo #btn-logout {
    background-color: #151E2D;
    color: #ffffff;
}
body.tenant-wide-logo #btn-logout:hover {
    background-color: #0c1420;
    color: #ffffff;
}
body.tenant-wide-logo #btn-go-home {
    grid-column: 2;
    justify-content: center;
}
body.tenant-wide-logo #header-actions {
    position: static;
    grid-column: 3;
    justify-self: end;
    right: auto;
}
body.tenant-wide-logo #logo-img,
body.tenant-wide-logo .logo-template-img {
    max-width: min(440px, 68vw);
    max-height: 92px;
    width: auto;
    height: auto;
}
body.tenant-wide-logo #brand-logo-frame,
body.tenant-wide-logo .logo-insert {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
}
body.tenant-wide-logo #brand-title,
body.tenant-wide-logo #tenant-badge {
    display: none;
}
@media (max-width: 640px) {
    body.tenant-wide-logo #app-header {
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 0.7rem 0.75rem;
        column-gap: 0.5rem;
    }
    body.tenant-wide-logo #btn-go-home {
        grid-column: 1;
        justify-self: start;
        min-width: 0;
    }
    body.tenant-wide-logo #header-actions {
        grid-column: 2;
    }
    body.tenant-wide-logo #logo-img {
        max-width: 100%;
        max-height: 72px;
    }
}
.logo-template-img {
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
    display: block;
}

/* Stili Bottaia */
.botte-shape {
    background: #8B4513; /* SaddleBrown */
    border-radius: 12px;
    position: relative;
    box-shadow: 2px 4px 6px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.95);
    border: 2px solid #5D4037;
    transition: transform 0.2s;
}
.botte-shape:hover {
    transform: scale(1.05);
}
/* Fasce metalliche della botte */
.botte-shape::before, .botte-shape::after {
    content: '';
    position: absolute;
    left: 1px;
    right: 1px;
    height: 3px;
    background: rgba(0,0,0,0.4);
    border-top: 1px solid rgba(255,255,255,0.2);
}
.botte-shape::before { top: 25%; }
.botte-shape::after { bottom: 25%; }

.botte-barrique { width: 60px; height: 75px; }
.botte-tonneau { width: 80px; height: 95px; border-radius: 16px; }
.botte-piena { background: #795548; } /* Brown 500 */
.botte-vuota { background: #D7CCC8; color: #5D4037; border-color: #A1887F; } /* Brown 100 */

/* Dashboard Home */
.dashboard-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 1rem 1.1rem 1.1rem;
    display: flex;
    flex-direction: column;
}
.dashboard-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.75rem;
}
.dashboard-chart-wrap {
    position: relative;
    width: 100%;
    min-height: 200px;
    height: 220px;
    flex-shrink: 0;
}
.dashboard-table-wrap {
    overflow: auto;
    max-height: 280px;
    border: 1px solid #9ca3af;
    border-radius: 0.375rem;
    background: #fff;
}
.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    table-layout: fixed;
}
.dashboard-table th,
.dashboard-table td {
    padding: 0.5rem 0.65rem;
    border: 1px solid #d1d5db;
    text-align: left;
    vertical-align: middle;
}
.dashboard-table th {
    color: #111827;
    font-weight: 700;
    background: #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1;
}
.dashboard-table tbody tr:nth-child(even) {
    background: #f9fafb;
}
.dashboard-table tbody tr:hover {
    background: #f3f4f6;
}
.dashboard-table td.num,
.dashboard-table th.num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    width: 4.5rem;
}
.dashboard-table th:first-child,
.dashboard-table td:first-child {
    width: auto;
}
.dashboard-table tfoot td {
    font-weight: 700;
    background: #f3f4f6;
}
.dashboard-swatch {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    margin-right: 0.35rem;
    vertical-align: middle;
}
.dashboard-filter-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: #374151;
    cursor: pointer;
}
.dashboard-filter-item input {
    accent-color: var(--primary);
}

/* Albero storia masse */
.massa-tree {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.massa-tree-legend {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0 0 0.25rem;
}
.massa-tree-node {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.massa-tree-card {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.75rem 0.9rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.massa-tree-card--root {
    border-color: var(--primary);
    background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 70%);
}
.massa-tree-card--missing,
.massa-tree-card--cycle {
    border-style: dashed;
    background: #f9fafb;
    color: #6b7280;
}
.massa-tree-card-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}
.massa-tree-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--primary);
    background: #ccfbf1;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
}
.massa-tree-pct {
    font-size: 0.75rem;
    font-weight: 700;
    color: #92400e;
    background: #fef3c7;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
}
.massa-tree-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1.35;
}
.massa-tree-meta {
    margin: 0.3rem 0 0;
    font-size: 0.75rem;
    color: #6b7280;
}
.massa-tree-date {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    color: #1f2937;
}
.massa-tree-date strong {
    margin-right: 0.3rem;
}
.massa-tree-lavorazioni {
    margin: 0.45rem 0 0;
    padding: 0.4rem 0.5rem;
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 0.4rem;
}
.massa-tree-lavorazioni-label {
    margin: 0 0 0.25rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9a3412;
}
.massa-tree-lavorazioni ul {
    margin: 0;
    padding-left: 0.95rem;
}
.massa-tree-lavorazioni li {
    font-size: 0.75rem;
    line-height: 1.3;
    color: #1f2937;
}
.massa-tree-lavorazioni li + li {
    margin-top: 0.2rem;
}
.massa-tree-origin {
    margin: 0;
    font-size: 0.72rem;
    color: #059669;
    font-weight: 600;
}
.massa-tree-children {
    margin-left: 0.75rem;
    padding-left: 0.85rem;
    border-left: 2px solid #fca5a5;
}
.massa-tree-branch-label {
    margin: 0 0 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9a3412;
}
.massa-tree-children-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
}
@media (min-width: 768px) {
    .massa-tree-children-row {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}
.massa-tree-imb {
    margin-top: 0.5rem;
    padding: 0.75rem 0.9rem;
    border-radius: 0.75rem;
    background: #fff7ed;
    border: 1px solid #fed7aa;
}
.massa-tree-imb ul {
    margin: 0.35rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.8rem;
    color: #374151;
}
.massa-tree-imb li + li {
    margin-top: 0.25rem;
}
#qr-code-display img,
#vasca-qr-inline img {
    width: 220px;
    height: auto;
    max-width: 100%;
}
@media print {
    body.qr-label-print > *:not(#qr-modal) {
        display: none !important;
    }
    body.qr-label-print #qr-modal {
        position: static !important;
        display: block !important;
        background: #fff !important;
        padding: 0 !important;
    }
    body.qr-label-print #qr-modal .bg-white {
        box-shadow: none !important;
        max-width: none !important;
    }
    body.qr-label-print #qr-print-btn,
    body.qr-label-print #qr-close-btn,
    body.qr-label-print #qr-info {
        display: none !important;
    }
    body.qr-label-print #qr-code-display img {
        width: 280px;
        height: auto;
    }
}