/* ==========================================================================
   app.css
   Smart Risk AI — shared component library reused by every screen.
   Layers on top of athera-tokens.css. One accent (A! Blue) per surface;
   interactive text uses Blue Deep (#2A8FB0) for AA contrast on light.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Reset / base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--athera-sans);
  font-weight: 400;
  color: var(--athera-charcoal);
  background: var(--athera-off-white);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.65;
}

a { color: var(--athera-blue-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--athera-blue-deep);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   App frame
   -------------------------------------------------------------------------- */
.app-frame {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 48px 96px;
}

.app-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--athera-line);
  background: var(--athera-white);
}
.app-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 48px;
  display: flex;
  gap: 24px;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
}
.app-footer .disclaimer {
  max-width: 760px;
  color: var(--athera-grey);
  font-size: 12px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Top bar — inline wordmark + product title
   -------------------------------------------------------------------------- */
.topbar {
  border-bottom: 1px solid var(--athera-line);
  background: var(--athera-white);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 48px;
  display: flex;
  align-items: center;
  gap: 24px;
}

/* Inline wordmark: A! in brand blue, "thera" charcoal, smaller lighter "Partners" */
.athera-wordmark {
  font-family: var(--athera-display);
  font-size: 30px;
  font-weight: 300;
  color: var(--athera-charcoal);
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
.athera-wordmark .mark { color: var(--athera-blue); }
.athera-wordmark .partners {
  font-family: var(--athera-sans);
  font-size: 0.42em;
  font-weight: 400;
  color: var(--athera-grey);
  letter-spacing: 0.08em;
  margin-left: 5px;
  vertical-align: super;
}

.topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--athera-line);
}

.product-title {
  font-family: var(--athera-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--athera-charcoal-light);
}

.topbar-spacer { flex: 1; }

.topbar-note {
  font-family: var(--athera-mono);
  font-size: 11px;
  color: var(--athera-grey-light);
}

/* --------------------------------------------------------------------------
   Step indicator — 1 Application . 2 Profile . 3 Risk . 4 Brief
   -------------------------------------------------------------------------- */
.stepper {
  border-bottom: 1px solid var(--athera-line);
  background: var(--athera-white);
}
.stepper[hidden] { display: none; }
.stepper-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-num {
  font-family: var(--athera-mono);
  font-size: 11px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--athera-line);
  border-radius: 50%;
  color: var(--athera-grey-light);
  transition: all 0.2s ease;
}
.step-label {
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--athera-grey-light);
  transition: color 0.2s ease;
}
.step-sep {
  width: 28px;
  height: 1px;
  background: var(--athera-line);
}
.step.is-active .step-num {
  border-color: var(--athera-blue);
  color: var(--athera-blue-deep);
}
.step.is-active .step-label {
  color: var(--athera-charcoal);
}
.step.is-done .step-num {
  border-color: var(--athera-blue);
  background: var(--athera-blue);
  color: var(--athera-white);
}
.step.is-done .step-label {
  color: var(--athera-charcoal-light);
}

/* --------------------------------------------------------------------------
   Eyebrow + title pattern, thin blue rule
   -------------------------------------------------------------------------- */
.eyebrow {
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--athera-blue-deep);
  margin: 0 0 16px;
  display: block;
}
.section-title {
  font-family: var(--athera-display);
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--athera-charcoal);
  margin: 0;
}
.blue-rule {
  width: 48px;
  height: 1px;
  background: var(--athera-blue);
  border: 0;
  margin: 28px 0;
}

.section-intro {
  font-family: var(--athera-sans);
  font-size: 18px;
  font-weight: 300;
  line-height: 1.7;
  color: var(--athera-charcoal-light);
  max-width: 560px;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--athera-sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 14px 28px;
  border: 1px solid transparent;
  line-height: 1;
}
.btn-primary {
  background: var(--athera-blue-deep);
  color: var(--athera-white);
  font-weight: 500;
}
.btn-primary:hover { background: #237a96; }
.btn-secondary {
  background: transparent;
  color: var(--athera-charcoal);
  border-color: var(--athera-line);
  font-weight: 400;
}
.btn-secondary:hover { background: var(--athera-off-white); border-color: var(--athera-grey-light); }
.btn-ghost {
  background: transparent;
  color: var(--athera-blue-deep);
  font-weight: 500;
  padding: 14px 8px;
}
.btn-ghost:hover { color: #237a96; }
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--athera-white);
  border: 1px solid var(--athera-line);
  border-radius: 4px;
  padding: 32px;
}
.card-dark {
  background: var(--athera-navy);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--athera-line-dark);
  border-radius: 4px;
  padding: 32px;
}

/* Selectable card (applicant picker) */
.card-select {
  background: var(--athera-white);
  border: 1px solid var(--athera-line);
  border-radius: 4px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  font-family: var(--athera-sans);
  display: block;
}
.card-select:hover {
  border-color: var(--athera-blue);
}
.card-select.is-selected {
  border-color: var(--athera-blue);
  box-shadow: inset 0 0 0 1px var(--athera-blue);
}

/* --------------------------------------------------------------------------
   Form fields — label + input/select, generous spacing
   -------------------------------------------------------------------------- */
