/* Amazing Tracker — design system condiviso (web app e backoffice).
   Minimalista: superfici neutre, un solo colore d'accento, bordi sottili, numeri tabulari. */

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f3f5;
  --text: #16181d;
  --muted: #6a7080;
  --faint: #9aa0ad;
  --border: #e6e7eb;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --good: #0f8a5f;
  --good-soft: #e7f6ef;
  --bad: #c43d32;
  --bad-soft: #fcecea;
  --warn: #a96500;
  --warn-soft: #fdf3e2;
  --radius: 10px;
  --radius-sm: 6px;
  --gap: 16px;
  --shadow: 0 1px 2px rgb(16 24 40 / 4%);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --surface: #161920;
    --surface-2: #1d2129;
    --text: #e8eaef;
    --muted: #99a0b0;
    --faint: #6b7282;
    --border: #262b35;
    --accent: #8b85ff;
    --accent-soft: #23224a;
    --good: #3ccf95;
    --good-soft: #12301f;
    --bad: #ff7a70;
    --bad-soft: #3a1a18;
    --warn: #f0b048;
    --warn-soft: #36280f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.num, .price, .kpi b, td.num { font-variant-numeric: tabular-nums; }

/* --- layout ------------------------------------------------------------------------------------ */

main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: var(--gap); }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.grid { display: grid; gap: var(--gap); }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
@media (max-width: 900px) { .grid.two, .grid.side { grid-template-columns: 1fr; } }

/* --- barra superiore --------------------------------------------------------------------------- */

.topbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 20px; align-items: center; height: 52px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 750; color: var(--text); display: flex; gap: 8px; align-items: center; }
.topbar .brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: var(--muted); padding: 6px 10px; border-radius: var(--radius-sm); }
.topbar nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topbar nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.user { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }

/* --- pannelli ---------------------------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card > h2, .card-head { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 14px 16px 0; }

/* --- controlli --------------------------------------------------------------------------------- */

