/*
Notes:
- Shared public estimator, verification, and results styling.
- Keep this file accessible and layout-focused; CSU Global brand-specific colors/overrides belong in branding/csuglobal.css.
*/

:root {
  --brand-primary: #1e4fa1;
  --brand-primary-dark: #173d7d;
  --brand-accent: #f0b323;
  --bg-page: #f5f7fb;
  --bg-card: #ffffff;
  --bg-soft: #f9fbff;
  --text-main: #18212f;
  --text-muted: #5b6678;
  --border: #d8e0eb;
  --border-strong: #c5d1e0;
  --success-bg: #eef8f1;
  --success-border: #b7ddc2;
  --success-text: #21613a;
  --code-bg: #101722;
  --code-text: #eef2f8;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: var(--bg-page);
  color: var(--text-main);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
  color: #fff;
  border-bottom: 4px solid var(--brand-accent);
}

.site-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-subtitle {
  font-size: 13px;
  opacity: 0.92;
}

.header-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.header-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
}

.header-nav a:hover {
  background: rgba(255,255,255,0.1);
}

.page-shell {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.page-header {
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 0 0 8px 0;
  font-size: 30px;
  color: var(--text-main);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.section-title {
  margin: 0 0 16px 0;
  font-size: 20px;
  color: var(--text-main);
}

.section-subtitle {
  color: var(--text-muted);
  margin: -8px 0 18px 0;
  font-size: 14px;
}

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

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-weight: 700;
  margin-bottom: 7px;
  font-size: 14px;
  color: var(--text-main);
}

.field input,
.field select,
.field textarea,
button {
  font-size: 14px;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text-main);
}

.cs-wrapper {
  position: relative;
  width: 100%;
}

.cs-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  user-select: none;
}

.cs-trigger:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(30, 79, 161, 0.12);
}

.cs-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-arrow {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: #666;
  transition: transform 0.15s ease;
}

.cs-wrapper.is-open .cs-arrow {
  transform: rotate(180deg);
}

.cs-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  max-height: 220px;
  overflow-y: auto;
}

.cs-wrapper.is-open .cs-list {
  display: block;
}

.cs-option {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-main);
}

.cs-option:hover {
  background: #f0f4ff;
}

