:root {
  --bg: #F3F5F8;
  --card: #ffffff;
  --text: #121826;
  --text-secondary: #6B7280;
  --line: #E2E6EF;
  --brand-bg: #121826;
  --danger: #D32F2F;
  --danger-bg: #FFF3F3;
  --danger-border: #F5C6C6;
  --success: #137333;
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
}

html {
  overflow-x: hidden;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

h1, h2, h3 {
  font-family: "Montserrat", "Inter", sans-serif;
}

/* ========== FOCUS STATES ========== */
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ========== TOPBAR ========== */
.topbar {
  background: var(--brand-bg);
  overflow-x: hidden;
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  cursor: default;
  pointer-events: none;
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-cta-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-cta-sm:hover {
  background: #e8eaee;
}

.btn-cta-sm.btn-cta-ghost {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-cta-sm.btn-cta-ghost:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

input[type="file"] {
  display: none;
}

.btn-strip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-strip.primary {
  background: var(--brand-bg);
  color: #fff;
  border-color: var(--brand-bg);
}

.btn-strip.primary:hover {
  background: #2d3548;
}

.btn-strip.outline {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.btn-strip.outline:hover {
  background: #f0f2f6;
  border-color: #cdd2de;
}

.btn-strip.accent {
  background: var(--brand-bg);
  color: #fff;
  border-color: var(--brand-bg);
}

.btn-strip.accent:hover {
  background: #2d3548;
}

.btn-strip.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-strip.ghost:hover {
  background: #f0f2f6;
}

.upload-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-status.success {
  color: var(--success);
}

.upload-status.warning {
  color: #92400E;
}

.upload-status.error {
  color: var(--danger);
}

.upload-post-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid var(--line);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== SKELETON LOADING ========== */
.skeleton-text {
  display: inline-block;
  height: 1em;
  width: 120px;
  background: linear-gradient(90deg, #e0e4ea 25%, #eef0f4 50%, #e0e4ea 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  vertical-align: middle;
}

.skeleton-text.wide {
  width: 180px;
}

.skeleton-text.short {
  width: 60px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== FADE-IN ANIMATION ========== */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========== HERO ========== */
.hero {
  background: var(--brand-bg);
  padding: 28px 28px 32px;
  text-align: center;
  overflow-x: hidden;
}

.hero-inner {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  overflow-wrap: break-word;
}

.hero h1 {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 8px;
}

.hero h1 span {
  color: rgba(255, 255, 255, 0.5);
}

.hero p {
  color: rgba(255, 255, 255, 0.4);
  font-size: 14px;
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ========== ACTION BANNER ========== */
.action-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 16px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow-wrap: break-word;
}

.action-banner.default {
  background: #f8f9fb;
}

.action-banner.custom {
  background: #f0f1f4;
  border-bottom-color: #d5d8e0;
}

.action-banner-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
}

.action-banner.default .action-banner-info {
  color: var(--text-secondary);
}

#bannerText {
  min-width: 0;
}

.action-banner.custom .action-banner-info {
  color: var(--text);
}

.action-banner-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.action-banner-title {
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.action-banner-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  min-width: 0;
}

/* ========== CONTAINER ========== */
.container {
  max-width: 1240px;
  width: 100%;
  margin: 24px auto;
  padding: 0 20px 32px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

/* ========== CARDS ========== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(18, 24, 38, 0.04);
  min-width: 0;
}

h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.muted {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ========== SECTION HEADER ========== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header h2 {
  margin-bottom: 0;
}

.btn-export {
  font-size: 12px;
  padding: 6px 12px;
}

/* ========== STAT CARDS ========== */
.grid.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  padding: 20px;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-family: "Montserrat", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-card.highlight {
  border-left: 3px solid var(--text);
}

/* ========== INSIGHT CARD ========== */
.insight-card {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.insight-icon-wrap {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--danger);
  color: #fff;
  display: grid;
  place-items: center;
}

.insight-icon-wrap svg {
  stroke: #fff;
}

.insight-body h2 {
  color: var(--danger);
}

.insight-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 10px;
}

.insight-value {
  font-family: "Montserrat", sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--danger);
}

.insight-cta-row {
  flex-shrink: 0;
  align-self: center;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.insight-cta {
  flex-shrink: 0;
}

.insight-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.insight-link:hover {
  color: var(--text);
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-bg);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
}

.btn-cta:hover {
  background: #2d3548;
  transform: translateY(-1px);
}

.btn-cta-lg {
  padding: 16px 36px;
  font-size: 16px;
}

/* ========== SOLARIFY CARD ========== */
.solarify-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(18, 24, 38, 0.10);
  min-width: 0;
}

.solarify-left {
  flex: 1;
  min-width: 260px;
  background: var(--brand-bg);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.solarify-badge-large {
  display: inline-block;
  background: #fff;
  color: var(--text);
  font-family: "Montserrat", sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 8px 20px;
  border-radius: 999px;
  margin-bottom: 14px;
  width: fit-content;
}

.solarify-left h2 {
  color: #fff;
  font-size: 20px;
  margin-bottom: 10px;
}

.solarify-left p {
  color: rgba(255, 255, 255, 0.45);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.solarify-cta-row {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.solarify-cta {
  width: fit-content;
  background: #fff;
  color: var(--text);
}

.solarify-cta:hover {
  background: #e8eaee;
}

.solarify-how-link {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  white-space: nowrap;
}

.solarify-how-link:hover {
  color: #fff;
}

.solarify-right {
  flex: 1.2;
  min-width: 320px;
  background: #1a2040;
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.solarify-compare {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.solarify-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  border-radius: 12px;
  min-width: 140px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.solarify-item.result {
  background: #fff;
  border: none;
}

.solarify-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.45);
}

.solarify-item.result .solarify-label {
  color: var(--text-secondary);
}

.solarify-amount {
  font-family: "Montserrat", sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.solarify-item.result .solarify-amount {
  color: var(--text);
  font-size: 24px;
}

.solarify-plus,
.solarify-equals {
  font-family: "Montserrat", sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.25);
}

@media (max-width: 900px) {
  .solarify-card {
    flex-direction: column;
  }
  .solarify-left,
  .solarify-right {
    min-width: unset;
  }
  .solarify-compare {
    gap: 10px;
  }
  .solarify-item {
    min-width: 110px;
    padding: 10px 12px;
  }
  .solarify-amount {
    font-size: 16px;
  }
  .solarify-item.result .solarify-amount {
    font-size: 18px;
  }
}

@media (max-width: 500px) {
  .solarify-compare {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .solarify-item {
    min-width: unset;
    flex-direction: row;
    justify-content: space-between;
    padding: 12px 16px;
  }
  .solarify-plus,
  .solarify-equals {
    display: none;
  }
  .solarify-left,
  .solarify-right {
    padding: 20px 20px;
  }
  .solarify-left h2 {
    font-size: 17px;
  }
  .solarify-badge-large {
    font-size: 15px;
    padding: 6px 16px;
  }
}

/* ========== DETAIL GRID ========== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-value {
  font-family: "Montserrat", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.detail-value.danger {
  color: var(--danger);
}

/* ========== CHART ========== */
.chart-wrap {
  position: relative;
  height: 350px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
}

/* ========== TABLES ========== */
.table-wrap {
  overflow-x: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: right;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 13px;
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #FAFBFD;
  position: sticky;
  top: 0;
  z-index: 1;
}

th.left, td.left {
  text-align: left;
}

td.neg {
  color: var(--danger);
  font-weight: 600;
}

td.pos {
  font-weight: 600;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover {
  background: #f8f9fb;
}

.empty {
  text-align: center !important;
  color: var(--text-secondary);
  padding: 28px;
}

/* ========== SHOW MORE BUTTON ========== */
.btn-show-more {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-show-more:hover {
  background: #eef0f4;
  border-color: #cdd2de;
}

/* ========== FINAL CTA ========== */
.final-cta {
  background: var(--brand-bg);
  padding: 56px 28px;
  text-align: center;
  overflow-x: hidden;
}

.final-cta-inner {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.final-cta h2 {
  color: #fff;
  font-size: 28px;
  margin-bottom: 12px;
}

.final-cta p {
  color: rgba(255, 255, 255, 0.45);
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 24px;
}

.final-cta-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  min-width: 0;
}

.final-cta-secondary {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
}

.final-cta-secondary:hover {
  color: #fff;
}

.final-cta .btn-cta {
  background: #fff;
  color: var(--text);
}

.final-cta .btn-cta:hover {
  background: #e8eaee;
}

/* ========== FOOTER ========== */
.footer {
  background: var(--brand-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 32px 28px;
  overflow-x: hidden;
}

.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-logo {
  height: 24px;
  width: auto;
  opacity: 0.7;
}

.footer p {
  color: rgba(255, 255, 255, 0.35);
  font-size: 13px;
}

.footer a {
  color: rgba(255, 255, 255, 0.55);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.footer a:hover {
  color: #fff;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .grid.stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
  }

  .topbar-right {
    flex-wrap: wrap;
    gap: 8px;
  }

  .hero {
    padding: 20px 16px 24px;
  }

  .hero h1 {
    font-size: 20px;
  }

  .container {
    padding: 0 16px 24px;
    margin: 16px auto;
  }

  .card {
    padding: 20px 16px;
  }

  .action-banner {
    padding: 12px 16px 14px;
  }

  .action-banner-info {
    font-size: 13px;
    text-align: center;
  }

  .action-banner-row {
    flex-direction: column;
    gap: 10px;
  }

  .action-banner-btns {
    flex-wrap: wrap;
    justify-content: center;
  }

  .btn-strip {
    min-height: 44px;
    padding: 10px 16px;
    white-space: normal;
    text-align: center;
  }

  .btn-cta-sm {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 12px;
  }

  .grid.stats,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 18px;
  }

  .insight-card {
    flex-direction: column;
    gap: 16px;
  }

  .insight-body {
    min-width: 0;
  }

  .insight-value {
    font-size: 24px;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .insight-cta-row {
    margin-left: 0;
    align-self: stretch;
    flex-wrap: wrap;
    flex-direction: column;
    gap: 10px;
  }

  .insight-cta {
    width: 100%;
    justify-content: center;
    text-align: center;
    white-space: normal;
  }

  .insight-link {
    white-space: normal;
    text-align: center;
    display: block;
  }

  .insight-cta {
    min-height: 44px;
    padding: 12px 16px;
  }

  .btn-cta {
    min-height: 44px;
    padding: 12px 16px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .chart-wrap {
    height: 280px;
  }

  .final-cta {
    padding: 40px 20px;
  }

  .final-cta h2 {
    font-size: 22px;
  }

  .final-cta .btn-cta {
    min-height: 44px;
    padding: 14px 24px;
    white-space: normal;
    text-align: center;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  th, td {
    padding: 10px 8px;
    font-size: 12px;
  }

  th {
    font-size: 10px;
  }

  .table-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, var(--bg));
    pointer-events: none;
  }
}
