:root {
  --purple: #a00091;
  --purple-dark: #7e0075;
  --grid: #c9bd8d;
  --sheet-bg: #fbfbf6;
  --input-bg: #a6a6a6;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d7d7d7;
  --green: #13a538;
  --yellow: #ffd84d;
  --red: #ff1616;
  --gray: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #eceff3;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f7;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}

.login-card h1 {
  margin: 0 0 20px;
  color: #064caa;
  font-size: 24px;
}

.login-card form,
.login-card label {
  display: grid;
  gap: 10px;
}

.login-card form {
  gap: 16px;
}

.login-card input {
  width: 100%;
  border: 1px solid #c7cbd1;
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: #111827;
}

.login-card button {
  background: #064caa;
  color: #fff;
  border-color: #063d88;
}

.login-error {
  margin: 0;
  color: #b91c1c;
  font-size: 14px;
}

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

button,
.file-button {
  border: 1px solid #b8bec8;
  border-radius: 6px;
  background: #fff;
  color: #172033;
  cursor: pointer;
  padding: 8px 12px;
}

button:hover,
.file-button:hover {
  border-color: var(--purple);
}

.app-shell {
  min-width: 1180px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  color: #064caa;
  font-size: 26px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.file-button {
  display: inline-flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

main {
  padding: 16px;
}

.toolbar {
  margin-bottom: 14px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.toolbar label,
.dialog-card label {
  display: grid;
  gap: 5px;
  color: #374151;
  font-size: 13px;
}

.toolbar input,
.toolbar select,
.dialog-card input,
.dialog-card select,
.dialog-card textarea {
  width: 100%;
  border: 1px solid #c7cbd1;
  border-radius: 5px;
  padding: 8px 9px;
  background: #fff;
  color: #111827;
}

.search-box {
  width: 360px;
}

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.panel-title span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  max-height: 52vh;
  background: var(--sheet-bg);
}

.followup-wrap {
  max-height: 430px;
}

.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  background: var(--sheet-bg);
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  border: 1px solid #d8c99b;
  background: var(--purple);
  color: #fff;
  font-weight: 500;
  padding: 6px;
  min-width: 120px;
  white-space: nowrap;
}

.data-table td {
  border: 1px solid var(--grid);
  height: 31px;
  padding: 0;
  background: #fffffb;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-table th:nth-child(1),
.main-table td:nth-child(1) {
  min-width: 70px;
  width: 70px;
}

.main-table th:nth-last-child(1),
.main-table td:nth-last-child(1) {
  min-width: 80px;
}

.main-table th[data-field="companyName"],
.main-table td[data-field="companyName"] {
  min-width: 220px;
}

.main-table th[data-field="website"],
.main-table td[data-field="website"],
.main-table th[data-field="companyLinkedIn"],
.main-table td[data-field="companyLinkedIn"],
.main-table th[data-field="keyPersonLinkedIn"],
.main-table td[data-field="keyPersonLinkedIn"],
.main-table th[data-field="companyLinkedInDetails"],
.main-table td[data-field="companyLinkedInDetails"],
.main-table th[data-field="keyPersonLinkedInDetails"],
.main-table td[data-field="keyPersonLinkedInDetails"] {
  min-width: 240px;
}

.main-table th[data-field="contact"],
.main-table td[data-field="contact"],
.main-table th[data-field="email"],
.main-table td[data-field="email"] {
  min-width: 210px;
}

.main-table th[data-field="otherContact"],
.main-table td[data-field="otherContact"] {
  min-width: 150px;
}

.main-table th[data-field="outreachStatus"],
.main-table td[data-field="outreachStatus"] {
  min-width: 130px;
}

.main-table th[data-field="lastFollowup"],
.main-table td[data-field="lastFollowup"] {
  min-width: 140px;
}

.data-table td:not(.sheet-input):not(.status-cell) {
  padding: 4px 6px;
}

.data-table tr:hover td {
  background: #f7f9ff;
}

.data-table .sheet-input {
  background: #fff;
  color: #111827;
}

.cell-input,
.followup-input,
.followup-blank {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 5px 4px;
  background: #fff;
  color: #111827;
}

.cell-input::placeholder,
.followup-input::placeholder,
.followup-blank::placeholder {
  color: #9ca3af;
}

.cell-input:focus,
.followup-input:focus,
.followup-blank:focus {
  outline: 2px solid #00a06a;
  outline-offset: -2px;
  background: #fff;
}

.sequence-button {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: #0645d8;
  text-decoration: underline;
}

.blank-row td {
  background: #fffffb;
}

.data-table a {
  color: #0645d8;
}

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

.row-actions button {
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 12px;
}

.status-cell {
  color: #000;
  font-weight: 700;
  text-align: center;
}

.status-ok {
  background: var(--green) !important;
}

.status-soon {
  background: var(--yellow) !important;
}

.status-overdue {
  background: var(--red) !important;
}

.status-none {
  background: var(--gray) !important;
  color: #374151;
}

.selected-row td {
  outline: 2px solid #0aa36f;
  outline-offset: -2px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(430px, 0.72fr) minmax(650px, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.page-head h2,
.page-head p {
  margin: 0;
}

.page-head p {
  color: var(--muted);
  font-size: 13px;
}

.followup-layout {
  display: grid;
  grid-template-columns: minmax(520px, 0.8fr) minmax(600px, 1fr);
  gap: 14px;
}

.followup-table {
  min-width: 920px;
}

.followup-table th:nth-child(1),
.followup-table td:nth-child(1) {
  width: 150px;
}

.followup-table th:nth-child(2),
.followup-table td:nth-child(2) {
  width: 360px;
}

.followup-table th:nth-child(3),
.followup-table td:nth-child(3) {
  width: 300px;
}

.followup-table td {
  background: #fff;
  color: #111827;
}

.followup-table td:last-child {
  background: #fffffb;
  color: var(--text);
}

.detail-card {
  padding: 0;
  background: #fff;
}

.detail-head {
  display: grid;
  grid-template-columns: 1fr 0.36fr 1fr;
  align-items: stretch;
  border-bottom: 1px solid var(--grid);
}

.detail-head .company-title {
  grid-column: span 2;
  min-height: 42px;
  padding: 8px 10px;
  color: #064caa;
  font-size: 24px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.detail-head .level {
  display: grid;
  place-items: center;
  color: #064caa;
  font-size: 20px;
  border-left: 1px solid var(--grid);
}

.detail-fields {
  display: grid;
  grid-template-columns: 110px 1fr 110px 1fr;
}

.detail-label {
  padding: 5px 8px;
  border: 1px solid var(--grid);
  background: var(--purple);
  color: #fff;
  text-align: center;
}

.detail-value {
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--grid);
  background: var(--input-bg);
  color: #fff;
  overflow-wrap: anywhere;
}

.detail-input {
  display: block;
  width: 100%;
  min-height: 28px;
  padding: 5px 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font: inherit;
}

textarea.detail-input {
  min-height: 76px;
  resize: vertical;
  line-height: 1.4;
}

.detail-head .company-title .detail-input,
.detail-head .level .detail-input {
  color: #064caa;
  font-weight: inherit;
}

.detail-section-title {
  display: grid;
  grid-template-columns: 110px 1fr 1fr;
  margin-top: 10px;
  background: var(--purple);
  color: #fff;
  text-align: center;
}

.detail-section-title div {
  padding: 6px;
  border: 1px solid var(--grid);
}

.detail-followups {
  width: 100%;
  border-collapse: collapse;
}

.detail-followups td {
  border: 1px solid var(--grid);
  height: 28px;
  padding: 4px 6px;
}

.empty-state {
  padding: 20px;
  color: var(--muted);
}

dialog {
  width: min(860px, calc(100vw - 28px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-card {
  padding: 18px;
}

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

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

.form-grid .wide {
  grid-column: span 3;
}

.dialog-card textarea {
  min-height: 74px;
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.dialog-actions button[type="submit"] {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple-dark);
}

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

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

  .data-table {
    min-width: 1320px;
  }

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

  .form-grid .wide {
    grid-column: span 1;
  }
}
