/* ═══════════════════════════════════════════════════════
   CTB Realty — Super Calculator (Stripe Design Language)
   ═══════════════════════════════════════════════════════ */

.sc-body { padding: 0 28px 60px; max-width: 1500px; margin: 0 auto; }

/* ── Page Header ── */
.sc-page-hrow {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 0 16px;
}
.sc-page-badge {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.sc-page-title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); margin: 0 0 3px; }
.sc-page-sub   { font-size: 13px; color: var(--ink-muted); margin: 0; }

/* ── Mode Bar ── */
.sc-mode-bar {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  padding: 12px 20px; border-radius: 14px; margin-bottom: 4px;
}
.sc-mode-tabs { display: flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 10px; border: 1px solid var(--border); }
.sc-mode-btn {
  padding: 7px 18px; border-radius: 7px; font-size: 12px; font-weight: 600;
  border: none; cursor: pointer; color: var(--ink-muted); background: transparent;
  transition: all 0.18s; font-family: inherit; letter-spacing: -0.01em;
}
.sc-mode-btn.active { background: var(--accent); color: #fff; box-shadow: 0 1px 6px rgba(99,91,255,0.35); }
.sc-mode-btn:hover:not(.active) { color: var(--ink); background: rgba(0,0,0,0.025); }
.sc-scenario-select {
  padding: 7px 30px 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); cursor: pointer; color: var(--ink-muted); background: var(--bg);
  font-family: inherit; outline: none; transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.sc-scenario-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,91,255,0.12); }
.sc-report-btn {
  padding: 7px 16px; border-radius: 8px; font-size: 12px; font-weight: 600; letter-spacing: -0.01em;
  border: none; cursor: pointer; background: var(--accent); color: #fff;
  font-family: inherit; transition: opacity 0.15s;
}
.sc-report-btn:hover { opacity: 0.85; }

/* ── Layout ── */
.sc-dashboard { display: grid; grid-template-columns: 1fr 340px; gap: 20px; margin-top: 16px; }
.sc-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sc-sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; align-self: start; }

/* ── Cards ── */
.sc-matrix-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  overflow: visible;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  border-left-width: 3px; border-left-style: solid;
  transition: box-shadow 0.2s;
}
.sc-matrix-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.04); }

