:root {
  --navy: #0b2d5b;
  --navy-dark: #071e3e;
  --cyan: #00c2ff;
  --cyan-soft: #e7f9ff;
  --orange: #f7aa36;
  --ink: #15243a;
  --muted: #617188;
  --line: #dce4ee;
  --surface: #ffffff;
  --background: #f4f7fb;
  --success: #137a4a;
  --success-soft: #e8f6ef;
  --warning: #9a5a08;
  --warning-soft: #fff5df;
  --danger: #a42a36;
  --danger-soft: #fdecef;
  --shadow: 0 12px 30px rgba(11, 45, 91, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--navy);
  text-underline-offset: 3px;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(220, 228, 238, 0.9);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 62px;
  height: 42px;
  object-fit: contain;
}

.brand span {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand strong {
  color: var(--navy);
  font-size: 18px;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-nav a,
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
}

.main-nav a:hover,
.main-nav a.active,
.link-button:hover {
  background: #eef3f9;
  color: var(--navy);
}

.main-nav .primary-link {
  background: var(--navy);
  color: #fff;
}

.main-nav .primary-link:hover {
  background: var(--navy-dark);
  color: #fff;
}

.menu-button {
  display: none;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font-weight: 700;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 136px);
  margin: 0 auto;
  padding: 44px 0 60px;
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
  padding: 32px 18px;
  background:
    radial-gradient(circle at 20% 10%, rgba(0, 194, 255, 0.18), transparent 28%),
    linear-gradient(145deg, var(--navy-dark), var(--navy) 62%, #12477f);
}

.site-footer {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 18px 24px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a {
  color: var(--muted);
}

.page-heading {
  margin-bottom: 28px;
}

.page-heading h1 {
  margin: 2px 0 8px;
  color: var(--navy-dark);
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.page-heading p {
  margin: 0;
}

.split {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #087fa4;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.button-row,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

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

.button-primary:hover {
  border-color: var(--navy-dark);
  background: var(--navy-dark);
}

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

.button-secondary:hover {
  border-color: #b7c6d8;
  background: #f9fbfd;
}

.button-wide {
  width: 100%;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  min-height: 130px;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card span {
  color: var(--muted);
  font-weight: 650;
}

.stat-card strong {
  color: var(--navy);
  font-size: 38px;
  line-height: 1;
}

.stat-card.accent {
  border-color: var(--navy);
  background: var(--navy);
}

.stat-card.accent span,
.stat-card.accent strong {
  color: #fff;
}

.panel,
.form-card {
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.no-pad {
  overflow: hidden;
  padding: 0;
}

.panel h2,
.form-card h2 {
  margin: 0 0 14px;
  color: var(--navy);
  font-size: 20px;
}

.panel p:last-child {
  margin-bottom: 0;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading p {
  margin-top: 4px;
  color: var(--muted);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  background: #f7f9fc;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfdff;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.table-link {
  color: var(--navy);
  font-weight: 750;
}

.status {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef3f9;
  color: #3e526e;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.status-large {
  padding: 8px 13px;
  font-size: 13px;
}

.status-qualified,
.status-appointment_scheduled,
.status-appointment_held,
.status-proposal,
.status-financing {
  background: var(--cyan-soft);
  color: #086d8b;
}

.status-signed,
.status-installed {
  background: var(--success-soft);
  color: var(--success);
}

.status-lost,
.status-do_not_contact {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-duplicate {
  background: var(--warning-soft);
  color: var(--warning);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #344761;
  font-size: 13px;
  font-weight: 700;
}

label small {
  color: var(--muted);
  font-weight: 500;
}

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

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 194, 255, 0.15);
}

input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  flex: 0 0 20px;
  accent-color: var(--navy);
}

.form-card {
  padding: 0;
  overflow: hidden;
}

.form-card.narrow {
  width: min(560px, 100%);
  padding: 24px;
}

fieldset {
  margin: 0;
  padding: 24px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

legend {
  width: 100%;
  margin-bottom: 18px;
  padding: 0;
  color: var(--navy);
  font-size: 19px;
  font-weight: 800;
}

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

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

.check {
  display: flex;
  min-height: 48px;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafcff;
  font-weight: 600;
}

.privacy-box {
  background: #f7fbfd;
}

.top-gap {
  margin-top: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px;
  background: #f7f9fc;
}

.flash {
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid #bfd1e3;
  border-radius: 12px;
  background: #eef5fb;
  color: #26445f;
}

.flash a {
  color: inherit;
  font-weight: 800;
}

.flash ul {
  margin: 8px 0 0;
}

.flash-success {
  border-color: #b9dfca;
  background: var(--success-soft);
  color: var(--success);
}

.flash-warning {
  border-color: #eed39e;
  background: var(--warning-soft);
  color: var(--warning);
}

.flash-error {
  border-color: #efbec5;
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
}

.empty-state h2,
.empty-state h3 {
  margin: 0 0 6px;
  color: var(--navy);
}

.empty-state p {
  margin: 0 0 18px;
  color: var(--muted);
}

.notice {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border-left: 4px solid var(--orange);
  border-radius: 10px;
  background: var(--warning-soft);
  color: var(--warning);
}

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

.details {
  margin: 0;
}

.details div {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid #edf1f5;
}

.details div:last-child {
  border-bottom: 0;
}

.details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.details dd {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.tag-list span {
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--cyan-soft);
  color: #076f90;
  font-size: 12px;
  font-weight: 700;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.stack h2 {
  margin-bottom: 0;
}

details summary {
  cursor: pointer;
  color: var(--navy);
  font-size: 18px;
  font-weight: 800;
}

.timeline {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.timeline span {
  color: var(--muted);
}

.credentials {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
  margin-bottom: 22px;
  padding: 22px;
  border: 2px solid var(--cyan);
  border-radius: var(--radius);
  background: var(--cyan-soft);
}

.credentials h2 {
  margin: 0;
  color: var(--navy);
}

.credentials dl {
  margin: 0;
}

.credentials dl div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
}

.credentials dt {
  color: var(--muted);
}

.credentials dd {
  margin: 0;
}

.credentials p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
}

code {
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(11, 45, 91, 0.08);
  color: var(--navy);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.small-button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

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

.login-card,
.error-card {
  width: min(460px, 100%);
  padding: 34px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(4, 20, 42, 0.28);
}

.login-logo {
  width: 92px;
  height: 72px;
  object-fit: contain;
}

.login-card h1,
.error-card h1 {
  margin: 4px 0 10px;
  color: var(--navy-dark);
  font-size: 34px;
  line-height: 1.05;
}

.login-card .muted {
  margin-bottom: 24px;
}

.login-help {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.error-card p {
  margin-bottom: 24px;
}

.legal-copy {
  max-width: 800px;
}

.legal-copy h2 {
  margin-top: 24px;
}

.source-banner {
  padding: 12px 18px;
  border-bottom: 1px solid #b7e7f5;
  background: var(--cyan-soft);
  color: #086d8b;
  font-weight: 750;
}

.compact-stats {
  grid-template-columns: repeat(3, 1fr);
}

.compact-stats .stat-card {
  min-height: 105px;
}

.opportunity-rule {
  margin-bottom: 18px;
}

.opportunity-filters {
  grid-template-columns: 2fr 1fr 1fr auto;
}

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

.opportunity-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.opportunity-card.mine {
  border: 2px solid var(--cyan);
}

.opportunity-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.opportunity-top h2 {
  margin: 2px 0 4px;
  color: var(--navy);
  font-size: 21px;
}

.opportunity-top p {
  margin: 0;
  color: var(--muted);
}

.opportunity-card address {
  margin: 16px 0 8px;
  color: var(--ink);
  font-style: normal;
}

.opportunity-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.opportunity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.opportunity-actions form {
  margin: 0;
}

.import-heading {
  padding: 20px 20px 0;
}

@media (max-width: 900px) {
  .menu-button {
    display: inline-flex;
  }

  .main-nav {
    position: absolute;
    top: 66px;
    right: 16px;
    display: none;
    width: min(310px, calc(100vw - 32px));
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav form,
  .main-nav .link-button {
    width: 100%;
  }

  .main-nav .link-button {
    justify-content: flex-start;
  }

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

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

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

@media (max-width: 680px) {
  body {
    font-size: 14px;
  }

  .topbar {
    min-height: 64px;
    padding: 8px 14px;
  }

  .brand img {
    width: 52px;
    height: 38px;
  }

  .brand small {
    display: none;
  }

  .app-shell {
    width: min(100% - 24px, 1180px);
    padding: 28px 0 40px;
  }

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

  .split > .button,
  .split > .button-row {
    width: 100%;
  }

  .button-row .button {
    flex: 1;
  }

  .stat-grid {
    gap: 10px;
  }

  .stat-card {
    min-height: 105px;
    padding: 16px;
  }

  .stat-card strong {
    font-size: 31px;
  }

  .panel,
  .form-card.narrow {
    padding: 18px;
    border-radius: 14px;
  }

  .form-card {
    border-radius: 14px;
  }

  fieldset {
    padding: 20px 16px;
  }

  .form-grid,
  .check-grid,
  .detail-grid,
  .admin-grid,
  .filter-bar,
  .credentials {
    grid-template-columns: 1fr;
  }

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

  .compact-stats .stat-card {
    padding: 12px;
  }

  .compact-stats .stat-card strong {
    font-size: 27px;
  }

  .details div {
    grid-template-columns: 118px 1fr;
    gap: 10px;
  }

  .form-actions {
    position: sticky;
    z-index: 5;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    padding: 14px;
    box-shadow: 0 -8px 24px rgba(11, 45, 91, 0.08);
  }

  .credentials p {
    grid-column: auto;
  }

  .notice,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  th,
  td {
    padding: 12px;
  }

  .login-card {
    padding: 26px 22px;
  }
}
