:root {
  --ink: #111318;
  --ivory: #f5f0e8;
  --lime: #c8ff3d;
  --mist: #dad9d3;
  --white: #ffffff;
  --muted: #676864;
  --danger: #b9382f;
  --danger-soft: #fae7e3;
  --warning: #9a5b09;
  --warning-soft: #fff1cc;
  --success: #2d641f;
  --success-soft: #e7f5d9;
  --border: 1.5px solid var(--ink);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 4px 4px 0 rgba(17, 19, 24, 0.09);
  --sidebar-width: 252px;
  --font-sans: "Manrope", "Avenir Next", Avenir, Inter, ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-sans);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 92% 7%, rgba(200, 255, 61, 0.12), transparent 25rem),
    var(--ivory);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

::selection {
  background: var(--lime);
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 200;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border: var(--border);
  border-radius: 10px;
  background: var(--white);
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 28px 18px 20px;
  border-right: var(--border);
  background: rgba(245, 240, 232, 0.96);
  backdrop-filter: blur(12px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-lockup.compact {
  gap: 8px;
}

.brand-mark {
  width: 36px;
  height: 43px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-lockup.compact .brand-mark {
  width: 26px;
  height: 31px;
}

.brand-name {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-name span {
  color: #8cc900;
}

.brand-product {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.primary-nav {
  display: grid;
  gap: 5px;
  margin-top: 38px;
}

.nav-item,
.bottom-nav-item {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  color: #4e504d;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.62);
  border-color: var(--mist);
}

.nav-item.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
  box-shadow: 3px 3px 0 var(--lime);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.nav-count {
  min-width: 21px;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
}

.save-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-inline: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
}

.save-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #71a817;
  box-shadow: 0 0 0 3px rgba(113, 168, 23, 0.13);
}

.main-content {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 42px clamp(28px, 4vw, 64px) 72px;
}

.mobile-header,
.bottom-nav,
.mobile-more-menu {
  display: none;
}

#view-root {
  width: min(100%, 1520px);
  min-width: 0;
  margin: 0 auto;
}

.view-enter {
  animation: view-in 180ms ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 30px;
}

.view-header-copy {
  min-width: 0;
  max-width: 780px;
}

.eyebrow,
.meta-label,
.kicker {
  margin: 0 0 9px;
  color: #5e605c;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.085em;
  line-height: 1.4;
  text-transform: uppercase;
}

.display-title {
  margin: 0;
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 800;
  letter-spacing: -0.065em;
  line-height: 0.98;
}

.page-title {
  margin: 0;
  font-size: clamp(30px, 3.4vw, 48px);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1.02;
}

.page-subtitle {
  max-width: 660px;
  margin: 12px 0 0;
  color: #5f615d;
  font-size: 14px;
  line-height: 1.65;
}

.view-header-actions,
.inline-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.button,
.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: transform 130ms ease, box-shadow 130ms ease, background 130ms ease;
}

.button {
  min-height: 42px;
  padding: 10px 15px;
  border: var(--border);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
  box-shadow: 2px 2px 0 rgba(17, 19, 24, 0.1);
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 3px 4px 0 rgba(17, 19, 24, 0.14);
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.button svg,
.icon-button svg,
.text-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

.button-primary,
.button-dark {
  background: var(--ink);
  color: var(--white);
}

.button-lime {
  background: var(--lime);
  color: var(--ink);
}

.button-ghost {
  border-color: var(--mist);
  background: transparent;
  box-shadow: none;
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: #77221c;
  box-shadow: none;
}

.button-small {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 11px;
}

.button-full {
  width: 100%;
}

.button[disabled],
.icon-button[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: var(--border);
  border-radius: 11px;
  background: var(--white);
}

.icon-button.dark {
  background: var(--ink);
  color: var(--white);
}

.text-button {
  padding: 4px 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: #9ea09a;
  text-underline-offset: 3px;
}

.text-button.danger {
  color: var(--danger);
}

.surface {
  border: var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.surface-dark {
  border: var(--border);
  border-color: var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--white);
  box-shadow: 5px 5px 0 var(--lime);
}

.surface-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 0;
}

.surface-body {
  padding: 22px 24px 24px;
}

.section-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.section-description {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.surface-dark .section-description,
.surface-dark .meta-label {
  color: #bfc0bc;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}

.metric-card {
  position: relative;
  min-width: 0;
  padding: 15px 15px 14px;
  overflow: hidden;
  border: 1px solid #b7b7b1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
}

.metric-card.is-highlight {
  border-color: var(--ink);
  background: var(--lime);
}

.metric-label {
  display: block;
  min-height: 30px;
  color: #646560;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
}

.metric-card.is-highlight .metric-label {
  color: #34362f;
}

.metric-value {
  display: block;
  margin-top: 7px;
  font-size: clamp(24px, 2vw, 34px);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
}

.metric-note {
  display: block;
  margin-top: 6px;
  color: #747570;
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.3;
}

.layout-grid {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.8fr);
  align-items: start;
  gap: 20px;
}

.stack {
  display: grid;
  min-width: 0;
  gap: 20px;
}

.layout-grid > *,
.surface,
.surface-dark,
.surface-header,
.surface-body,
.action-row,
.action-copy {
  min-width: 0;
}

.progress-list {
  display: grid;
  gap: 18px;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(105px, 1fr) 2.4fr auto;
  align-items: center;
  gap: 12px;
}

.progress-label {
  font-size: 12px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e0ddd6;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transition: width 220ms ease;
}

.progress-fill.complete {
  background: #75ad16;
}

.progress-value {
  min-width: 42px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: right;
}

.action-list,
.alert-list,
.timeline,
.notes-list,
.activity-list {
  display: grid;
  gap: 10px;
}

.action-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border: 1px solid #c7c6c0;
  border-radius: 13px;
  background: var(--white);
}

.action-row:hover {
  border-color: var(--ink);
}

.action-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--ivory);
}

