:root {
  --bg: #faf9f8;
  --bg-elev: #ffffff;
  --bg-soft: #f3f1ef;
  --line: rgba(48, 48, 48, 0.12);
  --line-strong: rgba(48, 48, 48, 0.18);
  --text: #303030;
  --muted: #6b6b6b;
  --accent: #ff705b;
  --accent-soft: rgba(255, 112, 91, 0.1);
  --accent-soft-2: #fff1ee;
  --peach: #fff6f3;
  --dark: #303030;
  --won: #2f7a5e;
  --won-soft: rgba(47, 122, 94, 0.12);
  --lost: #9a6a6a;
  --follow: #c46a3a;
  --radius: 16px;
  --radius-sm: 12px;
  --pill: 999px;
  --font: "Figtree", system-ui, sans-serif;
  --shadow: 0 10px 30px rgba(48, 48, 48, 0.06);
  --shadow-lg: 0 22px 50px rgba(48, 48, 48, 0.1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 480px at 0% 0%, rgba(255, 112, 91, 0.09), transparent 55%),
    radial-gradient(800px 420px at 100% 10%, rgba(255, 200, 185, 0.35), transparent 50%),
    radial-gradient(700px 400px at 80% 100%, rgba(255, 112, 91, 0.05), transparent 45%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.full { width: 100%; }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 1.35rem 1.1rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-height: 100vh;
  overflow: hidden;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.35rem 0.55rem 0.75rem;
}
.brand-logo {
  display: block;
  height: 28px;
  width: auto;
  max-width: 118px;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.nav-btn {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.72rem 0.9rem;
  border-radius: 14px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-btn[hidden] { display: none !important; }
.nav-group[hidden] { display: none !important; }
.nav-btn:hover { background: var(--accent-soft); color: var(--text); }
.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-group { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.72rem 0.9rem;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-group-toggle:hover { background: var(--accent-soft); color: var(--text); }
.nav-group.open > .nav-group-toggle,
.nav-group.has-active > .nav-group-toggle {
  color: var(--text);
}
.nav-chevron {
  font-size: 0.75rem;
  transition: transform 0.15s ease;
  color: var(--muted);
}
.nav-group.open .nav-chevron { transform: rotate(90deg); }
.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0 0 0.2rem 0.35rem;
}
.nav-group-items[hidden] { display: none; }
.nav-btn.nav-sub {
  padding: 0.55rem 0.85rem;
  font-size: 0.86rem;
  font-weight: 600;
}

.main { padding: 1.35rem 1.6rem 2.2rem; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.35rem;
  flex-wrap: wrap;
}
.topbar h1 {
  margin: 0;
  font-weight: 600;
  font-size: clamp(1.6rem, 2.2vw, 2.1rem);
  letter-spacing: -0.03em;
  color: var(--dark);
}
.topbar h1 .accent { color: var(--accent); }
.topbar p { margin: 0.25rem 0 0; font-size: 0.95rem; }
.topbar p .accent,
.topbar h1 .accent { color: var(--accent); }
.top-actions { display: flex; gap: 0.55rem; flex-wrap: wrap; }

/* Denser chrome when working the pipeline board */
body[data-view^="pipeline"] .main {
  padding: 0.7rem 0.85rem 1rem;
}
body[data-view^="pipeline"] .topbar {
  margin-bottom: 0.45rem;
  gap: 0.55rem;
  align-items: center;
}
body[data-view^="pipeline"] .topbar h1 {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
body[data-view^="pipeline"] .topbar p {
  font-size: 0.75rem;
  margin-top: 0.1rem;
}
body[data-view^="pipeline"] #search,
body[data-view^="pipeline"] #user-filter {
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  font-size: 0.82rem;
}
body[data-view^="pipeline"] .pipeline-toolbar .btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  border-radius: 10px;
}

#search,
#user-filter,
.field,
select,
textarea,
input[type="text"],
input[type="search"],
input[type="number"] {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.62rem 0.9rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#search:focus,
#user-filter:focus,
select:focus,
textarea:focus,
input:focus {
  outline: none;
  border-color: rgba(255, 112, 91, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 112, 91, 0.12);
}
#search { min-width: 250px; }

.user-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.user-select-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
body[data-view^="pipeline"] .user-select-label {
  font-size: 0.7rem;
}
#btn-undo {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
#btn-undo:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.undo-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--accent-soft, rgba(255, 112, 91, 0.12));
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--pill);
  padding: 0.58rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(255, 112, 91, 0.28);
}
.btn.primary:hover { filter: brightness(1.03); }
.btn.ghost { background: transparent; }
.btn.danger {
  color: #9a3b3b;
  border-color: rgba(154, 59, 59, 0.28);
  background: rgba(154, 59, 59, 0.06);
}
.btn.danger:hover {
  background: rgba(154, 59, 59, 0.12);
  border-color: rgba(154, 59, 59, 0.4);
}
.btn.danger.ghost {
  background: rgba(154, 59, 59, 0.06);
  border: 1px solid rgba(154, 59, 59, 0.22);
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.55rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 10px;
}
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }

