:root {
  --bg: #f6f8f7;
  --panel: #ffffff;
  --panel-strong: #f0f5f2;
  --text: #17211d;
  --muted: #64716b;
  --line: #dce5e0;
  --sidebar: #17231f;
  --sidebar-soft: #23312c;
  --mint: #11a56f;
  --mint-soft: #e5f7ef;
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --amber: #c47a13;
  --amber-soft: #fff4dd;
  --red: #c2413b;
  --red-soft: #ffe9e7;
  --shadow: 0 16px 42px rgba(23, 35, 31, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-screen {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-items: center;
  padding: 96px 24px 42px;
  background:
    radial-gradient(circle at 85% 18%, rgba(255, 210, 80, 0.24), transparent 30%),
    linear-gradient(135deg, #fffaf1 0%, #f8fbf8 44%, #edf7f1 100%);
}

.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.34) 48%, rgba(255, 255, 255, 0.08)),
    repeating-linear-gradient(100deg, rgba(31, 88, 72, 0.04) 0 1px, transparent 1px 18px);
  pointer-events: none;
}

.login-logo {
  position: absolute;
  z-index: 2;
  top: 30px;
  left: 34px;
  width: 268px;
  height: auto;
  filter: drop-shadow(0 8px 18px rgba(23, 35, 31, 0.12));
}