.action-icon.is-urgent {
  background: var(--lime);
}

.action-icon svg {
  width: 16px;
  height: 16px;
}

.action-copy {
  min-width: 0;
}

.action-title {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

.action-meta {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-left: 3px solid var(--warning);
  border-radius: 0 10px 10px 0;
  background: var(--warning-soft);
  color: #5f3c09;
  font-size: 11px;
  line-height: 1.5;
}

.alert-item.danger {
  border-left-color: var(--danger);
  background: var(--danger-soft);
  color: #762921;
}

.alert-item svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.quick-action {
  display: flex;
  min-height: 86px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 13px;
  border: 1px solid #c0c0ba;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
}

.quick-action:hover {
  border-color: var(--ink);
  background: var(--white);
}

.quick-action svg {
  width: 18px;
  height: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.toolbar-group {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.search-control {
  position: relative;
  min-width: min(320px, 100%);
}

.search-control svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 17px;
  height: 17px;
  color: #70716d;
  pointer-events: none;
  transform: translateY(-50%);
}

.search-control input {
  width: 100%;
  padding-left: 40px;
}

.control,
.field input,
.field select,
.field textarea,
.filter-select {
  width: 100%;
  min-height: 42px;
  border: 1.5px solid #aaa9a3;
  border-radius: 11px;
  background: var(--white);
  color: var(--ink);
  font-size: 13px;
  outline: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.control,
.field input,
.field select,
.filter-select {
  padding: 9px 11px;
}

.field textarea {
  min-height: 96px;
  padding: 10px 11px;
  line-height: 1.55;
  resize: vertical;
}

.control:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(200, 255, 61, 0.62);
}

.filter-select {
  width: auto;
  min-width: 120px;
  font-size: 11px;
  font-weight: 700;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  border: 1.5px solid #b2b2ac;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.5);
}

.segment-button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.segment-button.is-active {
  background: var(--ink);
  color: var(--white);
}

.segment-button svg {
  width: 14px;
  height: 14px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 14px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid #b9b9b3;
  border-radius: 999px;
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 9px;
}

.filter-chip button {
  display: grid;
  width: 16px;
  height: 16px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--mist);
  cursor: pointer;
}

.data-surface {
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.data-table th {
  padding: 13px 16px;
  border-bottom: 1.5px solid var(--ink);
  background: var(--ink);
  color: #d7d8d4;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #d5d3cd;
  font-size: 11px;
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

.data-table tbody tr:hover {
  background: rgba(200, 255, 61, 0.13);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.lead-name {
  display: block;
  max-width: 240px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-handle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid #aaa9a3;
  border-radius: 999px;
  background: var(--white);
  color: #4e504c;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #9b9c97;
  content: "";
}

.badge-grade-a {
  border-color: var(--ink);
  background: var(--lime);
  color: var(--ink);
}

.badge-grade-a::before { background: var(--ink); }
.badge-grade-b::before { background: #858680; }
.badge-grade-c { background: #eeece7; color: #6b6c68; }
.badge-danger { border-color: #d88c84; background: var(--danger-soft); color: #7b2922; }
.badge-danger::before { background: var(--danger); }
.badge-success { border-color: #84a66c; background: var(--success-soft); color: #28541d; }
.badge-success::before { background: var(--success); }
.badge-warning { border-color: #c99c54; background: var(--warning-soft); color: #6f460a; }
.badge-warning::before { background: var(--warning); }
.badge-stage::before { background: #696a66; }

.lead-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.lead-card {
  display: grid;
  min-width: 0;
  gap: 16px;
  padding: 18px;
  border: var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 3px 3px 0 rgba(17, 19, 24, 0.08);
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 130ms ease;
}

.lead-card:hover {
  transform: translateY(-2px);
  box-shadow: 5px 6px 0 rgba(17, 19, 24, 0.11);
}

.lead-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lead-card-title {
  min-width: 0;
}

.lead-card h3 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.lead-card-action {
  padding-top: 13px;
  border-top: 1px solid #d5d3cd;
}

.lead-card-action strong {
  display: block;
  margin-bottom: 5px;
  font-size: 10px;
  text-transform: uppercase;
}

.lead-card-action p {
  margin: 0;
  color: #575955;
  font-size: 11px;
  line-height: 1.45;
}

.results-summary {
  margin: 0 0 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.kanban-scroll {
  width: calc(100vw - var(--sidebar-width) - clamp(56px, 8vw, 128px));
  max-width: 1520px;
  overflow-x: auto;
  padding: 2px 2px 18px;
  scroll-snap-type: x proximity;
}

.kanban-board {
  display: grid;
  grid-auto-columns: 274px;
  grid-auto-flow: column;
  gap: 13px;
  min-width: max-content;
}

.kanban-column {
  display: flex;
  max-height: calc(100vh - 190px);
  min-height: 480px;
  flex-direction: column;
  overflow: hidden;
  border: 1.5px solid #a9a9a4;
  border-radius: 16px;
  background: rgba(218, 217, 211, 0.34);
  scroll-snap-align: start;
}

.kanban-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid #c4c3bd;
  background: rgba(255, 255, 255, 0.7);
}

.kanban-column-title {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
}

.kanban-count {
  display: grid;
  min-width: 23px;
  height: 23px;
  padding-inline: 5px;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 9px;
}

.kanban-cards {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 10px;
  min-height: 160px;
  padding: 11px;
  overflow-y: auto;
}

.kanban-cards.is-drag-target {
  background: rgba(200, 255, 61, 0.16);
}

.kanban-card {
  padding: 13px;
  border: 1.5px solid var(--ink);
  border-radius: 13px;
  background: var(--white);
  box-shadow: 2px 2px 0 rgba(17, 19, 24, 0.1);
  cursor: grab;
}

.kanban-card:active { cursor: grabbing; }
.kanban-card.sortable-ghost { opacity: 0.35; }
.kanban-card.sortable-chosen { box-shadow: 4px 4px 0 var(--lime); }

.kanban-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.kanban-card .lead-handle {
  margin-top: 4px;
}

.kanban-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.kanban-card-copy {
  margin: 11px 0 0;
  padding-top: 10px;
  border-top: 1px solid #dedcd6;
  color: #51534f;
  font-size: 10px;
  line-height: 1.45;
}

.kanban-card-copy.is-overdue {
  color: var(--danger);
  font-weight: 700;
}

.kanban-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.kanban-card-foot button {
  padding: 3px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.stage-select-mobile {
  width: 100%;
  margin-top: 9px;
  padding: 7px;
  border: 1px solid #b5b4af;
  border-radius: 8px;
  background: var(--ivory);
  font-size: 9px;
}

.followup-list {
  display: grid;
  gap: 12px;
}

.followup-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 17px;
  border: var(--border);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.82);
}

.date-tile {
  display: grid;
  width: 56px;
  height: 58px;
  place-content: center;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: var(--ivory);
  text-align: center;
}

.date-tile.is-overdue {
  background: var(--danger-soft);
  color: var(--danger);
}

.date-tile-day {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
}

.date-tile-month {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
}

.followup-copy h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

.followup-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.followup-message {
  margin-top: 9px !important;
  padding: 8px 10px;
  border-left: 2px solid var(--lime);
  background: var(--ivory);
  color: #454742 !important;
  font-style: italic;
}

.template-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.68fr) minmax(0, 1.65fr);
  gap: 18px;
}

.template-sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  padding: 10px;
  overflow-y: auto;
}

.template-nav-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  color: #5f615d;
  font-size: 10px;
  font-weight: 700;
  text-align: left;
}

.template-nav-button:hover,
.template-nav-button.is-active {
  background: var(--ink);
  color: var(--white);
}

.template-nav-button span:last-child {
  font-family: var(--font-mono);
  font-size: 8px;
}

.template-cards {
  display: grid;
  gap: 12px;
}

.template-card {
  padding: 20px;
  border: var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
}

.template-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.template-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.template-text {
  margin: 15px 0 0;
  color: #454743;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.template-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid #d7d5ce;
}

.character-count {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.character-count.is-long {
  color: var(--warning);
  font-weight: 700;
}

.variables-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.variable-token {
  padding: 5px 7px;
  border: 1px solid #bebdb7;
  border-radius: 7px;
  background: var(--ivory);
  font-family: var(--font-mono);
  font-size: 8px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.chart-card {
  min-width: 0;
  padding: 20px;
}

.chart-wrap {
  position: relative;
  height: 290px;
  margin-top: 15px;
}

.diagnostic-card {
  position: relative;
  padding: 22px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--white);
}

.diagnostic-card::after {
  position: absolute;
  right: -25px;
  bottom: -42px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--lime);
  content: "";
  opacity: 0.9;
}

.diagnostic-card h3,
.diagnostic-card p {
  position: relative;
  z-index: 1;
}

.diagnostic-card h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.diagnostic-card p {
  max-width: 86%;
  margin: 9px 0 0;
  color: #d0d1cd;
  font-size: 12px;
  line-height: 1.6;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #d7d5cf;
  font-size: 10px;
  text-align: left;
}

.comparison-table th {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 18px;
}

.settings-section {
  padding: 22px;
}

.settings-section.is-wide {
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.form-grid.compact {
  gap: 11px;
}

.field {
  display: grid;
  align-content: start;
  gap: 6px;
}

.field.span-2 {
  grid-column: 1 / -1;
}

.field label,
.field-label {
  color: #50524e;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 9px;
  font-weight: 700;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.45;
}

.checkbox-field input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--ink);
}

.form-section {
  padding: 0;
  border: 0;
}

.form-section + .form-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid #d2d0ca;
}

.form-section legend,
.form-section-title {
  width: 100%;
  margin: 0 0 14px;
  padding: 0;
  font-size: 14px;
  font-weight: 800;
}

details.form-details {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #d2d0ca;
}

details.form-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

details.form-details[open] summary {
  margin-bottom: 15px;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  padding: 36px;
  text-align: center;
}

.empty-state-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin: 0 auto 15px;
  place-items: center;
  border: var(--border);
  border-radius: 18px;
  background: var(--lime);
  box-shadow: 4px 4px 0 var(--ink);
}

.empty-state-icon svg {
  width: 26px;
  height: 26px;
}

.empty-state h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.empty-state p {
  max-width: 430px;
  margin: 8px auto 17px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.app-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(88vh, 900px);
  padding: 0;
  overflow: hidden;
  border: var(--border);
  border-radius: 20px;
  background: var(--ivory);
  color: var(--ink);
  box-shadow: 10px 12px 0 rgba(17, 19, 24, 0.25);
}

.app-dialog.dialog-large {
  width: min(1120px, calc(100vw - 28px));
}

.app-dialog::backdrop {
  background: rgba(17, 19, 24, 0.64);
  backdrop-filter: blur(4px);
}

.dialog-shell {
  display: flex;
  max-height: min(88vh, 900px);
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1.5px solid var(--ink);
  background: var(--white);
}

.dialog-header h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.05;
}

.dialog-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.dialog-body {
  padding: 22px 24px 26px;
  overflow-y: auto;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 24px;
  border-top: 1px solid #c9c7c1;
  background: var(--white);
}

.dialog-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.lead-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.detail-panel {
  padding: 17px;
  border: 1px solid #b8b7b1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
}

.detail-panel h3 {
  margin: 0 0 13px;
  font-size: 13px;
  font-weight: 800;
}

.definition-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.definition-list div {
  display: grid;
  gap: 3px;
}

.definition-list dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
}