.view { display: none; }
.view.active { display: block; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}
.stat .label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.stat .value {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-top: 0.25rem;
  color: var(--dark);
}
.stat .value.accent { color: var(--accent); }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.panel h3 {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.analytics-panel { padding-bottom: 0.85rem; }
.analytics-expand-btn {
  white-space: nowrap;
}
.analytics-expand-footer {
  margin-top: 0.75rem;
}
.bar-chart.is-expanded {
  max-height: min(70vh, 920px);
  overflow-y: auto;
  padding-right: 0.25rem;
}
.analytics-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.analytics-toolbar h3 { margin: 0 0 0.2rem; }
.analytics-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}
.analytics-jump-link {
  text-decoration: none;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.analytics-jump-link:hover {
  color: var(--accent);
  border-color: rgba(255, 112, 91, 0.35);
  background: var(--accent-soft);
}
.analytics-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.analytics-head h3 { margin: 0 0 0.2rem; }
.analytics-sub { margin: 0; font-size: 0.85rem; }
.analytics-card-title {
  margin: 0 0 0.15rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.analytics-limit {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.analytics-limit select {
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  font-size: 0.85rem;
}
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.95fr) minmax(280px, 1.35fr);
  gap: 1.25rem;
  align-items: start;
}
.analytics-pie-card,
.analytics-bars-card {
  min-width: 0;
}
.pie-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-top: 0.65rem;
}
.pie-chart-wrap { width: min(100%, 240px); }
.pie-svg { width: 100%; height: auto; display: block; }
.pie-slice {
  cursor: pointer;
  transition: opacity 0.12s ease;
}
.pie-slice:hover { opacity: 0.88; }
.pie-center-label {
  font-size: 11px;
  fill: var(--muted);
  font-family: var(--font);
}
.pie-center-value {
  font-size: 16px;
  font-weight: 700;
  fill: var(--text);
  font-family: var(--font);
}
.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  width: 100%;
}
.pie-legend-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.28rem 0.35rem;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
  font: inherit;
  color: inherit;
}
button.pie-legend-item:hover { background: var(--accent-soft); }
div.pie-legend-item { cursor: default; }
.pie-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
  margin-top: 0.28rem;
  flex: 0 0 auto;
}
.pie-legend-text {
  display: flex;
  flex-direction: column;
  gap: 0.02rem;
  min-width: 0;
}
.pie-legend-text strong {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pie-legend-text .muted { font-size: 0.72rem; }
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.55rem;
}
.bar-row {
  display: grid;
  grid-template-columns: 1.6rem minmax(9rem, 14rem) 1fr 3.2rem;
  gap: 0.65rem;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.35rem 0.25rem;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.bar-row:hover { background: var(--accent-soft); }
.bar-rank {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}
.bar-label {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.bar-label strong {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-label .muted { font-size: 0.72rem; }
.bar-track {
  height: 0.72rem;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8a76, var(--accent));
  transition: width 0.35s ease;
}
.bar-value {
  font-size: 0.88rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .analytics-grid { grid-template-columns: 1fr; }
  .bar-row {
    grid-template-columns: 1.4rem 1fr 2.8rem;
    grid-template-areas:
      "rank label value"
      "rank track value";
  }
  .bar-rank { grid-area: rank; }
  .bar-label { grid-area: label; }
  .bar-track { grid-area: track; }
  .bar-value { grid-area: value; align-self: center; }
}

.board {
  display: grid;
  grid-template-columns: repeat(10, minmax(165px, 165px));
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  align-items: start;
  justify-content: start;
}
.column {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.column-head {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-radius: 12px 12px 0 0;
  cursor: grab;
  user-select: none;
}
.column-head:active { cursor: grabbing; }
.column-head strong { font-size: 0.72rem; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drag-handle {
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: -0.08em;
  line-height: 1;
  opacity: 0.7;
}
.pipeline-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
.column-add {
  margin: 0.1rem 0 0.15rem;
  width: 100%;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.35);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.55rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  flex-shrink: 0;
}
.column-add:hover {
  color: var(--accent);
  border-color: rgba(255, 112, 91, 0.45);
  background: var(--accent-soft);
}
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 24, 22, 0.45);
}
.modal-card {
  position: relative;
  width: min(440px, 100%);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(28, 24, 22, 0.18);
  padding: 1rem 1.1rem 1.1rem;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.field-label input,
.field-label select,
.field-label textarea {
  font-weight: 500;
  color: inherit;
  width: 100%;
  box-sizing: border-box;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
@media (max-width: 520px) {
  .modal-grid { grid-template-columns: 1fr; }
}
.rename-btn {
  font-size: 0.72rem;
  opacity: 0.55;
  padding: 0.05rem 0.15rem;
}
.rename-btn:hover { opacity: 1; color: var(--accent); }
.delete-btn {
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.45;
  padding: 0.02rem 0.2rem;
  color: var(--muted);
}
.delete-btn:hover { opacity: 1; color: var(--lost); background: rgba(154, 106, 106, 0.12); }
.column-title { cursor: text; }
.lead-card.dragging,
.column.column-dragging {
  opacity: 0.45;
}
.lead-card.drop-before {
  box-shadow: inset 0 2px 0 0 var(--accent);
}
.lead-card.drop-after {
  box-shadow: inset 0 -2px 0 0 var(--accent);
}
.column.drop-target {
  border-color: rgba(255, 112, 91, 0.55);
  box-shadow: 0 0 0 2px rgba(255, 112, 91, 0.12);
}
.column.column-drop {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(255, 112, 91, 0.14);
}
.column-body {
  min-height: 80px;
}
.deep-link-flash {
  animation: deepLinkFlash 1.6s ease;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(255, 112, 91, 0.25) !important;
}
@keyframes deepLinkFlash {
  0% { transform: scale(1); }
  30% { transform: scale(1.015); }
  100% { transform: scale(1); }
}
button.social-link {
  cursor: pointer;
  font: inherit;
}
.pill {
  font-size: 0.62rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--pill);
  padding: 0.1rem 0.35rem;
}
.column-body {
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow: auto;
  max-height: 78vh;
}

.lead-card {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 0.45rem 0.5rem;
  width: 100%;
  box-shadow: 0 2px 8px rgba(48, 48, 48, 0.03);
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  cursor: pointer;
}
.lead-card:focus-visible {
  outline: 2px solid rgba(255, 112, 91, 0.45);
  outline-offset: 1px;
}
.lead-card.demo-done {
  background: linear-gradient(165deg, rgba(47, 122, 94, 0.14), #fff 62%);
  border-color: rgba(47, 122, 94, 0.38);
  box-shadow: 0 2px 10px rgba(47, 122, 94, 0.08);
}
.lead-card.demo-done:hover {
  border-color: rgba(47, 122, 94, 0.55);
  box-shadow: 0 10px 22px rgba(47, 122, 94, 0.12);
}
.lead-card .demo-check {
  flex: 0 0 auto;
  display: grid;
  place-items: start;
  padding-top: 0.05rem;
  margin: 0;
  cursor: pointer;
}
.lead-card .demo-check input {
  width: 0.85rem;
  height: 0.85rem;
  accent-color: var(--won);
  cursor: pointer;
}
.lead-card .body {
  min-width: 0;
  flex: 1;
}
.demo-check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.35rem 0 0.85rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}
.demo-check-row.demo-done {
  background: var(--won-soft);
  border-color: rgba(47, 122, 94, 0.28);
  color: var(--won);
}
.demo-check-row input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--won);
  cursor: pointer;
}
tr.demo-done td:first-child {
  box-shadow: inset 3px 0 0 var(--won);
}
tr.demo-done {
  background: rgba(47, 122, 94, 0.06);
}
.table-demo {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.table-demo.demo-done { color: var(--won); }
.table-demo input {
  width: 0.95rem;
  height: 0.95rem;
  accent-color: var(--won);
  cursor: pointer;
}
.drawer-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.drawer-logo.placeholder {
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}
.topic-row, .social-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.topic-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #b34a39;
  border: 1px solid rgba(255, 112, 91, 0.2);
}
.social-link {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid rgba(255, 112, 91, 0.25);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  background: #fff;
}
.social-link:hover { background: var(--accent-soft); }
.updates { display: grid; gap: 0.45rem; }
.update-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  background: var(--bg-soft);
  font-size: 0.82rem;
}
.update-item a { color: var(--text); text-decoration: none; font-weight: 600; }
.update-item a:hover { color: var(--accent); }
.update-item .src {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lead-card .body { min-width: 0; }
.table-logo {
  width: 28px; height: 28px; border-radius: 8px; object-fit: cover;
  vertical-align: middle; margin-right: 0.45rem; border: 1px solid var(--line);
}
.lead-card:hover {
  border-color: rgba(255, 112, 91, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(255, 112, 91, 0.08);
}
.lead-card .name { font-weight: 600; font-size: 0.72rem; line-height: 1.25; }
.lead-card .contact-person {
  margin-top: 0.15rem;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  opacity: 0.82;
  display: flex;
  flex-direction: column;
  gap: 0.04rem;
}
.lead-card .meta {
  margin-top: 0.2rem;
  font-size: 0.62rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fff;
  position: sticky;
  top: 0;
}
tr { cursor: pointer; }
tr:hover td { background: var(--accent-soft); }
.stage-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--pill);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.stage-tag.won { color: var(--won); background: rgba(47, 122, 94, 0.08); border-color: rgba(47, 122, 94, 0.2); }
.stage-tag.pilot { color: #b34a39; background: rgba(255, 112, 91, 0.1); border-color: rgba(255, 112, 91, 0.28); }
.stage-tag.agreement { color: #8a5a12; background: rgba(212, 163, 92, 0.14); border-color: rgba(180, 130, 50, 0.3); }
.stage-tag.lost { color: var(--lost); background: rgba(154, 106, 106, 0.08); border-color: rgba(154, 106, 106, 0.22); }
.stage-tag.follow_up { color: var(--follow); background: rgba(196, 106, 58, 0.08); border-color: rgba(196, 106, 58, 0.22); }
.stage-tag.meeting,
.stage-tag.engaged { color: #b34a39; background: var(--accent-soft); border-color: rgba(255, 112, 91, 0.25); }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.drawer[hidden] { display: none !important; }
.drawer-head {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.1rem 1.1rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--peach), #fff 70%);
}
.drawer-head-main {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}
.drawer-head-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}
.drawer-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  word-break: break-word;
}
.drawer-head .muted { margin: 0.35rem 0 0; font-size: 0.82rem; line-height: 1.4; }
.drawer-head .stage-tag { vertical-align: middle; }
.drawer-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.drawer-logo.placeholder {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}
.drawer-body {
  padding: 1.1rem;
  overflow: auto;
  display: grid;
  gap: 1rem;
}
.drawer-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}
.drawer-desc { margin: 0; font-size: 0.9rem; line-height: 1.45; }
.drawer-links { margin: 0; }
.note-actions { display: flex; gap: 0.45rem; margin-top: 0.45rem; }

