*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #09090B;
  background-color: #FFFFFF;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

code, pre, .mono-text {
  font-family: 'JetBrains Mono', monospace;
}

/* Base Layout */
.top-nav {
  border-bottom: 1px solid #E4E4E7;
  background: #FFFFFF;
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #09090B;
}

.brand-badge {
  background: #000000;
  color: #FFFFFF;
  font-weight: 800;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: -0.02em;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.03em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  color: #71717A;
  font-size: 14px;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: #09090B;
}

/* Buttons */
.btn-primary {
  background: #000000;
  color: #FFFFFF;
  border: 1px solid #000000;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: #FFFFFF;
  color: #09090B;
  border: 1px solid #E4E4E7;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-secondary:hover {
  background: #FAFAFA;
}

.btn-outline {
  background: transparent;
  color: #09090B;
  border: 1px solid #E4E4E7;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
}

.btn-outline:hover {
  background: #FAFAFA;
  border-color: #09090B;
}

.btn-full {
  width: 100%;
}

/* Container */
.main-wrapper {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 64px 24px;
  flex: 1;
  min-width: 0;
}

/* Header Banner */
.page-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #E4E4E7;
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #09090B;
  margin-bottom: 8px;
}

.page-desc {
  font-size: 15px;
  color: #71717A;
  max-width: 780px;
  line-height: 1.6;
}

.badge-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pill-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #E4E4E7;
  background: #FAFAFA;
  color: #71717A;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Advertisement Blocks */
.ad-slot-zone {
  margin-top: 32px;
  margin-bottom: 32px;
  background: #FAFAFA;
  border: 1px dashed #E4E4E7;
  border-radius: 6px;
  padding: 20px;
  text-align: center;
  min-width: 0;
}

.ad-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #71717A;
  margin-bottom: 10px;
  font-weight: 600;
}

.ad-box-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  text-align: left;
}

.ad-text-wrap {
  flex: 1;
  min-width: 240px;
}

.ad-title {
  font-size: 14px;
  font-weight: 700;
  color: #09090B;
  margin-bottom: 4px;
}

.ad-desc {
  font-size: 12px;
  color: #71717A;
}

/* App Grid */
.app-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

.app-grid > * {
  min-width: 0;
}

/* Panels */
.panel-card {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  padding: 24px;
  min-width: 0;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #09090B;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #09090B;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.form-hint {
  font-size: 11px;
  color: #71717A;
  margin-top: 4px;
}

.input-control {
  width: 100%;
  padding: 8px 12px;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  color: #09090B;
  outline: none;
  transition: border-color 0.15s ease;
}

.input-control:focus {
  border-color: #09090B;
}

.input-prefix-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 10px;
  font-size: 14px;
  color: #71717A;
  pointer-events: none;
}

.input-control.has-prefix {
  padding-left: 26px;
}

.input-control.has-suffix {
  padding-right: 28px;
}

.input-suffix {
  position: absolute;
  right: 10px;
  font-size: 13px;
  color: #71717A;
  pointer-events: none;
}

/* Segmented Control */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 2px;
  gap: 2px;
}

.seg-btn {
  background: transparent;
  border: none;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 500;
  color: #71717A;
  border-radius: 3px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: #000000;
  color: #FFFFFF;
  font-weight: 600;
}

/* Results Display */
.metrics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 16px;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: #71717A;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 22px;
  font-weight: 800;
  color: #09090B;
  letter-spacing: -0.03em;
  font-family: 'JetBrains Mono', monospace;
}

.metric-sub {
  font-size: 12px;
  color: #71717A;
  margin-top: 4px;
}

