/* Menu light theme — tokens lifted from menu.pl:
   - Brand indigo #3F37FB (hover #6F68FC, soft tint #ECEDFE, deep #2E27D4)
   - Navy ink #262C51, page bg #F8F9FE, white cards, ~12px radius
   - Secondary accents from the site: #FFBF02 yellow, #50D841 green, #A6DEFF blue
   - Typeface: Red Hat Display, same as menu.pl
   Layout/structure is the sellway-dashboard theme; only the palette and font
   differ, so fixes to either dashboard's CSS stay portable to the other.
*/
@import url("https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@400;500;600;700&display=swap");

:root {
  --bg: #F8F9FE;
  --surface: #ffffff;
  --surface-soft: #F7F8FC;
  --surface-alt: #F0F1F9;
  --ink: #262C51;
  --ink-soft: #3A4068;
  --ink-mid: #6B7192;
  --muted: #9AA0BC;
  --line: #E7E9F5;
  --line-strong: #D2D6EA;
  --accent: #3F37FB;
  --accent-hover: #6F68FC;
  --accent-soft: #ECEDFE;
  --accent-strong: #2E27D4;
  --good: #3AAF2C;
  --bad: #E4483B;
  --warn: #FFBF02;
  --radius: 12px;
  --radius-lg: 15px;
  --shadow-sm: 0 1px 2px rgba(38,44,81,0.05);
  --shadow: 0 0.1rem 1rem 0.25rem rgba(38,44,81,0.06);
  --font:  "Red Hat Display", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv01";
  /* Safety belt - no element should ever cause horizontal page scroll on mobile.
     Wide content (tables) has its own .table-wrap scroll. */
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}

/* ----- Top bar ----- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img.wordmark { display: block; height: 22px; width: auto; }
.brand .brand-name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; color: var(--ink); }

.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tab {
  padding: 7px 12px; border-radius: 8px; color: var(--ink-mid);
  font-weight: 500; font-size: 13.5px; letter-spacing: -0.005em;
  transition: background 120ms ease, color 120ms ease;
}
.tab:hover { background: var(--surface-alt); color: var(--ink); }
.tab.is-active { background: var(--accent); color: #fff; }
.tab-signout { display: none; }   /* visible only inside mobile hamburger menu */

