:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ed;
  --ink: #1f2823;
  --muted: #68736d;
  --line: #d9dfd8;
  --cold: #c77fa6;
  --warm: #be789f;
  --hot: #b86f98;
  --opened: #7d88b4;
  --joined: #28715d;
  --accent: #256f5a;
  --accent-strong: #155541;
  --danger: #a73737;
  --chip-s: #dcefd2;
  --chip-r: #d9e9f8;
  --chip-t: #d7efe7;
  --shadow: 0 18px 55px rgba(31, 40, 35, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body.is-logged-out .app-only {
  display: none;
}

body.is-logged-in .login-screen {
  display: none;
}

body:not(.is-admin) .admin-only {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 44px) 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  font-size: 34px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.demo-accounts {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.demo-accounts strong {
  color: var(--ink);
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(26px, 4vw, 44px);
}

h2 {
  font-size: 18px;
}

.header-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-chip {
  min-height: 44px;
  display: grid;
  align-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button.primary {
  background: var(--accent);
  color: white;
}

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

.button.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.button.danger {
  color: var(--danger);
}

.icon-button {
  width: 44px;
  padding: 0;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 28px;
}

.app-shell {
  padding: 22px clamp(14px, 3vw, 34px) 40px;
}

.admin-panel {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.row-action {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.row-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-panel {
  min-height: 112px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  align-content: space-between;
}

.summary-panel strong {
  font-size: 34px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.summary-label,
.summary-panel small,
.section-title p {
  color: var(--muted);
}

.summary-label {
  font-size: 13px;
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 170px auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 111, 90, 0.24);
  outline-offset: 2px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.checkline input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.checkline.large {
  justify-content: flex-start;
  padding: 10px 0;
}

.week-strip {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 20px;
}

.birthday-strip {
  margin-top: -8px;
}

.section-title {
  padding: 16px 0;
}

.section-title p {
  margin: 6px 0 0;
  line-height: 1.4;
}

.week-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.week-card {
  min-height: 106px;
  border: 1px solid #c8d8c4;
  border-radius: 8px;
  background: #edf6ea;
  padding: 14px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.birthday-card {
  background: #fff5e8;
  border-color: #ecd0a3;
}

.week-card strong,
td strong {
  font-size: 14px;
}

.week-card span,
td span,
.meta {
  color: var(--muted);
  font-size: 12px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(260px, 1fr));
  gap: 14px;
}

.stage-column {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
}

.stage-heading {
  min-height: 54px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
}

.stage-heading.cold {
  background: var(--cold);
}

.stage-heading.warm {
  background: var(--warm);
}

.stage-heading.hot {
  background: var(--hot);
}

.stage-heading.opened {
  background: var(--opened);
}

.stage-heading.joined {
  background: var(--joined);
}

.stage-heading span {
  min-width: 32px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: #fafbf9;
}

tr {
  transition: background 160ms ease;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f4f8f1;
}

tbody tr.week {
  background: #e3f1de;
}

.status-chip {
  min-width: 38px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-weight: 900;
}

.status-chip.s {
  background: var(--chip-s);
  color: #356127;
}

.status-chip.r {
  background: var(--chip-r);
  color: #2a5b86;
}

.status-chip.t {
  background: var(--chip-t);
  color: #276651;
}

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

.drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  justify-content: flex-end;
  background: rgba(31, 40, 35, 0.32);
}

.drawer.open {
  display: flex;
}

.drawer-panel {
  width: min(760px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.prospect-form {
  display: grid;
  gap: 18px;
}

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

.relationship-map {
  position: relative;
  min-height: 470px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.center-node {
  position: absolute;
  z-index: 2;
  width: 180px;
  height: 180px;
  border: 2px solid #18221d;
  border-radius: 999px;
  background: #e7f3ed;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  text-align: center;
}

.center-node strong {
  font-size: 22px;
}

.center-node span {
  max-width: 130px;
  border-bottom: 1px solid #8ea49a;
  padding-bottom: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.touchpoint {
  min-height: 128px;
  border: 1px solid #9da8a1;
  border-radius: 999px;
  background: white;
  padding: 18px 14px;
  display: grid;
  align-content: center;
  gap: 8px;
}

.touchpoint:nth-child(2),
.touchpoint:nth-child(3),
.touchpoint:nth-child(6),
.touchpoint:nth-child(7) {
  transform: translateY(34px);
}

.touchpoint label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.touchpoint input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
}

.touchpoint textarea {
  min-height: 52px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 0 0;
  text-align: center;
}

@media (max-width: 1050px) {
  .summary-grid,
  .pipeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .week-strip,
  .admin-form {
    grid-template-columns: 1fr;
  }

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

  .touchpoint:nth-child(n) {
    transform: none;
  }

  .relationship-map {
    place-items: start;
    padding-top: 220px;
  }
}

@media (max-width: 680px) {
  .app-header {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .pipeline,
  .form-grid,
  .touchpoint-grid {
    grid-template-columns: 1fr;
  }

  .drawer-panel {
    padding: 18px;
  }

  .relationship-map {
    min-height: auto;
    padding-top: 210px;
  }

  .center-node {
    top: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