input, select, textarea, button { font: inherit; }
input, select, textarea { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; min-height: 96px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { height: 16px; width: 16px; accent-color: var(--accent); }
button { height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--accent);
  color: #fff; font-weight: 500; cursor: pointer; white-space: nowrap; transition: filter .15s, background .15s; }
button:hover { filter: brightness(1.06); }
button:disabled { opacity: .5; cursor: default; filter: none; }
button.ghost, button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
button.ghost:hover, button.secondary:hover { background: var(--surface-2); }
button.danger, button.secondary.danger { background: var(--surface); color: var(--bad); border-color: var(--border); }
button.danger:hover { background: var(--bad-soft); }
button.link { background: none; color: var(--accent); padding: 0; height: auto; border: 0; }
button.small, select.small, input.small { height: 28px; font-size: 13px; padding: 0 10px; }
.search { width: 100%; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

/* --- testi e stati ----------------------------------------------------------------------------- */

.hint, .muted { color: var(--muted); }
.hint { font-size: 13px; }
.faint { color: var(--faint); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.error, .ko { color: var(--bad); }
.ok { color: var(--good); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.active { background: var(--good-soft); color: var(--good); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.error { background: var(--bad-soft); color: var(--bad); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.mp { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--surface-2); font-size: 11px; font-weight: 700; color: var(--muted); }
.meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; }

/* --- KPI --------------------------------------------------------------------------------------- */

.stats, .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stats > div, .kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); }
.stats small, .kpi small { color: var(--muted); font-size: 12px; }
.stats b, .kpi b { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.stats small + small { font-size: 11px; }

/* --- tabelle ----------------------------------------------------------------------------------- */

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 12px; font-weight: 500; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.title { max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- prodotti ---------------------------------------------------------------------------------- */

.thumb { width: 48px; height: 48px; flex: none; display: grid; place-items: center; background: #fff; border-radius: var(--radius-sm);
  border: 1px solid var(--border); overflow: hidden; }
.thumb img { max-width: 90%; max-height: 90%; object-fit: contain; }
.thumb.big { width: 100%; height: 220px; border: 0; background: #fff; border-radius: var(--radius); }
.list { display: flex; flex-direction: column; }
.listing { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--border); color: inherit; }
.listing:first-child { border-top: 0; }
.listing:hover { background: var(--surface-2); text-decoration: none; }
.info { flex: 1; min-width: 0; }
.title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { text-align: right; font-weight: 600; font-size: 16px; white-space: nowrap; }
.price small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.price.good { color: var(--good); }

/* scheda prodotto nelle griglie */
.tile { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; color: inherit; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); text-decoration: none; transform: translateY(-1px); }
.tile .img { height: 150px; display: grid; place-items: center; background: #fff; }
.tile .img img { max-width: 80%; max-height: 130px; object-fit: contain; }
.tile .body { display: flex; flex-direction: column; gap: 6px; padding: 12px; flex: 1; }
.tile .name { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.tile .foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: auto; }
.tile .foot b { font-size: 17px; font-variant-numeric: tabular-nums; }
.tile .foot b.good { color: var(--good); }

/* pagina prodotto */
.product-head { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; }
.product-head h1 { font-size: 18px; line-height: 1.35; }
.current { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin: 10px 0 2px; font-variant-numeric: tabular-nums; }
form.watch, form.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.watch input { width: 120px; }
form.add { display: flex; gap: 8px; }
form.add input { flex: 1; }
@media (max-width: 700px) { .product-head { grid-template-columns: 1fr; } form.add { flex-direction: column; } }

/* --- grafico ----------------------------------------------------------------------------------- */

.chart { width: 100%; height: 280px; display: block; }
.chart .axis { stroke: var(--border); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--accent-soft); stroke: none; }
.chart .dots circle { fill: var(--accent); }
.chart .target { stroke: var(--good); stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.chart .tick { fill: var(--faint); font-size: 11px; }
.chart .target-label { fill: var(--good); }

/* --- login ------------------------------------------------------------------------------------- */

.login { max-width: 380px; margin: 14vh auto; padding: 28px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); }
.login h1 { font-size: 22px; }
.login p { color: var(--muted); margin: 6px 0 18px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login button { width: 100%; }

.chart { height: auto; }
.ranges { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-2); border-radius: var(--radius-sm); }
.ranges button { border: 0; background: transparent; color: var(--muted); }
.ranges button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
ul.bullets { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
ul.bullets li { margin: 4px 0; }

/* --- embed (iframe dell'estensione) -------------------------------------------------------------- */
main.embed { max-width: none; padding: 12px 14px; }
html:has(main.embed), body:has(main.embed) { background: var(--surface); }
.embed-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.embed-head .brand { font-weight: 700; color: var(--text); }
.embed-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.embed-price { font-size: 22px; font-weight: 700; margin-right: 8px; font-variant-numeric: tabular-nums; }
.embed-stats { grid-template-columns: repeat(3, 1fr); margin: 8px 0; }
.embed-stats b { font-size: 15px; }
.embed-empty { text-align: center; padding: 16px 0; }
.embed-login { margin: 8px 0 0; }
main.embed .chart { max-height: 220px; }

/* --- acquisto e footer ---------------------------------------------------------------------------- */
a.button { display: inline-flex; align-items: center; height: 36px; padding: 0 16px; border-radius: var(--radius-sm);
  background: #ffd814; color: #0f1111; font-weight: 600; text-decoration: none; }
a.button:hover { filter: brightness(0.97); text-decoration: none; }
.buy { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.buy .hint { font-size: 12px; max-width: 460px; }
.site-footer { max-width: 1200px; margin: 0 auto; padding: 16px 24px 32px; display: flex; gap: 16px; justify-content: space-between;
  flex-wrap: wrap; color: var(--faint); font-size: 12px; border-top: 1px solid var(--border); }

/* --- accesso con i provider social ----------------------------------------------------------------- */
.providers { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 16px; }
.provider { display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 500; text-decoration: none; }
.provider:hover { background: var(--surface-2); text-decoration: none; }
.provider-google::before { content: "G"; font-weight: 700; color: #4285f4; }
.dev-hint { margin: 4px 0 8px; }

/* --- documenti legali ------------------------------------------------------------------------------ */
.legal { max-width: 760px; margin: 0 auto; line-height: 1.6; }
.legal h2 { margin-top: 20px; font-size: 16px; }
.legal ul { padding-left: 20px; }
.legal-links { display: inline-flex; gap: 12px; }
.legal-links a { color: inherit; }

/* --- offerte e coupon ------------------------------------------------------------------------------ */
.promos { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.badge.deal { background: #cc0c39; color: #fff; }
.badge.coupon { background: #e6f4ea; color: #137333; }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.effective { color: #137333; font-weight: 600; }
.chart .deal-band { fill: #cc0c39; opacity: .08; }
.chart .line.effective { stroke: #137333; stroke-dasharray: 4 3; fill: none; }
