/* YoSelling */
:root {
  --bg: #F6F6F4;
  --surface: #FFFFFF;
  --ink: #16181D;
  --ink-2: #3A3D45;
  --muted: #73767E;
  --line: #E6E6E2;
  --line-2: #D9D9D4;
  --ok: #32CC77;
  --ok-bg: #EAF9F1;
  --warn: #ff4f31;
  --warn-bg: #FFF0ED;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22,24,29,.04), 0 4px 16px rgba(22,24,29,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.02em; font-weight: 700; }
h2 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.ic { flex: none; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Topbar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 2px; }
.brand-mark { background: var(--ink); color: #fff; border-radius: 7px; padding: 1px 6px 2px; margin-right: 1px; }
.brand.big { font-size: 26px; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: 14px; white-space: nowrap; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--ink); color: #fff; }
.who { display: flex; align-items: center; gap: 8px; }
.who-name { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }

/* ---------- Layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title p { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 500; font-size: 14px; margin-bottom: 16px; }
.back:hover { color: var(--ink); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-size: 28px; letter-spacing: -0.02em; font-weight: 700; }
.stat span { color: var(--muted); font-size: 13px; }

/* ---------- Flash ---------- */
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash-ok { background: var(--ok-bg); border-color: #bfeed4; color: #145c35; }
.flash-warn { background: var(--warn-bg); border-color: #ffd0c6; color: #8f2410; }
.flash-info { background: #F2F2F0; border-color: var(--line-2); color: var(--ink-2); }
.flash code, .cred code { font-family: ui-monospace, Menlo, monospace; background: rgba(0,0,0,.06); padding: 2px 6px; border-radius: 6px; font-size: 14px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.form label, .lbl { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea {
  font: inherit; font-size: 15px; font-weight: 400; color: var(--ink);
  background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(22,24,29,.08); }
input[type=color] { width: 52px; height: 42px; padding: 3px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; cursor: pointer; }
input[type=file] { font-size: 14px; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; grid-template-columns: none !important; }
.check input { width: 17px; height: 17px; accent-color: var(--ink); }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.inline-form { display: inline; }
.input-group { display: flex; gap: 6px; }

.dropzone { border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); background: #FBFBFA; position: relative; }
.dropzone.drag { border-color: var(--ink); background: #F2F2F0; color: var(--ink); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .dz-files { color: var(--ink); font-weight: 500; margin-top: 6px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; font-size: 14px; border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2A2D35; }
.btn-ghost { background: #fff; border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: #fff; border-color: #ffd0c6; color: #c0391f; }
.btn-danger:hover { background: var(--warn-bg); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; width: 32px; height: 32px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.badge-new { background: var(--warn); color: #fff; }
.badge-off { background: var(--ink); color: #fff; }
.badge-ok { background: var(--ok-bg); color: #16733f; }
.badge-muted { background: #EEEEEB; color: var(--ink-2); }
.product-logo .badge { position: absolute; top: 12px; right: 12px; }
.product-logo .badge-off { left: 12px; right: auto; }

/* ---------- Product grid ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.product-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s, border-color .18s; display: flex; flex-direction: column; }
.product-card:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: 0 2px 4px rgba(22,24,29,.05), 0 12px 32px rgba(22,24,29,.09); }
.product-logo { position: relative; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; padding: 26px 34px; }
.product-logo img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.product-initial { font-size: 54px; font-weight: 700; color: rgba(22,24,29,.25); letter-spacing: -0.03em; }
.product-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.product-meta > div { display: grid; min-width: 0; }
.product-meta strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-meta .count { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 13px; white-space: nowrap; }

.product-hero { display: grid; grid-template-columns: 220px 1fr auto; gap: 24px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 28px; box-shadow: var(--shadow); }
.product-logo.small { border-radius: 12px; padding: 18px 24px; }
.product-hero p { margin: 0; }
.product-hero .desc { margin-top: 8px; color: var(--ink-2); max-width: 70ch; }
.hero-edit { align-self: start; }

.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 26px 0 10px; }
.doc-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.doc-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); transition: background .12s; }
.doc-row:first-child { border-top: 0; }
.doc-row:hover { background: #FAFAF8; }
.doc-ic { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: #F2F2F0; color: var(--ink-2); flex: none; }
.doc-main { flex: 1; display: grid; min-width: 0; }
.doc-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-open { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); display: grid; justify-items: center; gap: 8px; }
.empty p { margin: 0 0 6px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.cell-strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ev { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.ev::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.ev-view_doc::before { background: var(--ink); }
.ev-login::before { background: var(--ok); }
.ev-login_fail::before { background: var(--warn); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filters select, .filters input { padding: 8px 10px; font-size: 14px; min-width: 150px; }
.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; align-items: center; }

.sortable-row { cursor: default; }
.thumb { width: 64px; height: 36px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; padding: 4px 8px; border: 1px solid var(--line); }
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.edit-title { border: 1px solid transparent !important; background: transparent !important; padding: 6px 8px !important; font-weight: 600 !important; }
.edit-title:hover { border-color: var(--line-2) !important; background: #fff !important; }
.edit-title:focus { background: #fff !important; border-color: var(--ink) !important; }
.mini-input { width: 64px !important; padding: 6px 8px !important; text-align: center; }
.cat-input { width: 150px !important; padding: 6px 8px !important; }

.cred { background: #F2F2F0; border-radius: 12px; padding: 14px 16px; display: grid; gap: 6px; font-size: 14px; }

/* ---------- Auth ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #ECECE8, var(--bg)); }
.auth-wrap { width: 100%; padding: 20px; display: flex; justify-content: center; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: 0 2px 6px rgba(22,24,29,.04), 0 24px 60px rgba(22,24,29,.08); }
.auth-card .brand { margin-bottom: 4px; }
.auth-card > p.muted { margin: 0 0 22px; }
.checks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; font-size: 14px; }
.checks li { display: flex; align-items: center; gap: 8px; }
.checks .dot { width: 8px; height: 8px; border-radius: 50%; }
.checks .ok .dot { background: var(--ok); }
.checks .ko .dot { background: var(--warn); }
.checks .ko { color: #8f2410; font-weight: 600; }

/* ---------- Viewer ---------- */
body.viewer-body { background: #2A2C31; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.viewer-main { height: 100vh; display: flex; flex-direction: column; }
.viewer-bar { height: 58px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: #1B1C20; color: #fff; border-bottom: 1px solid #000; }
.viewer-title { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.viewer-title strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-title span { font-size: 12px; color: #9A9DA5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-tools { display: flex; align-items: center; gap: 4px; }
.icon-btn.light { color: #D5D6DA; }
.icon-btn.light:hover { background: #2E3036; color: #fff; }
.pager { font-size: 13px; color: #C5C7CC; padding: 0 8px; font-variant-numeric: tabular-nums; min-width: 60px; text-align: center; }
.lock-hint { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #9A9DA5; margin-left: 8px; padding: 6px 10px; border: 1px solid #34363C; border-radius: 999px; }
.stage { flex: 1; overflow: auto; position: relative; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 16px 40px; min-width: min-content; }
.page-holder { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.35); position: relative; flex: none; }
.page-holder .page-canvas { width: 100%; height: 100%; display: block; }
.page-canvas { display: block; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.35); pointer-events: none; }
.loading { color: #C5C7CC; display: flex; align-items: center; justify-content: center; gap: 10px; height: 100%; font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid #4A4C52; border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.video-wrap { position: relative; max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.video-wrap video { width: 100%; border-radius: 10px; background: #000; display: block; }
.wm-overlay { position: absolute; inset: 0 16px 56px; pointer-events: none; overflow: hidden; display: flex; flex-wrap: wrap; align-content: space-around; justify-content: space-around; transform: rotate(-12deg) scale(1.2); opacity: .16; }
.wm-overlay span { color: #fff; font-size: 13px; font-weight: 600; padding: 18px 26px; white-space: nowrap; }

@media print {
  body * { display: none !important; }
  body::after { content: "Stampa non consentita"; display: block; padding: 40px; font: 20px sans-serif; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-hero { grid-template-columns: 1fr; }
  .product-hero .product-logo.small { max-width: 260px; }
  .hero-edit { justify-self: start; }
}
@media (max-width: 720px) {
  .topbar-in { gap: 12px; padding: 0 12px; }
  .nav a span { display: none; }
  .nav a { padding: 8px 10px; }
  .who-name { display: none; }
  .wrap { padding: 20px 16px 48px; }
  .form .row { grid-template-columns: 1fr; }
  .lock-hint { display: none; }
  h1 { font-size: 22px; }
  .doc-open { display: none; }
}
