:root {
  --background: #fafaf8;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #6d7600;      /* tumma lime-oliivi: linkit/tekstiaksentit (lukukelpoinen) */
  --brand: #c8d300;       /* Mäkelä Alu lime: graafiset aksentit */
  --brand-warm: #ec683b;  /* Mäkelä Alu oranssi: signaalit/huomiot */
  --line: #e5e7eb;
  --soft: #f4f5f4;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--background);
  font-size: 15px;
  line-height: 1.6;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1560px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  background: rgba(250, 250, 248, 0.98);
  border-top: 4px solid var(--brand);
  border-bottom: 1px solid var(--line);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  gap: 32px;
}

.brand {
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.header-stats strong {
  color: var(--text);
  font-weight: 650;
}

.main-nav {
  display: flex;
  gap: 28px;
}

.main-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 42px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.main-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.main-nav a.active {
  color: var(--accent);
}

.main-nav a.active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--brand);
  content: "";
}

.page {
  min-height: calc(100vh - 190px);
  padding-block: 52px 40px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.25;
}

.page-heading h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.035em;
}

.page-intro {
  margin: 6px 0 0;
  color: var(--muted);
}

.result-count {
  padding-bottom: 3px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.result-count strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 680;
}

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  min-height: 76px;
  margin-bottom: 20px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-bar label > span:first-child,
.filter-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.025em;
}

select,
input[type="search"],
.auth-form input:not([type="hidden"]) {
  height: 36px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

select {
  min-width: 136px;
  padding: 0 32px 0 10px;
}

input[type="search"] {
  min-width: 230px;
  padding: 0 11px;
}

select:focus,
input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(200, 211, 0, 0.3);
}

.auth-form {
  align-items: stretch;
  flex-direction: column;
  width: min(100%, 480px);
}

.auth-form input:not([type="hidden"]) {
  width: 100%;
  padding: 0 11px;
}

.auth-form input:focus {
  outline: 2px solid var(--accent);
}

.auth-users { overflow-x: auto; }
.auth-users .search-row { margin: 6px 0; }
.err { font-weight: 600; border-left: 3px solid var(--brand-warm); padding-left: 12px; }

select.filter-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.search-filter {
  flex: 1;
}

.search-row {
  display: flex;
  gap: 7px;
}

.search-row input {
  width: 100%;
}

.search-row button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--brand);
  border-radius: 5px;
  background: var(--brand);
  color: #1a1d21;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.clear-filter {
  align-self: center;
  margin-top: 17px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfbfa;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.025em;
  text-align: left;
  white-space: nowrap;
}

td {
  min-height: 44px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.lead-table {
  min-width: 1180px;
}

.lead-table tbody tr {
  min-height: 44px;
  transition: background-color 120ms ease;
}

.lead-table tbody tr.clickable-row {
  cursor: pointer;
}

.lead-table tbody tr.clickable-row:hover,
.lead-table tbody tr.clickable-row:focus {
  outline: none;
  background: #f7faf9;
}

.rank-col {
  width: 44px;
}

.rank {
  width: 44px;
  color: #9ca3af;
  font-size: 12px;
  text-align: right;
}

.company-cell {
  min-width: 210px;
}

.company-name {
  display: block;
  width: fit-content;
  color: var(--text);
  font-weight: 650;
  line-height: 1.35;
}

.company-name:hover {
  color: var(--accent);
}

.company-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.gf-contact-cell {
  min-width: 220px;
  font-size: 12px;
  line-height: 1.35;
}

.contact-name {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.contact-email-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 3px;
}

.contact-email {
  overflow-wrap: anywhere;
}

.copy-email {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: none;
  padding: 0 1px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.copy-email:hover {
  color: var(--accent);
}

.copy-email .ico-check {
  display: none;
}

.copy-email.copied .ico-copy {
  display: none;
}

.copy-email.copied .ico-check {
  display: inline;
}

.email-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.04em;
  line-height: 1.5;
  white-space: nowrap;
}

.linkedin-link {
  display: block;
  width: fit-content;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
}

.chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  white-space: nowrap;
}

.segment-chip,
.sector-chip {
  background: #f2f4dc;
  color: #4c530f;
}

.in-leads-chip {
  background: rgba(200, 211, 0, 0.2);
  color: #565e00;
  font-weight: 650;
}

