/* Best Discount Portal - restyle 2026 */
:root {
  --brand: #1f4e79;
  --brand-600: #183f62;
  --brand-50: #eef4fa;
  --accent: #7cb342;
  --accent-50: #f1f8e9;
  --danger: #c62828;
  --danger-50: #fdecea;
  --warn: #b26a00;
  --warn-50: #fff4e5;
  --ok: #2e7d32;
  --ok-50: #edf7ee;
  --text: #1d2733;
  --muted: #64748b;
  --border: #dbe2ea;
  --bg: #f4f6f9;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--brand); }
a:hover { color: var(--brand-600); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand .mark { width: 50px; height: 34px; background: url(/logo1.png) no-repeat; background-size: 160px 160px; background-position: -55px -38px; }
.brand span { font-weight: 700; color: var(--brand); font-size: 16px; white-space: nowrap; }
.brand small { display: block; font-weight: 500; color: var(--accent); font-size: 11px; }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  text-decoration: none; color: var(--text); font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
}
.nav a:hover { background: var(--brand-50); color: var(--brand); }
.nav a.active { background: var(--brand); color: #fff; }

.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.userbox b { color: var(--text); }
.userbox a { text-decoration: none; font-weight: 600; }

/* ---------- Page ---------- */
.page { max-width: 1400px; margin: 0 auto; padding: 24px 20px 120px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 18px;
}
.card h2 {
  margin: 0 0 14px; font-size: 15px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--brand);
}
.card h2 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ---------- Grid ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
.layout .side { position: sticky; top: 78px; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .layout .side { position: static; }
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .row, .row-3 { grid-template-columns: 1fr; } }

/* ---------- Fields ---------- */
.field { margin-bottom: 14px; }
.field > label, .field .label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-weight: 600; margin-bottom: 5px; font-size: 13px;
}
.field .req::after { content: " *"; color: var(--danger); }
.field .counter { font-weight: 400; color: var(--muted); font-size: 12px; }
.field .counter.over { color: var(--danger); font-weight: 600; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }

