:root {
  --bg: #050509;
  --bg-2: #090910;
  --card: #0d0d14;
  --line: #262631;
  --line-soft: #1d1d27;
  --text: #f2f3f8;
  --muted: #a3a4b3;
  --purple: #7d5cff;
  --purple-soft: #b18bff;

  --tone-new: #9b70ff;
  --tone-contacted: #5fa8ff;
  --tone-quoted: #ffb65f;
  --tone-follow: #ffd870;
  --tone-won: #63e8ad;
  --tone-lost: #ff7f9f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "Sora", sans-serif;
  background: #020204;
}

.shader-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  transform: scale(1.02);
  filter: saturate(1.05) contrast(1.04);
}

.shader-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(circle at 50% 22%, rgba(6, 6, 10, 0.2), transparent 48%),
    linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.2) 35%, rgba(0, 0, 0, 0.44));
}

.hidden {
  display: none !important;
}

.auth-screen {
  position: relative;
  z-index: 3;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-card {
  position: relative;
  overflow: hidden;
  width: min(460px, 100%);
  border-radius: 18px;
  padding: 24px;
  border-color: rgba(165, 120, 255, 0.42);
  background:
    radial-gradient(circle at 82% 10%, rgba(177, 139, 255, 0.34), transparent 45%),
    radial-gradient(circle at 14% 112%, rgba(125, 92, 255, 0.24), transparent 45%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 35%),
    var(--card);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 0 45px rgba(125, 92, 255, 0.26),
    0 0 85px rgba(125, 92, 255, 0.16);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  border: 1px solid rgba(193, 158, 255, 0.22);
}

.auth-card h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  color: #f7f1ff;
  text-shadow: 0 0 16px rgba(125, 92, 255, 0.45), 0 0 32px rgba(125, 92, 255, 0.22);
}

.auth-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.auth-form {
  margin-top: 16px;
  display: grid;
  gap: 11px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  font-size: 0.84rem;
  color: #d2d2dd;
}

.auth-form input {
  border-color: rgba(168, 126, 255, 0.4);
  background: rgba(8, 7, 14, 0.86);
}

.auth-form input:focus {
  border-color: rgba(182, 143, 255, 0.86);
  box-shadow: 0 0 0 3px rgba(125, 92, 255, 0.26), 0 0 28px rgba(125, 92, 255, 0.2);
}

.auth-error {
  margin: 0;
  min-height: 1.2em;
  color: #ff98b0;
  font-size: 0.82rem;
}

.dashboard-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  position: relative;
  z-index: 2;
}

