:root {
  --bg: #f7fafc;
  --ink: rgba(0,0,0,0.9);
  --ink-muted: #666;
  --panel: #ffffff;
  --panel-2: #f5f8fd;
  --line: hsl(216,22%,91%);
  --brand: #E8A020;
  --brand-2: #C98818;
  --accent: #E8A020;
  --success: #0e9f6e;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-h: 0 6px 28px rgba(0,0,0,0.14);
  --msm-amber: #E8A020;
  --msm-dark: #0F0F0F;
  --msm-dark-2: #1C1C1C;
  --msm-text: rgba(0,0,0,0.9);
  --msm-text-muted: #666;
  --msm-border: hsl(216,22%,91%);
  --msm-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

/* Ensure [hidden] attribute always wins over class-level display rules */
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--msm-font);
  background: var(--bg);
  min-height: 100vh;
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px 18px 26px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.title-block {
  display: grid;
  gap: 4px;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand-2);
  font-weight: 700;
}

.toolbar h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.toolbar-actions {
  display: flex;
  align-items: start;
  gap: 10px;
}

.status {
  grid-column: 1 / -1;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.global-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid rgba(214, 223, 235, 0.88);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(22, 52, 92, 0.08);
}

.metric-label {
  margin: 0 0 2px;
  color: var(--ink-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-value {
  margin: 0;
  font-size: 1.16rem;
  font-weight: 700;
}

.sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  border: 1px solid rgba(162, 177, 202, 0.9);
  background: rgba(247, 250, 255, 0.94);
  color: #264267;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
}

.tab-btn.active {
  color: #fff;
  border-color: #0d5ba5;
  background: linear-gradient(120deg, #0f6abf 0%, #0b4a84 100%);
  box-shadow: 0 7px 16px rgba(15, 92, 165, 0.35);
}

.tab-btn.admin-tab {
  border-color: rgba(242, 143, 59, 0.75);
  background: rgba(232, 160, 32, 0.1);
  color: #7c4611;
}

.tab-btn.admin-tab.active {
  border-color: #aa5f16;
  background: linear-gradient(120deg, #d77f28 0%, #ae5714 100%);
  color: #fff;
  box-shadow: 0 7px 16px rgba(172, 91, 18, 0.35);
}

.sheet-panel {
  display: none;
  border: 1px solid rgba(214, 223, 235, 0.9);
  border-radius: 16px;
  box-shadow: var(--shadow);
  background: var(--panel);
  backdrop-filter: blur(4px);
  padding: 14px;
}

.sheet-panel.active {
  display: block;
}

.panel-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-subtitle {
  margin: 2px 0 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.panel-search {
  width: 280px;
  max-width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.sheet-quick-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.metric-card-money .metric-value {
  font-variant-numeric: tabular-nums;
}

.sheet-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rowform-panel {
  display: none;
}

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

.valuation-panel {
  border-color: rgba(167, 189, 214, 0.8);
  background:
    radial-gradient(circle at 8% -8%, rgba(16, 105, 188, 0.11) 0%, rgba(16, 105, 188, 0) 34%),
    radial-gradient(circle at 95% 4%, rgba(242, 143, 59, 0.1) 0%, rgba(242, 143, 59, 0) 30%),
    linear-gradient(168deg, rgba(255, 255, 255, 0.94) 0%, rgba(245, 250, 255, 0.92) 52%, rgba(240, 247, 254, 0.94) 100%);
}

.valuation-panel .panel-header {
  border: 1px solid #d6e5f6;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background:
    radial-gradient(circle at 0% 50%, rgba(15, 106, 191, 0.12) 0%, rgba(15, 106, 191, 0) 42%),
    linear-gradient(130deg, #f7fbff 0%, #f2f8ff 100%);
}

.valuation-panel .panel-title h2 {
  font-size: 1.26rem;
  letter-spacing: 0.01em;
  color: #153356;
}

.valuation-panel .panel-subtitle {
  color: #47607f;
}

.valuation-panel .panel-search {
  border-color: #bdd2e9;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.valuation-panel .panel-search:focus {
  outline: 2px solid rgba(15, 106, 191, 0.23);
  border-color: #2d82d0;
}

.valuation-keycards {
  border: 1px solid #d2e2f4;
  border-radius: 14px;
  background:
    radial-gradient(circle at 18% 0%, rgba(15, 106, 191, 0.08) 0%, rgba(15, 106, 191, 0) 34%),
    linear-gradient(180deg, #fcfeff 0%, #f4f9ff 100%);
  padding: 12px;
  margin-bottom: 14px;
}

.valuation-keycards-head {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.valuation-keycards-title {
  margin: 0;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #35577e;
}

.valuation-keycards-subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: #597696;
}

.valuation-keycards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 10px;
}

.valuation-keycard {
  position: relative;
  border: 1px solid #c6d8ed;
  border-radius: 13px;
  background: var(--panel);
  padding: 11px 12px;
  min-height: 96px;
  display: grid;
  align-content: start;
  gap: 5px;
  box-shadow: 0 9px 22px rgba(20, 59, 99, 0.08);
}

.valuation-keycard::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  border-radius: 13px 13px 0 0;
  background: linear-gradient(90deg, #2d78c5 0%, #4f97dc 100%);
}

.valuation-keycard[data-tone="2"]::before {
  background: linear-gradient(90deg, #0f8a7d 0%, #3bb8a7 100%);
}

.valuation-keycard[data-tone="3"]::before {
  background: linear-gradient(90deg, #d7842c 0%, #f3aa57 100%);
}

.valuation-keycard[data-tone="4"]::before {
  background: linear-gradient(90deg, #235592 0%, #3f75b8 100%);
}

.valuation-keycard-label {
  font-size: 0.72rem;
  color: #4b6586;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.valuation-keycard-value {
  font-size: 1.44rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: #132f51;
  line-height: 1.12;
}

.valuation-keycard-secondary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  padding-top: 4px;
  border-top: 1px dashed rgba(93, 123, 157, 0.3);
}

.valuation-keycard-secondary-label {
  font-size: 0.74rem;
  color: #5f7696;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.valuation-keycard-secondary-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1c426e;
  font-variant-numeric: tabular-nums;
}

.valuation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
}

.valuation-main {
  display: grid;
  gap: 11px;
}

.valuation-section {
  border: 1px solid #cfdff1;
  border-radius: 13px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 9px 24px rgba(18, 52, 90, 0.06);
}

.valuation-section-title {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: #233f61;
  background:
    linear-gradient(90deg, rgba(31, 117, 201, 0.16) 0%, rgba(31, 117, 201, 0) 30%),
    linear-gradient(180deg, #f5faff 0%, #eef6ff 100%);
  border-bottom: 1px solid #dbe8f6;
}

.valuation-section[data-section="operating-expenses"] .valuation-section-title {
  background:
    linear-gradient(90deg, rgba(242, 143, 59, 0.2) 0%, rgba(242, 143, 59, 0) 32%),
    linear-gradient(180deg, #fff8f1 0%, #fff4ea 100%);
}

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

.valuation-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.valuation-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6faff;
  border-bottom: 1px solid #dce8f6;
  color: #355274;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  text-align: right;
  padding: 8px 9px;
  white-space: nowrap;
}

.valuation-table thead th:first-child {
  text-align: left;
}

.valuation-table tbody td {
  border-bottom: 1px dashed #e3edf9;
  padding: 7px 9px;
  text-align: right;
  vertical-align: middle;
}

.valuation-table tbody tr:nth-child(even):not(.emphasis) td {
  background: #fcfeff;
}

.valuation-table tbody tr:hover td {
  background: #eef6ff;
}

.valuation-table tbody tr.emphasis td {
  background: #f2f8ff;
  font-weight: 700;
}

.valuation-table tbody tr.has-required .valuation-label-cell {
  color: #15395f;
  font-weight: 700;
}

.valuation-table tbody tr:last-child td {
  border-bottom: none;
}

.valuation-label-cell {
  text-align: left !important;
  color: #243d5b;
  min-width: 270px;
  max-width: 420px;
}

.valuation-label-main {
  font-size: 0.87rem;
}

.valuation-label-note {
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.72rem;
  color: #607694;
  line-height: 1.35;
}

.valuation-label-note-chunk {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.valuation-label-note-prefix {
  color: #4f6788;
}

.valuation-note-value {
  color: #173b61;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.valuation-label-note-suffix {
  color: #516987;
}

.valuation-cell {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.valuation-cell.empty {
  opacity: 0.42;
}

.valuation-output {
  font-variant-numeric: tabular-nums;
  color: #132f52;
}

.valuation-input {
  max-width: 136px;
  text-align: right;
  font-weight: 650;
  border-color: #b3cbe4;
  background: linear-gradient(180deg, #f8fbff 0%, #f1f7ff 100%);
}

.valuation-assumptions {
  border: 1px solid #b9d3ee;
  border-radius: 14px;
  background:
    radial-gradient(circle at 12% -30%, rgba(15, 106, 191, 0.18) 0%, rgba(15, 106, 191, 0) 34%),
    radial-gradient(circle at 96% 0%, rgba(242, 143, 59, 0.14) 0%, rgba(242, 143, 59, 0) 28%),
    linear-gradient(180deg, #fafdff 0%, #eef6ff 100%);
  padding: 12px;
  margin-bottom: 0;
  box-shadow: 0 10px 26px rgba(18, 52, 90, 0.09);
  align-self: start;
  position: sticky;
  top: 12px;
}

.valuation-assumptions-title {
  margin: 0 0 4px;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #234a74;
}

.valuation-assumptions-subtitle {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: #4f6d8f;
}

.valuation-assumptions-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.valuation-assumption-row {
  display: grid;
  gap: 5px;
  border: 1px solid #d6e5f5;
  border-radius: 9px;
  padding: 9px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.valuation-assumption-row.is-highlight {
  border-color: #aec8e4;
  background:
    linear-gradient(180deg, #ffffff 0%, #f3f8ff 100%);
}

.valuation-assumption-label {
  font-size: 0.74rem;
  color: #3c5b7e;
}

.valuation-assumption-note {
  font-size: 0.72rem;
  color: #5c7898;
}

.valuation-assumption-row .field-input {
  font-weight: 700;
  border-color: #adc7e3;
  background: #f7fbff;
}

.valuation-secondary-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.valuation-secondary-table tbody td {
  border-bottom: 1px dashed #e2ecf7;
  padding: 8px 9px;
  vertical-align: middle;
}

.valuation-secondary-table tbody tr:nth-child(even) td {
  background: #fbfdff;
}

.valuation-secondary-table tbody tr:last-child td {
  border-bottom: none;
}

.valuation-secondary-label {
  width: 58%;
  color: #233f61;
  font-weight: 700;
}

.valuation-secondary-value {
  width: 22%;
  text-align: right;
}

.valuation-secondary-value .valuation-output {
  font-weight: 700;
  font-size: 0.97rem;
}

.valuation-secondary-supplemental {
  width: 20%;
  text-align: right;
  color: #375476;
  font-size: 0.82rem;
}

.valuation-secondary-supplemental-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.valuation-secondary-supplemental-suffix {
  margin-left: 4px;
}

.valuation-additional-list {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.valuation-additional-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  border: 1px solid #deebf8;
  border-radius: 9px;
  padding: 8px 9px;
  background: #fbfdff;
}

.valuation-additional-label {
  font-size: 0.83rem;
  color: #2e4666;
}

.valuation-additional-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #123252;
  font-variant-numeric: tabular-nums;
}

.returns-panel {
  border-color: rgba(170, 192, 216, 0.84);
  background:
    radial-gradient(circle at 4% -6%, rgba(16, 105, 188, 0.08) 0%, rgba(16, 105, 188, 0) 32%),
    radial-gradient(circle at 98% 0%, rgba(242, 143, 59, 0.1) 0%, rgba(242, 143, 59, 0) 30%),
    linear-gradient(170deg, rgba(255, 255, 255, 0.94) 0%, rgba(245, 250, 255, 0.92) 54%, rgba(239, 247, 255, 0.94) 100%);
}

.returns-keycards {
  border: 1px solid #d2e2f4;
  border-radius: 14px;
  background: linear-gradient(180deg, #fcfeff 0%, #f4f9ff 100%);
  padding: 11px 12px;
  margin-bottom: 12px;
}

.returns-keycards-title {
  margin: 0 0 9px;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #35577e;
}

.returns-keycards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 9px;
}

.returns-keycard {
  border: 1px solid #c8daee;
  border-radius: 12px;
  background: var(--panel);
  padding: 10px 11px;
}

.returns-keycard-label {
  font-size: 0.73rem;
  color: #4d6687;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
}

.returns-keycard-value {
  margin-top: 4px;
  font-size: 1.2rem;
  font-weight: 760;
  color: #173a62;
  font-variant-numeric: tabular-nums;
}

.returns-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
}

.returns-main {
  display: grid;
  gap: 10px;
}

.returns-side {
  display: grid;
  gap: 8px;
  align-self: start;
  position: sticky;
  top: 12px;
  max-height: 78vh;
  overflow: auto;
  padding-right: 3px;
}

.returns-section {
  border: 1px solid #d0e0f1;
  border-radius: 13px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(18, 52, 90, 0.05);
}

.returns-section-title {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #23405f;
  background:
    linear-gradient(90deg, rgba(31, 117, 201, 0.14) 0%, rgba(31, 117, 201, 0) 32%),
    linear-gradient(180deg, #f5faff 0%, #eef6ff 100%);
  border-bottom: 1px solid #dbe8f6;
}

.returns-section-subtitle {
  margin: 0;
  padding: 0 12px 8px;
  font-size: 0.8rem;
  color: #587495;
  border-bottom: 1px solid #e3edf8;
  background: #f9fcff;
}

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

.returns-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

.returns-table thead th {
  background: #f7fbff;
  border-bottom: 1px solid #dce8f6;
  color: #355274;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  text-align: right;
  padding: 8px 9px;
}

.returns-table thead th:first-child {
  text-align: left;
}

.returns-table tbody td {
  border-bottom: 1px dashed #e2ecf8;
  padding: 7px 9px;
  vertical-align: middle;
  text-align: right;
}

.returns-table tbody tr:nth-child(even):not(.emphasis) td {
  background: #fcfeff;
}

.returns-table tbody tr.emphasis td {
  background: #f2f8ff;
  font-weight: 700;
}

.returns-table tbody tr.has-required .returns-label-cell {
  color: #15395f;
  font-weight: 700;
}

.returns-table tbody tr:last-child td {
  border-bottom: none;
}

.returns-label-cell {
  text-align: left !important;
  min-width: 260px;
  color: #233f61;
}

.returns-cell {
  min-height: 30px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.returns-cell.empty {
  opacity: 0.5;
}

.returns-output {
  color: #163659;
  font-variant-numeric: tabular-nums;
}

.returns-input {
  max-width: 130px;
  text-align: right;
}

.rei-ratios-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

.rei-ratios-table tbody td {
  border-bottom: 1px dashed #e2ecf8;
  padding: 8px 9px;
}

.rei-ratios-table tbody tr:last-child td {
  border-bottom: none;
}

.rei-ratio-label {
  color: #27476b;
  font-weight: 650;
}

.rei-ratio-value-cell {
  text-align: right;
}

.rei-ratio-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #12395f;
}

.rei-ratio-value.ratio-pass {
  color: #0e7d58;
}

.rei-ratio-value.ratio-fail {
  color: #a43d2f;
}

.rei-panel {
  border-color: rgba(170, 192, 216, 0.84);
  background:
    radial-gradient(circle at 0% -10%, rgba(16, 105, 188, 0.08) 0%, rgba(16, 105, 188, 0) 36%),
    linear-gradient(170deg, rgba(255, 255, 255, 0.94) 0%, rgba(244, 250, 255, 0.92) 100%);
}

.sensitivity-panel {
  border-color: rgba(170, 192, 216, 0.84);
  background:
    radial-gradient(circle at 2% -8%, rgba(16, 105, 188, 0.1) 0%, rgba(16, 105, 188, 0) 34%),
    radial-gradient(circle at 98% 0%, rgba(242, 143, 59, 0.1) 0%, rgba(242, 143, 59, 0) 30%),
    linear-gradient(170deg, rgba(255, 255, 255, 0.94) 0%, rgba(245, 250, 255, 0.92) 54%, rgba(239, 247, 255, 0.94) 100%);
}

.sensitivity-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.sensitivity-control-card {
  border: 1px solid #cfe0f2;
  border-radius: 12px;
  padding: 10px 11px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(18, 52, 90, 0.06);
}

.sensitivity-control-card label {
  display: block;
  font-size: 0.75rem;
  color: #3d5f84;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 6px;
}

.sensitivity-help {
  margin: 6px 0 0;
  color: #567395;
  font-size: 0.78rem;
  line-height: 1.35;
}

.sensitivity-rate-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  align-content: center;
}

.sensitivity-summary-label {
  margin: 0;
  font-size: 0.73rem;
  color: #527193;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sensitivity-summary-value {
  margin: 0;
  font-size: 1.14rem;
  font-weight: 760;
  color: #15395f;
  font-variant-numeric: tabular-nums;
}

.sensitivity-status {
  border: 1px solid #d9e7f6;
  border-radius: 10px;
  background: #f8fcff;
  color: #3d5f84;
  font-size: 0.84rem;
  padding: 9px 10px;
  margin-bottom: 10px;
}

.sensitivity-results {
  border: 1px solid #d0e0f1;
  border-radius: 13px;
  overflow: auto;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(18, 52, 90, 0.05);
}

.sensitivity-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.sensitivity-table thead th {
  background: #f7fbff;
  border-bottom: 1px solid #dce8f6;
  color: #355274;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  text-align: right;
  padding: 8px 9px;
}

.sensitivity-table thead th:first-child {
  text-align: left;
}

.sensitivity-table tbody td {
  border-bottom: 1px dashed #e2ecf8;
  padding: 8px 9px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #163659;
}

.sensitivity-table tbody tr:nth-child(even) td {
  background: #fcfeff;
}

.sensitivity-table tbody tr:last-child td {
  border-bottom: none;
}

.sensitivity-label {
  text-align: left !important;
  color: #26476c !important;
  font-weight: 650;
}

.sensitivity-delta {
  font-weight: 700;
}

.sensitivity-delta.delta-positive {
  color: #0e7d58;
}

.sensitivity-delta.delta-negative {
  color: #a43d2f;
}

/* Scenario bar (Add Scenario button + count) */
.sensitivity-scenario-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sensitivity-add-btn {
  font-size: 0.84rem;
  padding: 7px 16px;
}

.sensitivity-scenario-count {
  font-size: 0.8rem;
  color: #527193;
}

/* Multi-scenario table */
.sensitivity-table--multi {
  min-width: 820px;
  table-layout: auto;
}

/* Column group headers (span 2 sub-columns each) */
.sensitivity-col-header {
  background: #eef5fd;
  border-left: 2px solid #c5daf2;
  text-align: center;
  padding: 6px 8px;
  font-size: 0.72rem;
  color: #2d4f73;
  position: relative;
  vertical-align: middle;
}

.sensitivity-col-header.sensitivity-col-live {
  background: #e5f0fb;
  border-left-color: #6aabe3;
}

.sensitivity-col-name {
  font-weight: 700;
  display: block;
  font-size: 0.75rem;
}

.sensitivity-col-sublines {
  font-weight: 400;
  font-size: 0.68rem;
  color: #527193;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  display: inline-block;
  vertical-align: middle;
}

.sensitivity-label-col {
  text-align: left !important;
  color: #355274 !important;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 8px 9px;
}

.sensitivity-base-col {
  text-align: right;
  color: #355274;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 8px 9px;
}

/* Sub-headers ("Value" / "Δ vs Base") */
.sensitivity-subhead {
  background: #f2f8ff;
  font-size: 0.68rem;
  color: #5a7898;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: right;
  padding: 4px 9px;
  border-top: 1px solid #d8e8f4;
}

.sensitivity-subhead--delta {
  border-left: 1px dashed #d0e0f0;
}

/* Section separator rows (Inputs / Outputs) */
.sensitivity-section-header td {
  background: #f0f6ff;
  color: #3d5f84;
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 5px 9px;
  border-top: 2px solid #c8dcf0;
  border-bottom: 1px solid #c8dcf0;
  text-align: left;
}

/* Input display rows */
.sensitivity-input-row td {
  color: #527193;
  font-size: 0.82rem;
  font-style: italic;
}

/* Left border on each scenario's value column */
.sensitivity-table--multi tbody td.sensitivity-scenario {
  border-left: 2px solid #dceaf8;
}

.sensitivity-table--multi tbody td.sensitivity-scenario--live {
  border-left-color: #8bbde5;
}

/* Remove scenario button inside header */
.sensitivity-remove-btn {
  font-size: 0.75rem;
  padding: 1px 5px;
  border-radius: 50%;
  margin-left: 5px;
  line-height: 1;
  border: 1px solid #c0d5ed;
  color: #a43d2f;
  background: transparent;
  vertical-align: middle;
  cursor: pointer;
}

.sensitivity-remove-btn:hover {
  background: rgba(220, 60, 60, 0.15);
  border-color: #a43d2f;
}

/* Placeholder text when no analysis run */
.sensitivity-placeholder {
  padding: 20px;
  color: #6b8aab;
  font-size: 0.88rem;
  text-align: center;
}

@media (max-width: 900px) {
  .sensitivity-table--multi {
    min-width: 680px;
  }
}

@media (max-width: 760px) {
  .sensitivity-table--multi {
    min-width: 560px;
  }
}

.rowform-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

.rowform-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: #f4f8fd;
  border-bottom: 1px solid #dde8f5;
  padding: 9px 11px;
}

.rowform-row-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #1d3557;
}

.rowform-row-meta {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.rowform-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  padding: 10px;
}

.rowform-field {
  border: 1px solid #dce6f3;
  border-radius: 10px;
  padding: 8px;
  background: #fbfdff;
}

.rowform-field.is-input {
  background: #f5faff;
}

.rowform-field.is-output {
  background: #fbfcff;
}

.rowform-field-label {
  display: block;
  margin-bottom: 6px;
  color: #355272;
  font-size: 0.78rem;
}

.rentroll-panel {
  display: none;
}

.rentroll-config {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.rentroll-config-field {
  display: grid;
  gap: 4px;
}

.rentroll-config-field label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.rentroll-config-units {
  max-width: 260px;
}

.rentroll-grid-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  background: var(--panel);
  margin-bottom: 12px;
}

.rentroll-grid {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
}

.rentroll-grid thead th {
  text-align: left;
  font-size: 0.78rem;
  color: #2f4465;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #f3f7fd;
  border-bottom: 1px solid var(--line);
  padding: 8px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.rentroll-grid tbody td {
  border-bottom: 1px dashed #e1ebf7;
  padding: 7px;
}

.rentroll-grid tbody tr:last-child td {
  border-bottom: none;
}

.rentroll-grid .field-input {
  min-width: 90px;
}

.rr-total-cell {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rentroll-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.panel-column {
  background: var(--panel-2);
  border: 1px solid #dbe5f1;
  border-radius: 12px;
  padding: 10px;
  min-height: 280px;
}

.column-header {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #2f4465;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.field-group summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 11px;
  font-weight: 650;
  color: #213755;
  background: #f8fbff;
  border-bottom: 1px solid var(--line);
}

.field-group summary::-webkit-details-marker {
  display: none;
}

.group-count {
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.field-list {
  padding: 8px 10px 4px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 220px);
  gap: 10px;
  align-items: center;
  border-bottom: 1px dashed #e2eaf4;
  padding: 7px 0;
}

.field-row:last-child {
  border-bottom: none;
}

.field-label {
  display: grid;
  gap: 1px;
}

.field-label-main {
  font-size: 0.9rem;
}

.required-label {
  color: #14345a;
  font-weight: 750;
}

.field-label-meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.field-input {
  width: 100%;
  border: 1px solid #b8cee7;
  background: #f4f9ff;
  border-radius: 8px;
  padding: 8px 9px;
  font-size: 0.9rem;
}

.field-input:focus {
  outline: 2px solid rgba(15, 106, 191, 0.25);
  border-color: #1f78ca;
}

.required-field .field-label-main,
.required-field .rowform-field-label,
.required-field .valuation-assumption-label,
.required-field.valuation-cell {
  color: #173d67;
}

.field-input.is-required {
  border-color: #4f729b;
  background: linear-gradient(180deg, #eaf2ff 0%, #dde8fa 100%);
}

.field-input.is-required:focus {
  outline: 2px solid rgba(32, 90, 152, 0.3);
  border-color: #2f5f93;
}

.field-input.is-missing {
  border-color: #9d2f2a !important;
  background: rgba(220, 60, 60, 0.15) !important;
}

.derived-from-rentroll .field-input {
  border-color: #89a9c8;
  background: linear-gradient(180deg, #edf4ff 0%, #e2eefc 100%);
  color: #1f4469;
}

.derived-from-rentroll .field-input:disabled {
  opacity: 1;
  cursor: not-allowed;
}

.required-missing {
  border-color: rgba(157, 47, 42, 0.55) !important;
}

.rentroll-grid td.required-missing {
  box-shadow: inset 0 0 0 1px rgba(157, 47, 42, 0.35);
}

.field-output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d8e5f4;
  background: #fbfdff;
}

.field-output.error {
  color: #a43d2f;
  background: rgba(220, 60, 60, 0.1);
  border-color: #f0c8c2;
}

.btn {
  border: 1px solid #bccce0;
  background: var(--panel);
  border-radius: 10px;
  padding: 9px 13px;
  font-weight: 650;
  cursor: pointer;
}

.btn-primary {
  border-color: var(--brand-2);
  color: #ffffff;
  background: var(--brand);
  font-weight: 600;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.admin-panel {
  border-color: rgba(242, 143, 59, 0.55);
}

.metric-wide {
  grid-column: span 2;
}

.admin-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.admin-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
  max-height: 68vh;
  overflow-y: auto;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(270px, 1fr) 2fr;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px dashed #dce8f6;
}

.admin-row:last-child {
  border-bottom: none;
}

.admin-row.override {
  background: #fff8ed;
}

.admin-row.changed {
  background: #eef8ff;
}

.admin-formula-input {
  font-family: "SF Mono", "Consolas", "Liberation Mono", monospace;
  font-size: 0.84rem;
}

.hidden {
  display: none !important;
}

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

  .panel-search {
    width: 100%;
  }

  .rentroll-config {
    grid-template-columns: 1fr;
  }

  .valuation-layout {
    grid-template-columns: 1fr;
  }

  .valuation-assumptions {
    position: static;
  }

  .returns-layout {
    grid-template-columns: 1fr;
  }

  .returns-side {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .valuation-table {
    min-width: 680px;
  }

  .valuation-secondary-table {
    min-width: 560px;
  }

  .returns-table,
  .rei-ratios-table,
  .sensitivity-table {
    min-width: 560px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

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

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .btn {
    flex: 1;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .field-output {
    text-align: left;
  }

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

  .rowform-fields {
    grid-template-columns: 1fr;
  }

  .valuation-keycards-grid {
    grid-template-columns: 1fr;
  }

  .valuation-keycard {
    min-height: auto;
  }

  .valuation-table {
    min-width: 560px;
  }

  .valuation-secondary-table {
    min-width: 500px;
  }

  .returns-table,
  .rei-ratios-table,
  .sensitivity-table {
    min-width: 500px;
  }

  .valuation-additional-row {
    grid-template-columns: 1fr;
  }

  .metric-wide {
    grid-column: span 1;
  }

  .admin-row {
    grid-template-columns: 1fr;
  }
}

/* ── Login overlay ─────────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 18px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.14);
  padding: 40px 44px 44px;
  width: 100%;
  max-width: 400px;
}

.login-brand {
  margin-bottom: 28px;
}

.login-brand h2 {
  margin: 6px 0 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-subtitle {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.login-input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--panel-2);
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.login-input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--panel);
}

.login-submit {
  margin-top: 6px;
  width: 100%;
  padding: 11px;
  font-size: 0.97rem;
}

.login-error {
  margin: 4px 0 0;
  font-size: 0.87rem;
  color: #c0392b;
  background: #fdf0ee;
  border: 1px solid #f5c6c0;
  border-radius: 6px;
  padding: 8px 12px;
}

.login-success {
  margin: 4px 0 0;
  font-size: 0.87rem;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 8px 12px;
}

.forgot-password-link {
  font-size: 0.84rem;
  color: var(--brand);
  text-decoration: none;
  text-align: center;
  margin-top: 2px;
}

.forgot-password-link:hover {
  text-decoration: underline;
}

/* ── Product selector nav ──────────────────────────────────────────────────── */
.product-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.product-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 30px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.product-btn:hover:not(:disabled):not(.active) {
  background: var(--panel);
  border-color: var(--brand);
  color: var(--brand);
}

.product-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  cursor: default;
}

.product-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.badge-soon {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(242, 143, 59, 0.15);
  color: #b96a10;
  border-radius: 20px;
  padding: 2px 8px;
}

/* ── User chip ─────────────────────────────────────────────────────────────── */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 30px;
}

.user-email {
  font-size: 0.82rem;
  color: var(--ink-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 2px 9px;
}

.role-badge--admin {
  background: rgba(15, 106, 191, 0.12);
  color: var(--brand-2);
}

.role-badge--analyst {
  background: rgba(79, 95, 121, 0.1);
  color: var(--ink-muted);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

/* ── MSM branding ────────────────────────────────────────────────────────── */
.msm-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  margin-bottom: 8px;
}

.msm-header-logo {
  height: 32px;
  width: auto;
}

.msm-header-product {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: #1A1A2E;
  letter-spacing: -0.5px;
}

.login-logo {
  display: block;
  height: 36px;
  width: auto;
  margin-bottom: 16px;
}