.cs-option.is-selected {
  font-weight: 600;
  color: var(--brand-primary, #1e4fa1);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(30, 79, 161, 0.12);
}

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

.checkbox-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.checkbox-row label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

button {
  cursor: pointer;
  background: var(--brand-primary);
  color: #fff;
  border: none;
  min-width: 120px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

button:hover {
  background: var(--brand-primary-dark);
}

button.secondary {
  background: #6b7280;
}

button.secondary:hover {
  background: #4b5563;
}

.legal-banner {
  background: #eef5ff;
  border: 1px solid #c8daf7;
  color: var(--brand-primary-dark);
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
}

.notice-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.notice-row .actions {
  margin-top: 0;
}

.form-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.result-section {
  margin-bottom: 20px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.result-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.result-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.result-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.status-card {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}

.status-card #results-status {
  font-weight: 700;
}

.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 16px;
  border-radius: 12px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 760px;
  background: #fff;
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  margin-top: 0;
  color: var(--text-main);
}

.modal p {
  line-height: 1.6;
  color: var(--text-main);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.summary-chip {
  display: inline-block;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.site-footer {
  margin-top: auto;
  background: #13253f;
  color: #dfe7f3;
}

.site-footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.site-footer a {
  color: #fff;
  text-decoration: none;
}

@media (max-width: 760px) {
  .grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .notice-row {
    align-items: flex-start;
  }

  .site-header-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}


.chart-wrap {
  margin-top: 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.debug-readable {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debug-line {
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  line-height: 1.55;
}

/* ===== Preserved results-page additions from current v1 ===== */

.results-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

.results-main {
  min-width: 0;
}

.results-side {
  min-width: 0;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.debug-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.debug-item span {
  font-size: 12px;
  color: var(--text-muted);
}

.debug-item strong {
  font-size: 18px;
  color: var(--text-main);
}

.notes-card {
  margin-top: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.notes-card h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 16px;
}

.preview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.preview-card h3 {
  margin-top: 0;
  margin-bottom: 14px;
}

.bar-chart {
  position: relative;
  min-height: 280px;
}

.chart-frame {
  position: relative;
  height: 240px;
  border-left: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  margin: 12px 8px 8px 18px;
}

.bars {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-evenly;
  align-items: stretch;
}

.bar-col {
  width: 22%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  position: relative;
}

.bar-wrap {
  position: relative;
  height: 100%;
  width: 44px;
}

.bar {
  position: absolute;
  left: 0;
  width: 44px;
}

.asset-bar {
  background: #2b6cb0;
}

.income-bar {
  background: #2f855a;
}

.adjustment-bar {
  background: #d69e2e;
}

.total-bar {
  background: #7b61ff;
}

.bar-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
  min-height: 32px;
}

.bar-label {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.trace-textarea {
  width: 100%;
  min-height: 540px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  background: #fbfdff;
  color: var(--text-main);
}

@media (max-width: 960px) {
  .results-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .debug-grid {
    grid-template-columns: 1fr;
  }
}


.checkbox-field {
  display: flex;
  align-items: center;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.chart-frame {
  overflow: hidden;
  padding-top: 10px;
  padding-bottom: 12px;
}

.bars {
  gap: 8px;
}

.bar-col {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}

.bar-value {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

/* Calculator/results parity pass inspired by validated IIS layout */
:root {
  --iis-bg: #f7f3ef;
  --iis-panel: #ffffff;
  --iis-border: #d9d1c7;
  --iis-text: #2f2a24;
  --iis-muted: #6f665d;
  --iis-burgundy: #7a0019;
  --iis-gold: #c8a24a;
  --iis-shadow: 0 10px 28px rgba(35, 25, 20, 0.08);
  --iis-radius: 14px;
  --iis-radius-sm: 10px;
}

body {
  background: linear-gradient(180deg, #f7f3ef 0%, #efe7df 100%);
}

.page-shell {
  max-width: 1320px;
  padding: 20px 16px 40px;
}

.page-header {
  margin-bottom: 16px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 2rem;
  line-height: 1.15;
}

.page-subtitle {
  max-width: 860px;
  line-height: 1.5;
}

.card,
.preview-card,
.notes-card {
  border-radius: var(--iis-radius);
  border: 1px solid var(--iis-border);
  box-shadow: var(--iis-shadow);
}

.card {
  padding: 16px 18px;
  margin-bottom: 16px;
}

.step-progress-card {
  padding: 14px 16px;
}

.step-marker-row {
  gap: 8px;
  flex-wrap: wrap;
}

.step-marker {
  padding: 6px 10px;
  font-size: 12px;
}

.section-title {
  font-size: 1.15rem;
  margin-bottom: 12px;
}

.grid {
  gap: 14px 16px;
}

.field label {
  margin-bottom: 6px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  min-height: 44px;
  border-radius: var(--iis-radius-sm);
}

.field-hint,
.helper-text {
  color: var(--iis-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  margin-top: 6px;
}

.checkbox-label {
  gap: 8px;
  align-items: flex-start;
}

.compact-results .section-title {
  margin-bottom: 10px;
}

.result-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--iis-border);
  border-radius: var(--iis-radius-sm);
  padding: 14px 16px;
}

.metric-card-primary {
  background: linear-gradient(180deg, #fffaf7 0%, #f8ede5 100%);
}

.metric-card-secondary {
  background: linear-gradient(180deg, #fff9f4 0%, #f7efe7 100%);
}

.metric-label {
  color: var(--iis-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 1.6rem;
  line-height: 1.1;
  font-weight: 800;
  color: var(--iis-burgundy);
  overflow-wrap: anywhere;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--iis-border);
  padding-top: 12px;
  margin-top: 8px;
}

.summary-row strong {
  font-size: 1.2rem;
}

.compact-results-layout {
  gap: 16px;
}

.debug-grid.compact-debug-grid {
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.debug-item {
  min-width: 0;
  padding: 10px 12px;
}

.debug-item span,
.debug-item strong,
.bar-value,
.bar-label {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.debug-item strong {
  font-size: 1rem;
  line-height: 1.2;
}

.compact-debug-subgrid {
  margin-top: 14px;
}

.result-footnote {
  margin: 12px 0 0;
  color: var(--iis-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.result-legal-card {
  margin-top: 16px;
}

.result-legal-card p {
  margin: 0 0 10px;
  line-height: 1.45;
}

.result-legal-card h3 {
  margin: 12px 0 8px;
  font-size: 1rem;
}

.notes-card ul {
  margin: 0;
  padding-left: 18px;
}

.notes-card li {
  margin-bottom: 6px;
}

.chart-frame {
  position: relative;
  overflow: visible;
  height: 320px;
  border: 1px solid var(--iis-border);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, #fcf8f4 100%);
}

.chart-frame::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  border-top: 1px solid #c8d0db;
  z-index: 0;
}

.bars {
  z-index: 1;
  align-items: stretch;
}

.bar-col {
  width: 25%;
  min-width: 0;
}

.bar-wrap {
  position: relative;
  width: 56px;
  height: 230px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bar {
  width: 56px;
  max-width: 100%;
}

.bar-value {
  min-height: 44px;
  padding: 4px 6px 0;
  text-align: center;
  font-size: 0.92rem;
}

.bar-label {
  padding: 0 4px;
  text-align: center;
  font-size: 0.84rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .debug-grid.compact-debug-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .result-summary-grid,
  .debug-grid.compact-debug-grid,
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .result-summary-grid,
  .debug-grid.compact-debug-grid,
  .grid {
    grid-template-columns: 1fr;
  }

  .summary-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .bar-wrap,
  .bar {
    width: 42px;
  }

  .metric-value {
    font-size: 1.35rem;
  }
}


/* Chart/admin stability fixes */
.admin-page-shell {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-page-shell .card,
.admin-page-shell .admin-card,
.admin-page-shell .admin-content-stack,
.admin-page-shell .admin-content-stack > * {
  min-width: 0;
}

.admin-page-shell .admin-table,
.admin-page-shell .admin-table td,
.admin-page-shell .admin-table th,
.admin-page-shell p,
.admin-page-shell h1,
.admin-page-shell h2,
.admin-page-shell h3,
.admin-page-shell label,
.admin-page-shell strong,
.admin-page-shell span {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.preview-card {
  overflow: hidden;
}

.chart-frame {
  height: 300px;
  overflow: hidden;
}

.bar-wrap {
  height: 208px;
}

.bar-value {
  min-height: 52px;
  max-width: 100%;
  padding: 6px 4px 0;
  font-size: 0.84rem;
  line-height: 1.15;
  white-space: normal;
}

.bar-label {
  min-height: 34px;
  line-height: 1.15;
}

.bar.is-negative,
.bar.is-positive {
  transition: height 0.15s ease;
}


.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 1000;
  background: #ffffff;
  color: #0f172a;
  border: 2px solid #1d4ed8;
  border-radius: 8px;
  padding: 10px 14px;
  text-decoration: none;
}

.skip-link:focus { top: 12px; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #1d4ed8;
  outline-offset: 2px;
}

.field-help, .field-hint, .page-subtitle, #step-progress-label {
  color: #475569;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--brand-primary, #1d4ed8);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
.button-link.secondary {
  background: #fff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.status-card:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }

.modal-backdrop[aria-hidden='true'] { display: none; }