.glass {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 32%), var(--card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.topbar {
  border-radius: 20px;
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand-wrap {
  display: flex;
  align-items: flex-start;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 {
  font-size: clamp(1.55rem, 2.5vw, 2.25rem);
  letter-spacing: -0.015em;
  color: #f6f1ff;
  text-shadow: 0 0 16px rgba(125, 92, 255, 0.38), 0 0 34px rgba(125, 92, 255, 0.2);
}

.date-line {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid rgba(99, 232, 173, 0.46);
  background: rgba(12, 25, 18, 0.62);
  color: #ccffe4;
  font-size: 0.84rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #63e8ad;
  box-shadow: 0 0 12px #63e8ad;
}

.controls {
  margin-top: 14px;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.controls-title {
  margin: 0;
  color: #cecfe0;
  font-size: 0.83rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.controls-status {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

input,
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #2e2e3a;
  background: #0a0a10;
  color: var(--text);
  padding: 9px 10px;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(125, 92, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(125, 92, 255, 0.2);
}

.btn {
  height: 40px;
  border-radius: 10px;
  border: 1px solid #32323f;
  background: #13131a;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.75;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, #c39fff 0%, #7d5cff 58%, #603cf4 100%);
  border-color: transparent;
  color: #11071f;
}

.btn-primary:hover {
  filter: brightness(1.07);
}

.overview-grid {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.35fr 1.15fr 0.9fr 0.95fr;
}

.overview-card {
  border-radius: 16px;
  padding: 16px;
  min-height: 210px;
}

.overview-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.overview-head h3 {
  font-size: clamp(1rem, 1.6vw, 1.3rem);
}

.overview-head span {
  color: var(--muted);
  font-size: 0.84rem;
}

.overview-stats {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.overview-stats.two-col {
  grid-template-columns: 1fr 1fr;
}

.overview-stats p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.overview-stats strong {
  display: block;
  margin-top: 4px;
  font: 700 clamp(1.1rem, 1.75vw, 1.7rem)/1.1 "Space Grotesk", sans-serif;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.overview-bar {
  margin-top: 14px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #1a1a23;
}

.overview-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7d5cff, #bd80ff);
}

.breakdown-list {
  margin-top: 14px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.breakdown-row:last-child {
  border-bottom: 0;
}

.breakdown-row span {
  color: #d8d8e2;
}

.breakdown-row strong {
  font-size: 1.02rem;
}

.overview-live {
  position: relative;
  overflow: hidden;
}

.live-value {
  margin-top: 18px;
  font: 700 clamp(2.7rem, 5vw, 4.5rem)/1 "Space Grotesk", sans-serif;
  letter-spacing: -0.03em;
}

.muted-line {
  margin: 8px 0 0;
  color: var(--muted);
}

.live-wave {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -2px;
  height: 96px;
  border-top: 2px solid rgba(177, 139, 255, 0.78);
  border-top-left-radius: 55% 80%;
  background:
    radial-gradient(130px 40px at 15% 80%, rgba(125, 92, 255, 0.5), transparent 62%),
    radial-gradient(170px 54px at 48% 76%, rgba(125, 92, 255, 0.36), transparent 64%),
    radial-gradient(180px 58px at 92% 92%, rgba(255, 95, 133, 0.3), transparent 67%),
    linear-gradient(90deg, rgba(125, 92, 255, 0.34), rgba(255, 120, 140, 0.24));
}

.overview-won {
  border-color: rgba(99, 232, 173, 0.34);
  background:
    radial-gradient(circle at 84% 13%, rgba(99, 232, 173, 0.14), transparent 42%),
    var(--card);
}

.won-value {
  margin-top: 20px;
  font: 700 clamp(1.8rem, 2.5vw, 2.5rem)/1 "Space Grotesk", sans-serif;
  color: #d2ffea;
  letter-spacing: -0.02em;
}

.won-pill {
  margin-top: 14px;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(99, 232, 173, 0.45);
  color: #cbffe5;
  background: rgba(15, 34, 26, 0.62);
  font-size: 0.73rem;
}

.kpis {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.kpi {
  border-radius: 14px;
  padding: 14px;
}

.kpi-title {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 8px;
  font: 700 clamp(1.1rem, 2vw, 1.75rem)/1 "Space Grotesk", sans-serif;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.content-grid {
  margin-top: 12px;
}

.panel {
  border-radius: 16px;
  padding: 12px;
}

.pipeline-panel {
  min-height: 520px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-head h2 {
  font-size: 1.05rem;
}

#searchInput {
  max-width: 430px;
}

.table-wrap {
  height: clamp(420px, 63vh, 760px);
  overflow: auto;
  border-radius: 12px;
  border: 1px solid #1f1f28;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 10px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cfd0de;
  background: #101018;
  border-bottom: 1px solid #282833;
}

tbody td {
  padding: 10px;
  border-bottom: 1px solid #1f1f28;
  background: #0a0a10;
  color: #ececf2;
  font-size: 0.8rem;
  vertical-align: top;
}

.table-row:hover td {
  background: #10101a;
}

.col-lead {
  width: 12%;
}

.col-phone {
  width: 9%;
}

.col-stage {
  width: 9%;
}

.col-value {
  width: 11%;
}

.col-long {
  width: 13%;
}

.col-time {
  width: 8%;
}

.cell-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.lead-cell-wrap {
  display: grid;
  gap: 6px;
}

.row-expand-btn {
  display: none;
  width: fit-content;
  border: 1px solid rgba(125, 92, 255, 0.45);
  background: rgba(15, 13, 26, 0.9);
  color: #dccfff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.row-expand-btn.expanded {
  background: rgba(95, 66, 244, 0.24);
}

.col-long .cell-text {
  display: block;
  overflow: visible;
  max-height: none;
}

.row-detail td {
  background: #090913;
  border-bottom: 1px solid #252530;
  padding: 0;
}

.detail-shell {
  padding: 12px;
  border-top: 1px solid rgba(125, 92, 255, 0.22);
  background:
    radial-gradient(circle at 84% 8%, rgba(125, 92, 255, 0.12), transparent 45%),
    rgba(10, 10, 18, 0.92);
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.detail-pill {
  border-radius: 999px;
  border: 1px solid rgba(125, 92, 255, 0.45);
  background: rgba(30, 20, 54, 0.7);
  color: #ddd0ff;
  padding: 4px 10px;
  font-size: 0.72rem;
}

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

.detail-item {
  border: 1px solid rgba(57, 57, 75, 0.9);
  border-radius: 10px;
  background: rgba(15, 15, 26, 0.9);
  padding: 8px;
}

.detail-item dt {
  color: #abaac0;
  font-size: 0.67rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-item dd {
  margin: 4px 0 0;
  color: #f0eef7;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.stage-select {
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 7px 10px;
  background: #13131d;
}

.stage-select.tone-new {
  border-color: rgba(155, 112, 255, 0.62);
}

.stage-select.tone-contacted {
  border-color: rgba(95, 168, 255, 0.62);
}

.stage-select.tone-quoted {
  border-color: rgba(255, 182, 95, 0.62);
}

.stage-select.tone-follow {
  border-color: rgba(255, 216, 112, 0.66);
}

.stage-select.tone-won {
  border-color: rgba(99, 232, 173, 0.66);
}

.stage-select.tone-lost {
  border-color: rgba(255, 127, 159, 0.66);
}

.value-editor {
  display: grid;
  gap: 4px;
}

.value-input {
  font-size: 0.79rem;
  font-weight: 700;
  background: #12121a;
}

.value-input.tone-new {
  border-color: rgba(155, 112, 255, 0.42);
}

.value-input.tone-contacted {
  border-color: rgba(95, 168, 255, 0.42);
}

.value-input.tone-quoted {
  border-color: rgba(255, 182, 95, 0.42);
}

.value-input.tone-follow {
  border-color: rgba(255, 216, 112, 0.45);
}

.value-input.tone-won {
  border-color: rgba(99, 232, 173, 0.45);
}

.value-input.tone-lost {
  border-color: rgba(255, 127, 159, 0.44);
}

.value-preview {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
}

.table-row.tone-new td:first-child {
  box-shadow: inset 3px 0 0 var(--tone-new);
}

.table-row.tone-contacted td:first-child {
  box-shadow: inset 3px 0 0 var(--tone-contacted);
}

.table-row.tone-quoted td:first-child {
  box-shadow: inset 3px 0 0 var(--tone-quoted);
}

.table-row.tone-follow td:first-child {
  box-shadow: inset 3px 0 0 var(--tone-follow);
}

.table-row.tone-won td:first-child {
  box-shadow: inset 3px 0 0 var(--tone-won);
}

.table-row.tone-lost td:first-child {
  box-shadow: inset 3px 0 0 var(--tone-lost);
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(125, 92, 255, 0.92), rgba(96, 60, 244, 0.82));
}

*::-webkit-scrollbar-track {
  background: #0a0a10;
}

@media (max-width: 1450px) {
  .overview-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .col-long {
    width: 18%;
  }
}

@media (max-width: 1080px) {
  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  #searchInput {
    max-width: none;
  }

  .kpis {
    grid-template-columns: 1fr 1fr;
  }

  .controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .table-wrap {
    height: 60vh;
  }

  .col-long {
    width: 22%;
  }
}

@media (max-width: 760px) {
  .dashboard-shell {
    padding: 14px;
  }

  .auth-screen {
    padding: 14px;
  }

  .auth-card {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .overview-grid,
  .kpis {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 10px;
  }

  .pipeline-panel {
    min-height: 0;
  }

  .panel-head {
    gap: 8px;
    margin-bottom: 8px;
  }

  .panel-head h2 {
    font-size: 0.96rem;
  }

  .table-wrap {
    height: auto;
    max-height: 72vh;
    overflow: auto;
  }

  table {
    min-width: 0;
    table-layout: fixed;
  }

  thead th,
  tbody td {
    padding: 8px 7px;
    font-size: 0.76rem;
  }

  /* Keep only key mobile columns: Lead, Stage, Lead Value, Recap */
  thead th:nth-child(2),
  thead th:nth-child(6),
  thead th:nth-child(7),
  thead th:nth-child(8),
  thead th:nth-child(9),
  tbody td:nth-child(2),
  tbody td:nth-child(6),
  tbody td:nth-child(7),
  tbody td:nth-child(8),
  tbody td:nth-child(9) {
    display: none;
  }

  .col-lead {
    width: 26%;
  }

  .col-stage {
    width: 22%;
  }

  .col-value {
    width: 24%;
  }

  .col-long {
    width: 28%;
  }

  .col-long .cell-text {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
  }

  .row-expand-btn {
    display: inline-flex;
  }

  .stage-select {
    width: 100%;
    min-width: 0;
    font-size: 0.72rem;
    padding: 7px 8px;
  }

  .value-input {
    width: 100%;
    min-width: 0;
    font-size: 0.76rem;
    padding: 7px 8px;
  }

  .value-preview {
    font-size: 0.66rem;
  }

  .detail-shell {
    padding: 10px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
