/* =============================================
   Mortgage Calculator — Calculator-Specific Styles
   Shell (header, footer, page heading, base reset)
   is provided by <calc-shell> web component.
   ============================================= */

/* --- DESIGN TOKENS (needed by light DOM content slotted into calc-shell) --- */
:root {
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border: #e5e7eb;
  --accent-green: #059669;
  --accent-red: #dc2626;
  --accent-amber: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 14px rgba(0, 0, 0, 0.10);
}

/* --- CALCULATOR-SPECIFIC LAYOUT --- */
.layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* --- CARDS --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}

/* --- INPUT PANEL --- */
.input-panel {
  position: sticky;
  top: 1rem;
  /* max-height: calc(100vh - 2rem); */
  overflow-y: auto;
}

.field {
  margin-bottom: 1rem;
}

.field > label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0.3rem;
}

.input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s;
}

.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.prefix,
.suffix {
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #f9fafb;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.suffix {
  border-right: none;
  border-left: 1px solid var(--border);
}

.input-group input,
.input-group select {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.input-group select {
  cursor: pointer;
}

.input-stack {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* --- DIVIDER --- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* --- CHECKBOXES --- */
.field-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.field-check label {
  font-size: 0.88rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0;
  cursor: pointer;
}

/* --- MORE OPTIONS TOGGLE --- */
.btn-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.5rem 0;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  margin-top: 0.25rem;
  transition: color 0.15s;
}

.btn-link:hover {
  color: var(--primary-hover);
}

.toggle-arrow {
  font-size: 0.65rem;
  display: inline-block;
  transition: transform 0.2s;
}

.more-options {
  padding-left: 0.25rem;
  border-left: 2px solid var(--border);
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.more-options h3 {
  margin-top: 0.75rem;
}

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
  margin-bottom: 0.75rem;
}

/* --- BUTTONS --- */
.btn-primary {
  display: block;
  width: 100%;
  padding: 0.7rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0.5rem;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

/* --- RESULTS PANEL --- */
.big-number {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.breakdown {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.breakdown span {
  font-weight: 600;
  color: var(--text);
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--accent-green);
  color: #fff;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 0.3rem;
}

/* --- STATS GRID --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: #f9fafb;
  border-radius: 8px;
  padding: 0.85rem;
  text-align: center;
}

.stat .label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat .value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.stat .value.green {
  color: var(--accent-green);
}

.stat .value.red {
  color: var(--accent-red);
}

.stat .value.amber {
  color: var(--accent-amber);
}

/* --- CHARTS --- */
.chart-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.chart-wrapper {
  background: #f9fafb;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  max-height: 320px;
}

.chart-wrapper canvas {
  max-height: 280px;
}

.chart-pie {
  max-height: 300px;
}

.chart-pie canvas {
  max-height: 260px;
}

/* --- SCHEDULE HEADER (title + toggle) --- */
.schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.schedule-header h2 {
  margin-bottom: 0;
}

.schedule-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  background: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn:first-child {
  border-right: 1px solid var(--border);
}

.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

.toggle-btn:hover:not(.active) {
  background: #f3f4f6;
}

/* --- TABLE --- */
.table-scroll {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: #f9fafb;
}

th {
  text-align: right;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

th:first-child {
  text-align: left;
}

td {
  text-align: right;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

td:first-child {
  text-align: left;
  font-weight: 600;
}

tbody tr:hover {
  background: #f9fafb;
}

.paid-off {
  color: var(--accent-green) !important;
  font-weight: 700;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  .big-number {
    font-size: 2rem;
  }

  .breakdown {
    flex-direction: column;
    gap: 0.2rem;
    align-items: flex-start;
  }
}