﻿/* panell.css — estètica neta inspirada en gold standard NDF.
   Light + dark via [data-theme]. Variables per facilitar tweaks. */

:root {
  /* Càlid pro — beige/sand neutre, accent teal modern */
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #efeae0;
  --surface-3: #e7e2d6;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --muted: #78716c;
  --line: #e7e1d4;
  --line-strong: #d4cdbc;
  --accent: #0d9488;          /* teal-600 */
  --accent-soft: #ccfbf1;     /* teal-100 */
  --accent-strong: #0f766e;   /* teal-700 */
  --brand: #0d9488;
  --pending: #a8a29e;
  --progress: #d97706;
  --done: #059669;
  --na: #94a3b8;
  --blocked: #dc2626;
  --shadow-xs: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.06), 0 1px 2px rgba(28, 25, 23, 0.03);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.08), 0 2px 4px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 12px 32px rgba(28, 25, 23, 0.10), 0 4px 8px rgba(28, 25, 23, 0.05);
  --shadow: var(--shadow-sm);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;
  --font: ui-sans-serif, -apple-system, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --ring: 0 0 0 3px rgba(13, 148, 136, 0.25);
}

[data-theme="dark"] {
  --bg: #0c0a09;
  --surface: #1c1917;
  --surface-2: #292524;
  --surface-3: #3a342f;
  --ink: #fafaf9;
  --ink-soft: #e7e1d4;
  --muted: #a8a29e;
  --line: #292524;
  --line-strong: #44403c;
  --accent: #14b8a6;          /* teal-500 (més brillant sobre fons fosc) */
  --accent-soft: #134e4a;     /* teal-900 */
  --accent-strong: #2dd4bf;   /* teal-400 */
  --brand: #14b8a6;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);
  --shadow: var(--shadow-sm);
  --ring: 0 0 0 3px rgba(20, 184, 166, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  scrollbar-gutter: stable;
}

a { color: var(--accent); text-decoration: none; font-weight: 500; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }

button { font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
button:focus-visible, a:focus-visible, .chip:focus-visible { box-shadow: var(--ring); }

/* ─── Icones SVG ─── */
.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  vertical-align: -3px;
}
.icon-sm { width: 14px; height: 14px; stroke-width: 2; vertical-align: -2px; }
.icon-lg { width: 22px; height: 22px; stroke-width: 1.5; }
.icon-xl { width: 28px; height: 28px; stroke-width: 1.5; }

/* Evita el zoom automàtic d'iOS Safari quan es focus un input amb
   font-size < 16px. Mínim 16px només en viewports mòbil. */
@media screen and (max-width: 768px) {
  input[type="text"], input[type="search"], input[type="email"],
  input[type="number"], input[type="tel"], input[type="url"],
  input[type="password"], textarea, select {
    font-size: 16px;
  }
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ─── Top bar ──────────────────────────────────────────────── */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: nowrap;
  box-shadow: var(--shadow-xs);
}
.topbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: nowrap; min-width: 0; }
.topbar-left .brand { align-self: center; }
.topbar-right { display: flex; gap: 4px; flex-wrap: nowrap; flex-shrink: 0; }
.brand-logo { width: 36px; height: 36px; border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); flex-shrink: 0; }
.topbar-offline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(217, 119, 6, 0.13);
  color: var(--progress);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--progress);
}
.brand {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.btn {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 16px;
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .05s ease;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-secondary {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-strong);
  font-weight: 600;
}
.btn-secondary:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); filter: brightness(0.97); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; padding: 9px 12px; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }
.btn-icon { padding: 9px; min-width: 38px; min-height: 38px; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Project chips ────────────────────────────────────────── */
#projects {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 16px 20px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.chip:hover { background: var(--surface-2); color: var(--ink); }
.chip-active {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  font-weight: 600;
}
.chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.chip-family {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.chip-active .chip-family { background: var(--bg); }

/* ─── Top bar selectors (General + Project dropdown) ────────────────── */
#projects { display: none; }  /* deprecat: chips ara al top bar */

.topbar-env-segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
  margin-left: 8px;
}
.topbar-env-btn {
  background: transparent;
  color: var(--ink-soft);
  border: none;
  padding: 7px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .15s ease, color .15s ease;
}
.topbar-env-btn:hover { background: var(--surface); color: var(--ink); }
.topbar-env-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.topbar-env-active:hover { background: var(--surface); color: var(--ink); }
.env-icon { display: inline-flex; align-items: center; }

.topbar-general { font-weight: 600; margin-left: 4px; }
.topbar-general-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.topbar-general-active:hover { background: var(--ink); color: var(--surface); border-color: var(--ink); }
[data-theme="dark"] .topbar-general-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ─── Scope segmented (General | Projecte ▾) ──────────────── */
.topbar-scope-segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
  margin-left: auto;            /* l'empenyem a la dreta */
}
.topbar-scope-btn {
  background: transparent;
  color: var(--ink-soft);
  border: none;
  padding: 7px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .15s ease, color .15s ease;
}
.topbar-scope-btn:hover { background: var(--surface); color: var(--ink); }
.topbar-scope-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.topbar-scope-active:hover { background: var(--surface); color: var(--ink); }

/* Dropdown del projecte: dins el grup, mateix llenguatge visual */
.topbar-scope-segmented .topbar-projsel { margin-left: 0; }
.topbar-scope-segmented .topbar-projsel-trigger {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 7px 14px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 14px;
  min-width: 140px;
  transition: background .15s ease, color .15s ease;
}
.topbar-scope-segmented .topbar-projsel-trigger:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: transparent;
}
/* Quan hi ha projecte actiu (no General) */
.topbar-scope-segmented .topbar-projsel-trigger.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  border-color: transparent;
  box-shadow: var(--shadow-xs);
}
.topbar-scope-segmented .topbar-projsel-trigger.active:hover {
  background: var(--surface);
  filter: none;
  color: var(--ink);
}
.topbar-scope-segmented .topbar-projsel-trigger.active .chip-dot {
  background: var(--accent) !important;
  border: none;
}

/* ─── Mobile: amaga labels, mostra només icones ─── */
@media (max-width: 720px) {
  #topbar { padding: 10px 12px; gap: 8px; }
  .topbar-left { gap: 8px; }
  .brand { display: none; }                /* el logo ja identifica */
  .brand-logo { width: 32px; height: 32px; }

  /* Env + Scope: tots els labels amagats, només icones */
  .topbar-env-segmented,
  .topbar-scope-segmented { padding: 2px; gap: 1px; margin-left: 0; }
  .topbar-env-btn,
  .topbar-scope-btn,
  .topbar-scope-segmented .topbar-projsel-trigger { padding: 8px 10px; min-width: 0; gap: 0; }
  .btn-label { display: none; }

  /* Empenyem el scope-segmented a la dreta amb auto-margin */
  .topbar-scope-segmented { margin-left: auto; }

  /* La fletxa del dropdown segueix visible per indicar interactivitat */
  .topbar-scope-segmented .topbar-projsel-trigger { gap: 4px; }
  .projsel-caret { margin-left: 2px; }

  /* Indicador offline més compacte */
  .topbar-offline { padding: 3px 8px; font-size: 11px; }
  .topbar-offline .icon { width: 12px; height: 12px; }

  /* Icona del settings més tocable */
  .btn-icon { padding: 8px; min-width: 36px; min-height: 36px; }
}

/* Pantalles molt petites: amaguem el text "Offline" si està */
@media (max-width: 480px) {
  .topbar-offline span:not(.icon) { display: none; }
}

.topbar-projsel { position: relative; display: inline-block; margin-left: 4px; }
.topbar-projsel-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  min-width: 150px; justify-content: flex-start; font-weight: 600;
}
.topbar-projsel-trigger.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.topbar-projsel-trigger.active:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}
.topbar-projsel-trigger.active .chip-dot {
  background: rgba(255,255,255,0.95) !important;
  border: 1px solid rgba(255,255,255,0.4);
}
.projsel-caret { margin-left: auto; opacity: 0.7; display: inline-flex; align-items: center; transition: transform .15s ease; }
.projsel-caret.projsel-caret-open { transform: rotate(180deg); }
.topbar-projsel-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 260px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 100; padding: 6px;
}
.projsel-item { display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: none; background: none; cursor: pointer;
  border-radius: var(--radius-sm); font: inherit; color: var(--ink); text-align: left;
  font-size: 14px; transition: background .12s; }
