:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-muted: #eef2ef;
  --line: #d6ddd5;
  --text: #17221d;
  --muted: #66726b;
  --green: #15845c;
  --green-soft: #dff4ea;
  --amber: #a56812;
  --amber-soft: #f8ead5;
  --red: #a63c3c;
  --red-soft: #f7dfdf;
  --ink: #263d36;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.05;
}

h2 {
  font-size: clamp(22px, 2.3vw, 30px);
  line-height: 1.12;
}

h3 {
  font-size: 15px;
  line-height: 1.2;
}

.version {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 40px) 48px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.tab-button.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.entry-panel,
.auth-panel,
.summary-band,
.wide-panel,
.side-panel,
.full-panel,
.dashboard-head,
.metric-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.entry-panel {
  padding: 18px;
  margin-bottom: 18px;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  margin-bottom: 16px;
  border-color: rgba(165, 104, 18, 0.32);
  background: #fffaf2;
}

.auth-panel.authenticated {
  border-color: rgba(21, 132, 92, 0.32);
  background: #f1faf5;
}

.auth-panel h2 {
  font-size: 17px;
}

.auth-panel p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto auto;
  gap: 8px;
  align-items: center;
}

.auth-form input {
  min-height: 40px;
}

.auth-form button {
  min-height: 40px;
}

.score-form {
  display: grid;
  gap: 10px;
}

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

.entry-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #c8d0c8;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus {
  outline: 2px solid rgba(21, 132, 92, 0.22);
  border-color: var(--green);
}