/* CRM-lippu (scripts/crm_dedup.py): yritys on jo Mäkelä Alun Dynamicsissa */
.crm-chip {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.crm-chip-customer {
  background: #e0e7ff;
  color: #3730a3;
}

.crm-chip-former_customer {
  background: #f1f5f9;
  color: #475569;
}

.crm-chip-crm_lead {
  background: #fce7f3;
  color: #9d174d;
}

.crm-toggle {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.crm-toggle:hover {
  background: #e0e7ff;
}

.crm-toggle-active {
  background: #3730a3;
  border-color: #3730a3;
  color: #fff;
}

.tier-a {
  background: #dcfce7;
  color: #166534;
}

.tier-b {
  background: #fef3c7;
  color: #92400e;
}

.tier-c {
  background: #f3f4f6;
  color: #4b5563;
}

.tier-d {
  background: #e5e7eb;
  color: #374151;
}

.company-name-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tier-score-cell {
  white-space: nowrap;
}

.score-num {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 650;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--text);
}

th.sortable::after {
  content: "↕";
  margin-left: 4px;
  opacity: 0.45;
  font-size: 10px;
}

th.sortable.sort-asc::after {
  content: "▲";
  opacity: 1;
}

th.sortable.sort-desc::after {
  content: "▼";
  opacity: 1;
}

.export-link {
  margin-left: auto;
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.export-link:hover {
  border-color: var(--accent);
}

.score {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.score strong {
  width: 22px;
  font-weight: 650;
  text-align: right;
}

.score-track {
  display: inline-block;
  width: 60px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.score-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.signal-col,
.signal-cell {
  width: 64px;
  text-align: center;
}

.fresh-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-warm);
  box-shadow: 0 0 0 3px rgba(236, 104, 59, 0.15);
}

.angle {
  color: #374151;
  font-size: 13px;
}

.brief-link {
  position: relative;
  font-size: 13px;
  font-weight: 600;
  z-index: 1;
}

.muted {
  color: var(--muted);
}

.empty-inline {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.family-filter {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-links {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8f8f7;
}

.filter-links a {
  padding: 4px 9px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.filter-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.filter-links a.active {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  color: var(--accent);
}

.signal-filters {
  justify-content: space-between;
}

.signal-form {
  display: flex;
  align-items: flex-end;
  gap: 18px;
}

.checkbox-filter {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  min-height: 36px;
  color: #4b5563;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.checkbox-filter input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.checkbox-filter span {
  color: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  letter-spacing: normal !important;
}

.signal-feed {
  display: grid;
  gap: 30px;
}

.signal-day h2 {
  margin: 0 0 10px;
  color: #4b5563;
  font-size: 13px;
  font-weight: 650;
}

.signal-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.signal-card {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr) 170px;
  align-items: center;
  gap: 20px;
  min-height: 86px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.signal-card:last-child {
  border-bottom: 0;
}

.signal-taxonomy {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.family-a {
  background: #fee2e2;
  color: #991b1b;
}

.family-b {
  background: #dbeafe;
  color: #1e40af;
}

.family-c {
  background: #dcfce7;
  color: #166534;
}

.signal-type {
  overflow: hidden;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strength {
  display: inline-flex;
  gap: 3px;
  margin-left: auto;
}

.strength span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d1d5db;
}

.strength span.filled {
  background: #a9b300;
}

.signal-summary {
  margin: 0;
  line-height: 1.55;
}

.signal-summary-original {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.signal-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.signal-target {
  max-width: 100%;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fair-groups {
  display: grid;
  gap: 32px;
}

.fair-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 10px;
}

.fair-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 680;
}

.fair-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.fair-table {
  min-width: 760px;
}

.fair-table td {
  font-size: 13px;
}

.fair-table .fair-company {
  color: var(--text);
  font-weight: 650;
}

.fair-table tr.matched-exhibitor {
  background: #f7faf9;
}

.source-link {
  color: var(--muted);
  font-size: 11px;
}

.empty-state,
.not-found-card {
  display: grid;
  min-height: 220px;
  place-content: center;
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty-state code {
  color: #4b5563;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.brief-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.contact-panel {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px 28px;
  max-width: 900px;
  margin: 0 auto 16px;
  padding: 16px 20px;
  border-width: 1px;
  border-style: solid;
  border-radius: 8px;
  font-size: 13px;
}

.contact-panel-item {
  display: flex;
  flex-direction: column;
  min-width: 120px;
}

.contact-panel-person {
  min-width: 180px;
}

.contact-panel-label {
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.contact-panel .contact-email-row,
.contact-panel .linkedin-link {
  margin-top: 0;
}

.back-link,
.domain-link {
  font-size: 13px;
  font-weight: 600;
}

.domain-link {
  color: var(--muted);
  font-weight: 500;
}

.brief-card {
  max-width: 900px;
  margin-inline: auto;
  padding: 46px 58px 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.markdown-body h1 {
  margin: 0 0 30px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--brand);
  font-size: 28px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

.markdown-body h2 {
  margin: 30px 0 9px;
  font-size: 18px;
}

.markdown-body p {
  margin: 0 0 18px;
}

.markdown-body ol,
.markdown-body ul {
  margin: -5px 0 22px;
  padding-left: 24px;
}

.markdown-body li {
  margin-bottom: 7px;
}

.markdown-body blockquote {
  margin: 20px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--brand);
  background: #fafbe9;
  color: #3a3e1a;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body hr {
  margin: 34px 0 20px;
  border: 0;
  border-top: 1px solid var(--line);
}

.markdown-body em {
  color: #4b5563;
}

.not-found-card {
  max-width: 620px;
  margin: 50px auto 0;
}

.not-found-card h1 {
  margin: 2px 0 8px;
  color: var(--text);
  font-size: 26px;
}

.not-found-card .back-link {
  margin-top: 14px;
}

.footer {
  padding-block: 20px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 28px, 1100px);
  }

  .header-top,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-top {
    gap: 5px;
    padding-block: 16px 12px;
  }

  .page-heading {
    gap: 12px;
  }

  .filter-bar,
  .signal-form {
    align-items: stretch;
    flex-direction: column;
  }

  .lead-filters label,
  .signal-form label,
  select,
  input[type="search"] {
    width: 100%;
  }

  .signal-filters {
    align-items: stretch;
  }

  .filter-links {
    flex-wrap: wrap;
  }

  .signal-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .fair-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .fair-heading p {
    white-space: normal;
  }

  .signal-meta {
    flex-direction: row;
    justify-content: space-between;
  }

  .brief-card {
    padding: 32px 26px 38px;
  }

  .contact-panel {
    gap: 12px 20px;
  }
}

@media (max-width: 520px) {
  .header-stats {
    flex-wrap: wrap;
  }

  .page {
    padding-top: 34px;
  }

  .page-heading h1 {
    font-size: 27px;
  }

  .brief-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}

.nowrap {
  white-space: nowrap;
}

.contact-variants { display: block; margin-top: 5px; font-size: 12px; line-height: 1.4; }
.purchasing-contact { flex-basis: 100%; border-top: 1px solid var(--line); padding-top: 12px; }
/* Sales queue: structure only; palette is in theme.css. */
.lead-filters { flex-wrap: wrap; }
.status-counters { margin: 12px 0; font-size: 13px; overflow-x: auto; white-space: nowrap; }
.status-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px; margin-bottom: 12px; border: 2px solid; border-radius: 8px; }
#status-form { position: sticky; top: 8px; z-index: 5; }
.status-actions[hidden] { display: none; }
.status-actions select, .status-actions input { max-width: 100%; padding: 7px 9px; border: 1px solid; border-radius: 5px; font: inherit; }
.status-actions button, .status-quick-actions button { border: 1px solid; border-radius: 5px; padding: 6px 9px; font: inherit; cursor: pointer; }
.status-actions [data-selection-count] { font-size: 13px; white-space: nowrap; }
.status-chip { display: inline-block; padding: 4px 7px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.status-cell { min-width: 175px; max-width: 260px; }
.status-note { display: block; margin-top: 4px; font-size: 12px; overflow-wrap: anywhere; }
.status-quick-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.status-quick-actions form { margin: 0; }
.status-quick-actions button { font-size: 12px; }
.select-col { width: 38px; text-align: center; }
.select-col input { width: 18px; height: 18px; cursor: pointer; }
.flash { padding: 12px 14px; border-left: 3px solid; border-radius: 5px; overflow-wrap: anywhere; }
.status-history { margin: 18px 0; }
.status-history li, .batch-items li { padding: 5px 0; overflow-wrap: anywhere; }
.batch-card { padding: 20px; margin: 16px 0; }
.batch-card summary { cursor: pointer; }
.assignees-panel { margin-top: 32px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
