/* Cliko Tools — estètica premium clara (Stripe/Apple), amb mode fosc opcional */
:root {
  --bg: #f7f8fc;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-hover: #fafbff;
  --border: #e7eaf3;
  --border-strong: #d8dded;
  --text: #16192c;
  --text-soft: #5a6178;
  --text-dim: #8f96ab;
  --accent: #5a5cf0;
  --accent-2: #9333ea;
  --accent-soft: #eef0ff;
  --ok: #0d9d6c;
  --warn: #c77b00;
  --fail: #dc3545;
  --info: #6366f1;
  --shadow: 0 1px 2px rgba(22, 25, 44, .05), 0 4px 16px rgba(22, 25, 44, .06);
  --shadow-lift: 0 2px 4px rgba(22, 25, 44, .06), 0 12px 32px rgba(22, 25, 44, .10);
  --radius: 14px;
  --grad: linear-gradient(120deg, #5a5cf0, #9333ea);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Inter", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d0f16;
  --bg-soft: #12151f;
  --card: #171b28;
  --card-hover: #1c2132;
  --border: #262c3e;
  --border-strong: #333a52;
  --text: #e9ebf4;
  --text-soft: #9aa3ba;
  --text-dim: #636b82;
  --accent: #7b8cff;
  --accent-2: #b06bff;
  --accent-soft: rgba(123, 140, 255, .13);
  --ok: #34d399;
  --warn: #fbbf24;
  --fail: #f87171;
  --shadow: none;
  --shadow-lift: 0 12px 32px rgba(0, 0, 0, .4);
  --grad: linear-gradient(120deg, #7b8cff, #b06bff);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 256px;
  min-width: 256px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-logo {
  font-size: 20px; width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--grad); border-radius: 12px;
  box-shadow: 0 4px 14px rgba(90, 92, 240, .35);
}
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { display: block; color: var(--text-dim); font-size: 11px; letter-spacing: .02em; }
.nav-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .13em;
  color: var(--text-dim); margin: 18px 10px 6px; font-weight: 600;
}
.nav-link {
  display: block; padding: 8px 11px; border-radius: 9px; color: var(--text-soft);
  text-decoration: none; font-size: 13.5px; margin-bottom: 2px; font-weight: 450;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.sidebar-footer {
  margin-top: auto; padding: 14px 8px 2px; color: var(--text-dim); font-size: 11.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.theme-toggle {
  border: 1px solid var(--border); background: var(--card); color: var(--text-soft);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px;
  transition: all .15s;
}
.theme-toggle:hover { border-color: var(--border-strong); transform: translateY(-1px); }

/* ---------- Main ---------- */
main { flex: 1; padding: 40px 48px 90px; max-width: 1240px; }
.tool { display: none; animation: fadein .28s ease; }
.tool.visible { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.tool-header { margin-bottom: 24px; max-width: 780px; }
.tool-header h1 {
  font-size: 27px; letter-spacing: -.03em; margin-bottom: 7px; font-weight: 700;
}
.tool-header p { color: var(--text-soft); font-size: 14.5px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1020px) {
  .grid-2 { grid-template-columns: 1fr; }
  main { padding: 26px 20px 60px; }
  .sidebar { width: 215px; min-width: 215px; }
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.row:first-child { margin-top: 0; }
.space-between { justify-content: space-between; }
.hint { color: var(--text-dim); font-size: 12.5px; }

/* ---------- Formularis ---------- */
input[type=text], input[type=number], textarea, select {
  background: var(--bg-soft); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 9px; padding: 9px 13px; font-family: inherit; font-size: 14px;
  width: 100%; transition: border-color .15s, box-shadow .15s;
}
.row > input[type=text] { flex: 1; width: auto; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; }
label { display: block; font-size: 12.5px; color: var(--text-soft); margin: 13px 0 5px; font-weight: 550; }
label:first-child { margin-top: 0; }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; margin-top: 10px; }
.check-label input { accent-color: var(--accent); width: 15px; height: 15px; }
select { cursor: pointer; width: auto; }
input[type=color] { width: 46px; height: 38px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--bg-soft); cursor: pointer; padding: 3px; }
.counter { float: right; color: var(--text-dim); font-weight: 400; }
.mini-details { margin-top: 12px; font-size: 13px; color: var(--text-soft); }
.mini-details summary { cursor: pointer; }
.mini-details input { margin-top: 8px; }

/* ---------- Botons ---------- */
.btn {
  border: 1px solid var(--border-strong); background: var(--card); color: var(--text);
  padding: 9px 18px; border-radius: 9px; font-size: 13.5px; font-weight: 550;
  cursor: pointer; font-family: inherit; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--text-dim); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary {
  background: var(--grad); border: none; color: #fff; padding: 10px 19px;
  box-shadow: 0 4px 14px rgba(90, 92, 240, .30);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 6px 18px rgba(90, 92, 240, .38); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--fail); }
.btn.sm { padding: 5px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: wait; transform: none; }

/* ---------- Resultats ---------- */
.loading { display: flex; align-items: center; gap: 12px; color: var(--text-soft); padding: 26px 22px; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-box {
  background: color-mix(in srgb, var(--fail) 7%, var(--card)); border: 1px solid color-mix(in srgb, var(--fail) 30%, transparent);
  color: var(--fail); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px;
}

.score-ring { display: flex; align-items: center; gap: 22px; }
.ring { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring-value { position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; font-weight: 700; }

.check-item {
  display: flex; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border);
  font-size: 14px; align-items: baseline;
}
.check-item:last-child { border-bottom: none; }
.check-item .st { font-size: 13px; min-width: 18px; font-weight: 700; }
.check-item .detail { color: var(--text-dim); font-size: 12.5px; display: block; }
.st-ok { color: var(--ok); } .st-warn { color: var(--warn); }
.st-fail { color: var(--fail); } .st-info { color: var(--info); }
.cat-title { font-size: 15px; margin: 4px 0 8px; display: flex; align-items: center; gap: 10px; font-weight: 650; }
.badge {
  font-size: 11px; padding: 2.5px 10px; border-radius: 20px; font-weight: 650;
  border: 1px solid var(--border); color: var(--text-soft);
}
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 9%, transparent); }
.badge.fail { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 30%, transparent); background: color-mix(in srgb, var(--fail) 8%, transparent); }