.contact-list { display: grid; gap: 0.45rem; }
.contact-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.55rem 0.7rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.contact-main { display: grid; gap: 0.15rem; min-width: 0; }
.contact-main strong { font-size: 0.9rem; }
.contact-main a { font-size: 0.82rem; color: var(--accent); word-break: break-all; }
.contact-src {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.contact-phones {
  font-size: 0.86rem;
  padding: 0.2rem 0.15rem 0;
}
.contact-phones a { color: var(--text); font-weight: 600; }
.contact-more { margin-top: 0.2rem; }
.contact-more summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.25rem 0.15rem;
}
.contact-more .contact-row { margin-top: 0.45rem; }

.timeline { display: grid; gap: 0; position: relative; }
.timeline-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 0.65rem;
  position: relative;
  padding-bottom: 0.85rem;
}
.timeline-item:last-of-type { padding-bottom: 0; }
.timeline-rail {
  width: 10px;
  justify-self: center;
  border-radius: 999px;
  background: var(--accent);
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 12px;
  bottom: -2px;
  width: 2px;
  background: rgba(48, 48, 48, 0.1);
}
.timeline-item:last-of-type::before { display: none; }
.timeline-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  min-width: 0;
}
.timeline-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.25rem;
}
.timeline-kind {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}
.timeline-item.kind-meeting .timeline-kind { color: #b34a39; }
.timeline-item.kind-email .timeline-kind { color: #2f7a5e; }
.timeline-item.kind-call .timeline-kind { color: #c46a3a; }
.timeline-item.kind-stage .timeline-kind { color: #6b6b6b; }
.timeline-when { font-size: 0.72rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.timeline-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
}
.timeline-meta,
.timeline-detail,
.timeline-by {
  margin: 0.28rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
.timeline-detail { color: var(--text); }
.timeline-more { margin: 0.6rem 0 0; font-size: 0.78rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.form-grid .span-2 { grid-column: span 2; }
label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
label input, label select, label textarea { color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 500; }
textarea { min-height: 80px; resize: vertical; }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.84rem;
}
.metrics div {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
}
.metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  margin-bottom: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.activities { display: grid; gap: 0.55rem; }
.activity {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.75rem;
  background: var(--bg-soft);
  border-radius: 0 12px 12px 0;
  font-size: 0.84rem;
}
.activity .when {
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 0.2rem;
  font-weight: 600;
}

.news-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.news-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 1;
}
.news-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--pill);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: capitalize;
}
.news-chip.active {
  background: var(--accent-soft);
  border-color: rgba(255, 112, 91, 0.35);
  color: #b34a39;
}
.news-chip.wisit.active {
  background: rgba(47, 122, 94, 0.12);
  border-color: rgba(47, 122, 94, 0.35);
  color: #2f7a5e;
}
.news-score {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.news-score.hot { color: #2f7a5e; }
.news-source.source-grant { color: #8a5a12; }
.grants-blurb {
  margin: 0 0 0.85rem;
  font-size: 0.84rem;
  line-height: 1.4;
}
.grant-summary {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
}
.grant-item .news-item-body { grid-column: 1 / -1; }
.news-meta { font-size: 0.8rem; }
.news-feed {
  display: grid;
  gap: 0.65rem;
}
.news-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(48, 48, 48, 0.03);
}
.news-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.news-logo.placeholder {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}
.news-item-top {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
  margin-bottom: 0.25rem;
}
.news-source {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}
.news-source.source-rss { color: #2f7a5e; }
.news-source.source-facebook { color: #3b5998; }
.news-source.source-instagram { color: #c13584; }
.news-when {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.news-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}
.news-title a {
  color: var(--text);
  text-decoration: none;
}
.news-title a:hover { color: var(--accent); }
.news-museum {
  margin-top: 0.35rem;
  font-size: 0.84rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
button.linkish {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: inherit;
}
button.linkish:hover { text-decoration: underline; }

.toast {
  position: fixed;
  bottom: 1.35rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: #fff;
  border: 0;
  padding: 0.75rem 1.15rem;
  border-radius: var(--pill);
  z-index: 40;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  font-size: 0.9rem;
}

.auth-card { z-index: 90; }
.auth-hint { margin: 0 0 0.25rem; font-size: 0.9rem; }
.auth-error {
  margin: 0;
  color: var(--danger, #c45c5c);
  font-size: 0.85rem;
  font-weight: 600;
}
body.auth-locked .app {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}
#auth-modal { z-index: 90; }


@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { width: 100%; }
  .nav-group-items { flex-direction: row; flex-wrap: wrap; padding-left: 0; }
  .form-grid, .metrics { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
