:root {
  --bg: #fbfbfa;
  --panel: #ffffff;
  --ink: #070b14;
  --muted: #6f737c;
  --line: #e7e2dc;
  --red: #df1719;
  --red-dark: #c70f12;
  --green: #35a94a;
  --blue: #1f73d9;
  --orange: #ff9f16;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.10);
  --soft-shadow: 0 8px 26px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, #ffffff 0, #f7f7f5 38rem, #fbfbfa 100%);
}

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

.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.65);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 34px 22px 26px;
  background: rgba(255,255,255,0.94);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  justify-items: center;
  gap: 5px;
  color: var(--ink);
}

.brand.compact {
  justify-items: start;
}

.nw-logo {
  font-size: 58px;
  line-height: .9;
  font-weight: 800;
  letter-spacing: -0.10em;
}

.nw-logo span:first-child { color: #050913; }
.nw-logo span:last-child { color: var(--red); }

.brand-sub {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 800;
}

.brand-crm {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--red);
  font-size: 13px;
  letter-spacing: .22em;
  font-weight: 700;
}

.brand-crm span {
  display: block;
  width: 28px;
  height: 1px;
  background: var(--red);
}

.nav {
  display: grid;
  gap: 12px;
}

.nav button,
.bottom-nav button {
  border: 0;
  background: transparent;
  color: #22252b;
}

.nav button {
  width: 100%;
  min-height: 58px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  font-size: 16px;
  text-align: left;
}

.nav button.active {
  color: var(--red);
  background: linear-gradient(90deg, rgba(223,23,25,.12), rgba(223,23,25,.04));
}

