:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #151515;
  --panel-2: #202020;
  --line: #303030;
  --text: #f4f4f4;
  --muted: #a8a8a8;
  --red: #d71920;
  --red-2: #ff3b42;
  --good: #2ec36b;
  --warn: #f4b942;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.customer-page {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.customer-hero,
.customer-lookup {
  width: min(980px, 100%);
  margin: 0 auto;
}

.customer-hero {
  padding-top: 28px;
}

.customer-hero p:last-child {
  max-width: 620px;
  color: var(--muted);
}

.customer-lookup {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

button {
  cursor: pointer;
}

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

.topbar,
.metrics,
.filters,
.view-tabs,
.lead-list-view,
.status-lookup {
  max-width: 1680px;
  margin: 0 auto 16px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--red-2);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
}

.topbar-actions,
.dialog-actions,
.dialog-actions > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-tabs {
  display: flex;
  gap: 8px;
}

.view-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--panel);
}

.view-tab.active {
  border-color: var(--red);
  color: var(--text);
  background: rgba(215, 25, 32, 0.22);
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  color: var(--text);
  background: var(--panel-2);
}

.primary-button {
  border-color: var(--red);
  background: var(--red);
  padding: 0 16px;
  font-weight: 800;
}

.ghost-button,
.danger-button {
  padding: 0 14px;
}

.danger-button {
  border-color: rgba(215, 25, 32, 0.5);
  color: #ffb4b7;
}

.icon-button {
  width: 42px;
  display: inline-grid;
  place-items: center;
  font-size: 1.15rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metrics article,
.filters,
.stage-column {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics article {
  border-radius: 8px;
  padding: 14px;
}

.metrics span,
label span,
.stage-meta,
.card-label,
.helper {
  color: var(--muted);
  font-size: 0.82rem;
}

.metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 1.4rem;
}

.filters {
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f0f0f;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red-2);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.22);
}

.board {
  max-width: 1680px;
  margin: 0 auto;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 18px;
}

.stage-column {
  border-radius: 8px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.stage-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(21, 21, 21, 0.96);
}

.stage-head h3 {
  margin-bottom: 8px;
  font-size: 0.98rem;
}

.stage-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.dropzone {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
}

.dropzone.drag-over {
  background: rgba(215, 25, 32, 0.12);
}

.deal-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  background: #101010;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.deal-card[draggable="true"] {
  cursor: grab;
}

.deal-card.dragging {
  opacity: 0.55;
}

.deal-card h4 {
  margin: 0;
  font-size: 1rem;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.card-value {
  font-weight: 900;
}

.card-label {
  display: block;
  margin-bottom: 2px;
}

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

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: #e7e7e7;
  background: var(--panel-2);
  font-size: 0.76rem;
}

.pill.good {
  border-color: rgba(46, 195, 107, 0.5);
  color: #9ff0bd;
}

.pill.warn {
  border-color: rgba(244, 185, 66, 0.5);
  color: #ffdfa0;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.card-actions select {
  min-width: 0;
  padding: 8px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px 12px;
  color: var(--muted);
  text-align: center;
}

.lead-list-view {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lead-list-head,
.lead-row {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr 1.35fr 1.25fr 0.7fr;
  gap: 12px;
  align-items: center;
}

.lead-list-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-list {
  display: grid;
}

.lead-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.lead-row:hover,
.lead-row:focus {
  background: rgba(215, 25, 32, 0.12);
  outline: none;
}

.lead-row span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.lead-row strong,
.lead-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-row small {
  color: var(--muted);
  font-size: 0.78rem;
}

.lead-row mark {
  width: fit-content;
  border: 1px solid rgba(215, 25, 32, 0.5);
  border-radius: 999px;
  padding: 5px 9px;
  color: #ffd5d7;
  background: rgba(215, 25, 32, 0.14);
  font-size: 0.78rem;
}

.lead-list-empty {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.status-lookup {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.status-result {
  margin-top: 14px;
}

.status-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  padding: 16px;
  background: #101010;
}

.status-card h2 {
  margin: 4px 0 14px;
}

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

.customer-order-card + .customer-order-card {
  margin-top: 12px;
}

.status-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.status-step {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 0.8rem;
}

.status-step.active {
  border-color: rgba(215, 25, 32, 0.65);
  color: #ffd5d7;
  background: rgba(215, 25, 32, 0.18);
}

.hidden {
  display: none !important;
}

dialog {
  width: min(980px, calc(100vw - 26px));
  max-height: calc(100vh - 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.deal-form,
.settings-form {
  display: grid;
  gap: 18px;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

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

.full-width {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.settings-form {
  max-width: 720px;
}

.sync-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: #101010;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--panel-2);
  box-shadow: var(--shadow);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

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

  .metrics,
  .filters,
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .lead-list-head {
    display: none;
  }

  .lead-row {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .status-form,
  .status-grid {
    grid-template-columns: 1fr 1fr;
  }

  .board {
    grid-auto-columns: minmax(260px, 86vw);
  }
}

@media (max-width: 620px) {
  .metrics,
  .filters,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .lead-row {
    grid-template-columns: 1fr;
  }

  .status-form,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .customer-page {
    padding: 16px;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 42px 42px 1fr;
  }

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

  .dialog-actions > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
