:root {
  --teal: #087984;
  --teal-dark: #05616b;
  --ink: #17262a;
  --muted: #607074;
  --line: #d8e1e3;
  --surface: #f5f8f8;
  --panel: #ffffff;
  --danger: #c63535;
  --warn: #c97c14;
  font-family: Inter, Arial, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(23, 38, 42, 0.12);
}

.login-panel h1 {
  margin: 4px 0 0;
  font-size: 25px;
  letter-spacing: 0;
}

.form-error {
  margin: 0;
  border: 1px solid #f0b7b7;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fdeaea;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  padding: 8px 11px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 700;
}

.topbar {
  min-height: 64px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--teal);
  color: #fff;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 24px;
  letter-spacing: 0;
}

.eyebrow {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  opacity: 0.8;
}

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

.signed-in {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 800;
}

.top-actions button:not(.primary) {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}

.view-tabs {
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
}

.view-tabs button,
.view-tabs a {
  min-height: 34px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 800;
}

.view-tabs a {
  display: inline-flex;
  align-items: center;
  padding: 8px 11px;
  text-decoration: none;
}

.view-tabs button:last-child,
.view-tabs a:last-child {
  border-right: 0;
}

.view-tabs .active {
  background: #fff;
  color: var(--teal-dark);
}

.workspace {
  padding: 16px 18px 18px;
  display: grid;
  gap: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 180px auto auto auto;
  align-items: end;
  gap: 12px;
}

.crm-toolbar {
  grid-template-columns: minmax(240px, 1fr) 220px 180px;
}

label {
  display: grid;
  gap: 6px;
  color: #304449;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid #c7d4d6;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented .active {
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.detail-toggle {
  align-self: end;
  font-weight: 800;
}

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

.metrics div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  display: grid;
  gap: 3px;
}

.metrics strong {
  font-size: 24px;
  color: var(--teal-dark);
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 14px;
  align-items: start;
}

.content.details-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.board-shell {
  min-width: 0;
}

.board-scroll-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 16px rgba(23, 38, 42, 0.08);
}