.projsel-item:hover { background: var(--surface-2); }
.projsel-item-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.projsel-item-name { flex: 1; }
.projsel-item-family { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.tab-project-only { /* Visual diferencial subtil; opcional */ }

/* ─── Tabs ─────────────────────────────────────────────────── */
#tabs {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 65px;
  z-index: 9;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab {
  background: transparent;
  border: none;
  padding: 14px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab-active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tab .icon { width: 16px; height: 16px; }

/* ─── Section headers (consistent across views) ─── */
.settings-h3,
.view-h2,
.view-h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-weight: 600;
}
.settings-h3 { font-size: 16px; }
.view-h2 { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.02em; }
.view-h3 { font-size: 16px; margin: 0 0 10px; }
.settings-h3 .icon,
.view-h2 .icon,
.view-h3 .icon { color: var(--accent); }
.view-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 16px; }

/* ─── Progress bar ─────────────────────────────────────────── */
#progress-bar {
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
#progress-bar:empty { display: none; }
.pbar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.pbar-fill {
  height: 100%;
  background: var(--done);
  transition: width .3s ease;
}
.pbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.pbar-pct { font-weight: 700; color: var(--ink); }

/* ─── Caixa de cerca ────────────────────────────────────────── */
.search-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.search-input {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 14px 10px 38px;
  font-size: 14px;
  color: var(--ink);
  width: 280px;
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, width .2s, background .15s;
  /* Icona de cerca inline com a background-image SVG */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a8a29e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px 16px;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  width: 320px;
}
.search-input::placeholder { color: var(--muted); font-weight: 400; }
.search-clear {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  width: 24px; height: 24px;
  font-size: 16px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover {
  background: rgba(220,38,38,0.1);
  color: var(--blocked);
  border-color: var(--blocked);
}
.search-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  font-size: 14px;
}
/* Highlight de coincidències de cerca dins de cel·les / files */
mark.hl {
  background: #fde68a;          /* amber-200 */
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
  font-weight: 600;
}
[data-theme="dark"] mark.hl {
  background: #92400e;          /* amber-800 */
  color: #fef3c7;
}
.search-empty p { margin: 0 0 12px; }
/* La progress bar ha de fluir bé amb la cerca dins */
.pbar-meta { flex-wrap: wrap; }

/* ─── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 4px;
}
.badge-pending  { background: rgba(168,162,158,.18); color: var(--ink-soft); }
.badge-progress { background: rgba(245,158,11,.16); color: var(--progress); }
.badge-blocked  { background: rgba(220,38,38,.16); color: var(--blocked); }

/* ─── Content / categories ─────────────────────────────────── */
#content {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}
.cat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.cat-head {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--surface);
  border: none;
  padding: 14px 16px;
  cursor: pointer;
  color: var(--ink);
  text-align: left;
  border-bottom: 1px solid var(--line);
  transition: background .15s;
}
.cat-head:hover { background: var(--surface-2); }
.cat-head.collapsed { border-bottom: none; }
.caret {
  width: 18px;
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  transition: transform .15s ease;
}
.caret.caret-collapsed { transform: rotate(-90deg); }
.cat-title {
  font-weight: 600;
  flex: 1;
  font-size: 15px;
}
.cat-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.cat-pct { font-weight: 600; min-width: 50px; text-align: right; }
.mini-pbar {
  display: inline-block;
  width: 80px;
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.mini-pbar-fill {
  display: block;
  height: 100%;
  background: var(--done);
  transition: width .25s;
}
.cat-body { padding: 4px 0; }
.cat-body.hidden { display: none; }

/* ─── Items ────────────────────────────────────────────────── */
.item {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  align-items: flex-start;
}
.item:first-child { border-top: none; }
.item-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.item-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
}
.item-na .item-text { color: var(--muted); text-decoration: line-through; }
.note-input {
  background: transparent;
  border: 1px dashed transparent;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--ink-soft);
  width: 100%;
  max-width: 100%;
  outline: none;
  transition: border-color .15s, background .15s;
}
.note-input:hover, .note-input:focus {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
}
.note-input::placeholder { color: var(--muted); font-style: italic; }
.stamp { font-size: 10px; color: var(--muted); }

/* ─── Status button ────────────────────────────────────────── */
.status-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid;
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s, background .15s;
  flex-shrink: 0;
  margin-top: 2px;
}
.status-btn:hover { transform: scale(1.08); }
.status-btn:active { transform: scale(.95); }
.status-pending  { color: var(--pending); border-color: var(--pending); }
.status-progress { color: var(--progress); border-color: var(--progress); background: rgba(245,158,11,.06); }
.status-done     { color: var(--done); border-color: var(--done); background: rgba(22,163,74,.08); }
.status-na       { color: var(--na); border-color: var(--na); background: var(--surface-2); }
.status-blocked  { color: white; border-color: var(--blocked); background: var(--blocked); }

