:root {
  --bg: #f4f5ef;
  --panel: #ffffff;
  --panel-soft: #f8f9f4;
  --ink: #111412;
  --muted: #667066;
  --line: #d9ded3;
  --line-strong: #b8c0b0;
  --accent: #8dee3f;
  --accent-dark: #315f16;
  --blue: #1f5eff;
  --amber: #a46100;
  --red: #9f251f;
  --shadow: 0 18px 54px rgba(17, 20, 18, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(17, 20, 18, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 20, 18, 0.03) 1px, transparent 1px),
    var(--bg);
  background-size: 72px 72px;
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Aptos", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button.status-button {
  min-height: 38px;
  padding: 8px 10px;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100dvh;
}

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

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.login-panel img {
  width: 210px;
  margin-bottom: 32px;
}

.login-panel h1 {
  margin: 0 0 20px;
  font-size: 2.3rem;
  line-height: 1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(141, 238, 63, 0.72);
  outline-offset: 2px;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.login-panel button {
  min-height: 44px;
}

#loginMessage {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.portal-view {
  min-height: 100dvh;
  padding: 18px;
}

.portal-header,
.metric-strip,
.workbench {
  width: min(1440px, 100%);
  margin-inline: auto;
}

.portal-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

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

.brand-lockup img {
  width: 190px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.brand-lockup span,
.metric-card span,
.lead-row span,
.detail-meta span,
.field-row span,
.activity-row span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-lockup strong {
  display: block;
  margin-top: 4px;
  font-size: 1.1rem;
}

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

.header-actions button {
  min-height: 40px;
  padding: 8px 12px;
}

.profile-chip {
  min-height: 40px;
  min-width: 170px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.profile-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
}

.profile-chip strong {
  display: block;
  margin-top: 2px;
  font-size: 0.9rem;
}

.header-actions button:not(:last-child) {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric-card {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.8rem;
  line-height: 1;
}

.workbench {
  height: calc(100dvh - 202px);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(340px, 0.36fr) minmax(0, 0.64fr);
  gap: 12px;
  margin-top: 12px;
}

.lead-panel,
.detail-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.lead-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.filters label {
  min-width: 0;
}

.lead-list {
  overflow: auto;
}

.lead-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.lead-row:hover,
.lead-row.is-selected {
  background: #f0f7e9;
}

.lead-row strong {
  display: block;
  margin: 5px 0;
  font-size: 0.98rem;
}

.lead-row small,
.detail-meta small {
  color: var(--muted);
  font-weight: 750;
}

.pill {
  align-self: start;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.pill.high {
  background: rgba(141, 238, 63, 0.28);
  color: var(--accent-dark);
}

.pill.medium {
  background: rgba(255, 190, 92, 0.32);
  color: var(--amber);
}

.pill.low {
  background: rgba(159, 37, 31, 0.11);
  color: var(--red);
}

.detail-panel {
  overflow: auto;
}

.empty-state {
  height: 100%;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.3rem;
}

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

.detail-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-top h1 {
  margin: 0 0 12px;
  font-size: clamp(1.7rem, 4vw, 3.2rem);
  line-height: 0.96;
}

.detail-meta,
.contact-actions,
.status-grid,
.evidence-list,
.activity-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-meta div,
.field-row,
.evidence-item,
.activity-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.confidence-block {
  min-width: 160px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.confidence-block strong {
  display: block;
  margin-top: 8px;
  font-size: 2.1rem;
  line-height: 1;
}

.section-title {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 950;
  text-transform: uppercase;
}

.contact-actions a,
.evidence-item a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
}

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

.workflow-form label:last-of-type {
  grid-column: 1 / -1;
}

.workflow-form textarea {
  min-height: 96px;
}

.workflow-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workflow-actions button {
  min-height: 40px;
  padding: 8px 12px;
}

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

.field-row strong,
.activity-row strong {
  display: block;
  margin-top: 5px;
}

.evidence-item,
.activity-row {
  width: 100%;
}

.evidence-item p,
.activity-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.admin-panel {
  width: min(1440px, 100%);
  margin: 12px auto 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 12px;
}

.admin-card {
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.report-table,
.user-list {
  display: grid;
  gap: 8px;
}

.report-row,
.user-row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.report-row {
  grid-template-columns: minmax(160px, 1fr) minmax(100px, auto) repeat(4, minmax(82px, auto));
}

.user-row {
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 1fr) auto;
}

.report-row span,
.user-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.report-row b,
.user-row b {
  font-size: 0.82rem;
}

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

.user-form button {
  grid-column: 1 / -1;
  min-height: 40px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 850;
}

@media (max-width: 1050px) {
  .workbench {
    height: auto;
    grid-template-columns: 1fr;
  }

  .lead-panel {
    min-height: 420px;
  }

  .metric-strip,
  .field-grid,
  .workflow-form,
  .admin-grid {
    grid-template-columns: 1fr 1fr;
  }

  .report-row,
  .user-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .portal-view {
    padding: 10px;
  }

  .portal-header,
  .brand-lockup,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filters,
  .metric-strip,
  .field-grid,
  .workflow-form,
  .admin-grid,
  .user-form,
  .report-row,
  .user-row {
    grid-template-columns: 1fr;
  }

  .detail-top {
    grid-template-columns: 1fr;
  }

  .brand-lockup img {
    width: 170px;
  }
}
