/* ============================================
   Zaini Sync - Admin Panel Stylesheet
   ============================================ */

:root {
    --color-bg: #f5f6fa;
    --color-surface: #ffffff;
    --color-sidebar: #1a1d2e;
    --color-sidebar-hover: #252840;
    --color-sidebar-active: #3b3f5c;
    --color-primary: #4f6ef7;
    --color-primary-hover: #3b5de7;
    --color-text: #2d3436;
    --color-text-muted: #8395a7;
    --color-border: #e8ecf1;
    --color-success: #00b894;
    --color-warning: #fdcb6e;
    --color-danger: #e74c3c;
    --color-info: #74b9ff;

    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --transition: 150ms ease;

    --sidebar-width: 240px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    display: flex;
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f0f2f5; padding: 2px 6px; border-radius: var(--radius-sm); font-size: 13px; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: #c8cdd5;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h1 {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-subtitle {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
}

.nav-menu {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #c8cdd5;
    text-decoration: none;
    transition: all var(--transition);
    font-size: 14px;
}

.nav-menu a:hover {
    background: var(--color-sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.nav-menu a.active {
    background: var(--color-sidebar-active);
    color: #fff;
    border-right: 3px solid var(--color-primary);
}

.nav-menu svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sync-actions-global {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-footer .btn {
    width: 100%;
    justify-content: center;
    color: #c8cdd5;
    border-color: rgba(255,255,255,0.15);
}

.sidebar-footer .btn:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
    background: var(--color-sidebar-hover);
}

/* ---- Main content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.page-header {
    padding: 20px 32px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.page-body {
    padding: 24px 32px;
}

/* ---- Cards ---- */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-body.no-padding {
    padding: 0;
}

/* ---- Stats grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ---- Tables ---- */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    background: #fafbfc;
}

/* Header ordinabili nella lista prodotti */
.sort-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.sort-link:hover {
    color: var(--color-text, #111);
}
.sort-link.active {
    color: var(--color-primary, #1f6feb);
}

.table-sm th, .table-sm td {
    padding: 6px 12px;
    font-size: 13px;
}

.table-hover tbody tr {
    transition: background var(--transition);
}

.table-hover tbody tr:hover {
    background: #f8f9ff;
}

.clickable-row {
    cursor: pointer;
}

.row-removed {
    opacity: 0.5;
}

.row-removed td {
    text-decoration: line-through;
    text-decoration-color: var(--color-text-muted);
}

.row-removed td .badge,
.row-removed td .thumb,
.row-removed td .thumb-placeholder,
.row-removed td button {
    text-decoration: none;
}

.col-actions {
    width: 40px;
    text-align: center;
}

.btn-toggle-remove {
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

.btn-toggle-remove:hover {
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 12px; }
.text-success { color: var(--color-success); font-weight: 600; }
.text-danger { color: var(--color-danger); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-new { background: #dfe6fd; color: #3b5de7; }
.badge-updated { background: #fef3cd; color: #856404; }
.badge-unchanged { background: #e8ecf1; color: #636e72; }
.badge-removed { background: #fce4ec; color: #c0392b; }
.badge-warning { background: #fef3cd; color: #856404; }

/* Chip aree di stampa: label cliccabile per upload foto (LOTUS) */
.print-position-label { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.print-position-label:hover { color: #3b5de7; }

/* Area Import Excel */
.import-excel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.import-excel-card h4 { margin: 0 0 6px; }
.import-excel-desc { margin-bottom: 16px; }

/* Zona di selezione file (input nativo nascosto, label cliccabile) */
.import-excel-drop {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    margin-bottom: 14px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.import-excel-drop:hover { border-color: var(--color-primary); background: #f0f3fe; }
.import-excel-drop input[type="file"] { display: none; }
.import-excel-drop svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    color: var(--color-text-muted);
    transition: color var(--transition);
}
.import-excel-drop:hover svg { color: var(--color-primary); }
.import-excel-drop-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.import-excel-drop-text strong { font-size: 13px; }
.import-excel-file-name {
    font-size: 12px;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.import-excel-drop.has-file { border-color: var(--color-primary); border-style: solid; background: #eef1fe; }
.import-excel-drop.has-file svg { color: var(--color-primary); }
.import-excel-drop.has-file .import-excel-file-name { color: var(--color-primary); font-weight: 600; }

/* Box anteprima e risultato */
.import-excel-preview {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid #cfe0fc;
    border-radius: var(--radius);
    background: #f2f7ff;
}
.import-excel-preview .btn-import-confirm { margin-top: 12px; }
.import-excel-result {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    font-weight: 500;
}
.import-excel-result.is-success { background: #e9f9f4; border-color: #b7ecd9; color: #0a7d5f; }
.import-excel-result.is-error { background: #fdecea; border-color: #f5c6c0; color: #b03a2e; }
.import-excel-lines { max-height: 300px; overflow: auto; background: #fff; border: 1px solid #d5e3f7; border-radius: 4px; padding: 10px; font-size: 12px; line-height: 1.5; }
.badge-success { background: #d4edda; color: #155724; }
.badge-partial { background: #fff3cd; color: #856404; }
.badge-failed { background: #f8d7da; color: #721c24; }
.badge-pending { background: #e8ecf1; color: #636e72; }
.badge-supplier { background: #e3f2fd; color: #1565c0; }
.badge-shopify { background: #e8f5e9; color: #2e7d32; }
.badge-phase { background: #f3e5f5; color: #7b1fa2; }

/* Iconine link Shopify accanto al badge (admin / shop online) */
.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e8f5e9;
    color: #2e7d32;
    transition: background 0.15s;
}
.icon-link:hover { background: #c8e6c9; }
.icon-link svg { width: 12px; height: 12px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    background: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }

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

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

.btn-outline {
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: #f8f9ff;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

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

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

.btn-icon {
    width: 16px;
    height: 16px;
}

.btn:disabled, .btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 4px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Forms / Inputs ---- */
.input {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border var(--transition);
    width: 100%;
}

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

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

/* ---- Filters bar ---- */
.filters-bar {
    margin-bottom: 20px;
}

.filters-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    min-width: 160px;
}

.filter-group .input {
    width: 100%;
}

.results-info {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 20px;
}

/* ---- Thumbnails ---- */
.col-img { width: 48px; }

.thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    cursor: pointer;
}

.thumb-placeholder {
    width: 40px;
    height: 40px;
    background: #f0f2f5;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--color-border);
}

.thumb-placeholder.small {
    width: 32px;
    height: 32px;
}

.col-title { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Product detail ---- */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.detail-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-badges {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

.detail-main { min-width: 0; }

.detail-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 4px 12px;
}

.detail-list dt {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 6px 0;
}

.detail-list dd {
    padding: 6px 0;
    word-break: break-word;
}

/* ---- Field sync buttons ---- */
.field-with-sync {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.btn-sync-field {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 3px 5px;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all var(--transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.btn-sync-field:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: #f8f9ff;
}

.btn-sync-field svg {
    width: 13px;
    height: 13px;
}

.btn-sync-field.loading {
    opacity: 0.5;
    pointer-events: none;
}

.btn-sync-field.loading svg {
    animation: spin 0.6s linear infinite;
}

.field-content {
    font-size: 14px;
    line-height: 1.6;
}

/* ---- Sync phase cards (dashboard) ---- */
.sync-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.sync-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    background: #fafbfc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.sync-action-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow);
}

.sync-action-card.sync-action-full {
    background: #f0f2ff;
    border-color: var(--color-primary);
}

.sync-action-icon {
    width: 40px;
    height: 40px;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.sync-action-icon svg {
    width: 100%;
    height: 100%;
}

.sync-action-card h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.sync-action-card p {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0 0 16px 0;
    flex: 1;
}

@media (max-width: 768px) {
    .sync-actions-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Image gallery ---- */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.gallery-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--color-border);
    aspect-ratio: 1;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition);
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item.main-image {
    border-color: var(--color-primary);
    border-width: 2px;
}

.gallery-label {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: var(--color-primary);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
}

.gallery-item.img-error {
    background: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item.img-error img { display: none; }
.gallery-item.img-error::after {
    content: 'Errore';
    color: var(--color-text-muted);
    font-size: 11px;
}

/* ---- Toast notifications ---- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-success { background: #d4edda; color: #155724; border-left: 4px solid var(--color-success); }
.toast-error { background: #f8d7da; color: #721c24; border-left: 4px solid var(--color-danger); }
.toast-info { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--color-info); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-width: 640px;
    width: 90%;
    max-height: 85vh;
    overflow: auto;
}

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

.modal-header h3 { font-size: 16px; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0 4px;
}

.modal-body {
    padding: 20px;
}

.modal-body img {
    max-width: 100%;
    border-radius: var(--radius);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        overflow: hidden;
    }
    .sidebar-header h1,
    .sidebar-subtitle,
    .nav-menu a span,
    .sidebar-footer { display: none; }
    .nav-menu a { justify-content: center; padding: 14px; }
    .main-content { margin-left: 60px; }
    .page-body { padding: 16px; }
    .filters-form { flex-direction: column; }
    .filter-group { width: 100%; }
}

/* ============================================
   Sezione Problemi (Dashboard)
   ============================================ */

.problems-card {
    border-left: 4px solid var(--color-danger);
    margin-bottom: 20px;
}

.brand-issues-card {
    border-left: 4px solid var(--color-warning);
    margin-bottom: 20px;
}

/* Card collassabile (details/summary): chiusa di default, header sempre visibile */
.collapsible-card > summary.card-header {
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.collapsible-card > summary.card-header::-webkit-details-marker {
    display: none;
}

.collapsible-card > summary.card-header:hover {
    background: rgba(0, 0, 0, 0.02);
}

.collapsible-card:not([open]) > summary.card-header {
    border-bottom: none;
}

.collapsible-chevron {
    color: var(--color-text-muted, #888);
    font-size: 14px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.collapsible-card[open] .collapsible-chevron {
    transform: rotate(90deg);
}

.shopify-load-errors {
    background: #fef9ec;
    color: #b7791f;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
}

.shopify-load-errors ul {
    margin: 6px 0 0 18px;
}

.warning-count-badge {
    background: #fef9ec;
    color: #b7791f;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.brand-issue-label {
    color: #b7791f;
    font-size: 13px;
}

.brand-issue-group + .brand-issue-group {
    border-top: 1px solid var(--color-border);
}

.brand-issue-group summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px;
    cursor: pointer;
    list-style-position: inside;
}

.brand-issue-group summary:hover {
    background: #fefbf3;
}

.brand-issue-products {
    margin: 0 0 10px 26px;
    padding: 0;
    list-style: none;
    max-height: 260px;
    overflow-y: auto;
    font-size: 14px;
}

.brand-issue-products li {
    padding: 3px 0;
}

.error-count-badge {
    background: #fef2f2;
    color: var(--color-danger);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.problem-item {
    background: #fef2f2;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.problem-item:last-child { margin-bottom: 0; }

.problem-content { flex: 1; min-width: 0; }

.problem-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.problem-message {
    color: #555;
    font-size: 14px;
    margin: 4px 0 0;
    line-height: 1.4;
}

.problem-details {
    margin-top: 6px;
}

.problem-details summary {
    font-size: 12px;
    color: #999;
    cursor: pointer;
}

.problem-details code {
    font-size: 11px;
    color: #888;
    display: block;
    margin-top: 4px;
    background: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    word-break: break-all;
}

.problem-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.status-ok-card {
    border-left: 4px solid #22c55e;
    margin-bottom: 20px;
}

.status-ok-icon {
    color: #22c55e;
    font-size: 20px;
    font-weight: bold;
}

/* ============================================
   Sync Logs (nuova versione)
   ============================================ */

.sync-log-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.sync-log-filters .btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.sync-log-date {
    font-size: 13px;
    color: #999;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 10px;
}

.sync-log-date:first-child { margin-top: 0; }

.sync-log-entry {
    background: var(--color-surface);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.sync-log-entry.has-errors {
    border-left: 3px solid var(--color-danger);
}

.sync-log-icon {
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.sync-log-icon.success { background: #dcfce7; color: #22c55e; }
.sync-log-icon.error { background: #fef2f2; color: var(--color-danger); }
.sync-log-icon.partial { background: #fef3c7; color: #d97706; }

.sync-log-info { flex: 1; margin-left: 12px; }

.sync-log-title {
    font-weight: 600;
    color: var(--color-text);
}

.sync-log-time {
    color: #999;
    font-size: 13px;
    margin-left: 8px;
}

.sync-log-summary {
    color: #888;
    font-size: 13px;
    margin-top: 2px;
}

.sync-log-errors {
    margin: 10px 0 0 40px;
    background: #fef2f2;
    border-radius: 6px;
    padding: 10px 12px;
}

.sync-log-errors div {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.sync-log-errors div:last-child { margin-bottom: 0; }

.sync-log-details-block {
    width: 100%;
    margin-top: 10px;
    padding-left: 40px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sync-log-sku-details {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
}

.sync-log-sku-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.sync-log-sku-list {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sync-log-sku-list code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.sync-log-sku-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f8f9fa;
    border-radius: 4px;
    padding: 2px 4px;
}

.sync-log-sku-clickable {
    cursor: pointer;
    transition: background 0.15s;
}
.sync-log-sku-clickable:hover {
    background: #e2e8f0;
}

.sync-log-field-changes {
    display: inline-flex;
    gap: 2px;
}

.sync-log-field-change {
    background: #dbeafe;
    color: #1e40af;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
}

.changes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.changes-table th {
    text-align: left;
    padding: 8px 10px;
    background: #f1f5f9;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    color: #475569;
}
.changes-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
    max-width: 280px;
    word-break: break-word;
}

.sync-log-errors-inline {
    background: #fef2f2;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    color: #666;
}

.sync-log-duration {
    color: #999;
    font-size: 13px;
    flex-shrink: 0;
}

/* ============================================
   Form Creazione Prodotto
   ============================================ */

.create-product-form .card {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
    flex: 1;
    min-width: 0;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    margin-bottom: 40px;
}

/* Varianti - input nella tabella */
#variants-table .input {
    padding: 6px 8px;
    font-size: 12px;
}

#variants-table td {
    vertical-align: middle;
}

.btn-remove-variant {
    background: none;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    line-height: 1;
}

.btn-remove-variant:hover {
    opacity: 0.7;
}

.btn-add-product {
    margin-left: auto;
    order: 99;
}
.btn-import-excel { order: 100; }

/* ---- Dev Panel ---- */
.dev-supplier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.dev-supplier-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.dev-supplier-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* ============================================
   Scale sconto B2B (dettaglio prodotto)
   ============================================ */

.btn-toggle-scale {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    cursor: pointer;
    color: var(--color-primary);
    font-size: 12px;
    transition: var(--transition);
}
.btn-toggle-scale:hover { border-color: var(--color-primary); }

.scale-row td {
    background: var(--color-bg);
    padding: 10px 16px;
}
.scale-detail {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}
.scale-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}
.scale-meta { color: var(--color-text-muted); }
.scale-table-wrap { overflow-x: auto; }
.scale-table {
    border-collapse: collapse;
    background: var(--color-surface);
    font-size: 13px;
}
.scale-table th, .scale-table td {
    border: 1px solid var(--color-border);
    padding: 5px 14px;
    text-align: right;
    white-space: nowrap;
}
.scale-table thead th {
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-weight: 600;
}
.scale-table th:first-child, .scale-table td:first-child {
    text-align: left;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* ===== Aree di stampa disponibili sul sito ===== */
.print-positions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.print-position-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    font-size: 13px;
}
.print-position-chip img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}

/* ---- Pagina di login ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    width: 340px;
    padding: 32px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.login-box h1 {
    margin: 0;
    font-size: 22px;
    color: var(--color-text);
}

.login-subtitle {
    margin: 4px 0 20px;
    color: var(--color-text-muted);
    font-size: 13px;
}

.login-box label {
    display: block;
    margin: 12px 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.login-box input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    font-size: 14px;
    color: var(--color-text);
}

.login-box button {
    width: 100%;
    justify-content: center;
    margin-top: 20px;
}

.login-error {
    margin-bottom: 12px;
    padding: 8px 10px;
    background: #fdecea;
    color: var(--color-danger);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* Footer sidebar: utente e logout */
.sidebar-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sidebar-username { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { background: none; border: 1px solid rgba(255,255,255,.15); color: inherit; font-size: 11px; padding: 2px 8px; border-radius: 4px; cursor: pointer; }
.btn-logout:hover { background: rgba(255,255,255,.08); }

/* Form creazione utente */
.user-create-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.user-create-form input, .user-create-form select { padding: 7px 10px; border: 1px solid #ddd; border-radius: 6px; }