.board-scroll-controls span {
  min-width: 58px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.board-scroll-controls button {
  min-width: 40px;
  min-height: 32px;
  padding: 4px 10px;
  border-color: var(--teal);
  color: var(--teal-dark);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.crm-content {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 440px;
  gap: 14px;
  align-items: start;
}

.contact-list {
  display: grid;
  gap: 10px;
}

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 292px;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.stage {
  min-height: 600px;
  background: #e9eeee;
  border: 1px solid #d0dcde;
  border-radius: 8px;
  overflow: hidden;
}

.stage.drag-over {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 2px var(--teal);
}

.stage header {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--teal);
  color: #fff;
}

.stage header div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.stage header span {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 11px;
  font-weight: 900;
}

.stage h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.stage header strong {
  font-size: 13px;
  white-space: nowrap;
}

.cards {
  padding: 10px;
  display: grid;
  gap: 9px;
}

.deal-card {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid #83c09d;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(23, 38, 42, 0.12);
  padding: 11px;
}

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

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

.contact-card {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  background: #fff;
  border-left: 4px solid #3f8fa8;
  box-shadow: 0 1px 4px rgba(23, 38, 42, 0.12);
  padding: 12px;
}

.contact-card.selected {
  outline: 2px solid var(--teal);
}

.deal-card.selected {
  outline: 2px solid var(--teal);
}

.card-top,
.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-top strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-address,
.detail-address {
  margin: 0;
  color: #304449;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-top span,
.mini-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-top .danger {
  color: var(--danger);
}

.card-top .warn {
  color: var(--warn);
}

.amount {
  color: var(--teal-dark);
  font-size: 20px;
  font-weight: 900;
}

.stage-age {
  width: fit-content;
  border: 1px solid #c7d4d6;
  border-radius: 999px;
  padding: 3px 7px;
  color: #304449;
  background: #f5f8f8;
  font-size: 12px;
  font-weight: 800;
}

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

.tag-row span {
  border: 1px solid #c7d4d6;
  border-radius: 999px;
  padding: 3px 7px;
  background: #f5f8f8;
  color: #304449;
  font-size: 12px;
  font-weight: 800;
}

.linked-deals {
  display: grid;
  gap: 8px;
}

.linked-deals button {
  display: grid;
  gap: 4px;
  min-height: auto;
  text-align: left;
  border-left: 4px solid #83c09d;
}

.linked-deals span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.subline {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.deal-type-line {
  color: #304449;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.deal-card p {
  margin: 0;
  color: #33464a;
  font-size: 13px;
  line-height: 1.35;
}

.empty {
  border: 1px dashed #bac8ca;
  border-radius: 6px;
  color: var(--muted);
  padding: 18px 12px;
  text-align: center;
  font-size: 13px;
}

.detail {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.detail form {
  display: grid;
  gap: 14px;
}

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

.detail h2,
.detail h3 {
  margin: 0;
  letter-spacing: 0;
}

.detail h2 {
  margin-top: 6px;
  margin-bottom: 4px;
  font-size: 21px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e9eeee;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.pill.high {
  background: #fdeaea;
  color: var(--danger);
}

.pill.medium {
  background: #fff3df;
  color: var(--warn);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wide,
.notes {
  grid-column: 1 / -1;
}

.doc-panel {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  display: grid;
  gap: 10px;
}

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

.doc-head p,
.doc-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.doc-head strong {
  white-space: nowrap;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.doc-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  line-height: 1.35;
}

.doc-checks input {
  width: 16px;
  min-height: 16px;
}

.detail-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

@media (max-width: 1000px) {
  .toolbar,
  .content {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .top-actions,
  .detail-actions,
  .segmented {
    flex-wrap: wrap;
  }

  .metrics,
  .field-grid,
  .doc-checks {
    grid-template-columns: 1fr;
  }

  .board {
    grid-auto-columns: 86vw;
  }
}

@media screen {
  :root {
    --teal: #005b94;
    --teal-dark: #0b2437;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #d8e1ea;
    --surface: #eef4f8;
    --panel: #ffffff;
    --danger: #b42318;
    --warn: #a55410;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  }

  body.pipeline-modern {
    background:
      linear-gradient(180deg, #f7fbff 0, #eef4f8 360px, #eaf0f5 100%);
    color: var(--ink);
  }

  .pipeline-modern button {
    align-items: center;
    background: #ffffff;
    border: 1px solid #cfd9e4;
    border-radius: 8px;
    color: #172033;
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    gap: 8px;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  }

  .pipeline-modern button:hover:not(:disabled) {
    border-color: #99b7cf;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
  }

  .pipeline-modern .primary {
    background: linear-gradient(135deg, #005b94, #0b7bc1);
    border-color: #005b94;
    box-shadow: 0 10px 22px rgba(0, 91, 148, 0.22);
    color: #ffffff;
  }

  .pipeline-modern .login-shell {
    background:
      radial-gradient(circle at 20% 16%, rgba(11, 123, 193, 0.16), transparent 32%),
      linear-gradient(135deg, #eef7ff, #ffffff 48%, #eaf0f5);
  }

  .pipeline-modern .login-panel {
    border-color: rgba(207, 217, 228, 0.95);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.16);
    padding: 26px;
  }

  .pipeline-modern .login-brand {
    display: grid;
    gap: 8px;
  }

  .pipeline-modern .brand-logo {
    height: 40px;
    object-fit: contain;
    width: 152px;
  }

  .pipeline-modern .topbar {
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(207, 217, 228, 0.9);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
    color: #0b2437;
    min-height: 82px;
    padding: 14px 26px;
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .pipeline-modern .brand-lockup {
    align-items: center;
    display: flex;
    gap: 14px;
  }

  .pipeline-modern .topbar h1,
  .pipeline-modern .login-panel h1 {
    color: #0b2437;
    font-size: 24px;
    line-height: 1.1;
  }

  .pipeline-modern .eyebrow {
    color: #0b7bc1;
    opacity: 1;
  }

  .pipeline-modern .signed-in {
    background: #f4f8fb;
    border: 1px solid #dce6ee;
    border-radius: 8px;
    color: #445468;
    padding: 9px 12px;
  }

  .pipeline-modern .top-actions button:not(.primary),
  .pipeline-modern .view-tabs button,
  .pipeline-modern .view-tabs a {
    background: #ffffff;
    border-color: #cfd9e4;
    color: #172033;
  }

  .pipeline-modern .view-tabs {
    background: #f4f8fb;
    border-color: #cfd9e4;
    border-radius: 8px;
    padding: 3px;
  }

  .pipeline-modern .view-tabs button,
  .pipeline-modern .view-tabs a {
    border: 0;
    border-radius: 6px;
  }

  .pipeline-modern .view-tabs .active {
    background: #0b2437;
    color: #ffffff;
  }

  .pipeline-modern .workspace {
    gap: 16px;
    padding: 20px 22px 24px;
  }

  .pipeline-modern .toolbar {
    align-items: end;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(207, 217, 228, 0.95);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 14px;
  }

  .pipeline-modern label {
    color: #344256;
    font-size: 12px;
  }

  .pipeline-modern input,
  .pipeline-modern select,
  .pipeline-modern textarea {
    background: #ffffff;
    border: 1px solid #cfd9e4;
    border-radius: 8px;
    color: #172033;
    min-height: 40px;
    outline: none;
    padding: 9px 11px;
    transition: border-color 140ms ease, box-shadow 140ms ease;
  }

  .pipeline-modern input:focus,
  .pipeline-modern select:focus,
  .pipeline-modern textarea:focus {
    border-color: #0b7bc1;
    box-shadow: 0 0 0 3px rgba(11, 123, 193, 0.14);
  }

  .pipeline-modern .segmented {
    background: #f4f8fb;
    border-color: #cfd9e4;
    border-radius: 8px;
    padding: 3px;
  }

  .pipeline-modern .segmented button {
    border: 0;
    border-radius: 6px;
  }

  .pipeline-modern .segmented .active {
    background: #0b2437;
    color: #ffffff;
  }

  .pipeline-modern .metrics {
    gap: 12px;
  }

  .pipeline-modern .metrics div {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(207, 217, 228, 0.95);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-height: 104px;
    padding: 16px;
  }

  .pipeline-modern .metrics strong {
    color: #0b2437;
    font-size: 28px;
    line-height: 1.05;
  }

  .pipeline-modern .metrics span {
    color: var(--muted);
    text-transform: uppercase;
  }

  .pipeline-modern .content,
  .pipeline-modern .crm-content {
    gap: 16px;
  }

  .pipeline-modern .board-scroll-controls {
    border-color: #d8e1ea;
    border-radius: 8px;
    box-shadow: var(--shadow);
    top: 98px;
  }

  .pipeline-modern .board {
    gap: 12px;
    grid-auto-columns: 308px;
  }

  .pipeline-modern .stage {
    background: #f2f6f9;
    border-color: #d8e1ea;
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  .pipeline-modern .stage header {
    background: linear-gradient(135deg, #0b2437, #064d79);
    min-height: 60px;
  }

  .pipeline-modern .stage header span {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
    border-radius: 8px;
  }

  .pipeline-modern .stage h2 {
    font-size: 15px;
  }

  .pipeline-modern .stage.drag-over {
    border-color: #0b7bc1;
    box-shadow: inset 0 0 0 2px #0b7bc1, var(--shadow);
  }

  .pipeline-modern .cards,
  .pipeline-modern .contact-list {
    gap: 10px;
    padding: 12px;
  }

  .pipeline-modern .deal-card,
  .pipeline-modern .contact-card {
    border: 1px solid #d8e1ea;
    border-left: 4px solid #0b7bc1;
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
    padding: 13px;
  }

  .pipeline-modern .deal-card.selected,
  .pipeline-modern .contact-card.selected {
    outline: 2px solid #0b7bc1;
    outline-offset: 2px;
  }

  .pipeline-modern .card-top strong {
    color: #0b2437;
    font-size: 14px;
  }

  .pipeline-modern .card-top span,
  .pipeline-modern .mini-row span,
  .pipeline-modern .stage-age,
  .pipeline-modern .tag-row span,
  .pipeline-modern .pill {
    background: #f4f8fb;
    border: 1px solid #d8e1ea;
    border-radius: 999px;
    color: #526277;
    padding: 3px 7px;
  }

  .pipeline-modern .amount {
    color: #005b94;
    font-size: 21px;
  }

  .pipeline-modern .subline,
  .pipeline-modern .deal-type-line,
  .pipeline-modern .deal-card p,
  .pipeline-modern .card-address,
  .pipeline-modern .detail-address {
    color: #526277;
  }

  .pipeline-modern .detail {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(207, 217, 228, 0.95);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 122px);
    top: 98px;
  }

  .pipeline-modern .detail-actions {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), #ffffff 22%);
    bottom: -16px;
    margin: 2px -16px -16px;
    padding: 14px 16px 16px;
    position: sticky;
    z-index: 2;
  }

  .pipeline-modern .detail h2,
  .pipeline-modern .detail h3 {
    color: #0b2437;
  }

  .pipeline-modern .doc-panel {
    background: #f7fafc;
    border: 1px solid #d8e1ea;
    border-radius: 8px;
    padding: 14px;
  }

  .pipeline-modern .doc-head strong {
    color: #005b94;
  }

  .pipeline-modern .empty {
    background: #f7fafc;
    border-color: #cfd9e4;
    border-radius: 8px;
  }

  .pipeline-modern .form-error {
    border-radius: 8px;
  }
}

@media screen and (max-width: 1000px) {
  .pipeline-modern .topbar {
    align-items: flex-start;
    position: static;
  }

  .pipeline-modern .topbar,
  .pipeline-modern .top-actions {
    flex-wrap: wrap;
  }

  .pipeline-modern .toolbar,
  .pipeline-modern .content,
  .pipeline-modern .crm-content {
    grid-template-columns: 1fr;
  }

  .pipeline-modern .detail {
    max-height: none;
    position: static;
  }

  .pipeline-modern .board-scroll-controls {
    top: 0;
  }
}

@media screen and (max-width: 720px) {
  .pipeline-modern .workspace {
    padding: 12px;
  }

  .pipeline-modern .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .pipeline-modern .metrics,
  .pipeline-modern .field-grid,
  .pipeline-modern .doc-checks {
    grid-template-columns: 1fr;
  }

  .pipeline-modern .board {
    grid-auto-columns: 86vw;
  }
}