.definition-list dd {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.timeline-item {
  position: relative;
  padding-left: 20px;
}

.timeline-item::before {
  position: absolute;
  top: 4px;
  left: 2px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--lime);
  content: "";
}

.timeline-item::after {
  position: absolute;
  top: 15px;
  bottom: -13px;
  left: 5px;
  width: 1px;
  background: #bbb9b3;
  content: "";
}

.timeline-item:last-child::after { display: none; }

.timeline-item strong {
  display: block;
  font-size: 10px;
}

.timeline-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.timeline-item p {
  margin: 4px 0 0;
  color: #555752;
  font-size: 9px;
  line-height: 1.5;
}

.note-item {
  padding: 10px 11px;
  border-left: 2px solid var(--ink);
  background: var(--white);
  font-size: 9px;
  line-height: 1.5;
}

.note-item time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.toast-region {
  position: fixed;
  z-index: 150;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 9px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border: var(--border);
  border-radius: 12px;
  background: var(--ink);
  color: var(--white);
  box-shadow: 4px 4px 0 var(--lime);
  font-size: 11px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 180ms ease both;
}

.toast.is-error {
  background: #6f211c;
  box-shadow: 4px 4px 0 #f2a197;
}

.toast svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.only-mobile {
  display: none;
}

@media (max-width: 1180px) {
  :root { --sidebar-width: 214px; }
  .sidebar { padding-inline: 14px; }
  .brand-product { display: none; }
  .stats-grid { grid-template-columns: repeat(4, minmax(110px, 1fr)); }
  .lead-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-panel:last-child { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 0px; }

  body {
    padding-bottom: 74px;
  }

  .sidebar {
    display: none;
  }

  .mobile-header {
    position: sticky;
    z-index: 35;
    top: 0;
    display: flex;
    height: 62px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-bottom: 1.5px solid var(--ink);
    background: rgba(245, 240, 232, 0.94);
    backdrop-filter: blur(12px);
  }

  .main-content {
    margin-left: 0;
    padding: 28px 20px 46px;
  }

  .bottom-nav {
    position: fixed;
    z-index: 50;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-top: 1.5px solid var(--ink);
    background: var(--ink);
  }

  .bottom-nav-item {
    position: relative;
    display: flex;
    min-height: 50px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 10px;
    color: #bdbeb9;
    font-size: 8px;
    font-weight: 700;
  }

  .bottom-nav-item.is-active {
    background: #25282d;
    color: var(--lime);
  }

  .bottom-nav-item svg {
    width: 19px;
    height: 19px;
  }

  .bottom-nav-dot {
    position: absolute;
    top: 5px;
    right: calc(50% - 17px);
    width: 7px;
    height: 7px;
    border: 1px solid var(--ink);
    border-radius: 50%;
    background: var(--lime);
  }

  .mobile-more-menu {
    position: fixed;
    z-index: 49;
    right: 10px;
    bottom: 76px;
    display: grid;
    width: 190px;
    padding: 8px;
    border: var(--border);
    border-radius: 14px;
    background: var(--white);
    box-shadow: 5px 5px 0 rgba(17, 19, 24, 0.2);
  }

  .mobile-more-menu[hidden] { display: none; }

  .mobile-more-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
    text-align: left;
  }

  .mobile-more-menu button:hover { background: var(--ivory); }
  .mobile-more-menu svg { width: 17px; height: 17px; }

  .layout-grid,
  .template-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .template-sidebar {
    position: static;
    display: flex;
    max-height: none;
    gap: 5px;
    overflow-x: auto;
  }

  .template-nav-button {
    width: auto;
    flex: 0 0 auto;
  }

  .settings-section.is-wide { grid-column: auto; }
  .kanban-scroll { width: calc(100vw - 40px); }
  .kanban-column { max-height: calc(100vh - 210px); }
  .toast-region { bottom: 88px; }
}