.user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--ink-mid); }
.freshness-badge {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 6px;
  letter-spacing: 0.02em; font-variant-numeric: tabular-nums;
  background: var(--surface-alt); color: var(--ink-mid);
  border: 1px solid var(--line);
  cursor: help;
}
.freshness-badge.fresh { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.freshness-badge.stale { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.freshness-badge.broken { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.avatar { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); }
.email { font-size: 13px; color: var(--ink-soft); }
.logout {
  color: var(--muted); font-size: 12.5px; padding: 6px 10px; border-radius: 6px;
}
.logout:hover { color: var(--ink); background: var(--surface-alt); }

/* Hamburger button - only visible on narrow viewports (toggled via media query) */
.hamburger {
  display: none;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 0; cursor: pointer;
  flex-direction: column; gap: 4px; align-items: center; justify-content: center;
  width: 38px; height: 38px;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 1px; transition: transform 200ms ease, opacity 200ms ease; }
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ----- Range bar ----- */
.range {
  display: flex; align-items: center; gap: 14px; padding: 18px 28px 8px;
  flex-wrap: wrap; max-width: 1480px; margin: 0 auto;
}
.range label {
  color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; font-weight: 500;
}
.range input[type="date"] {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-family: var(--font); font-size: 13.5px; color: var(--ink);
}
.range input[type="date"]:hover { border-color: var(--line-strong); }
.btn-primary {
  background: var(--accent); color: white; border: 0; padding: 8px 16px; border-radius: 8px;
  font-weight: 600; font-size: 13.5px; cursor: pointer; font-family: var(--font);
  letter-spacing: -0.005em;
  transition: background 120ms ease, transform 80ms ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.muted { color: var(--muted); font-size: 12px; }
.range-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.range-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }

main { padding: 8px 28px 64px; max-width: 1480px; margin: 0 auto; }

/* ----- KPIs ----- */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 22px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
  position: relative;
}
.kpi .kpi-ic {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
}
.kpi .kpi-ic .ic { width: 15px; height: 15px; }
.kpi .label {
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 500; padding-right: 34px;
  /* reserve two lines so the value sits at the same height on every card,
     even when a label wraps (e.g. "Koszt leada hotelowego") */
  min-height: 2.7em; line-height: 1.35;
  display: flex; align-items: flex-start;
}
.kpi .value {
  font-size: 22px; font-weight: 600; margin-top: 6px;
  letter-spacing: -0.02em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kpi .sub { color: var(--ink-mid); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ----- Cards ----- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card.no-pad { padding: 0; }
.card h2 {
  margin: 0 0 14px 0; font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink);
  display: flex; align-items: center; gap: 9px;
}
/* Inline section icons (Feather-style, themed to the brand accent). */
.ic {
  width: 17px; height: 17px; flex: 0 0 auto;
  color: var(--accent); stroke-width: 2;
}
.ic-badge {
  width: 30px; height: 30px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
}
.ic-badge .ic { width: 16px; height: 16px; }
.card h3 {
  margin: 18px 0 8px 0; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap > table { min-width: 720px; }
/* "fit" tables aim to sit inside a normal desktop width without sideways
   scroll: drop the min-width and let text columns wrap. */
.table-wrap.fit > table { min-width: 0; }
.table-wrap.fit td.wrap, .table-wrap.fit th.wrap { white-space: normal; }
.table-wrap.fit td, .table-wrap.fit th { padding: 9px 10px; }
.link-btn {
  color: var(--accent); font-weight: 600; font-size: 12.5px;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 7px;
  display: inline-block; white-space: nowrap;
}
.link-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
th:first-child, td:first-child { text-align: left; font-variant-numeric: normal; }
thead th {
  background: var(--surface-soft); color: var(--muted);
  font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
}
tbody tr:hover { background: var(--surface-soft); }
tbody tr:last-child td { border-bottom: 0; }
tr.total td {
  font-weight: 600; background: var(--surface-alt);
  border-top: 1px solid var(--line-strong);
}
td.num { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
td.dim { color: var(--muted); }

/* ----- Subtabs ----- */
.subtabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--line); padding-bottom: 0;
}
.subtab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 14px; font-family: var(--font); font-weight: 500; font-size: 13px;
  color: var(--ink-mid); cursor: pointer; letter-spacing: -0.005em;
  margin-bottom: -1px;
  transition: color 120ms ease, border-color 120ms ease;
}
.subtab:hover { color: var(--ink); }
.subtab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* Segmented control */
.card-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.seg {
  display: inline-flex; background: var(--surface-alt); border-radius: 8px; padding: 3px;
  border: 1px solid var(--line);
}
.seg-btn {
  background: transparent; border: 0; padding: 6px 12px; border-radius: 6px;
  font-family: var(--font); font-size: 12.5px; font-weight: 500; color: var(--ink-mid);
  cursor: pointer; letter-spacing: -0.005em;
  transition: background 120ms ease, color 120ms ease;
}
.seg-btn:hover:not(.is-active) { color: var(--ink); }
.seg-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ----- Charts ----- */
.two-col {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px; margin-bottom: 18px;
}
.two-col > .card { margin-bottom: 0; }
/* Wrap every canvas in .chart-box with a fixed height to stop Chart.js
   from growing the canvas every resize (canvas grows -> parent grows -> canvas grows -> ...). */
.chart-box { position: relative; width: 100%; }
.chart-box > canvas { width: 100% !important; height: 100% !important; display: block; }

/* Status pill (good/warn/bad) - generic, reusable for pacing etc. */
.pct-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pct-pill.pace-good { background: #d1fae5; color: #065f46; }
.pct-pill.pace-warn { background: #fef3c7; color: #92400e; }
.pct-pill.pace-bad { background: #fee2e2; color: #991b1b; }
.pct-pill.pace-neutral { background: var(--surface-alt); color: var(--muted); }

.cat-current { margin-bottom: 4px; font-variant-numeric: tabular-nums; }

.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }

/* Select used by the manual status editor */
.cat-select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-family: var(--font); font-size: 12.5px;
  color: var(--ink); max-width: 180px;
}
.cat-select:focus { border-color: var(--accent); outline: none; }

/* ===== Mobile / narrow viewport ===== */
@media (max-width: 900px) {
  /* Topbar: brand left, freshness + avatar + hamburger right */
  .topbar {
    flex-wrap: wrap; gap: 10px 8px; padding: 10px 16px;
    position: relative;
  }
  .brand { order: 0; flex: 1 1 auto; min-width: 0; }
  .user { order: 1; gap: 8px; margin-left: auto; }
  .user .email { display: none; }
  .user .logout { display: none; }  /* sign-out moves into hamburger menu */
  .hamburger { display: inline-flex; order: 2; }

  /* Hamburger dropdown contains tabs + sign-out */
  .tabs {
    order: 99; width: 100%; margin-left: 0;
    flex-direction: column; gap: 2px;
    background: var(--surface); border-top: 1px solid var(--line);
    margin: 8px -16px -10px; padding: 8px 16px 12px;
    display: none;
  }
  .tabs.is-open { display: flex; }
  .tab { padding: 12px 14px; font-size: 14px; border-radius: 8px; }
  .tab-signout {
    display: block; margin-top: 8px; padding-top: 14px;
    border-top: 1px solid var(--line); color: var(--bad); font-weight: 600;
  }
  .tab-signout:hover { background: #fee2e2; }

  /* Range bar: stack into clean rows on mobile.
     Row 1: From + To dates (50/50). Row 2: quick chips. Row 3: Apply (full width). */
  .range {
    padding: 12px 16px 8px;
    gap: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "from to"
      "quick quick"
      "apply apply";
    align-items: center;
  }
  .range > label:nth-of-type(1) { grid-area: from; }
  .range > label:nth-of-type(2) { grid-area: to; }
  .range > #applyRange { grid-area: apply; width: 100%; }
  .range > #quickRange { grid-area: quick; }
  .range-sep, .range-label { display: none; }
  .range label {
    font-size: 10.5px;
    flex-direction: column; align-items: stretch; gap: 4px;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 500;
  }
  .range input[type="date"] {
    width: 100%; padding: 9px 10px; font-size: 14px;
  }
  #quickRange {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: 100%;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 3px;
  }
  #quickRange .seg-btn { padding: 8px 4px; font-size: 12px; }

  /* Main padding tighter */
  main { padding: 4px 16px 48px; }

  /* KPI cards: 2 per row on phones */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .value { font-size: 18px; }
  .kpi .label { font-size: 10px; }

  /* Two-col layout always 1 col on phone */
  .two-col { grid-template-columns: 1fr; gap: 12px; }

  /* Subtabs: horizontal scroll */
  .subtabs {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap; scrollbar-width: none;
  }
  .subtabs::-webkit-scrollbar { display: none; }
  .subtab { flex: 0 0 auto; }

  /* Card paddings */
  .card { padding: 14px 14px; }
  .card h2 { font-size: 14px; }

  /* Freshness badge in topbar: smaller on phone */
  .freshness-badge { font-size: 10.5px; padding: 3px 8px; }
}

@media (max-width: 480px) {
  /* Even tighter for small phones */
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 17px; }
  .freshness-badge { display: none; }     /* save space; tooltip irrelevant on phone */
  main { padding: 4px 12px 40px; }
  .range { padding: 10px 12px 4px; }
}

/* ===== Menu-specific components ===== */

/* Card body padding when the card itself is .no-pad (table cards with a header) */
.card-pad { padding: 18px 20px 0; }
.card.no-pad .card-pad + .table-wrap { margin-top: 14px; }

/* Config-gap notice: unclassified segments, missing emoji meanings. Deliberately
   loud and always visible — a silent default bucket is the failure mode this
   whole design avoids. */
.notice {
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px;
  font-size: 13px; color: var(--ink-soft);
}
.notice code {
  font-family: var(--mono); font-size: 12px; background: var(--surface);
  padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line);
}