input[type=text], input[type=url], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, .15);
}
input[readonly] { background: #f6f8fa; }

.field.has-error > label, .field.has-error .label { color: var(--danger); }
.field.has-error input, .field.has-error select, .field.has-error textarea {
  border-color: var(--danger); background: #fffafa;
}
.field.has-error input:focus, .field.has-error textarea:focus { box-shadow: 0 0 0 3px rgba(198, 40, 40, .15); }
.err-msg { color: var(--danger); font-size: 12px; font-weight: 600; margin-top: 4px; }
.err-msg:empty { display: none; }

.input-group { display: flex; gap: 6px; }
.input-group > input { flex: 1; min-width: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  border-radius: 8px; padding: 8px 16px; border: 1px solid transparent;
  background: var(--brand); color: #fff; white-space: nowrap;
}
.btn:hover { background: var(--brand-600); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--brand-50); color: var(--brand); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #689f38; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--danger-50); color: var(--danger); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-icon { padding: 5px 8px; font-size: 12px; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; border: 1px solid; }
.alert strong { display: block; margin-bottom: 4px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-error { background: var(--danger-50); border-color: #f5c2c0; color: #7f1d1d; }
.alert-warn { background: var(--warn-50); border-color: #ffd8a8; color: #663c00; }
.alert-ok { background: var(--ok-50); border-color: #b7dfb9; color: #1b4d1e; }
.alert-info { background: var(--brand-50); border-color: #c9dcef; color: var(--brand-600); }

.report { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.report li { display: flex; gap: 6px; align-items: baseline; }
.report .ok { color: var(--ok); font-weight: 700; }
.report .ko { color: var(--danger); font-weight: 700; }
.report .msg { color: var(--muted); font-size: 12px; word-break: break-word; }
.report li.fail { grid-column: 1 / -1; }

/* ---------- Fetch bar ---------- */
.fetchbar { display: grid; grid-template-columns: 1.1fr 1fr auto auto; gap: 10px; align-items: end; }
.fetchbar .field { margin-bottom: 0; }
@media (max-width: 900px) { .fetchbar { grid-template-columns: 1fr 1fr; } }
.fetch-status { margin-top: 10px; font-size: 13px; }
.fetch-status:empty { display: none; }
.fetch-status.loading { color: var(--muted); }
.fetch-status.ok { color: var(--ok); }
.fetch-status.error { color: var(--danger); font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

/* ---------- Image preview / price ---------- */
.img-preview {
  width: 100%; aspect-ratio: 1 / 1; max-height: 260px;
  border: 1px dashed var(--border); border-radius: 8px; background: #fafbfc;
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); font-size: 12px;
}
.img-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.discount-badge {
  display: inline-block; background: var(--accent-50); color: #33691e;
  border: 1px solid #c5e1a5; border-radius: 999px; padding: 2px 10px; font-weight: 700; font-size: 12px;
}
.discount-badge.bad { background: var(--danger-50); color: var(--danger); border-color: #f5c2c0; }

/* ---------- Channels ---------- */
.channels-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ch-group { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fbfcfd; }
.ch-group-title { display: flex; justify-content: space-between; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.ch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.ch-grid .check { font-size: 13px; }
.sites { display: flex; flex-direction: column; gap: 8px; }
.toggle-row { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ---------- Action bar ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(16, 24, 40, .06);
}
.actionbar-inner { max-width: 1400px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.actionbar .legend { color: var(--muted); font-size: 12px; }
.actionbar .legend .req::after { content: " *"; color: var(--danger); }

/* ---------- Table ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form { display: flex; gap: 8px; flex: 1; min-width: 260px; max-width: 520px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: 7px 14px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 13px; }
.seg a + a { border-left: 1px solid var(--border); }
.seg a.active { background: var(--brand); color: #fff; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.deals { width: 100%; border-collapse: collapse; font-size: 13px; }
table.deals th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: #f8fafc; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.deals td { padding: 9px 12px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
table.deals tbody tr:hover { background: #fafcff; }
table.deals tbody tr:last-child td { border-bottom: 0; }
.cell-actions { display: flex; gap: 4px; white-space: nowrap; }
.cell-actions form { margin: 0; }
.cell-title { font-weight: 600; }
.cell-title small { display: block; font-weight: 400; color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
.cell-price { white-space: nowrap; }
.cell-price .new { font-weight: 700; }
.cell-price .old { color: var(--muted); text-decoration: line-through; margin-left: 6px; font-size: 12px; }
.cell-url a { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.partner-logo { height: 22px; max-width: 70px; object-fit: contain; }
.code { font-family: ui-monospace, Consolas, monospace; background: #f1f5f9; border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.pill-ok { background: var(--ok-50); color: var(--ok); }
.pill-warn { background: var(--warn-50); color: var(--warn); }
.pill-off { background: #eef1f4; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); font-size: 13px; }
.pager .links { display: flex; gap: 6px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo { text-align: center; margin-bottom: 18px; }
.login-card .logo img { height: 140px; }
.login-card .card { padding: 26px; }
.login-card .btn { width: 100%; }
.login-note { color: var(--muted); font-size: 11px; text-align: center; margin-top: 14px; line-height: 1.5; }

[hidden] { display: none !important; }

input[type=date] { cursor: pointer; }

/* ---------- Post multiplo ---------- */
.bulk-input { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.bulk-input textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
@media (max-width: 900px) { .bulk-input { grid-template-columns: 1fr; } }
.bulk-table td { vertical-align: top; }
.bulk-table input[type=text] { padding: 6px 8px; }
.bulk-table .thumb { width: 52px; height: 52px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.bulk-table .num { font-weight: 700; color: var(--brand); padding-top: 14px; }
.bulk-table .sub { font-size: 11px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.bulk-table .sub a { color: var(--muted); }
.bulk-table .row-msg { font-size: 12px; margin-top: 4px; font-weight: 600; }
.bulk-table .row-msg.warn { color: var(--warn); }
.bulk-table .row-msg.err { color: var(--danger); }
.bulk-table tr.is-error td { background: #fff7f7; }
.bulk-table tr.is-error .thumb { opacity: .4; }
.bulk-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; padding-top: 4px; }
.bulk-table .counter-inline { font-size: 11px; color: var(--muted); float: right; margin-top: 3px; }
.bulk-table .counter-inline.over { color: var(--danger); font-weight: 700; }
.bulk-result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .bulk-result { grid-template-columns: 1fr; } }
.collage-box {
  min-height: 220px; border: 1px dashed var(--border); border-radius: 8px; background: #fafbfc;
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); font-size: 13px; position: relative;
}
.collage-box img { max-width: 100%; height: auto; display: block; }
.collage-box.loading::after {
  content: "Generazione in corso…"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .75); color: var(--text); font-weight: 600;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.tg-preview {
  background: #eef3f8; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 560px; overflow: auto;
}
.tg-preview a { color: #2481cc; text-decoration: none; font-weight: 600; }
.ok-flash { color: var(--ok) !important; }
.field > label.check { justify-content: flex-start; font-weight: 500; }

/* opzioni collage */
.collage-opts { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 12px; margin-bottom: 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; }
.collage-opts .opt { display: flex; align-items: center; gap: 8px; }
.collage-opts .opt-grow { flex: 1; min-width: 180px; }
.collage-opts .opt-grow input[type=range] { flex: 1; accent-color: var(--brand); }
.collage-opts .opt-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.collage-opts .opt-label b { color: var(--text); }
.collage-opts input[type=color] { width: 36px; height: 28px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; }
.collage-opts .seg a { padding: 4px 12px; }

.logout-form { margin: 0; display: inline; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--brand); cursor: pointer; }
.linklike:hover { text-decoration: underline; }