.sidebar-footer {
  margin-top: auto;
  min-height: 250px;
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  align-content: end;
  justify-items: center;
  text-align: center;
  gap: 12px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.sidebar-footer strong {
  line-height: 1.45;
  font-weight: 500;
}

.sidebar-footer span,
.sidebar-footer small {
  color: var(--red);
}

.naples-card-art {
  font-size: 68px;
  color: #1d1d1d;
  transform: rotate(-8deg);
}

.mobile-header,
.bottom-nav,
.mobile-lead-cta,
.mobile-dots,
.priority-mobile {
  display: none;
}

.main {
  padding: 44px 52px 70px;
  display: grid;
  gap: 26px;
  align-content: start;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
}

.title h2 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.title p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.actions {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.search-box {
  width: min(460px, 36vw);
  height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border: 1px solid #ddd8d3;
  border-radius: 8px;
  background: rgba(255,255,255,.88);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--soft-shadow);
}

.btn.primary {
  min-height: 54px;
  padding: 0 26px;
  color: #fff;
  background: linear-gradient(135deg, #ed2525, #d51214);
  border-color: #d51214;
  box-shadow: 0 16px 25px rgba(223,23,25,.24);
}

.btn.green { color: #fff; background: var(--green); border-color: var(--green); }
.btn.utility { min-height: 42px; padding: 0 13px; font-size: 13px; color: var(--muted); }

.grid { display: grid; gap: 26px; }
.grid.stats { grid-template-columns: repeat(4, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: 1.35fr .65fr; align-items: start; }
.grid.three { grid-template-columns: repeat(3, 1fr); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, .98fr) minmax(0, 1.02fr);
  gap: 26px;
}

.dashboard-grid.lower {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
}

.card {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.card.pad { padding: 22px; }

.card-title {
  min-height: 58px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card-title.no-border { border-bottom: 0; }
.card-title h3 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.card-title span { color: var(--muted); font-size: 13px; }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--red);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.link-btn .icon { width: 18px; height: 18px; }

.stat {
  min-height: 160px;
  padding: 28px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.stat > div:last-child {
  min-width: 0;
}

.stat-icon {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.stat-icon .icon { width: 34px; height: 34px; }
.stat-icon.red { color: var(--red); background: #fde8e8; }
.stat-icon.orange { color: var(--orange); background: #fff0d8; }
.stat-icon.green { color: #188a2c; background: #e7f5e9; }
.stat-icon.blue { color: var(--blue); background: #e7f0ff; }

.stat label {
  display: block;
  color: #11141b;
  font-size: 18px;
  font-weight: 500;
}

.stat strong {
  display: block;
  margin: 4px 0;
  font-size: clamp(34px, 2.6vw, 42px);
  line-height: 1;
  letter-spacing: -0.05em;
  white-space: nowrap;
}

.stat small {
  color: var(--muted);
  font-size: 15px;
}

.lead-state-card,
.payments-panel,
.accepted-panel { min-height: 330px; }

.lead-state-body {
  padding: 14px 26px 28px;
  display: grid;
  grid-template-columns: 240px 1fr;
  align-items: center;
  gap: 34px;
}

.donut {
  width: 210px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}

.donut > div {
  width: 98px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  align-content: center;
}

.donut strong { font-size: 34px; }
.donut small { color: var(--muted); }

.legend-list {
  display: grid;
  gap: 20px;
}

.legend-list div {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

.legend-list p { margin: 0; font-size: 16px; }
.legend-list strong { font-weight: 500; }

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot.red { background: var(--red); }
.dot.orange { background: var(--orange); }
.dot.blue { background: #2b8edb; }
.dot.green { background: var(--green); }

.payment-summary-row {
  min-height: 78px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}

.payment-summary-row span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.payment-summary-row .icon { width: 22px; height: 22px; }
.payment-summary-row p { margin: 0; font-weight: 700; }
.payment-summary-row strong { font-size: 20px; }
.payment-summary-row small { color: var(--muted); grid-column: 3; margin-top: -18px; }
.payment-summary-row.danger { color: var(--red); }
.payment-summary-row.warning { color: var(--orange); }
.payment-summary-row.success { color: var(--green); }
.payment-summary-row.danger span { background: #fde8e8; }
.payment-summary-row.warning span { background: #fff0d8; }
.payment-summary-row.success span { background: #e7f5e9; }

.panel-total {
  min-height: 58px;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(250,247,244,.8);
  font-size: 17px;
}
.panel-total strong { font-size: 24px; }

.accepted-list {
  padding: 18px 26px;
  display: grid;
  gap: 16px;
}
.accepted-list p {
  margin: 0;
  display: flex;
  justify-content: space-between;
}

.job-row {
  display: grid;
  grid-template-columns: 1fr 150px 46px;
  align-items: center;
  gap: 14px;
}

.job-bar {
  height: 5px;
  border-radius: 999px;
  background: #e5e5e5;
  overflow: hidden;
}

.job-bar i {
  display: block;
  height: 100%;
  background: var(--green);
}

.filters {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(140px, .45fr));
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 800; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
}
.field textarea { min-height: 92px; resize: vertical; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
.compact-table table { min-width: 760px; }
th, td {
  padding: 13px 24px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-size: 13px;
  color: #171a20;
  font-weight: 500;
  background: rgba(250,250,249,.92);
}
td { font-size: 14px; }
td strong { display: block; margin-bottom: 5px; }
td small { color: var(--muted); line-height: 1.45; }
td a { color: #0b5fd7; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.pill.lead { background: #fff1dc; color: #b85e00; }
.pill.callback { background: #e9f4ff; color: #075ea7; }
.pill.accepted, .pill.paid { background: #e8f8e9; color: #0d831f; }
.pill.rejected, .pill.overdue { background: #ffe6e6; color: #c41414; }
.pill.waiting { background: #efefef; color: #444; }
.pill.due { background: #fff1dc; color: #b85e00; }

.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-actions a, .mini-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 12px;
}

.note-input {
  width: 100%;
  min-height: 62px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
  background: #fff;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.lane {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 260px;
  box-shadow: var(--soft-shadow);
}
.lane h4 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); }

.work-card {
  margin: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.work-card strong { display: block; margin-bottom: 8px; }
.progress {
  height: 7px;
  background: #e5e5e5;
  border-radius: 99px;
  overflow: hidden;
  margin: 12px 0;
}
.progress span { display: block; height: 100%; background: var(--green); }

.payment-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
}
.payment-row:last-child { border-bottom: 0; }
.amount { font-weight: 800; font-size: 22px; }

.billing-grid {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.billing-card {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(130px, .45fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.billing-card strong,
.billing-card small { display: block; }
.billing-card small { margin-top: 6px; color: var(--muted); line-height: 1.45; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }

.source-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #11141b;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 50;
}
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1050px) {
  body { background: #fff; }
  .app-shell {
    display: block;
    border: 0;
    border-radius: 0;
    padding-bottom: 104px;
  }
  .sidebar,
  .topbar .title p,
  .search-box,
  .btn.utility,
  .topbar .new-lead-btn,
  .dashboard-grid.lower {
    display: none;
  }
  .mobile-header {
    height: 124px;
    padding: 24px 30px;
    display: grid;
    grid-template-columns: 150px 1fr auto;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }
  .mobile-header .nw-logo { font-size: 58px; }
  .mobile-header .brand-sub { font-size: 9px; letter-spacing: .08em; }
  .mobile-header h1 {
    margin: 0;
    text-align: center;
    font-size: 37px;
    letter-spacing: -0.04em;
  }
  .mobile-icons {
    display: flex;
    gap: 26px;
    color: #070b14;
  }
  .mobile-icons .icon { width: 38px; height: 38px; stroke-width: 1.8; }
  .main {
    padding: 28px 30px 24px;
    gap: 28px;
  }
  .topbar {
    display: block;
  }
  .title h2,
  .topbar .actions {
    display: none;
  }
  .mobile-lead-cta {
    display: flex;
    justify-content: flex-end;
  }
  .mobile-lead-cta .btn {
    min-width: 208px;
    min-height: 82px;
    border-radius: 18px;
    font-size: 30px;
  }
  .mobile-lead-cta .icon {
    width: 42px;
    height: 42px;
  }
  .grid.stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 24px;
  }
  .stat {
    min-height: 204px;
    padding: 34px 24px;
    gap: 26px;
    border-radius: 18px;
  }
  .stat-icon {
    width: 108px;
    height: 108px;
  }
  .stat-icon .icon {
    width: 52px;
    height: 52px;
  }
  .stat label { font-size: 27px; color: #34363b; }
  .stat strong { font-size: 58px; }
  .stat small { font-size: 23px; }
  .mobile-dots {
    display: flex;
    justify-content: center;
    gap: 16px;
  }
  .mobile-dots span {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #d7d7d7;
  }
  .mobile-dots span:first-child { background: var(--red); }
  .dashboard-grid,
  .grid.two,
  .grid.three,
  .kanban {
    grid-template-columns: 1fr;
  }
  .lead-state-card {
    border-radius: 18px;
  }
  .lead-state-card .card-title {
    min-height: auto;
    padding: 28px 34px 0;
  }
  .lead-state-card .link-btn {
    display: none;
  }
  .lead-state-body {
    padding: 18px 34px 34px;
    grid-template-columns: 310px 1fr;
    gap: 30px;
  }
  .donut { width: 286px; }
  .donut > div { width: 112px; }
  .donut strong { display: none; }
  .donut small { display: none; }
  .legend-list { gap: 27px; }
  .legend-list p,
  .legend-list strong {
    font-size: 24px;
  }
  .dot {
    width: 20px;
    height: 20px;
  }
  .payments-panel {
    display: none;
  }
  .priority-mobile {
    display: grid;
    gap: 0;
  }
  .priority-mobile h3 {
    margin: 0 0 18px 22px;
    font-size: 30px;
    letter-spacing: -0.02em;
  }
  .action-row {
    min-height: 116px;
    position: relative;
    display: grid;
    grid-template-columns: 10px 86px 1fr auto auto;
    align-items: center;
    gap: 20px;
    padding: 14px 28px 14px 24px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--soft-shadow);
  }
  .action-row + .action-row {
    margin-top: -1px;
  }
  .action-rail {
    width: 9px;
    height: 72px;
    border-radius: 999px;
    background: var(--orange);
  }
  .action-row.blue .action-rail { background: var(--blue); }
  .action-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #fbf1e8;
    color: #8a5b27;
    font-size: 25px;
    font-weight: 700;
  }
  .action-row.blue .action-avatar {
    color: var(--blue);
    background: #e8f1ff;
  }
  .action-row strong {
    display: block;
    font-size: 28px;
    letter-spacing: -0.03em;
  }
  .action-row small {
    display: block;
    color: var(--muted);
    font-size: 25px;
  }
  .action-row b {
    color: var(--red);
    font-size: 29px;
    font-weight: 500;
  }
  .action-row.blue b { color: var(--blue); }
  .action-row .icon {
    color: #6f737c;
    width: 34px;
    height: 34px;
  }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 104px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 25px rgba(16, 24, 40, .06);
  }
  .bottom-nav button {
    height: 100%;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    font-size: 20px;
    color: #292d33;
  }
  .bottom-nav button.active { color: var(--red); }
  .bottom-nav .icon {
    width: 38px;
    height: 38px;
  }
  .filters,
  .form-grid,
  .billing-card {
    grid-template-columns: 1fr;
  }
  .card {
    border-radius: 18px;
  }
}

@media (max-width: 620px) {
  .mobile-header {
    height: 92px;
    padding: 18px;
    grid-template-columns: 86px 1fr auto;
  }
  .mobile-header .nw-logo { font-size: 40px; }
  .mobile-header h1 { font-size: 28px; }
  .mobile-icons { gap: 14px; }
  .mobile-icons .icon { width: 28px; height: 28px; }
  .main { padding: 22px 16px; }
  .mobile-lead-cta .btn {
    min-width: 132px;
    min-height: 58px;
    font-size: 22px;
  }
  .grid.stats { gap: 14px; }
  .stat {
    min-height: 146px;
    padding: 14px 12px;
    gap: 10px;
  }
  .stat-icon { width: 54px; height: 54px; }
  .stat-icon .icon { width: 30px; height: 30px; }
  .stat label { font-size: 16px; }
  .stat strong { font-size: clamp(27px, 8vw, 32px); letter-spacing: -0.07em; }
  .stat small { font-size: 14px; }
  .lead-state-body {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .donut { width: 230px; }
  .legend-list { width: 100%; }
  .legend-list p,
  .legend-list strong { font-size: 18px; }
  .action-row {
    grid-template-columns: 8px 58px 1fr auto;
    gap: 12px;
    padding: 12px;
  }
  .action-row .icon { display: none; }
  .action-avatar { width: 58px; height: 58px; font-size: 18px; }
  .action-row strong { font-size: 20px; }
  .action-row small { font-size: 17px; }
  .action-row b { font-size: 20px; }
  .bottom-nav { height: 86px; }
  .bottom-nav button { font-size: 14px; }
  .bottom-nav .icon { width: 30px; height: 30px; }
}