.field { margin-bottom: 24px; }
.field-label {
  display: block;
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--athera-grey);
  margin-bottom: 8px;
}
.field-code {
  font-family: var(--athera-mono);
  font-size: 10px;
  color: var(--athera-grey-light);
  margin-left: 8px;
  letter-spacing: 0;
}
.input,
.select,
.textarea {
  width: 100%;
  font-family: var(--athera-sans);
  font-size: 15px;
  color: var(--athera-charcoal);
  background: var(--athera-white);
  border: 1px solid var(--athera-line);
  border-radius: 2px;
  padding: 12px 14px;
  transition: border-color 0.2s ease;
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--athera-blue);
  outline: 2px solid transparent;
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236B7280' stroke-width='1.5' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 32px;
}
@media (max-width: 720px) {
  .field-grid { grid-template-columns: 1fr; }
}

/* Toggle (collateral / guarantor) */
.toggle-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-family: var(--athera-sans);
  font-size: 14px;
  color: var(--athera-charcoal);
  border: 1px solid var(--athera-line);
  border-radius: 2px;
  padding: 12px 16px;
  transition: all 0.2s ease;
}
.toggle:hover { border-color: var(--athera-grey-light); }
.toggle input { accent-color: var(--athera-blue-deep); width: 16px; height: 16px; }

/* Field group with eyebrow heading */
.field-group { margin-bottom: 48px; }
.field-group-head {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--athera-line);
}

/* --------------------------------------------------------------------------
   Badges — risk bands (color + word, never color alone)
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--athera-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 2px;
  border: 1px solid transparent;
  line-height: 1;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
/* Low = blue */
.badge-low { color: var(--athera-blue-deep); background: rgba(95, 184, 214, 0.12); border-color: rgba(95, 184, 214, 0.35); }
/* Medium = amber */
.badge-medium { color: #9a6b32; background: rgba(200, 149, 90, 0.12); border-color: rgba(200, 149, 90, 0.35); }
/* High = muted, restrained red */
.badge-high { color: #9b4a44; background: rgba(155, 74, 68, 0.10); border-color: rgba(155, 74, 68, 0.30); }
/* Manual Review = steel / grey */
.badge-review { color: #5c7186; background: rgba(138, 165, 190, 0.14); border-color: rgba(138, 165, 190, 0.40); }
/* Neutral / preview hint */
.badge-neutral { color: var(--athera-grey); background: var(--athera-surface); border-color: var(--athera-line); }

/* --------------------------------------------------------------------------
   Signal row (used by later risk/profile screens)
   -------------------------------------------------------------------------- */
.signal-row {
  display: flex;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--athera-line-light);
}
.signal-row:last-child { border-bottom: 0; }
.signal-marker {
  width: 4px;
  flex-shrink: 0;
  border-radius: 2px;
  background: var(--athera-line);
}
.signal-row.is-positive .signal-marker { background: var(--athera-blue); }
.signal-row.is-negative .signal-marker { background: #9b4a44; }
.signal-body { flex: 1; }
.signal-title {
  font-family: var(--athera-sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--athera-charcoal);
  margin: 0 0 4px;
}
.signal-explanation {
  font-family: var(--athera-sans);
  font-size: 13px;
  color: var(--athera-grey);
  line-height: 1.55;
  margin: 0;
}
.signal-weight {
  font-family: var(--athera-mono);
  font-size: 12px;
  color: var(--athera-grey-light);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Score / gauge (used by later risk screen)
   -------------------------------------------------------------------------- */
.score-block { display: flex; align-items: baseline; gap: 12px; }
.score-value {
  font-family: var(--athera-display);
  font-weight: 300;
  font-size: clamp(48px, 7vw, 88px);
  line-height: 1;
  color: var(--athera-charcoal);
}
.score-max {
  font-family: var(--athera-mono);
  font-size: 14px;
  color: var(--athera-grey-light);
}
.gauge {
  width: 100%;
  height: 6px;
  background: var(--athera-surface);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 16px;
}
.gauge-fill {
  height: 100%;
  background: var(--athera-blue);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* --------------------------------------------------------------------------
   Table
   -------------------------------------------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--athera-sans);
  font-size: 13px;
}
.table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--athera-grey-light);
  border-bottom: 1px solid var(--athera-line);
}
.table td {
  padding: 12px 16px;
  color: var(--athera-charcoal);
  border-bottom: 1px solid var(--athera-line-light);
}
.table td.mono { font-family: var(--athera-mono); color: var(--athera-charcoal-light); }

/* --------------------------------------------------------------------------
   States — loading + error (calm, inline)
   -------------------------------------------------------------------------- */
.inline-note {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--athera-sans);
  font-size: 14px;
  color: var(--athera-grey);
  padding: 16px 0;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--athera-line);
  border-top-color: var(--athera-blue-deep);
  border-radius: 50%;
  animation: athera-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes athera-spin { to { transform: rotate(360deg); } }

.error-note {
  font-family: var(--athera-sans);
  font-size: 14px;
  color: #9b4a44;
  background: rgba(155, 74, 68, 0.06);
  border: 1px solid rgba(155, 74, 68, 0.25);
  border-radius: 2px;
  padding: 14px 16px;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   Placeholder — "Coming up next" (router guard for unbuilt screens)
   -------------------------------------------------------------------------- */
.placeholder {
  max-width: 560px;
  padding: 32px 0;
}

/* --------------------------------------------------------------------------
   Layout helpers
   -------------------------------------------------------------------------- */
.stack-sm > * + * { margin-top: 16px; }
.stack-md > * + * { margin-top: 24px; }
.stack-lg > * + * { margin-top: 48px; }

.card-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
@media (max-width: 880px) {
  .card-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-main { padding: 40px 24px 72px; }
  .topbar-inner, .stepper-inner, .app-footer-inner { padding-left: 24px; padding-right: 24px; }
}