.sc-card--params    { border-left-color: #635bff; }
.sc-card--matrix    { border-left-color: #2563eb; }
.sc-card--pnl       { border-left-color: #059669; }
.sc-card--sens      { border-left-color: #d97706; }
.sc-card--breakeven { border-left-color: #0891b2; }
.sc-card--amort     { border-left-color: #7c3aed; }

/* ── Card Header ── */
.sc-matrix-header {
  padding: 13px 20px 12px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--bg); border-radius: 13px 13px 0 0;
}
.sc-card-head-left { display: flex; align-items: center; gap: 10px; }
.sc-card-badge {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sc-badge--params    { background: rgba(99,91,255,0.1);  color: #635bff; }
.sc-badge--matrix    { background: rgba(37,99,235,0.1);  color: #2563eb; }
.sc-badge--pnl       { background: rgba(5,150,105,0.1);  color: #059669; }
.sc-badge--sens      { background: rgba(217,119,6,0.1);  color: #d97706; }
.sc-badge--breakeven { background: rgba(8,145,178,0.1);  color: #0891b2; }
.sc-badge--amort     { background: rgba(124,58,237,0.1); color: #7c3aed; }

.sc-matrix-title { font-size: 13px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.sc-matrix-sub   { font-size: 11px; color: var(--ink-muted); margin-top: 1px; }
.sc-collapse-chevron { flex-shrink: 0; color: var(--ink-faint); transition: transform 0.25s ease; }
.sc-matrix-header.collapsed .sc-collapse-chevron { transform: rotate(-90deg); }

/* ── Parameter Group Layout ── */
.sc-param-section { padding: 18px 20px; }
.sc-param-section + .sc-param-section { border-top: 1px solid var(--hairline); padding-top: 16px; }
.sc-param-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-faint); margin-bottom: 12px;
}
.sc-param-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ── Field + Input ── */
.sc-field { display: flex; flex-direction: column; gap: 4px; }
.sc-label {
  font-size: 10px; font-weight: 700; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.sc-input {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s; width: 100%; box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.sc-input:focus {
  border-color: #635bff;
  box-shadow: 0 0 0 3px rgba(99,91,255,0.15), 0 1px 2px rgba(0,0,0,0.02);
}
select.sc-input {
  cursor: pointer; appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* ── Matrix Table ── */
.sc-matrix-table { width: 100%; border-collapse: collapse; }
.sc-matrix-table th {
  text-align: left; padding: 10px 20px; background: var(--bg); color: var(--ink-faint);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.sc-matrix-table th:not(:first-child) { text-align: right; }
.sc-matrix-table td {
  padding: 10px 20px; border-bottom: 1px solid var(--hairline);
  font-size: 12px; font-weight: 500; vertical-align: middle;
}
.sc-matrix-table tr:last-child td { border-bottom: none; }
.sc-matrix-table tbody tr:hover td { background: rgba(0,0,0,0.014); }
.sc-matrix-table .highlight-row td {
  background: rgba(99,91,255,0.04); font-weight: 700;
  border-top: 1px solid rgba(99,91,255,0.1); border-bottom: 1px solid rgba(99,91,255,0.1);
}
.sc-matrix-table .highlight-row:hover td { background: rgba(99,91,255,0.06); }
.sc-matrix-table .highlight-row .sc-matrix-label { color: var(--accent); }
.sc-matrix-label { color: var(--ink-muted); font-size: 12px; }
.sc-matrix-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.sc-matrix-val input.sc-input { width: 100%; min-width: 0; box-sizing: border-box; display: block; text-align: right; }
.sc-input-mo { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.sc-input-mo input.sc-input { flex: 1; min-width: 0; display: block; }
.sc-input-mo span { color: var(--ink-muted); font-size: 11px; white-space: nowrap; }
.sc-matrix-val.resale { color: #2563eb; }
.sc-matrix-val.nl { color: #d97706; }
.sc-win-dot { font-size: 11px; margin-left: 6px; }
.sc-win-dot.win  { color: var(--emerald); }
.sc-win-dot.lose { color: var(--ink-faint); }

/* ── Metric Tooltips ── */
.sc-metric-cell {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: relative;
}
.sc-tip-icon {
  flex-shrink: 0; color: var(--ink-faint); opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.sc-matrix-table tbody tr:hover .sc-tip-icon { opacity: 1; }
.sc-metric-cell:hover .sc-tip-icon { color: var(--accent); opacity: 1; }

.sc-metric-cell .sc-tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  background: #0a2540; color: #fff;
  font-size: 11px; font-weight: 500; line-height: 1.45;
  padding: 8px 12px; border-radius: 7px;
  white-space: normal; max-width: 230px; min-width: 150px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  z-index: 300; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateY(5px);
}
.sc-metric-cell:hover .sc-tooltip {
  opacity: 1; visibility: visible; transform: translateY(0);
}

/* ── P&L Grid ── */
.sc-pnl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 20px; }
.sc-pnl-col { display: flex; flex-direction: column; gap: 0; }
.sc-pnl-head {
  font-size: 12px; font-weight: 700; padding: 8px 12px; border-radius: 8px; margin-bottom: 8px;
}
.sc-pnl-head.resale { background: rgba(37,99,235,0.08); color: #2563eb; }
.sc-pnl-head.nl { background: rgba(217,119,6,0.08); color: #d97706; }
.sc-pnl-row { display: flex; justify-content: space-between; padding: 6px 12px; font-size: 12px; border-bottom: 1px solid var(--hairline); }
.sc-pnl-row.sub { padding-left: 24px; color: var(--ink-muted); font-size: 11px; }
.sc-pnl-row.total { font-weight: 700; border-top: 1px solid var(--border); border-bottom: none; margin-top: 4px; padding-top: 10px; color: var(--ink); }
.sc-pnl-row .pos { color: var(--emerald); }
.sc-pnl-row .neg { color: var(--rose); }
.sc-pnl-section-head {
  font-size: 9px; font-weight: 800; color: var(--ink-faint); text-transform: uppercase;
  letter-spacing: 0.08em; padding: 8px 12px 4px; margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* ── Sensitivity Grid ── */
.sc-sensitivity-wrap { padding: 4px 20px 20px; }
#sensitivityTable { width: 100%; border-collapse: separate; border-spacing: 3px; }
#sensitivityTable td {
  text-align: center; padding: 9px 10px; font-size: 11px;
  font-variant-numeric: tabular-nums; border-radius: 7px;
  transition: transform 0.15s, box-shadow 0.15s; cursor: default;
  position: relative;
}
#sensitivityTable td:not(.sens-header):hover {
  transform: scale(1.08); z-index: 5;
  box-shadow: 0 3px 10px rgba(0,0,0,0.14);
}
#sensitivityTable .sens-hot  { background: rgba(5,150,105,0.12); color: var(--emerald); font-weight: 700; }
#sensitivityTable .sens-warm { background: rgba(245,158,11,0.09); color: #d97706; font-weight: 600; }
#sensitivityTable .sens-cold { background: rgba(239,68,68,0.07);  color: var(--rose); font-weight: 600; }
#sensitivityTable .sens-header {
  font-weight: 700; color: var(--ink-faint); background: var(--bg);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  border-radius: 6px;
}

/* ── Break-even Chart ── */
.sc-breakeven-wrap { position: relative; padding: 16px 20px 20px; height: 320px; }

/* ── Breakdown Tables ── */
.sc-breakdown-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sc-breakdown-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border-left-width: 3px; border-left-style: solid;
}
.sc-breakdown-card:first-child { border-left-color: #2563eb; }
.sc-breakdown-card:last-child  { border-left-color: #d97706; }
.sc-breakdown-head { padding: 13px 18px; background: var(--bg); border-bottom: 1px solid var(--border); }
.sc-breakdown-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.sc-table-container { max-height: 340px; overflow-y: auto; }
.sc-mini-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.sc-mini-table th {
  text-align: left; padding: 8px 14px; background: var(--bg); color: var(--ink-faint);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border);
}
.sc-mini-table td { padding: 8px 14px; border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; }
.sc-mini-table tbody tr:hover td { background: rgba(0,0,0,0.015); }

/* ── Sidebar Stats ── */
.sc-stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
}
.sc-stat-item { padding: 14px 18px; border-bottom: 1px solid var(--hairline); transition: background 0.15s; }
.sc-stat-item:last-child { border-bottom: none; }
.sc-stat-item:hover { background: rgba(0,0,0,0.01); }
.sc-stat-hrow { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sc-stat-label {
  font-size: 10px; font-weight: 700; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.sc-stat-tip {
  position: relative; display: inline-flex; cursor: help; padding: 2px;
}
.sc-stat-tip svg { color: var(--ink-faint); opacity: 0.4; transition: opacity 0.15s, color 0.15s; }
.sc-stat-item:hover .sc-stat-tip svg { opacity: 0.9; color: var(--accent); }
.sc-stat-tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); right: 0;
  background: #0a2540; color: #fff;
  font-size: 11px; font-weight: 500; line-height: 1.45;
  padding: 8px 12px; border-radius: 7px;
  white-space: normal; max-width: 210px; min-width: 140px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  z-index: 300; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateY(4px);
}
.sc-stat-tip:hover::after { opacity: 1; visibility: visible; transform: translateY(0); }

.sc-stat-val {
  font-size: 22px; font-weight: 800; letter-spacing: -0.03em;
  color: var(--ink); line-height: 1.1;
}
.sc-stat-sub { font-size: 11px; color: var(--ink-muted); margin-top: 3px; }
.sc-stat-val.positive { color: var(--emerald); }
.sc-stat-val.negative { color: var(--rose); }

/* ── Sidebar Chart Cards ── */
.sc-chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
}
.sc-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-faint); margin-bottom: 10px;
}
.sc-chart-wrap { position: relative; height: 200px; }

/* ── Number Flash Animation ── */
@keyframes scValFlash {
  from { opacity: 0.25; transform: translateY(4px); }
  to   { opacity: 1;    transform: translateY(0);   }
}
.sc-val-anim { animation: scValFlash 0.3s ease-out; }

/* ── Dark Mode ── */
[data-theme="dark"] .sc-matrix-table th,
[data-theme="dark"] .sc-mini-table th,
[data-theme="dark"] .sc-matrix-header,
[data-theme="dark"] .sc-breakdown-head    { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .sc-matrix-card,
[data-theme="dark"] .sc-breakdown-card,
[data-theme="dark"] .sc-stat-card,
[data-theme="dark"] .sc-chart-card,
[data-theme="dark"] .sc-mode-bar          { box-shadow: none; }
[data-theme="dark"] .sc-matrix-table .highlight-row td { background: rgba(99,91,255,0.07); }
[data-theme="dark"] .sc-matrix-table .highlight-row:hover td { background: rgba(99,91,255,0.1); }
[data-theme="dark"] .sc-pnl-head.resale   { background: rgba(37,99,235,0.14); }
[data-theme="dark"] .sc-pnl-head.nl       { background: rgba(217,119,6,0.14); }
[data-theme="dark"] .sc-matrix-table tbody tr:hover td { background: rgba(255,255,255,0.025); }
[data-theme="dark"] .sc-mini-table tbody tr:hover td  { background: rgba(255,255,255,0.025); }
[data-theme="dark"] #sensitivityTable .sens-header     { background: rgba(255,255,255,0.03); }
[data-theme="dark"] #sensitivityTable .sens-hot  { background: rgba(5,150,105,0.2); }
[data-theme="dark"] #sensitivityTable .sens-warm { background: rgba(245,158,11,0.16); }
[data-theme="dark"] #sensitivityTable .sens-cold { background: rgba(239,68,68,0.14); }
[data-theme="dark"] .sc-input   { background: var(--bg); }
[data-theme="dark"] .sc-mode-btn.active { box-shadow: 0 1px 3px rgba(99,91,255,0.4); }
[data-theme="dark"] .sc-stat-item:hover { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .sc-page-badge { background: rgba(99,91,255,0.18); }
[data-theme="dark"] .sc-metric-cell .sc-tooltip { background: #1e293b; }
[data-theme="dark"] .sc-stat-tip::after { background: #1e293b; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .sc-dashboard { grid-template-columns: 1fr; }
  .sc-sidebar { position: static; }
  .sc-breakdown-row { grid-template-columns: 1fr; }
  .sc-pnl-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sc-param-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sc-body { padding: 0 16px 60px; }
  .sc-param-grid { grid-template-columns: repeat(2, 1fr); }
  .sc-mode-bar { flex-direction: column; align-items: flex-start; }
}