/* ─── Summary ──────────────────────────────────────────────── */
.summary-intro {
  color: var(--ink-soft);
  margin: 0 0 16px;
  font-size: 14px;
}
.summary-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.summary-table th {
  background: var(--surface-2);
  padding: 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
.summary-table th.th-project { width: 200px; }
.summary-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.summary-table tbody tr {
  cursor: pointer;
  transition: background .15s;
}
.summary-table tbody tr:hover { background: var(--surface-2); }
.summary-table tbody tr:last-child td { border-bottom: none; }
.td-project {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.td-total { font-weight: 700; }
.cell-pct { font-size: 16px; font-weight: 700; }
.cell-meta { font-size: 11px; color: var(--ink-soft); }
.cell-blocked { color: var(--blocked); font-weight: 600; }
.cell-heat-1 { background: rgba(220,38,38,.06); }
.cell-heat-2 { background: rgba(245,158,11,.08); }
.cell-heat-3 { background: rgba(234,179,8,.08); }
.cell-heat-4 { background: rgba(22,163,74,.06); }
.cell-heat-5 { background: rgba(22,163,74,.12); }

.alerts-title {
  font-size: 16px;
  margin: 24px 0 12px;
  color: var(--blocked);
}
.alerts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.alert {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blocked);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.alert:hover { background: var(--surface-2); transform: translateX(2px); }
.alert-proj {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.alert-text { font-size: 14px; color: var(--ink); }
.alert-note {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
}

/* ─── Today: dashboard d'urgències ────────────────────────── */
.today-intro { margin-bottom: 24px; }
.today-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.today-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}
.today-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.today-section-urgent  { border-left-color: var(--blocked); }
.today-section-progress{ border-left-color: var(--progress); }
.today-section-bugs    { border-left-color: var(--blocked); }
.today-section-overdue { border-left-color: var(--brand); }

.today-sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.today-sec-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.today-sec-count {
  background: var(--surface-2);
  color: var(--ink-soft);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.today-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.today-item {
  display: grid;
  grid-template-columns: 100px 130px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .15s, background .15s, transform .1s;
}
.today-item:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateX(2px);
}
/* Quan està dins un block per projecte, sense la columna projecte */
.today-list-byproject .today-item {
  grid-template-columns: 28px 130px 1fr auto;
}
.today-list-byproject { gap: 6px; margin-top: 8px; }

/* Pill de bucket dins l'item (urgent/progress/bug/overdue) */
.today-bucket-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
}
.today-bucket-urgent { background: rgba(220,38,38,0.15); color: var(--blocked); }
.today-bucket-progress { background: rgba(217,119,6,0.15); color: var(--progress); }
.today-bucket-bugs { background: rgba(220,38,38,0.15); color: var(--blocked); }
.today-bucket-overdue { background: rgba(217,119,6,0.15); color: var(--progress); }

/* Chips de breakdown al header del bloc per projecte */
.today-project-buckets {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.today-bucket-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
}
.today-proj {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  white-space: nowrap;
}
.today-where {
  color: var(--ink-soft);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.today-text {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.today-note {
  display: block;
  grid-column: 3;
  font-size: 11px;
  color: var(--ink-soft);
  font-style: italic;
  white-space: normal;
  margin-top: 2px;
}
.today-age {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.today-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.today-empty p:first-child {
  font-size: 18px;
  margin: 0 0 6px;
  color: var(--ink);
}

/* ─── Kanban (Issues / Roadmap) ──────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.kanban-col {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
  box-shadow: var(--shadow);
}
.kanban-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.kanban-col-count {
  background: var(--surface-2);
  color: var(--ink-soft);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.kanban-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  margin-bottom: 10px;
}
.kanban-empty {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  text-align: center;
  padding: 20px 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
}
.kanban-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 3px solid var(--line-strong);
  transition: border-color .15s, transform .1s;
}
.kanban-card:hover { border-color: var(--accent); }
.kanban-card-bug { border-left-color: var(--blocked); }
.kanban-card-feature { border-left-color: var(--done); }
.kanban-card-idea { border-left-color: var(--progress); }
.kanban-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
}
.kanban-type {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.kanban-type.type-bug     { background: rgba(220,38,38,0.12); color: var(--blocked); }
.kanban-type.type-feature { background: rgba(22,163,74,0.12); color: var(--done); }
.kanban-type.type-idea    { background: rgba(245,158,11,0.14); color: var(--progress); }
.kanban-card-date {
  color: var(--muted);
  font-size: 10px;
}
.kanban-card-text {
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink);
  outline: none;
  border-radius: 3px;
  padding: 2px 4px;
  margin: -2px -4px;
  cursor: text;
}
.kanban-card-text:focus {
  background: var(--surface-2);
  outline: 1px solid var(--accent);
}
.kanban-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}
.kanban-btn {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.kanban-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--accent);
}
.kanban-btn-del:hover {
  background: rgba(220,38,38,0.12);
  color: var(--blocked);
  border-color: var(--blocked);
}
.kanban-add {
  display: flex;
  gap: 6px;
  align-items: stretch;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.kanban-add-select,
.kanban-add-input {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--ink);
  outline: none;
}
.kanban-add-select { flex: 0 0 auto; }
.kanban-add-input { flex: 1; min-width: 0; }
.kanban-add-input:focus,
.kanban-add-select:focus { border-color: var(--accent); }
.kanban-add-btn {
  flex: 0 0 auto;
  padding: 6px 12px;
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}
.td-issues .cell-pct {
  font-size: 18px;
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 720px) {
  #topbar, #projects, #tabs { padding-left: 12px; padding-right: 12px; }
  #content { padding: 12px; }
  .summary-table th.th-project { width: auto; }
  .item { padding: 8px 12px; }
  .cat-pct { display: none; }
  .mini-pbar { width: 50px; }
  .kanban { grid-template-columns: 1fr; }
  .today-item { grid-template-columns: 1fr; gap: 4px; }
  .today-proj, .today-where, .today-age { grid-column: 1; }
  .search-input { width: 100%; }
  .search-input:focus { width: 100%; }
}

/* ─── Pestanya Contactes ────────────────────────────────────────────── */
.contacts-loading,
.contacts-error,
.contacts-empty { padding: 32px; text-align: center; color: var(--ink-soft); }
.contacts-error code { display: inline-block; background: var(--surface-2); padding: 4px 8px; border-radius: 4px; margin: 4px 0; }
.contacts-hint { font-size: 0.9em; opacity: 0.85; }

.contacts-intro { margin-bottom: 12px; }
.contacts-intro h2 { margin: 0 0 4px 0; }
.contacts-sub { color: var(--ink-soft); font-size: 0.92em; margin: 0 0 8px 0; }
.contacts-sync { font-style: italic; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }

.contacts-sources { list-style: none; padding: 0; margin: 8px 0 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.contacts-source-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--surface-2); border-radius: 999px; cursor: pointer; font-size: 0.85em; user-select: none; }
.contacts-source-pill:hover { background: var(--surface-3); }
.contacts-source-pill.active { background: var(--accent); color: #fff; }
.contacts-source-pill .source-count { background: rgba(0,0,0,0.1); padding: 0 6px; border-radius: 999px; font-weight: 600; }
.contacts-source-pill.active .source-count { background: rgba(255,255,255,0.25); }

.contacts-legal { background: rgba(245,158,11,0.08); border-left: 3px solid #f59e0b; padding: 8px 12px; margin: 10px 0; font-size: 0.85em; border-radius: 4px; }

.contacts-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.contacts-filters .search-input { flex: 1; min-width: 220px; }
.contacts-select { padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 0.9em; }

.contacts-table-wrap { overflow-x: auto; margin-top: 8px; }
.contacts-table { width: 100%; border-collapse: collapse; font-size: 0.88em; }
.contacts-table th { text-align: left; padding: 8px; background: var(--surface-2); position: sticky; top: 0; font-weight: 600; }
.contacts-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.contacts-table tbody tr:hover { background: var(--surface-2); }
.td-email a { color: var(--accent); text-decoration: none; word-break: break-all; }
.td-email a:hover { text-decoration: underline; }
.td-name { max-width: 320px; }
.td-url { text-decoration: none; opacity: 0.6; }
.td-url:hover { opacity: 1; }
.td-alsoin { color: var(--accent); font-size: 0.85em; margin-left: 4px; cursor: help; }
.td-source { font-family: ui-monospace, monospace; font-size: 0.82em; color: var(--ink-soft); white-space: nowrap; }
.td-tags { max-width: 220px; }
.contact-tag { display: inline-block; background: var(--surface-2); border-radius: 4px; padding: 1px 6px; margin: 1px 2px; font-size: 0.78em; cursor: pointer; }
.contact-tag:hover { background: var(--accent); color: #fff; }
.contact-tag-more { font-size: 0.78em; color: var(--muted); margin-left: 2px; }
.td-phone { font-family: ui-monospace, monospace; font-size: 0.85em; white-space: nowrap; }
.td-outreach { white-space: nowrap; }
.outreach-empty { color: var(--muted); }
.outreach-badge { background: #dcfce7; color: #14532d; padding: 2px 8px; border-radius: 999px; font-size: 0.78em; }
[data-theme="dark"] .outreach-badge { background: #14532d; color: #dcfce7; }
.td-actions { white-space: nowrap; }
.btn-mini { background: none; border: 1px solid var(--line-strong); border-radius: 4px; padding: 2px 6px; margin: 0 1px; cursor: pointer; font-size: 1em; }
.btn-mini:hover { background: var(--surface-2); }

/* ─── Modal genèric ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(28, 25, 23, 0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: modalFade .15s ease;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0 24px 24px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-card.modal-wide { max-width: 880px; }
.modal-card h3 { margin: 0 0 14px; font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.modal-card h3 .icon { color: var(--accent); }
.modal-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  background: var(--surface);
  padding: 10px 0 4px;
  margin: 0 -24px;
  padding-left: 24px;
  padding-right: 24px;
  border-bottom: 1px solid transparent;
  transition: border-color .15s, box-shadow .15s;
}
/* Quan hi ha scroll, ressaltem la línia inferior del header sticky */
.modal-card[data-scrolled="true"] .modal-header {
  border-bottom-color: var(--line);
  box-shadow: 0 4px 8px -4px rgba(0,0,0,0.08);
}
.modal-close {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }

/* ─── Formularis: send/templates/detail/etc. (shared) ──────────────── */
.send-modal h3,
.detail-modal h3,
.templates-modal h3 { margin-top: 0; }
.send-to {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin: 8px 0 14px;
  font-size: 13px;
  color: var(--ink);
}
.send-to-name { color: var(--ink-soft); }
.send-label,
.template-name {
  display: block;
  margin: 14px 0 6px;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.send-template, .send-subject, .send-body,
.template-subject, .template-body,
.tpl-name-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
.send-template:focus, .send-subject:focus, .send-body:focus,
.template-subject:focus, .template-body:focus,
.tpl-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.send-body, .template-body {
  resize: vertical;
  min-height: 200px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}
.send-actions, .detail-actions, .templates-add { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

/* ─── Detail modal ─────────────────────────────────────────────────── */
.detail-meta {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 14px;
  font-size: 13px;
  margin: 14px 0;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.detail-meta dt {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
}
.detail-meta dd { margin: 0; word-break: break-word; color: var(--ink); }
.detail-empty { color: var(--muted); font-style: italic; }
.detail-outreach { list-style: none; padding: 0; margin: 0; }
.detail-outreach li {
  display: grid;
  grid-template-columns: 110px 1fr auto 32px;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  align-items: center;
}
.detail-outreach li:last-child { border-bottom: none; }
.detail-date {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 12px;
}
.detail-result { font-size: 12px; color: var(--muted); }

/* ─── Templates modal ──────────────────────────────────────────────── */
.templates-hint { font-size: 13px; color: var(--ink-soft); margin: 6px 0 14px; }
.template-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 10px 0;
  background: var(--surface-2);
}
.template-head { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.template-name {
  margin: 0;
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
}

/* ─── Pestanya Dades (read-only) ─────────────────────────────────────── */
.ds-head { margin-bottom: 16px; }
.ds-head h2 { margin: 0 0 4px 0; }
.ds-sub { color: var(--ink-soft); font-size: 0.92em; margin: 0; }
.ds-readonly-badge { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 999px; font-size: 0.78em; font-weight: 600; }
[data-theme="dark"] .ds-readonly-badge { background: #78350f; color: #fef3c7; }

.ds-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.ds-card { text-align: left; padding: 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; font-family: inherit; }
.ds-card:hover { border-color: var(--accent); background: var(--surface-2); }
.ds-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ds-card-label { font-weight: 600; font-size: 1em; }
.ds-card-id { font-family: ui-monospace, monospace; font-size: 0.78em; color: var(--muted); }
.ds-card-meta { font-size: 0.88em; color: var(--ink-soft); margin: 4px 0; }
.ds-card-rows { font-weight: 600; color: var(--accent); }
.ds-card-source { font-family: ui-monospace, monospace; font-size: 0.78em; color: var(--muted); margin-top: 4px; }
.ds-card-preview { font-size: 0.78em; color: var(--muted); margin-top: 6px; font-style: italic; }

.ds-breadcrumb { margin-bottom: 10px; font-size: 0.92em; }
.ds-source { color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.85em; }
.ds-sep { color: var(--muted); margin: 0 4px; }
.ds-loading { padding: 24px; text-align: center; color: var(--muted); }

.ds-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.ds-toolbar .search-input { flex: 1; min-width: 220px; }
.ds-counter { font-size: 0.88em; color: var(--ink-soft); }
.ds-pagenav { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.ds-pagenum { font-family: ui-monospace, monospace; font-size: 0.88em; padding: 0 8px; }

.ds-table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line-strong); border-radius: 4px; }
.ds-table { border-collapse: collapse; font-size: 0.82em; }
.ds-table th, .ds-table td { padding: 4px 8px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.ds-table thead th { background: var(--surface-2); position: sticky; top: 0; z-index: 1; cursor: pointer; user-select: none; font-weight: 600; white-space: nowrap; }
.ds-table thead th:hover { background: var(--surface-3); }
.ds-th-sorted { background: var(--accent) !important; color: #fff; }
.ds-th-rownum, .ds-td-rownum { background: var(--surface-2); font-family: ui-monospace, monospace; font-size: 0.78em; color: var(--muted); text-align: right; min-width: 40px; }
.ds-cell { max-width: 360px; }
.ds-cell-null { color: var(--muted); text-align: center; }
.ds-cell-bool { text-align: center; font-weight: 700; }
.ds-cell-num { text-align: right; font-family: ui-monospace, monospace; }
.ds-cell-array { line-height: 1.6; }
.ds-cell-long { font-size: 0.92em; }
.ds-chip { display: inline-block; background: var(--surface-2); padding: 1px 6px; margin: 1px 2px; border-radius: 4px; font-size: 0.82em; }
.ds-cell-json details { font-size: 0.9em; }
.ds-cell-json summary { cursor: pointer; font-family: ui-monospace, monospace; color: var(--accent); }
.ds-json { font-family: ui-monospace, monospace; font-size: 0.78em; background: var(--surface-2); padding: 6px; border-radius: 4px; margin: 4px 0; max-height: 300px; overflow: auto; white-space: pre-wrap; }
.ds-link { color: var(--accent); text-decoration: none; }
.ds-link:hover { text-decoration: underline; }

/* ─── Pestanya Vitals (Web Vitals dashboard) ────────────────────────── */
.vitals-head { margin-bottom: 12px; }
.vitals-head h2 { margin: 0 0 4px 0; }
.vitals-scope { font-weight: 400; color: var(--ink-soft); }
.vitals-sub { color: var(--ink-soft); font-size: 0.92em; margin: 0; }
.vitals-loading { padding: 32px; text-align: center; color: var(--muted); }
.vitals-hint { color: var(--muted); font-size: 0.88em; margin: 8px 0 0 0; }

.vitals-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0 16px 0; }
.vitals-segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg-btn { background: var(--surface); color: var(--ink); border: none; border-right: 1px solid var(--line-strong); padding: 6px 12px; cursor: pointer; font: inherit; font-size: 0.88em; }
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--surface-2); }
.seg-active { background: var(--accent); color: #fff; }
.seg-active:hover { background: var(--accent); filter: brightness(0.92); }
.vitals-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88em; user-select: none; cursor: pointer; }

.vitals-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.vitals-kpi { background: var(--surface-2); padding: 14px; border-radius: 8px; border: 1px solid var(--line); }
.kpi-label { font-size: 0.82em; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.kpi-value { font-size: 1.8em; font-weight: 700; line-height: 1.1; }
.kpi-value.kpi-good { color: #14532d; }
.kpi-value.kpi-ni { color: #92400e; }
.kpi-value.kpi-poor { color: #991b1b; }
[data-theme="dark"] .kpi-value.kpi-good { color: #4ade80; }
[data-theme="dark"] .kpi-value.kpi-ni { color: #fbbf24; }
[data-theme="dark"] .kpi-value.kpi-poor { color: #f87171; }
.kpi-sub { font-size: 0.82em; color: var(--muted); margin-top: 4px; }

.vitals-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.vitals-card h3 {
  margin: 0 0 14px 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.vitals-card-sub { color: var(--muted); font-weight: 400; font-size: 13px; }

.metric-chart { width: 100%; max-width: 720px; height: auto; }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-line { stroke-width: 2; }
.chart-dot { cursor: help; }
.chart-dot-good { fill: #16a34a !important; }
.chart-dot-needs-improvement { fill: #f59e0b !important; }
.chart-dot-poor { fill: #dc2626 !important; }
.chart-threshold-good { stroke: #16a34a; stroke-width: 1; opacity: 0.5; }
.chart-threshold-poor { stroke: #dc2626; stroke-width: 1; opacity: 0.5; }
.chart-threshold-label { font-size: 10px; font-family: ui-monospace, monospace; }
.chart-threshold-label-good { fill: #16a34a; }
.chart-threshold-label-poor { fill: #dc2626; }
.chart-label { font-size: 11px; fill: var(--ink-soft); font-family: ui-monospace, monospace; }
.chart-empty { font-size: 13px; fill: var(--muted); }

.vitals-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.vitals-breakdown h3 { margin-bottom: 8px; font-size: 0.95em; }
.vitals-breakdown-wide .breakdown-key { word-break: break-all; font-size: 0.85em; }
.vitals-breakdown-wide { grid-column: 1 / -1; }

/* ─── Bar chart i comparativa ─────────────────────────────────────── */
.chart-bar { transition: opacity 0.15s; }
.chart-bar:hover { opacity: 0.8; }
.chart-bar-label { font-weight: 500; }
.chart-bar-value { font-variant-numeric: tabular-nums; font-size: 10px; fill: var(--ink); }

/* ─── Matriu pàgines × projecte ───────────────────────────────────── */
.pages-matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pages-matrix-block { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: var(--surface-2); }
.pages-matrix-head { font-weight: 600; font-size: 0.92em; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.pages-matrix-list { list-style: none; padding: 0; margin: 0; }
.pages-matrix-item { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-size: 0.85em; }
.pages-matrix-path { font-family: ui-monospace, monospace; font-size: 0.88em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pages-matrix-count { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ─── Health grid (Resum) ─────────────────────────────────────────── */
.health-section { margin: 16px 0 24px 0; }
.health-title { margin: 0 0 8px 0; font-size: 1.15em; }
.health-sub { color: var(--muted); font-size: 0.78em; font-weight: 400; }
.health-loading { padding: 16px; color: var(--muted); text-align: center; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.health-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.health-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.health-card-name { flex: 1; font-weight: 600; font-size: 0.95em; }
.health-status { font-size: 0.82em; padding: 2px 8px; border-radius: 999px; white-space: nowrap; cursor: help; }
.health-up { background: #dcfce7; color: #14532d; }
.health-down { background: #fee2e2; color: #991b1b; }
.health-warn { background: #fef3c7; color: #92400e; }
.health-na { background: var(--surface-2); color: var(--ink-soft); }
[data-theme="dark"] .health-up { background: #14532d; color: #dcfce7; }
[data-theme="dark"] .health-down { background: #991b1b; color: #fee2e2; }
[data-theme="dark"] .health-warn { background: #78350f; color: #fef3c7; }
.health-meta { font-size: 0.82em; color: var(--ink-soft); margin-bottom: 6px; }
.health-meta-val { font-weight: 500; color: var(--ink); }
.health-meta-na { font-style: italic; }
.health-note { width: 100%; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 4px; font-family: inherit; font-size: 0.85em; background: var(--surface); color: var(--ink); resize: vertical; min-height: 40px; box-sizing: border-box; }

/* ─── Pestanya Avisos ─────────────────────────────────────────────── */
.alerts-head h2 { margin: 0 0 4px 0; }
.alerts-active { margin: 16px 0; }
.alerts-none { padding: 24px; text-align: center; color: var(--ink-soft); background: var(--surface-2); border-radius: 8px; }
.alerts-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.alert-card { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 12px; border-radius: 6px; border-left: 4px solid; background: var(--surface); }
.alert-high { border-left-color: #dc2626; background: #fef2f2; }
.alert-medium { border-left-color: #f59e0b; background: #fffbeb; }
.alert-low { border-left-color: #0284c7; background: #eff6ff; }
.alert-info { border-left-color: var(--muted); background: var(--surface-2); }
[data-theme="dark"] .alert-high { background: #1f1212; }
[data-theme="dark"] .alert-medium { background: #1c1610; }
[data-theme="dark"] .alert-low { background: #0f1620; }
[data-theme="dark"] .alert-info { background: #181818; }
.alert-icon { font-size: 1.8em; line-height: 1; align-self: center; text-align: center; }
.alert-body { min-width: 0; }
.alert-title { font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.alert-msg { font-size: 0.9em; color: var(--ink-soft); }
.alert-action { margin-top: 6px; }

.alerts-config { margin-top: 24px; padding: 16px; background: var(--surface-2); border-radius: 8px; }
.alerts-config h3 { margin: 0 0 8px 0; }
.alerts-config-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.alerts-config-row:last-child { border-bottom: none; }
.alerts-config-label { display: flex; align-items: flex-start; gap: 8px; flex: 1; cursor: pointer; }
.alerts-config-label input { margin-top: 4px; }
.alerts-config-name { font-weight: 600; }
.alerts-config-desc { font-size: 0.85em; color: var(--ink-soft); margin-top: 2px; }
.alerts-config-param { width: 70px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 4px; text-align: right; background: var(--surface); color: var(--ink); }
.alerts-config-paramlabel { font-size: 0.82em; color: var(--ink-soft); align-self: center; }

/* ─── Pestanya Campanyes ──────────────────────────────────────────── */
.campaigns-head h2 { margin: 0 0 4px 0; }
.campaigns-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 14px 0 18px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.campaigns-filters .search-input { flex: 1; min-width: 240px; }
.campaigns-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.campaigns-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.campaigns-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.campaigns-card-flag { font-size: 1.4em; }
.campaigns-card-title { flex: 1; }
.campaigns-card-iso { color: var(--muted); font-size: 0.85em; font-family: ui-monospace, monospace; }
.campaigns-langs { list-style: none; padding: 0; margin: 0 0 8px 0; }
.campaigns-lang { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 0.9em; }
.campaigns-lang .lang-name { flex: 1; }
.campaigns-lang .lang-code { background: var(--surface-2); padding: 1px 6px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.78em; color: var(--ink-soft); }
.campaigns-lang-colonial .lang-name { text-decoration: line-through; opacity: 0.7; }
.lang-colonial-badge { background: #fef3c7; color: #92400e; padding: 1px 6px; border-radius: 999px; font-size: 0.72em; font-weight: 600; white-space: nowrap; }
[data-theme="dark"] .lang-colonial-badge { background: #78350f; color: #fef3c7; }
.campaigns-rec { background: var(--surface-2); padding: 8px 10px; border-radius: 4px; font-size: 0.85em; margin-top: 8px; border-left: 3px solid #0284c7; }
.campaigns-rec-ok { border-left-color: #16a34a; }

.campaigns-add-btn { font-size: 1.2em; font-weight: 700; padding: 2px 10px; line-height: 1; }
.campaigns-contacts { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.campaigns-contacts-head { font-size: 0.82em; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.campaign-contact { background: var(--surface-2); padding: 8px 10px; border-radius: 4px; margin-bottom: 6px; font-size: 0.88em; }
.campaign-contact-head { display: flex; align-items: center; gap: 6px; }
.campaign-contact-name { font-weight: 600; flex: 1; }
.campaign-contact-icon { font-size: 1em; }
.campaign-contact-email, .campaign-contact-link { display: block; color: var(--accent); text-decoration: none; font-size: 0.85em; margin-top: 2px; word-break: break-all; }
.campaign-contact-email:hover, .campaign-contact-link:hover { text-decoration: underline; }
.campaign-contact-actions { display: flex; gap: 4px; justify-content: flex-end; margin-top: 6px; }
.campaign-status { font-size: 0.72em; padding: 1px 6px; border-radius: 999px; font-weight: 600; }
.status-sent { background: #dbeafe; color: #1e40af; }
.status-replied { background: #dcfce7; color: #14532d; }
.status-bounced { background: #fee2e2; color: #991b1b; }
.status-unsubscribed { background: var(--surface-2); color: var(--ink-soft); }

/* ─── Secció de contactes globals (no associats a cap país) ─────────── */
.campaigns-section-title { font-size: 1.05em; font-weight: 600; margin: 18px 0 10px 0; color: var(--ink); }
.campaigns-global-section { margin-bottom: 24px; background: var(--surface-2); padding: 14px 16px; border-radius: 8px; border-left: 3px solid var(--accent); }
.campaigns-global-group { margin-bottom: 14px; }
.campaigns-global-group:last-child { margin-bottom: 0; }
.campaigns-global-group-head { font-weight: 600; font-size: 0.92em; color: var(--ink-soft); margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.campaigns-global-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.campaigns-global-list .campaign-contact { margin-bottom: 0; }

/* ─── Compose modal + outreach badge ──────────────────────────────── */
.compose-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.compose-controls > div { display: flex; flex-direction: column; }
.btn-mini-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-mini-primary:hover { filter: brightness(0.92); }
.campaign-outreach-badge {
  font-size: 0.78em;
  background: #dcfce7;
  color: #14532d;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
  margin-top: 4px;
}
[data-theme="dark"] .campaign-outreach-badge { background: #14532d; color: #dcfce7; }

/* ─── Pestanya Mencions ────────────────────────────────────────────── */
.mentions-list { display: grid; gap: 10px; }
.mention-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; border-left: 3px solid var(--accent); }
.mention-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.mention-icon { font-size: 1.2em; }
.mention-date { font-family: ui-monospace, monospace; font-size: 0.82em; color: var(--muted); }
.mention-proj { font-size: 0.82em; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); display: inline-flex; align-items: center; gap: 4px; }
.mention-source { font-weight: 600; }
.mention-url { display: block; color: var(--accent); font-size: 0.85em; text-decoration: none; word-break: break-all; margin-top: 4px; }
.mention-url:hover { text-decoration: underline; }
.mention-quote { font-style: italic; border-left: 2px solid var(--line-strong); padding: 4px 8px; margin: 6px 0; color: var(--ink-soft); }
.mention-notes { font-size: 0.88em; color: var(--ink-soft); margin-top: 4px; }
.mention-reach { font-size: 0.82em; color: var(--ink-soft); margin-top: 4px; }

/* ─── Pestanya Press kit ───────────────────────────────────────────── */
.presskit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.presskit-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.presskit-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.presskit-domain { display: block; color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.82em; margin-bottom: 8px; text-decoration: none; }
.presskit-domain:hover { color: var(--accent); }
.presskit-pitch { font-size: 0.9em; line-height: 1.4; margin: 6px 0; }
.presskit-pitch-short { font-weight: 500; color: var(--ink); }
.presskit-indicators { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pk-ok { background: #dcfce7; color: #14532d; padding: 1px 6px; border-radius: 999px; font-size: 0.75em; }
[data-theme="dark"] .pk-ok { background: #14532d; color: #dcfce7; }
.presskit-empty { color: var(--muted); font-style: italic; font-size: 0.88em; margin: 8px 0; }

.presskit-detail { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 20px; max-width: 800px; }
.presskit-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.presskit-detail-head h3 { margin: 0; flex: 1; }
.presskit-section { margin-bottom: 20px; }
.presskit-section h4 { font-size: 0.92em; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 6px 0; }
.presskit-quote { font-style: italic; font-size: 1.1em; border-left: 3px solid var(--accent); padding-left: 12px; }
.presskit-long { white-space: pre-wrap; line-height: 1.6; }
.presskit-facts { padding-left: 20px; }
.presskit-facts li { margin: 4px 0; }

/* ─── Pestanya Costs ───────────────────────────────────────────────── */
.cost-bar-wrap { margin: 10px 0; }
.cost-bar-label { font-size: 0.92em; margin-bottom: 4px; }
.cost-bar-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.cost-bar { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.cost-bar-fill { height: 100%; transition: width 0.3s; }
.cost-tables { list-style: none; padding: 0; margin: 8px 0; }
.cost-tables li { display: flex; justify-content: space-between; padding: 3px 0; font-size: 0.88em; border-bottom: 1px solid var(--line); }
.cost-tables li:last-child { border-bottom: none; }
.cost-table-name { font-family: ui-monospace, monospace; color: var(--ink-soft); }
.cost-table-size { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ─── Editor visual de plantilles ──────────────────────────────────── */
.tpl-editor h3 { margin-top: 0; }
.tpl-editor-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; margin: 12px 0; max-height: 70vh; }
.tpl-editor-sidebar { border: 1px solid var(--line); border-radius: 6px; overflow-y: auto; }
.tpl-editor-sidebar-head { font-size: 0.78em; font-weight: 600; color: var(--ink-soft); padding: 8px 12px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.05em; }
.tpl-editor-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border: none; background: none; cursor: pointer; border-bottom: 1px solid var(--line); color: var(--ink); }
.tpl-editor-item:hover { background: var(--surface-2); }
.tpl-editor-item-active { background: var(--accent); color: #fff; }
.tpl-editor-item-active:hover { background: var(--accent); filter: brightness(0.95); }
.tpl-editor-item-name { font-weight: 600; font-size: 0.92em; }
.tpl-editor-item-desc { font-size: 0.78em; opacity: 0.85; margin-top: 2px; }

.tpl-editor-main { overflow-y: auto; padding-right: 4px; }
.tpl-editor-name { font-weight: 700; font-size: 1.05em; margin-bottom: 8px; }
.tpl-editor-lang-tabs { display: flex; gap: 2px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tpl-lang-tab { padding: 6px 12px; background: none; border: none; cursor: pointer; font-weight: 600; font-size: 0.85em; border-bottom: 2px solid transparent; color: var(--ink-soft); position: relative; }
.tpl-lang-tab:hover { color: var(--ink); }
.tpl-lang-active { color: var(--accent); border-bottom-color: var(--accent); }
.tpl-lang-filled::after { content: '•'; color: #16a34a; margin-left: 2px; }

.tpl-translate-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 8px 10px; background: var(--surface-2); border-radius: 4px; font-size: 0.88em; }
.tpl-translate-row select { padding: 4px 8px; }
.breakdown-list { list-style: none; padding: 0; margin: 0; }
.breakdown-item { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; align-items: baseline; padding: 4px 0; font-size: 0.9em; }
.breakdown-key { font-family: ui-monospace, monospace; font-size: 0.92em; }
.breakdown-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.breakdown-bar { grid-column: 1 / -1; height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.breakdown-bar-fill { height: 100%; background: var(--accent); }

/* ──────────────────────────────────────────────────────────────────── */
/* Pass 2: refinaments visuals — badges, taules, cards, empty states  */
/* ──────────────────────────────────────────────────────────────────── */

/* Capçaleres unificades per a totes les pestanyes */
.contacts-intro h2,
.ds-head h2,
.vitals-head h2,
.alerts-head h2,
.campaigns-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}
.contacts-intro h2 .icon,
.ds-head h2 .icon,
.vitals-head h2 .icon,
.alerts-head h2 .icon,
.campaigns-head h2 .icon { color: var(--accent); }

.contacts-sub,
.ds-sub,
.vitals-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 14px; }

/* Pills — contacts source */
.contacts-source-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  user-select: none;
  transition: background .15s, color .15s, border-color .15s;
}
.contacts-source-pill:hover { background: var(--surface-3); color: var(--ink); }
.contacts-source-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
.contacts-source-pill .source-count {
  background: rgba(0,0,0,0.08);
  padding: 0 7px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 11px;
}
.contacts-source-pill.active .source-count { background: rgba(255,255,255,0.22); }

/* Contacts/forms selects */
.contacts-select,
.tpl-translate-row select {
  padding: 10px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
.contacts-select:hover { border-color: var(--accent); }

/* Auto-filter hint (territori del projecte) */
.campaigns-auto-filter-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: help;
}

/* Settings: territori per projecte */
.settings-territory-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  padding: 2px;
}
.settings-territory-row {
  display: grid;
  grid-template-columns: 12px 1fr 200px;
  align-items: center;
  gap: 10px;
}
.settings-territory-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.settings-territory-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}
.settings-territory-row .contacts-select { padding: 6px 10px; font-size: 13px; }
.contacts-select:focus,
.tpl-translate-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.contacts-legal {
  background: rgba(245,158,11,0.10);
  border: 1px solid rgba(245,158,11,0.30);
  border-left: 3px solid var(--progress);
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--ink);
  border-radius: var(--radius-sm);
}

/* Taules — Contacts + Dades */
.contacts-table,
.ds-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.contacts-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
.contacts-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.contacts-table tbody tr { transition: background .12s; }
.contacts-table tbody tr:hover { background: var(--surface-2); }
.contacts-table tbody tr:last-child td { border-bottom: none; }

.ds-table-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.ds-table th, .ds-table td {
  padding: 8px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.ds-table thead th {
  background: var(--surface-2);
  position: sticky; top: 0; z-index: 1;
  cursor: pointer; user-select: none;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
.ds-table tbody tr:hover { background: var(--surface-2); }

/* Mini buttons */
.btn-mini {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  margin: 0 1px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-mini:hover { background: var(--surface-2); color: var(--ink); border-color: var(--accent); }
.btn-mini .icon { width: 14px; height: 14px; stroke-width: 2; vertical-align: 0; }
.btn-mini-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-mini-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.btn-link:hover { color: var(--accent-strong); }

/* Badges semàntics — refinats */
.outreach-badge,
.campaign-outreach-badge,
.pk-ok {
  display: inline-flex;
  align-items: center;
  background: rgba(5,150,105,0.12);
  color: var(--done);
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}
[data-theme="dark"] .outreach-badge,
[data-theme="dark"] .campaign-outreach-badge,
[data-theme="dark"] .pk-ok { background: rgba(20,184,166,0.18); color: var(--accent-strong); }

.ds-readonly-badge,
.lang-colonial-badge {
  background: rgba(217,119,6,0.14);
  color: var(--progress);
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.campaign-status {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-weight: 600;
}
.status-sent { background: rgba(13,148,136,0.14); color: var(--accent-strong); }
.status-replied { background: rgba(5,150,105,0.14); color: var(--done); }
.status-bounced { background: rgba(220,38,38,0.14); color: var(--blocked); }
.status-unsubscribed { background: var(--surface-2); color: var(--ink-soft); }

.health-status {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}
.health-up { background: rgba(5,150,105,0.14); color: var(--done); }
.health-down { background: rgba(220,38,38,0.14); color: var(--blocked); }
.health-warn { background: rgba(217,119,6,0.14); color: var(--progress); }
.health-na { background: var(--surface-2); color: var(--ink-soft); }
[data-theme="dark"] .health-up { background: rgba(20,184,166,0.18); color: var(--accent-strong); }
[data-theme="dark"] .health-down { background: rgba(220,38,38,0.20); color: #f87171; }
[data-theme="dark"] .health-warn { background: rgba(217,119,6,0.20); color: #fbbf24; }

/* Cards: campaigns / mentions / presskit / health */
.campaigns-card,
.mention-card,
.presskit-card,
.health-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

/* Botó de notes: compacte amb dot teal si hi ha contingut */
.health-note-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  transition: background .12s, color .12s, border-color .12s;
}
.health-note-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.health-note-btn-has {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent-soft);
  font-weight: 600;
}
.health-note-btn-has:hover { background: var(--accent-soft); border-color: var(--accent); }
.health-note-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 2px;
}
.campaigns-card:hover,
.mention-card:hover,
.presskit-card:hover,
.health-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.mention-card { border-left: 3px solid var(--accent); }
.campaigns-card-head,
.health-card-head,
.presskit-card-head { gap: 10px; margin-bottom: 10px; }
.campaigns-card-title h3,
.health-card-name,
.presskit-card-head h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}

.campaigns-rec {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 10px;
  color: var(--ink-soft);
}
.campaigns-rec-ok { border-left-color: var(--done); }

.campaign-contact {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.campaign-contact:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.campaign-contact-icon { color: var(--accent); display: inline-flex; align-items: center; flex-shrink: 0; }
.campaign-contact-name {
  flex: 1;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.campaign-contact-source {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--ink);
  color: var(--surface);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  margin-left: auto;
}
/* Font: icona compacta amb tooltip */
.campaign-contact-source-icon {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  margin-left: auto;
  flex-shrink: 0;
  cursor: help;
}
.campaign-contact-source-icon:hover { color: var(--accent-strong); }

/* Estrella per habilitar contactes a una campanya (Difusió) */
.campaign-contact-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
  transition: background .12s, color .12s, border-color .12s, transform .05s;
}
.campaign-contact-star:hover { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.campaign-contact-star.is-on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.campaign-contact-star.is-on:hover { background: var(--accent-strong); }
.campaign-contact-star:active { transform: scale(0.92); }

/* Difusió: selector campanya activa */
.difusio-selector { margin-bottom: 18px; }
.difusio-row {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0;
  background: var(--surface);
  border: 1.5px solid var(--accent-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-xs);
}
.difusio-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.difusio-row .contacts-select.difusio-select { flex: 1; }
.difusio-filter-toggle {
  flex-shrink: 0;
  font-size: 13px;
  padding: 8px 14px;
  white-space: nowrap;
}
.difusio-filter-toggle.is-on {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent);
}

.difusio-active-summary {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 12px 0;
}
.difusio-featured-block { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.difusio-featured-block .collapsible-head { background: var(--accent-soft); }

/* Footer: web + accions */
.campaign-contact-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.campaign-contact-web-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  color: var(--accent-strong);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.campaign-contact-web-badge:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  text-decoration: none;
}
.campaign-contact-actions { margin-left: auto; }

.presskit-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.presskit-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.presskit-download-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  text-decoration: none;
}
.presskit-download-btn:active { transform: translateY(1px); }

/* Header de Contactes públics — títol + dropdown bases de dades inline */
.contacts-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.contacts-title { margin: 0; }
.contacts-title-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.contacts-title-dbrow {
  display: flex;
  align-items: center;
  gap: 8px;
}
.contacts-toggle-all {
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  padding: 9px 14px;
  font-weight: 500;
  font-size: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.contacts-toggle-all:hover { border-color: var(--accent); color: var(--accent-strong); }
.contacts-toggle-all .collapsible-chev { color: var(--muted); transition: transform .15s; }
.contacts-toggle-all .collapsible-chev-rot { transform: rotate(-180deg); }
.contacts-toggle-empty-inline {
  font-size: 12.5px;
  color: var(--ink-soft);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}
.contacts-toggle-empty-inline input { transform: translateY(1px); }

.contacts-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.contacts-sub-row .contacts-sub { margin: 0; }

.sources-dropdown {
  position: relative;
  display: inline-block;
}
.sources-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, color .15s;
}
.sources-dropdown-trigger:hover { border-color: var(--accent); color: var(--accent-strong); }
.sources-dropdown-trigger .icon { color: var(--accent); }
.sources-dropdown-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.sources-dropdown-label { font-weight: 600; }
.sources-dropdown-count {
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.sources-dropdown-active .sources-dropdown-count {
  background: var(--accent);
  color: #fff;
}

.sources-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
}
.sources-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
  transition: background .12s;
}
.sources-dropdown-item:hover { background: var(--surface-2); }
.sources-dropdown-item-on {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.sources-dropdown-item-on:hover { background: var(--accent-soft); }
.sources-item-name { font-family: var(--font-mono); font-size: 12.5px; }
.sources-item-count {
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.sources-dropdown-item-on .sources-item-count { background: var(--surface); color: var(--accent-strong); }
.sources-dropdown-item-xkno { background: var(--ink); color: var(--surface); margin-top: 4px; }
.sources-dropdown-item-xkno:hover { background: var(--ink); opacity: 0.92; }
.sources-dropdown-item-xkno .sources-item-count { background: rgba(255,255,255,0.18); color: var(--surface); }

.contacts-info-btn {
  padding: 4px;
  min-width: 28px;
  min-height: 28px;
  margin-left: 4px;
  color: var(--muted);
}
.contacts-info-btn:hover { color: var(--accent); }

.contacts-intl-section {
  margin-top: 12px;
  margin-bottom: 24px;
}

/* ─── Stats agregats al damunt de Contactes globals ─── */
.contacts-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin: 16px 0 12px;
}
.contacts-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-xs);
}
.contacts-stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.contacts-stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 4px;
}
.contacts-stat-warn { border-left: 3px solid var(--progress); }
.contacts-stat-warn .contacts-stat-num { color: var(--progress); }

.contacts-type-overview {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.contacts-type-overview-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-right: 4px;
}
.contacts-type-overview .type-breakdown { margin-left: 0; }
.contacts-type-overview .type-chip { background: var(--surface); }

.contacts-section-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.contacts-section-controls .btn-sm { margin-left: 0; }
.contacts-toggle-empty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.contacts-toggle-empty input { accent-color: var(--accent); cursor: pointer; }

/* ─── Featured: Països Catalans destacats al damunt de la llista ─── */
.contacts-featured {
  background: linear-gradient(180deg, rgba(13,148,136,0.04) 0%, transparent 100%);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 14px 14px 10px;
  margin: 12px 0 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.contacts-featured-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
  padding: 0 4px;
}
.contacts-featured .collapsible {
  border-color: var(--accent-soft);
}
.contacts-featured .collapsible-featured .collapsible-head {
  background: var(--surface);
}
.contacts-rest-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.contacts-rest-divider .icon { color: var(--muted); }

/* ─── Plegable genèric (used by Contactes globals) ─── */
.collapsible {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .15s;
}
.collapsible:hover { box-shadow: var(--shadow-sm); }
.collapsible-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  text-align: left;
  transition: background .12s;
}
.collapsible-head:hover { background: var(--surface-2); }
.collapsible-chev {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.collapsible-collapsed .collapsible-chev { transform: rotate(-90deg); }
.collapsible-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink);
}
.collapsible-iso {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.collapsible-meta {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}
.collapsible-flag { color: var(--accent); display: inline-flex; align-items: center; }
.rec-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}
.rec-partial { background: rgba(217,119,6,0.13); color: var(--progress); }
.rec-subnational { background: rgba(13,148,136,0.13); color: var(--accent-strong); }
.rec-ppcc { background: #1c1917; color: #f7f4ee; }
[data-theme="dark"] .rec-ppcc { background: #f7f4ee; color: #1c1917; }

/* Pill XKNO al source filter (visualment distintiu) */
.contacts-source-pill-xkno { background: var(--ink); color: var(--surface); }
.contacts-source-pill-xkno:hover { background: var(--ink); opacity: 0.92; }
.contacts-source-pill-xkno .source-name { font-weight: 700; }
.contacts-source-pill-xkno .source-count { background: rgba(255,255,255,0.15); color: var(--surface); }
[data-theme="dark"] .contacts-source-pill-xkno { background: var(--ink); color: var(--bg); }
.collapsible-body {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.collapsible-foot-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 16px auto 0;
  padding: 6px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  transition: background .12s, color .12s, border-color .12s;
}
.collapsible-foot-close:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.collapsible-chev-rot-up { transform: rotate(-180deg); display: inline-flex; align-items: center; }
.collapsible-body { display: flex; flex-direction: column; align-items: stretch; }
.collapsible-body > .collapsible-foot-close { align-self: center; }

/* Type breakdown chips (utilitzats al header dels plegables) */
.type-breakdown {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
}
.type-chip .icon { color: var(--accent-strong); }
.type-breakdown-empty {
  color: var(--muted);
  font-size: 11.5px;
  font-style: italic;
}

/* Country body type groups (al cos del plegable) */
.country-type-group { margin-top: 14px; }
.country-type-group:first-child { margin-top: 8px; }
.country-type-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  width: 100%;
}
/* Grid: targes en 3 columnes (responsive amb auto-fill) */
.country-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.country-type-grid .campaign-contact { margin-bottom: 0; }
@media (max-width: 720px) {
  .country-type-grid { grid-template-columns: 1fr; }
}

/* Mobile: stack header */
@media (max-width: 720px) {
  .collapsible-head { flex-wrap: wrap; }
  .type-breakdown { margin-left: 0; width: 100%; }
}

/* ─── Campaign projects (repositori per-projecte) ─────────── */
.campaigns-actions-bar { display: flex; justify-content: flex-end; margin: 16px 0; }

/* ─── General view: campaigns grouped by project ─── */
.campaigns-project-section { margin: 28px 0; }
.campaigns-project-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.campaigns-project-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.campaigns-project-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.campaigns-project-count {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.btn-sm { padding: 6px 10px; font-size: 12.5px; margin-left: auto; }
.campaign-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.campaign-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.campaign-stat-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.campaign-stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 4px;
}

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.campaign-project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.campaign-project-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.campaign-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.campaign-card-titlewrap { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.campaign-card-aud { color: var(--accent); flex-shrink: 0; }
.campaign-card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
  line-height: 1.3;
}
.campaign-card-audience {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.campaign-card-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}
/* ─── Template editor inside campaign modal ─── */
.modal-sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0 8px;
}
.template-vars-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}
.template-vars-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.template-var-chip {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  color: var(--accent-strong);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.template-var-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.campaign-card-tpl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 600;
  align-self: flex-start;
}
/* Botó d'editar plantilla — destaca quan la campanya ja té plantilla */
.campaign-card-actions .btn-icon.has-template {
  color: var(--accent-strong);
  background: var(--accent-soft);
}
.campaign-card-actions .btn-icon.has-template:hover {
  background: var(--accent);
  color: #fff;
}

/* ─── Country picker ─── */
.country-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.country-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  align-items: center;
}
.country-picker-empty {
  color: var(--muted);
  font-size: 12.5px;
  font-style: italic;
}
.country-picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: none;
  padding: 4px 6px 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s;
}
.country-picker-chip:hover { background: var(--accent); color: #fff; }
.country-picker-chip-code { font-family: var(--font-mono); }
.country-picker-chip-name { font-weight: 500; }
.country-picker-search {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
.country-picker-search:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.country-picker-list {
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.country-picker-row {
  display: grid;
  grid-template-columns: 18px 36px 1fr;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  transition: background .1s;
}
.country-picker-row:hover { background: var(--surface-2); }
.country-picker-row-on { background: var(--accent-soft); }
.country-picker-row-on:hover { background: var(--accent-soft); }
.country-picker-row input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.country-picker-row-code { font-family: var(--font-mono); font-weight: 600; color: var(--muted); font-size: 11.5px; }
.country-picker-row-name { color: var(--ink); }

.campaign-card-geo {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.campaign-card-zone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}
.campaign-card-country {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  color: var(--ink-soft);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  border: 1px solid var(--line);
  letter-spacing: 0.02em;
}
.campaign-card-dates {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.campaign-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  margin-top: 4px;
}
.campaign-metric { display: flex; flex-direction: column; align-items: center; }
.campaign-metric-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.campaign-metric-label {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 2px;
}
.campaign-card-notes {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  font-style: italic;
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent);
}
.campaign-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* Generic empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 24px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  margin: 24px 0;
}
.empty-state .icon { color: var(--muted); margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { margin: 0 0 8px 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.empty-state p { margin: 0; color: var(--muted); font-size: 14px; max-width: 380px; }

/* Form-row helpers */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

/* Generic badge (status pills) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-pending  { background: var(--surface-2);  color: var(--ink-soft); }
.badge-progress { background: rgba(217,119,6,0.13); color: var(--progress); }
.badge-done     { background: rgba(5,150,105,0.13); color: var(--done); }
.badge-na       { background: rgba(148,163,184,0.15); color: var(--na); }
.badge-blocked  { background: rgba(220,38,38,0.13); color: var(--blocked); }

/* Empty + loading states */
.contacts-loading, .contacts-error, .contacts-empty,
.vitals-loading, .ds-loading, .health-loading,
.alerts-none {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.alerts-none { background: var(--surface-2); border-style: solid; border-color: var(--line); }
.contacts-error code {
  display: inline-block;
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 6px 0;
}

/* Alerts cards — més calidesa */
.alert-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.alert-high   { border-left-color: var(--blocked);  background: rgba(220,38,38,0.05); }
.alert-medium { border-left-color: var(--progress); background: rgba(245,158,11,0.05); }
.alert-low    { border-left-color: var(--accent);   background: rgba(13,148,136,0.05); }
.alert-info   { border-left-color: var(--muted);    background: var(--surface-2); }
[data-theme="dark"] .alert-high   { background: rgba(220,38,38,0.10); }
[data-theme="dark"] .alert-medium { background: rgba(245,158,11,0.10); }
[data-theme="dark"] .alert-low    { background: rgba(20,184,166,0.10); }
[data-theme="dark"] .alert-info   { background: var(--surface-2); }
.alerts-config {
  margin-top: 24px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.alerts-config h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; color: var(--ink); }

/* Vitals KPIs polits */
.vitals-kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.kpi-label {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 6px;
}
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }

/* Segmented buttons (vitals) */
.vitals-segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  overflow: hidden;
}
.seg-btn {
  background: transparent;
  color: var(--ink-soft);
  border: none;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  transition: background .15s, color .15s;
}
.seg-btn:hover { background: var(--surface); color: var(--ink); }
.seg-active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-xs); }
.seg-active:hover { background: var(--surface); }

/* Datasets cards */
.ds-card {
  text-align: left;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.ds-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Costs cards (use breakdown card surface) */
.cost-bar {
  height: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--line);
}
.breakdown-bar {
  grid-column: 1 / -1;
  height: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 4px;
}

/* Detail/Send modals — fine-tune */
.send-modal, .detail-modal, .templates-modal { display: block; }

/* Tpl editor */
.tpl-editor-layout { gap: 18px; }
.tpl-editor-sidebar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow-y: auto;
}
.tpl-editor-sidebar-head {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
}
.tpl-editor-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tpl-editor-item:hover { background: var(--surface-3); }
.tpl-editor-item-active { background: var(--accent); color: #fff; }
.tpl-editor-item-active:hover { background: var(--accent-strong); color: #fff; }
.tpl-editor-item-name { font-weight: 600; font-size: 14px; }
.tpl-editor-item-desc { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.tpl-lang-tab {
  padding: 8px 14px;
  background: none; border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  color: var(--ink-soft);
  position: relative;
  transition: color .15s;
}
.tpl-lang-tab:hover { color: var(--ink); }
.tpl-lang-active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tpl-translate-row {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-soft);
}

/* Tags / chips de contactes */
.contact-tag {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1px 8px;
  margin: 1px 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.contact-tag:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.ds-chip {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 1px 8px;
  margin: 1px 2px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--ink-soft);
}

/* Globals (Resum notes) */
.health-note {
  margin-top: 8px;
  min-height: 50px;
  font-size: 13px;
}