@media (max-width: 680px) {
  .main-content { padding: 24px 15px 38px; }

  .view-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 23px;
  }

  .view-header-actions { width: 100%; }
  .view-header-actions .button { flex: 1; }
  .display-title { font-size: 38px; }
  .page-title { font-size: 33px; }
  .page-subtitle { font-size: 12px; }

  .stats-grid {
    display: flex;
    margin-inline: -15px;
    padding: 0 15px 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .metric-card {
    min-width: 130px;
    flex: 0 0 130px;
    scroll-snap-align: start;
  }

  .surface-header,
  .surface-body {
    padding-inline: 17px;
  }

  .surface,
  .surface-dark {
    max-width: 100%;
  }

  .action-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .action-row > .button {
    grid-column: 2;
    justify-self: start;
  }

  .surface-header {
    padding-top: 18px;
  }

  .surface-body {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-row { grid-template-columns: minmax(90px, 1fr) 1.5fr auto; }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-group { width: 100%; }
  .search-control { width: 100%; min-width: 0; }
  .filter-select { flex: 1; min-width: 115px; }
  .lead-card-grid { grid-template-columns: 1fr; }
  .table-wrap { display: none; }
  .only-desktop-table { display: none !important; }
  .only-mobile { display: block; }
  .kanban-scroll { width: calc(100vw - 30px); }
  .kanban-board { grid-auto-columns: min(84vw, 300px); }

  .followup-card {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 12px;
  }

  .followup-card .card-actions {
    grid-column: 1 / -1;
    padding-top: 10px;
    border-top: 1px solid #d7d5cf;
  }

  .followup-card .card-actions .button { flex: 1; }
  .report-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 250px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }

  .app-dialog,
  .app-dialog.dialog-large {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 16px;
  }

  .dialog-shell { max-height: calc(100dvh - 16px); }
  .dialog-header { padding: 18px 17px 15px; }
  .dialog-body { padding: 18px 17px 22px; }

  .dialog-footer {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 17px max(12px, env(safe-area-inset-bottom));
  }

  .dialog-footer-actions { width: 100%; margin-left: 0; }
  .dialog-footer-actions .button { flex: 1; }
  .lead-detail-grid { grid-template-columns: 1fr; }
  .detail-panel:last-child { grid-column: auto; }
  .template-card-head { flex-direction: column; }
  .template-card-foot { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 390px) {
  .brand-name { font-size: 15px; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .button { padding-inline: 12px; }
  .progress-row { grid-template-columns: 1fr auto; }
  .progress-track { grid-column: 1 / -1; grid-row: 2; }
}

@media print {
  .sidebar,
  .mobile-header,
  .bottom-nav,
  .view-header-actions,
  .toolbar,
  .button,
  .icon-button {
    display: none !important;
  }

  .main-content {
    margin: 0;
    padding: 0;
  }

  body {
    background: #fff;
  }

  .surface,
  .data-surface,
  .metric-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
