:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --ink: #17201d;
  --muted: #6b7773;
  --line: #d9e2df;
  --accent: #0c7b6f;
  --accent-strong: #085f57;
  --warm: #e6a547;
  --danger: #b5443c;
  --ok: #237a4b;
  --shadow: 0 18px 40px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.sidebar {
  background: #11231f;
  color: #f7fbfa;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.sidebar .brand span {
  color: #b6c9c3;
}

.search-box input,
.contact-form input,
.message-form input,
.message-form select,
.type-select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.search-box input {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.search-box input::placeholder {
  color: #a7bab5;
}

.sidebar-actions,
.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 13px;
  cursor: pointer;
  min-height: 40px;
}

a.button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.ghost {
  background: transparent;
}

.sidebar .button.ghost {
  color: #f7fbfa;
  border-color: rgba(255, 255, 255, 0.18);
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
}

.contact-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  padding: 12px;
  cursor: pointer;
}

.contact-item.active {
  border-color: var(--warm);
  background: rgba(230, 165, 71, 0.14);
}

.contact-item strong,
.contact-item span {
  display: block;
}

.contact-item span {
  color: #bbcbc7;
  font-size: 0.86rem;
  margin-top: 3px;
}

.main {
  height: 100vh;
  padding: 24px;
  min-width: 0;
  overflow: auto;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2vw, 2.2rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.panel,
.pipeline-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  position: relative;
}

.panel-heading.compact {
  margin-top: 18px;
  margin-bottom: 8px;
}

.type-menu {
  position: relative;
}

.type-select {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 160px;
  width: auto;
  font-weight: 700;
  cursor: pointer;
}

.type-options {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 190px;
  display: none;
  overflow: hidden;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(23, 32, 29, 0.16);
}

.type-menu.open .type-options {
  display: grid;
}

.type-options button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 9px 10px;
  text-align: left;
}

.type-options button:hover,
.type-options button[aria-selected="true"] {
  background: #e7f4f1;
}

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

.contact-form label {
  color: var(--muted);
  font-size: 0.82rem;
  display: grid;
  gap: 5px;
}

.contact-form .wide {
  grid-column: 1 / -1;
}

textarea {
  min-height: 154px;
  resize: vertical;
  line-height: 1.45;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
  padding: 4px 2px;
}

.message {
  max-width: 86%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f7faf9;
}

.message.out {
  align-self: flex-end;
  background: #e7f4f1;
  border-color: #c7dfd9;
}

.message small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
}

.message-form {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 14px;
}

.pipeline-section {
  padding: 18px;
}

.pipeline-page .main {
  min-height: 100vh;
}

.pipeline-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(190px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.pipeline-column {
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 180px;
  padding: 12px;
}

.pipeline-column header {
  font-weight: 800;
  margin-bottom: 10px;
}

.pipeline-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.pipeline-card strong,
.pipeline-card span {
  display: block;
}

.pipeline-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.pipeline-card select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.hidden {
  display: none;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    height: auto;
    max-height: 100vh;
    min-height: 420px;
  }

  .contact-list {
    max-height: none;
  }

  .main {
    height: auto;
    overflow: visible;
  }

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

@media (max-width: 680px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .type-select {
    width: 100%;
  }

  .type-menu,
  .type-options {
    width: 100%;
  }

  .type-options {
    left: 0;
    right: auto;
  }
}