/* Segment + status pills. Colour comes from the config via a --pill var, so a
   new segment/status needs no CSS. */
.seg-pill, .status-pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  color: var(--pill, var(--accent));
  background: color-mix(in srgb, var(--pill, var(--accent)) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--pill, var(--accent)) 35%, #fff);
}
/* An LLM-inferred status is visually weaker than a human's or an emoji's -
   it is a suggestion, and must not read as a decision. */
.status-pill.is-guess { border-style: dashed; opacity: 0.85; }

th.seg-head {
  color: var(--pill, var(--ink-mid)); text-align: center;
  border-bottom: 2px solid var(--pill, var(--line));
}
th.seg-head.dim { color: var(--muted); border-bottom-color: var(--line-strong); }

/* ----- Filters (lead table) ----- */
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 14px 0 10px; }
.input {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-family: var(--font); font-size: 13.5px;
  color: var(--ink); min-width: 260px; flex: 1 1 260px;
}
.input:focus { border-color: var(--accent); outline: none; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-mid); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 14px; }
.chip {
  background: var(--surface-alt); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-family: var(--font); font-size: 12.5px; font-weight: 500;
  color: var(--ink-mid); cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ----- Lead rows ----- */
table.leads tbody tr.lead-row { cursor: pointer; }
table.leads td { vertical-align: top; }

.emoji-chip {
  display: inline-block; font-family: var(--mono); font-size: 11px;
  background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 6px; margin: 0 3px 3px 0; color: var(--ink-mid);
}

.lead-summary {
  margin-top: 5px; font-size: 12.5px; color: var(--ink-mid); white-space: normal;
  line-height: 1.4;
}
.lead-summary.is-weak { color: var(--muted); font-style: italic; }
.tag-llm {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); border-radius: 4px;
  padding: 1px 5px; margin-left: 4px; white-space: nowrap;
}