.login-art {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 0.98;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 3;
  width: min(420px, calc(100vw - 32px));
  transform: translate(-6vw, -8vh);
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(18px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 16px;
  box-shadow: 0 28px 74px rgba(86, 77, 38, 0.12), 0 12px 28px rgba(23, 35, 31, 0.06);
  padding: 32px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #17231f;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
}

.brand-title {
  font-weight: 800;
  font-size: 22px;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

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

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  min-height: 38px;
  padding: 9px 11px;
  outline: none;
}

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

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px var(--mint-soft);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  min-height: 36px;
  border-radius: var(--radius);
  padding: 0 13px;
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled,
.danger-btn:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.primary-btn {
  background: var(--mint);
  color: #fff;
}

.secondary-btn {
  background: #17231f;
  color: #fff;
}

.ghost-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-btn {
  background: var(--red-soft);
  color: var(--red);
}

.error-text {
  color: var(--red);
  font-size: 13px;
  min-height: 20px;
}

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

.sidebar {
  background: var(--sidebar);
  color: #d7e4de;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar .brand {
  margin: 0;
  padding: 0 8px;
}

.sidebar .brand-mark {
  background: #f4fff9;
  color: var(--sidebar);
}

.sidebar .brand-sub {
  color: #91a59b;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav button {
  height: 38px;
  border-radius: var(--radius);
  background: transparent;
  color: #c7d8d0;
  text-align: left;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav button.active,
.nav button:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.help-entry {
  margin: 16px 8px 0;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: #f4fff9;
  font-size: 13px;
  font-weight: 850;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-entry:hover {
  background: rgba(255, 255, 255, 0.14);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: #aabcb4;
  font-size: 12px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  padding: 20px 24px 28px;
}

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

.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 850;
}

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

.page-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

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

.user-chip {
  height: 34px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.account-menu {
  position: relative;
}

.account-dropdown {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  right: 0;
  min-width: 128px;
  display: none;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.account-dropdown.open {
  display: grid;
  gap: 3px;
}

.account-dropdown button {
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-weight: 750;
}

.account-dropdown button:hover {
  background: var(--panel-strong);
}

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

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.kpi-value {
  font-size: 24px;
  font-weight: 850;
  margin-top: 6px;
}

.toolbar,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-left {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.toolbar-right {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.selection-count {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  background: #edf3f0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.compact-btn {
  padding-left: 12px;
  padding-right: 12px;
}

.toolbar .input {
  width: 250px;
  flex: 1 1 250px;
}

.toolbar .select {
  width: 146px;
  flex: 0 0 146px;
}

.quarter-select {
  width: 116px;
  flex: 0 0 116px;
}

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

.table-wrap {
  overflow: auto;
}

.logs-panel {
  padding: 14px;
  overflow: auto;
}

.log-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.logs-table th,
.logs-table td {
  white-space: normal;
}

.logs-table td:first-child {
  min-width: 118px;
  color: var(--muted);
  font-weight: 750;
}

.pagination {
  min-height: 46px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

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

th {
  position: sticky;
  top: 0;
  background: #f8fbf9;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  letter-spacing: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.select-col {
  width: 36px;
  padding-left: 10px;
  padding-right: 4px;
}

.row-check {
  width: 16px;
  height: 16px;
  accent-color: var(--mint);
  cursor: pointer;
}

tr {
  background: #fff;
}

tr:hover,
tr.selected {
  background: #f2faf6;
}

.lead-name {
  font-weight: 850;
  margin-bottom: 4px;
}

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

.lead-summary {
  max-width: 340px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.45;
}

.text-link {
  color: #0f766e;
  font-weight: 750;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.text-link:hover {
  text-decoration: underline;
}

.link-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.detail-contact-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  align-items: start;
  gap: 8px;
  margin-top: 5px;
}

.detail-contact-lines {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
  min-width: 0;
}

.detail-contact-lines .text-link {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.info-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: #0f766e;
  font-weight: 900;
  font-size: 13px;
  line-height: 1;
}

.info-btn:hover {
  background: var(--mint-soft);
  border-color: rgba(17, 165, 111, 0.32);
}

.compact-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-links .text-link {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: #fff;
  font-size: 12px;
}

.compact-links .text-link:hover {
  background: var(--mint-soft);
  border-color: rgba(17, 165, 111, 0.32);
  text-decoration: none;
}

.search-progress {
  position: fixed;
  z-index: 40;
  right: 20px;
  bottom: 22px;
  width: 280px;
  min-height: 72px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--mint-soft);
  border-top-color: var(--mint);
  animation: spin 0.9s linear infinite;
}

.search-progress-title {
  font-size: 13px;
  font-weight: 850;
}

.search-progress-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.help-modal {
  width: min(760px, calc(100vw - 32px));
}

.help-note {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbf9;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 14px;
}

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

.help-step {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.help-visual {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: var(--mint-soft);
  color: #08784f;
  display: grid;
  place-items: center;
}

.help-number {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #17231f;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
}

.help-icon {
  font-size: 22px;
  font-weight: 900;
}

.help-step-title {
  font-weight: 850;
  margin-bottom: 5px;
}

.help-step-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.help-safe {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #6d450f;
  font-size: 12px;
  line-height: 1.5;
}

.help-safe-title {
  font-weight: 900;
  margin-bottom: 4px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.badge {
  height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: #edf3f0;
  color: #42524b;
}

.badge.mint {
  background: var(--mint-soft);
  color: #08784f;
}

.badge.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.red {
  background: var(--red-soft);
  color: var(--red);
}

.status-select {
  max-width: 104px;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 24px 0 10px;
  font-size: 12px;
  font-weight: 850;
  outline: none;
  cursor: pointer;
  white-space: nowrap;
  appearance: auto;
}

.status-select:focus {
  border-color: rgba(17, 165, 111, 0.38);
  box-shadow: 0 0 0 3px var(--mint-soft);
}

.status-select.mint {
  background-color: var(--mint-soft);
  color: #08784f;
}

.status-select.blue {
  background-color: var(--blue-soft);
  color: var(--blue);
}

.status-select.amber {
  background-color: var(--amber-soft);
  color: var(--amber);
}

.status-select.red {
  background-color: var(--red-soft);
  color: var(--red);
}

.status-select.gray {
  background-color: #edf3f0;
  color: #42524b;
}

.grade {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.grade.S {
  background: #dff8ee;
  color: #078155;
}

.grade.A {
  background: #e8f0ff;
  color: #2563eb;
}

.grade.B {
  background: #fff4dd;
  color: #b76b00;
}

.grade.C {
  background: #ffe9e7;
  color: #b8322b;
}

.detail {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.detail-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-header > div:first-child {
  min-width: 0;
}

.detail-title {
  font-size: 18px;
  font-weight: 850;
}

.detail-body {
  padding: 14px 16px 16px;
  display: grid;
  gap: 14px;
}

.section-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 900;
  margin-bottom: 8px;
}

.draft,
.draft-editor {
  background: #f8fbf9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  color: #26322e;
  line-height: 1.48;
  font-size: 12px;
  min-height: 180px;
  max-height: 260px;
  overflow: auto;
}

.draft {
  white-space: pre-wrap;
}

.draft-editor {
  width: 100%;
  resize: vertical;
  outline: none;
}

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

.stack {
  display: grid;
  gap: 10px;
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 16, 0.4);
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal {
  width: min(720px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
}

.info-modal {
  width: min(560px, calc(100vw - 40px));
}

.info-title {
  font-weight: 900;
  margin-bottom: 14px;
}

.info-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.info-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.info-value {
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
}

.info-value .text-link {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.modal-header,
.modal-footer {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
}

.modal-body {
  padding: 16px;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.bar {
  height: 9px;
  background: #edf3f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--mint);
}

.queue-status {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fbf9;
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
  }

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

  .sidebar-footer {
    display: none;
  }

  .kpi-grid,
  .content-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

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

  .toolbar-left,
  .toolbar-right {
    flex-wrap: wrap;
  }

  .toolbar .input {
    width: 100%;
  }

  .detail {
    position: static;
  }

  .login-screen {
    place-items: center;
    padding: 108px 16px 34px;
  }

  .login-card {
    transform: translateY(-4vh);
    background: rgba(255, 255, 255, 0.66);
  }

  .login-logo {
    top: 24px;
    left: 22px;
    width: 214px;
  }

  .login-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 58% center;
    opacity: 0.72;
  }
}