/* Prospecció i zona */
.prospect-card { margin-bottom: 12px; transition: box-shadow .2s, transform .2s; }
.prospect-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.prospect-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.prospect-score {
  font-size: 20px; font-weight: 750; width: 62px; height: 62px; border-radius: 14px;
  display: grid; place-items: center; flex-shrink: 0;
}
.prospect-domain { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.prospect-note { font-size: 12.5px; color: var(--text-soft); }
.prospect-issues { margin: 10px 0 0; padding-left: 4px; list-style: none; }
.prospect-issues li { font-size: 13px; color: var(--text-soft); padding: 2px 0; }
.prospect-issues li::before { content: "•"; color: var(--warn); margin-right: 8px; }
.prospect-contact { font-size: 12.5px; color: var(--accent); margin-top: 8px; font-weight: 500; }
.chip {
  display: inline-block; font-size: 11.5px; border: 1px solid var(--border);
  padding: 2.5px 10px; border-radius: 20px; color: var(--text-soft); margin: 2px 6px 2px 0;
  background: var(--bg);
}
.pitch-box {
  background: var(--bg); border: 1px dashed var(--border-strong); border-radius: 10px;
  padding: 14px 16px; margin-top: 12px; font-size: 13.5px; white-space: pre-wrap;
  color: var(--text-soft); line-height: 1.6;
}
.summary-strip { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 22px; box-shadow: var(--shadow); flex: 1; min-width: 130px;
}
.stat-tile .n { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.stat-tile .l { font-size: 12px; color: var(--text-dim); }

/* PSI */
.psi-scores { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 8px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.metric-tile { background: var(--bg); border: 1px solid var(--border); border-radius: 11px; padding: 12px 15px; }
.metric-tile .m-label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.metric-tile .m-value { font-size: 19px; font-weight: 700; margin-top: 2px; }

/* Codi generat */
.code-output {
  background: #14172a; border: 1px solid #262c4a; border-radius: 10px;
  padding: 15px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow-y: auto; color: #cdd6f9;
}
.code-output.tall { max-height: 640px; }
.preview-label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-dim); margin-bottom: 10px; font-weight: 650;
}

/* SERP + OG preview */
.serp { background: #fff; border: 1px solid #e7eaf3; border-radius: 12px; padding: 16px 18px; margin-bottom: 20px; display: block; }
.serp-url { color: #202124; font-size: 13px; display: block; font-family: arial, sans-serif; }
.serp-title { color: #1a0dab; font-size: 19px; display: block; margin: 3px 0; font-family: arial, sans-serif; cursor: pointer; }
.serp-title:hover { text-decoration: underline; }
.serp-desc { color: #4d5156; font-size: 13.5px; display: block; font-family: arial, sans-serif; }
.og-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg); }
.og-img {
  aspect-ratio: 1200/630; background: var(--bg); display: grid; place-items: center;
  color: var(--text-dim); font-size: 13px; background-size: cover; background-position: center;
  border-bottom: 1px solid var(--border);
}
.og-body { padding: 11px 15px; }
.og-site { font-size: 11px; color: var(--text-dim); text-transform: uppercase; display: block; }
.og-title { font-weight: 650; font-size: 14.5px; display: block; margin: 2px 0; }
.og-desc { font-size: 12.5px; color: var(--text-soft); display: block; }

/* Checklist */
.progress-wrap { position: relative; background: var(--bg); border-radius: 20px; height: 28px; margin-top: 16px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar { height: 100%; width: 0; background: var(--grad); transition: width .35s ease; border-radius: 20px; }
#cl-progress-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 650; }
.cl-group h3 { font-size: 14px; margin: 6px 0 8px; color: var(--accent); font-weight: 650; }
.cl-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.cl-item:hover { background: var(--bg); }
.cl-item input { accent-color: var(--ok); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.cl-item.done span { text-decoration: line-through; color: var(--text-dim); }

/* Pressupost */
.items-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.items-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); padding: 6px 8px; border-bottom: 1px solid var(--border-strong); font-weight: 650; }
.items-table td { padding: 5px 4px; }
.items-table input { padding: 7px 10px; font-size: 13.5px; }
.items-table .import-cell { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; padding-right: 10px; }
.del-item { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px; }
.del-item:hover { color: var(--fail); }
.totals { text-align: right; margin-top: 14px; font-size: 14px; color: var(--text-soft); }
.totals .grand { font-size: 21px; font-weight: 750; color: var(--text); letter-spacing: -.01em; }

/* Contrast */
.contrast-preview { border-radius: 12px; padding: 26px; border: 1px solid var(--border); }
.contrast-preview h2 { font-size: 22px; margin-bottom: 8px; }
.contrast-preview .small-text { font-size: 12px; margin-top: 8px; }
.ratio-big { font-size: 36px; font-weight: 750; margin: 16px 0 4px; letter-spacing: -.02em; }
.wcag-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Monitor */
.mon-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.mon-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 15%, transparent); }
.mon-name { font-weight: 650; font-size: 15px; }
.mon-url { font-size: 12px; color: var(--text-dim); }
.mon-stats { display: flex; gap: 20px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.mon-stat { text-align: center; }
.mon-stat .v { font-weight: 700; font-size: 15px; }
.mon-stat .k { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.mon-bars { display: flex; gap: 2px; align-items: flex-end; height: 30px; margin-top: 12px; width: 100%; }
.mon-bars span { flex: 1; max-width: 8px; border-radius: 2px; min-height: 6px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--text); color: var(--bg-soft);
  padding: 11px 22px; border-radius: 11px; font-size: 13.5px; opacity: 0;
  transition: all .25s ease; pointer-events: none; z-index: 99; box-shadow: var(--shadow-lift);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Impressió del pressupost */
.print-only { display: none; }
@media print {
  body > *:not(#pr-print-area), .sidebar, main { display: none !important; }
  .print-only { display: block !important; }
  #pr-print-area { display: block; color: #111; font-family: Georgia, serif; padding: 20px; }
  html { color-scheme: light; }
  body { background: #fff; display: block; }
}

/* ---------- Generador de campanyes ---------- */
.camp-types {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 8px 0 4px;
}
.camp-card {
  font: inherit;
  text-align: left;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.camp-card:hover { border-color: var(--text-dim); transform: translateY(-1px); box-shadow: var(--shadow); }
.camp-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.camp-card .camp-icon { font-size: 22px; }
.camp-card small { color: var(--text-soft); font-size: 12px; line-height: 1.4; }
.camp-audiences { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.camp-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.camp-variacio h3 { font-size: 16px; }
.camp-seccio { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.camp-seccio h4 { font-size: 13.5px; margin-bottom: 4px; color: var(--text-soft); text-transform: none; }
.camp-seccio p { white-space: normal; }
.camp-viral { background: var(--accent-soft); border: none; border-radius: 10px; padding: 12px 14px; }