/* ----- Expanded lead detail ----- */
/* Grid children default to min-width:auto, so a long unbroken answer (the
   "dlaczego chcesz zostać partnerem" free text) widens its track and spills
   over the neighbouring column. This is the fix - not a width on the text. */
.detail-col { min-width: 0; }
.detail-col h3 {
  margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 10px;
}
.detail-col h3 + h3, .detail-col > *  + h3 { margin-top: 18px; }
.kv {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px;
}
.kv span { color: var(--muted); }
.kv b { font-weight: 500; color: var(--ink); text-align: right; word-break: break-word; }

.slack-raw {
  margin: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-mid);
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto;
}

.reply {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; margin-bottom: 8px;
}
.reply-head {
  font-size: 12px; font-weight: 600; color: var(--ink); display: flex;
  justify-content: space-between; gap: 12px; margin-bottom: 3px;
}
.reply-head .dim { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.reply-body { font-size: 13px; color: var(--ink-soft); white-space: pre-wrap; word-break: break-word; }

.status-editor { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.status-editor .input { min-width: 160px; }

@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; gap: 16px; padding: 14px; }
  .card-pad { padding: 14px 14px 0; }
  .input { min-width: 0; }
}

/* Warning variant of .notice: a data caveat rather than a config gap. */
.notice-warn { background: #FFF8E1; border-color: var(--warn); }
/* Cell where Meta's reported lead count exceeds what we hold (retention gap). */
td.is-gap { color: #8A6100; font-weight: 600; cursor: help; }

/* Local no-auth banner. Deliberately loud and un-dismissable: a dashboard
   serving client lead data with the login gate off must never look normal. */
.devbar {
  background: #7A1D12; color: #fff; font-size: 12.5px; font-weight: 500;
  padding: 7px 28px; letter-spacing: 0.01em;
}
.devbar strong { font-weight: 700; }
@media (max-width: 900px) { .devbar { padding: 7px 16px; font-size: 11.5px; } }

/* ----- Lead table: wrapping discipline -----
   The base rule is `white-space: nowrap` on every cell (numeric tables need
   it). Text columns opt out explicitly, and every one of them breaks long
   words so nothing can push the table wider than its scroll container. */
table.leads td.wrap, table.leads th.wrap { white-space: normal; overflow-wrap: anywhere; }
table.leads td.nowrap { white-space: nowrap; }
table.leads td.wrap { max-width: 320px; }
table.leads td.contact { font-size: 12.5px; color: var(--ink-mid); max-width: 220px; }

/* Real emoji instead of Slack shortcodes. */
.emoji-cell { font-size: 17px; line-height: 1.3; letter-spacing: 2px; }
.emoji { cursor: help; }

/* Qualification answers: three fixed slots, colour-coded yes/no. */
.qual {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  padding: 2px 6px; border-radius: 5px; margin-right: 3px; cursor: help;
  border: 1px solid transparent;
}
.qual.is-yes { background: #E3F7E0; color: #1F7A14; border-color: #BEECB8; }
.qual.is-no { background: #FDE8E6; color: #A32A1E; border-color: #F7C7C2; }
.qual.is-other { background: var(--accent-soft); color: var(--accent-strong); }
.qual.is-unknown { background: var(--surface-alt); color: var(--muted); }

/* Note written in the dashboard, shown inline under the lead name. */
.lead-note {
  margin-top: 5px; font-size: 12.5px; color: var(--ink-soft); white-space: normal;
  border-left: 2px solid var(--accent); padding-left: 8px; line-height: 1.4;
}

/* Follow-up date; turns red once it's today or overdue. */
.due-pill {
  display: inline-block; margin-top: 4px; font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 5px; background: var(--surface-alt);
  color: var(--ink-mid); font-variant-numeric: tabular-nums;
}
.due-pill.is-due { background: #FDE8E6; color: #A32A1E; }

/* One-click status buttons, Pipedrive-style, instead of select + save. */
.status-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.status-btn {
  border: 1px solid color-mix(in srgb, var(--pill, var(--line)) 40%, #fff);
  background: color-mix(in srgb, var(--pill, var(--accent)) 8%, #fff);
  color: var(--ink); font-family: var(--font); font-size: 12.5px; font-weight: 500;
  padding: 6px 11px; border-radius: 7px; cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.status-btn:hover { border-color: var(--pill, var(--accent)); }
.status-btn.is-active {
  background: var(--pill, var(--accent)); color: #fff; font-weight: 600;
  border-color: var(--pill, var(--accent));
}
.status-btn.is-clear { background: transparent; color: var(--muted); border-color: var(--line); }
.status-btn.is-clear:hover { color: var(--bad); border-color: var(--bad); }

.editor-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; }
.editor-row label {
  display: flex; flex-direction: column; gap: 4px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 500;
}
.editor-row input[type="date"] {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-family: var(--font); font-size: 13px; color: var(--ink);
}
.note-input { flex: 1 1 220px; resize: vertical; font-size: 13px; line-height: 1.45; padding: 8px 11px; }

/* Free-text motivation answer. Must wrap hard - it is 2-3 sentences. */
.motivation {
  margin: 0; padding: 10px 12px; background: var(--surface);
  border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
  font-size: 13px; line-height: 1.5; color: var(--ink-soft);
  white-space: pre-wrap; overflow-wrap: anywhere;
}

.empty.small { padding: 12px; font-size: 12.5px; text-align: left; }

/* ===== Lead modal =====
   Replaces the in-place row expansion: expanding a row reflowed the entire
   table and jumped the reader's position on every save. */
body.modal-open { overflow: hidden; }

#leadModal:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(38,44,81,0.45);
  backdrop-filter: blur(2px); z-index: 100;
}
.modal {
  position: fixed; z-index: 101;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(1060px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(38,44,81,0.28);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.modal-title { min-width: 0; flex: 1 1 auto; }
.modal-title h2 {
  margin: 0 0 6px; font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink); overflow-wrap: anywhere;
}
.modal-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.modal-sub .emoji { font-size: 15px; }
.modal-close {
  flex: 0 0 auto; background: transparent; border: 1px solid var(--line);
  border-radius: 8px; width: 32px; height: 32px; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--ink-mid); font-family: var(--font);
}
.modal-close:hover { background: var(--surface-alt); color: var(--ink); }

.modal-body {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 26px; padding: 20px 22px 24px; overflow-y: auto;
}
/* Grid children default to min-width:auto, so a long free-text answer would
   widen its track and spill over the neighbouring column. */
.modal-body .detail-col { min-width: 0; }

/* ----- Contact log ----- */
.act-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.act-form input[type="date"] {
  flex: 0 0 auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-family: var(--font); font-size: 13px; color: var(--ink);
}
.act-form input[type="text"] { flex: 1 1 180px; min-width: 0; }

.act-list { list-style: none; margin: 0 0 4px; padding: 0; }
.act {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.act:last-child { border-bottom: 0; }
.act-date {
  flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--ink-mid); font-size: 12.5px;
}
.act-note { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; color: var(--ink-soft); }
.act-tag {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 1px 6px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent-strong);
}
.act.is-planned .act-date { color: var(--accent); }
.act.is-empty { color: var(--muted); border-bottom: 0; }
.act-del {
  flex: 0 0 auto; background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font-size: 17px; line-height: 1; padding: 0 2px;
}
.act-del:hover { color: var(--bad); }

/* Contact column in the table: newest entry, planned ones highlighted. */
.due-pill.is-planned { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.act-count {
  display: inline-block; margin-left: 5px; font-size: 10.5px; font-weight: 700;
  color: var(--muted); background: var(--surface-alt); border-radius: 4px; padding: 1px 5px;
}

table.leads tbody tr.lead-row { cursor: pointer; }
table.leads tbody tr.lead-row:hover { background: var(--accent-soft); }

@media (max-width: 900px) {
  .modal { width: calc(100vw - 16px); max-height: calc(100vh - 24px); }
  .modal-body { grid-template-columns: 1fr; gap: 18px; padding: 16px; }
  .modal-head { padding: 14px 16px; }
}

/* Slack-origin entries in the contact timeline: read-only, tagged with author. */
.act.is-slack .act-date { color: var(--muted); }
.act-who {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 600; color: var(--ink-mid);
  background: var(--surface-alt); border-radius: 4px; padding: 1px 6px;
  white-space: nowrap; cursor: help;
}

/* Footnote under a table whose rows are a filtered subset — keeps totals
   reconcilable without putting a non-row back into the table. */
.table-foot {
  padding: 10px 20px 14px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); line-height: 1.5;
}

/* ===== Table legibility =====
   Wide numeric tables (Miesiąc po miesiącu has 4 column groups) blur into one
   grey field without structure. Three cheap signals, in order of importance:
   a vertical rule between column GROUPS, zebra rows, and a stronger header. */

/* Group boundary: first cell of each segment / "Razem" block. */
table th.grp, table td.grp { border-left: 2px solid var(--line-strong); }
table th.grp:first-child, table td.grp:first-child { border-left: 0; }

/* Zebra striping. Kept subtle - it must not compete with the hover state. */
tbody tr:nth-child(even) { background: var(--surface-soft); }
tbody tr:nth-child(even):hover, tbody tr:hover { background: var(--accent-soft); }

/* Header block reads as a header, not as another row. */
thead th {
  border-bottom: 2px solid var(--line-strong);
  background: var(--surface-alt);
}
/* Two-row header: the group titles keep their coloured underline. */
thead tr:first-child th.seg-head { border-bottom-width: 3px; }

/* The month/name column anchors the eye while scrolling sideways. */
table td:first-child { font-weight: 600; color: var(--ink); }

/* Row separators slightly stronger than the template default. */
tbody td { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