button {
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.secondary-button {
  min-height: 34px;
  padding: 0 12px;
  background: var(--surface-muted);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.message {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--amber-soft);
  color: #553c13;
  font-size: 14px;
}

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

.loading-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.loading-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.loading-head h2 {
  font-size: 17px;
  line-height: 1.2;
}

.loading-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.loading-count {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.loading-overview {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(260px, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.loading-now,
.loading-facts {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.loading-now {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 126px;
  padding: 14px;
  box-shadow: inset 3px 0 0 var(--green);
}

.loading-now h3 {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

.loading-now p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.loading-connection {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.loading-connection span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.loading-connection.pending span,
.loading-connection.active span {
  animation: live-dot 1s ease-in-out infinite;
}

.loading-connection.active {
  background: var(--green-soft);
  color: var(--green);
}

.loading-connection.done {
  background: var(--green-soft);
  color: var(--green);
}

.loading-connection.fallback {
  background: var(--amber-soft);
  color: var(--amber);
}

.loading-connection.failed {
  background: var(--red-soft);
  color: var(--red);
}

.loading-facts {
  display: grid;
  grid-template-columns: 1fr;
}

.loading-facts div {
  display: grid;
  gap: 5px;
  padding: 11px 12px;
}

.loading-facts div + div {
  border-top: 1px solid var(--line);
}

.loading-facts span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.loading-facts strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.loading-status-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) repeat(2, minmax(110px, 0.7fr));
  gap: 10px;
  margin-top: 14px;
}

.loading-stat {
  min-height: 68px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.loading-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.loading-stat strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface-muted);
  border-top-color: var(--green);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

.loading-panel.complete .spinner,
.loading-panel.failed .spinner {
  animation: none;
  border-color: var(--green);
  background: var(--green-soft);
}

.loading-panel.failed .spinner {
  border-color: var(--red);
  background: var(--red-soft);
}

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

.progress-track {
  height: 8px;
  margin: 14px 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.28) 50%, rgba(255, 255, 255, 0.28) 75%, transparent 75%, transparent),
    linear-gradient(90deg, #15845c, #48a56f);
  background-size: 22px 22px, 100% 100%;
  transition: width 180ms ease;
}

.loading-panel.running .progress-bar {
  animation: progress-stripes 0.7s linear infinite;
}

.loading-panel.failed .progress-bar {
  background: var(--red);
}

@keyframes progress-stripes {
  to {
    background-position: 22px 0, 0 0;
  }
}

.progress-steps {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.progress-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.progress-step.pending {
  color: var(--muted);
}

.step-marker {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.progress-step.active {
  border-color: rgba(21, 132, 92, 0.45);
  background: #f1faf5;
  box-shadow: inset 3px 0 0 var(--green);
}

.progress-step.active .step-marker {
  background: var(--green);
  color: #fff;
  animation: marker-pulse 1.2s ease-in-out infinite;
}

.progress-step.done .step-marker {
  background: var(--green-soft);
  color: var(--green);
}

.progress-step.failed {
  border-color: rgba(166, 60, 60, 0.45);
  background: #fff8f8;
}

.progress-step.failed .step-marker {
  background: var(--red-soft);
  color: var(--red);
}

.step-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.step-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
}

.step-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

.step-detail {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.loading-live {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

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

.loading-log-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.progress-log {
  display: grid;
  gap: 6px;
  max-height: 180px;
  padding: 0;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.progress-log-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.progress-log-item > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.progress-log-item strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
}

.progress-log-item em {
  display: inline-block;
  width: fit-content;
  margin-bottom: 3px;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.progress-log-item.done em {
  background: var(--green-soft);
  color: var(--green);
}

.progress-log-item.failed em {
  background: var(--red-soft);
  color: var(--red);
}

.progress-log-item p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.progress-log-item.failed {
  border-color: rgba(166, 60, 60, 0.45);
  background: #fff8f8;
}

@keyframes marker-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(21, 132, 92, 0.25);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(21, 132, 92, 0);
  }
}

@keyframes live-dot {
  0%,
  100% {
    opacity: 0.38;
    transform: scale(0.82);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.result {
  display: grid;
  gap: 16px;
}

.dashboard {
  display: grid;
  gap: 16px;
}

.dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.metric-tile {
  padding: 14px;
}

.metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.85fr);
  gap: 16px;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-item {
  display: grid;
  gap: 6px;
}

.bar-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.bar-row span:last-child {
  color: var(--muted);
  font-weight: 700;
}

.bar-shell {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--green);
}

.bar-fill.tier-a {
  background: var(--green);
}

.bar-fill.tier-b {
  background: var(--amber);
}

.bar-fill.tier-c {
  background: var(--red);
}

.bar-list.compact {
  gap: 8px;
}

.bar-list.compact .bar-shell {
  height: 7px;
}

.summary-band {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 18px;
}

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

.deal-title p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.tier-badge {
  display: grid;
  place-items: center;
  width: 74px;
  min-width: 74px;
  height: 74px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 28px;
  font-weight: 900;
}

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

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

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
}

.score-strip div {
  padding: 12px;
  border-radius: 6px;
  background: var(--surface-muted);
}

.score-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.1;
}

.request-fit {
  padding: 14px 16px;
  border-left: 4px solid var(--green);
  background: #edf7f1;
  color: var(--ink);
  font-weight: 700;
}

.request-fit.warn {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.request-fit.danger {
  border-left-color: var(--red);
  background: var(--red-soft);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.85fr);
  gap: 16px;
}

.wide-panel,
.side-panel,
.full-panel {
  padding: 16px;
}

.full-panel {
  grid-column: 1 / -1;
}

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

.section-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 72px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pass {
  background: var(--green-soft);
  color: var(--green);
}

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

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

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

.fact {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.fact span,
.compact-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.fact strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.compact-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.compact-list dd {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tag-list li {
  padding: 7px 9px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.assessment-text {
  padding: 14px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

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

.assessment-block {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.assessment-block strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.assessment-block p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 960px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-band {
    grid-template-columns: 1fr;
  }

  .score-strip,
  .content-grid,
  .dashboard-grid,
  .fact-grid,
  .assessment-blocks,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .dashboard-actions,
  .entry-row {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .dashboard-actions button {
    width: 100%;
  }

  .auth-form button {
    width: 100%;
  }

  .loading-head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .loading-count {
    grid-column: 2;
    width: fit-content;
  }

  .loading-overview {
    grid-template-columns: 1fr;
  }

  .loading-status-grid {
    grid-template-columns: 1fr;
  }

  .step-title-row,
  .loading-log-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .progress-log-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .version {
    text-align: left;
  }
}