.savings-highlight {
  color: #09090B;
  background: #FAFAFA;
  border: 1px solid #000000;
  padding: 16px;
  border-radius: 4px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.savings-highlight .savings-num {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-family: 'JetBrains Mono', monospace;
}

/* Comparison Table */
.table-container {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 24px;
  -webkit-overflow-scrolling: touch;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.comparison-table th {
  background: #FAFAFA;
  padding: 12px 14px;
  font-weight: 600;
  color: #09090B;
  border-bottom: 1px solid #E4E4E7;
  white-space: nowrap;
}

.comparison-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #E4E4E7;
  color: #09090B;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

.comparison-table .tag-current {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: #000000;
  color: #FFFFFF;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
  font-family: 'Inter', sans-serif;
}

/* Amortization Schedule Drawer/Viewer */
.schedule-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.amortization-scroll-area {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  background: #FFFFFF;
}

.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

.amort-table th {
  position: sticky;
  top: 0;
  background: #FAFAFA;
  padding: 10px 12px;
  font-weight: 600;
  text-align: right;
  border-bottom: 1px solid #E4E4E7;
  color: #09090B;
  font-family: 'Inter', sans-serif;
}

.amort-table th:first-child,
.amort-table td:first-child {
  text-align: left;
}

.amort-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #F4F4F5;
  text-align: right;
  color: #09090B;
}

/* Methodology Section (E-E-A-T) */
.content-section {
  margin-top: 48px;
  padding-top: 36px;
  border-top: 1px solid #E4E4E7;
}

.section-heading {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #09090B;
  margin-bottom: 16px;
}

.prose {
  color: #71717A;
  font-size: 14px;
  line-height: 1.7;
}

.prose p {
  margin-bottom: 16px;
}

.prose h3 {
  font-size: 16px;
  font-weight: 700;
  color: #09090B;
  margin-top: 24px;
  margin-bottom: 8px;
}

.formula-box {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 16px;
  margin: 16px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: #09090B;
  overflow-x: auto;
}

/* Micro-Affiliate Recommendation Panel */
.affiliate-recommendation-box {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  padding: 20px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.affiliate-content {
  flex: 1;
  min-width: 250px;
}

.affiliate-title {
  font-size: 14px;
  font-weight: 700;
  color: #09090B;
  margin-bottom: 4px;
}

.affiliate-desc {
  font-size: 13px;
  color: #71717A;
}

/* Modal System */
.modal-scrim {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(9, 9, 11, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
}

.modal-scrim.hidden {
  display: none !important;
}

.modal-card {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  width: 100%;
  max-width: 520px;
  padding: 24px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #E4E4E7;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #71717A;
  cursor: pointer;
  padding: 4px;
}

.close-btn:hover {
  color: #09090B;
}

.modal-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid #E4E4E7;
  margin-bottom: 20px;
}

.modal-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #71717A;
  cursor: pointer;
}

.modal-tab-btn.active {
  color: #09090B;
  border-bottom-color: #000000;
  font-weight: 600;
}

/* Floating Coffee Widget */
.support-widget-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  background: #000000;
  color: #FFFFFF;
  border: 1px solid #000000;
  border-radius: 30px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.support-widget-float:hover {
  transform: translateY(-2px);
  opacity: 0.95;
}

/* Structural Footer */
.site-footer {
  background: #FAFAFA;
  border-top: 1px solid #E4E4E7;
  padding: 40px 24px 32px 24px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 32px;
  margin-bottom: 32px;
}

.footer-brand-col {
  max-width: 380px;
}

.footer-brand-col p {
  font-size: 13px;
  color: #71717A;
  margin-top: 8px;
  line-height: 1.6;
}

.footer-links-col {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}

.footer-col-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #09090B;
  margin-bottom: 12px;
}

.footer-link-list {
  list-style: none;
}

.footer-link-list li {
  margin-bottom: 8px;
}

.footer-link-list a {
  font-size: 13px;
  color: #71717A;
  text-decoration: none;
}

.footer-link-list a:hover {
  color: #09090B;
}

.footer-bottom {
  border-top: 1px solid #E4E4E7;
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: #71717A;
}

/* Responsive Overrides */
@media (max-width: 860px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .main-wrapper {
    padding: 16px 12px 64px 12px;
  }

  .panel-card {
    padding: 16px;
  }

  .segmented-control {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  }

  .seg-btn {
    padding: 6px 4px;
    font-size: 11px;
    white-space: normal;
    word-break: break-word;
  }

  .nav-container {
    padding: 12px 16px;
  }

  .nav-actions {
    gap: 10px;
  }

  .btn-primary {
    padding: 6px 12px;
    font-size: 12px;
  }

  .page-title {
    font-size: 22px;
  }

  .support-widget-float {
    bottom: 16px;
    right: 16px;
    padding: 8px 12px;
    font-size: 12px;
  }

  .savings-highlight {
    flex-direction: column;
    align-items: flex-start;
  }
}