* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f0f0f; color: #e0e0e0; }
nav { background: #1a1a2e; padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; }
nav h1 { color: #00d4ff; font-size: 1.3rem; }
.nav-links a { color: #aaa; text-decoration: none; margin-left: 1.5rem; }
.nav-links a:hover { color: #00d4ff; }
main { width: 100%; max-width: none; margin: 1.5rem 0; padding: 0 2rem; }
h2 { color: #00d4ff; margin-bottom: 1rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: #1a1a2e; padding: 1.5rem; border-radius: 8px; text-align: center; }
.stat-card h3 { color: #888; font-size: 0.85rem; margin-bottom: 0.5rem; }
.stat-number { font-size: 2rem; font-weight: bold; color: #00d4ff; }
.stat-number.published { color: #00e676; }
.stat-number.pending { color: #ffd740; }
table { width: 100%; border-collapse: collapse; background: #1a1a2e; border-radius: 8px; overflow: hidden; }
th { background: #16213e; padding: 0.75rem 1rem; text-align: left; font-size: 0.85rem; color: #888; }
td { padding: 0.75rem 1rem; border-top: 1px solid #222; }
td a { color: #00d4ff; text-decoration: none; }
.price-error { color: #ff5252; font-weight: bold; }
.discount { color: #00e676; font-weight: bold; }
.badge { padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.75rem; }
.badge.published { background: #00e67622; color: #00e676; }
.badge.pending { background: #ffd74022; color: #ffd740; }
.badge.failed { background: #ff525222; color: #ff5252; }
.badge.success { background: #00e67622; color: #00e676; }

/* Config page */
.tab-bar { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid #333; margin-bottom: 0; }
.tab-btn { background: transparent; border: none; border-bottom: 3px solid transparent; color: #aaa; padding: 0.7rem 1.1rem; cursor: pointer; font-size: 0.95rem; font-family: inherit; transition: color 0.15s ease, border-color 0.15s ease; border-radius: 0; }
.tab-btn:hover { color: #e0e0e0; }
.tab-btn.active { color: #00d4ff; border-bottom-color: #00d4ff; font-weight: 600; }
.tab-panel[hidden] { display: none; }
.config-section { background: #1a1a2e; border-radius: 0 8px 8px 8px; padding: 1.5rem; margin-bottom: 1.5rem; }
.config-section h3 { color: #00d4ff; margin-bottom: 1rem; font-size: 1rem; border-bottom: 1px solid #333; padding-bottom: 0.5rem; }
.form-group { margin-bottom: 0.8rem; }
.form-group label { display: block; margin-bottom: 0.3rem; color: #aaa; font-size: 0.9rem; }
.form-group input { width: 100%; padding: 0.6rem; background: #16213e; border: 1px solid #333; border-radius: 4px; color: #e0e0e0; font-size: 0.95rem; font-family: monospace; }
.form-group input:focus { outline: none; border-color: #00d4ff; }
.form-group input::placeholder { color: #555; }
.btn { background: #00d4ff; color: #000; border: none; padding: 0.8rem 2rem; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 1rem; margin-top: 0.5rem; }
.btn:hover { background: #00b8d9; }

/* Flash messages */
.flash { padding: 0.8rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-success { background: #00e67622; color: #00e676; border: 1px solid #00e67644; }
.flash-error { background: #ff525222; color: #ff5252; border: 1px solid #ff525244; }

/* Actions */
.actions { background: #1a1a2e; border-radius: 8px; padding: 1.5rem; margin-bottom: 2rem; }
.action-buttons { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fb-btn { background: #1877f2; color: #fff; border: none; border-radius: 4px; padding: 0.4rem 0.8rem; cursor: pointer; font-size: 0.8rem; font-weight: 600; white-space: nowrap; transition: background 0.15s ease; }
.fb-btn:hover { background: #145dbf; }
.fb-btn:disabled { background: #333; color: #888; cursor: not-allowed; }
a.fb-btn { display: inline-block; text-decoration: none; }
.fb-connect-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.fb-connect { padding: 0.7rem 1.2rem; font-size: 0.95rem; }
.fb-disconnect { background: #333; color: #bbb; }
.fb-disconnect:hover { background: #c0392b; color: #fff; }
.fb-status { color: #aaa; font-size: 0.85rem; }
.fb-status.ok { color: #00e676; }
.fb-status.warn { color: #ffd740; }
.scan-btn { margin-top: 0; }
.scan-btn:disabled { background: #333; color: #888; cursor: not-allowed; }
.scan-btn .spinner { display: inline-block; width: 0.9rem; height: 0.9rem; border: 2px solid #000; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 0.4rem; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: #1a1a2e; border-radius: 10px; width: 90%; max-width: 600px; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid #333; }
.modal-header h3 { color: #00d4ff; font-size: 1.1rem; margin: 0; }
.modal-close { background: none; border: none; color: #aaa; font-size: 1.5rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: #ff5252; }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.progress-info { display: flex; justify-content: space-between; margin-bottom: 0.5rem; color: #aaa; font-size: 0.9rem; }
.progress-bar { width: 100%; height: 12px; background: #16213e; border-radius: 6px; overflow: hidden; margin-bottom: 1rem; }
.progress-fill { height: 100%; background: #00d4ff; border-radius: 6px; transition: width 0.3s ease; }
.result-count { color: #00d4ff; margin: 0.5rem 0 0.75rem; }
.result-list { list-style: none; padding: 0; margin: 0; }
.result-list li { padding: 0.6rem 0; border-bottom: 1px solid #222; font-size: 0.9rem; }
.result-list li:last-child { border-bottom: none; }
.result-list a { color: #00d4ff; text-decoration: none; }
.orig { color: #888; font-size: 0.85rem; }
.no-errors { color: #888; margin-top: 0.5rem; }

/* Filter toolbar */
.errors-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.errors-toolbar h2 { margin: 0; }
.category-filter { display: flex; align-items: center; gap: 0.5rem; color: #aaa; font-size: 0.9rem; }
.category-filter select { background: #16213e; color: #fff; border: 1px solid #333; border-radius: 6px; padding: 0.45rem 0.6rem; font-size: 0.9rem; }
.category-filter select:focus { outline: none; border-color: #00d4ff; }

/* Responsive: card su schermi piccoli */
@media (max-width: 900px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr; }
    main { padding: 0 1rem; }
}

/* Product preview popover */
.product-popover { position: fixed; z-index: 1200; width: 320px; background: #1a1a2e; border: 1px solid #333; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,0.6); overflow: hidden; }
.product-popover .pp-image { width: 100%; height: 180px; object-fit: contain; background: #fff; display: block; }
.product-popover .pp-body { padding: 0.9rem 1rem; }
.pp-title { font-size: 0.95rem; font-weight: 600; color: #e0e0e0; margin-bottom: 0.5rem; line-height: 1.3; }
.pp-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.pp-category { color: #aaa; font-size: 0.8rem; }
.pp-prices { display: flex; gap: 0.75rem; align-items: baseline; margin-bottom: 0.8rem; flex-wrap: wrap; }
.pp-prices .orig { text-decoration: line-through; }
.pp-btn { display: block; width: 100%; text-align: center; margin-top: 0; padding: 0.6rem 1rem; font-size: 0.9rem; text-decoration: none; }
.product-preview { cursor: pointer; }

/* Last scans indicator */
.last-scans { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 2rem; }
.last-scan-item { background: #16213e; border: 1px solid #333; border-radius: 8px; padding: 0.7rem 1rem; flex: 1 1 280px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.ls-label { color: #aaa; font-size: 0.85rem; }
.ls-value { color: #00d4ff; font-weight: 600; font-size: 0.95rem; }
@media (max-width: 560px) {
    .last-scan-item { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
}

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #0f0f0f; }
.login-card { background: #1a1a2e; border: 1px solid #333; border-radius: 12px; padding: 2.5rem 2rem; width: 100%; max-width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.login-card h1 { color: #00d4ff; font-size: 1.3rem; text-align: center; margin-bottom: 0.3rem; }
.login-sub { color: #888; text-align: center; margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-btn { width: 100%; margin-top: 0.5rem; }

/* Logout link in nav */
.nav-logout { color: #ff5252; margin-left: 1rem; }
