/* ---------------------------------------
GLOBAL & PAGE LAYOUT
---------------------------------------- */

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #003366 0%, #c89b3c 100%);
  color: #e0e7ff;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 32px;
  box-sizing: border-box;
}

.header {
  margin-bottom: 24px;
}

.logo {
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c89b3c;
  margin-bottom: 4px;
}

.title {
  font-size: 26px;
  font-weight: 600;
  color: #c89b3c;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 14px;
  color: #c89b3c;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------------------------------------
CARDS
---------------------------------------- */

.card {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.card-input {
  border-color: rgba(94, 234, 212, 0.4);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: #e5edff;
  margin-bottom: 8px;
}

.card-subtitle {
  font-size: 15px;
  font-weight: 500;
  color: #cbd2ff;
  margin-bottom: 6px;
}

.card-text {
  font-size: 13px;
  color: #9fb3c8;
  margin-bottom: 10px;
}

/* ---------------------------------------
BUTTONS
---------------------------------------- */

.btn-primary,
#add-row-btn,
#export-btn,
#import-btn {
  margin-top: 12px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #0b1b33;
  background: linear-gradient(135deg, #22d3ee, #4ade80);
  box-shadow: 0 12px 30px rgba(34, 211, 238, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn-primary:hover,
#add-row-btn:hover,
#export-btn:hover,
#import-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(34, 211, 238, 0.45);
}

.small-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.analysis-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

/* ---------------------------------------
STATUS
---------------------------------------- */

.loading {
  margin-top: 8px;
  font-size: 12px;
  color: #a5b4fc;
}

.error {
  margin-top: 8px;
  font-size: 12px;
  color: #fecaca;
}

.hidden {
  display: none;
}

/* ---------------------------------------
SUMMARY CARDS
---------------------------------------- */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-value {
  font-size: 22px;
  font-weight: 600;
  color: #f0f4ff;
}

.summary-label {
  font-size: 12px;
  color: #9fb3c8;
}

/* ---------------------------------------
HEATMAP (FULLY RESPONSIVE)
---------------------------------------- */

.heatmap {
  margin-top: 10px;
  display: inline-grid;
  grid-auto-rows: 28px;
  grid-auto-columns: 50px; /* smaller columns */
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: max-content;
  padding-bottom: 6px;
}

.heatmap-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border-radius: 6px;
  color: #0b1b33;
}

.heatmap-header {
  font-size: 10px;
  color: #cbd2ff;
  text-align: center;
}

/* ---------------------------------------
TABLES (FULLY RESPONSIVE)
---------------------------------------- */


.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  display: block;
}

.table-scroll table {
  min-width: 700px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.table th,
.table td {
  padding: 6px 8px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(51, 65, 85, 0.8);
}

.table th {
  text-align: left;
  color: #cbd2ff;
  font-weight: 500;
}

.table td {
  color: #e0e7ff;
}

/* ---------------------------------------
SECTOR LAYOUT (FULLY RESPONSIVE)
---------------------------------------- */

.sector-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.8fr);
  gap: 16px;
  margin-top: 10px;
}

.sector-panel {
  background: rgba(15, 23, 42, 0.7);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  overflow-x: auto;      /* ✅ allow horizontal scroll inside each panel */
}


.sector-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 12px;
}

.sector-list li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(51, 65, 85, 0.7);
}

/* ---------------------------------------
CLUSTERS & GRAPH (FULLY RESPONSIVE)
---------------------------------------- */

.cluster-list {
  margin-top: 10px;
  font-size: 12px;
}

.cluster-item {
  margin-bottom: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(30, 64, 175, 0.35);
  border: 1px solid rgba(129, 140, 248, 0.6);
}

.cluster-graph {
  width: 100%;
  height: 500px;
  border: 1px solid rgba(255,255,255,0.1);
  margin-top: 20px;
  overflow-x: auto;
}

.cluster-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  color: #e0e7ff;
  padding: 8px 12px;
  border-radius: 8px;
  pointer-events: none;
  font-size: 13px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}

/* ---------------------------------------
PORTFOLIO ROWS (FULLY RESPONSIVE)
---------------------------------------- */

.portfolio-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #003366;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.portfolio-row input {
  padding: 8px 10px;
  border: 1px solid #c89b3c;
  border-radius: 6px;
  font-size: 14px;
  flex: 1;
}

.portfolio-row .ticker-input {
  max-width: 140px;
}

.portfolio-row .weight-input {
  max-width: 100px;
}

.delete-row-btn {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.delete-row-btn:hover {
  background: #dc2626;
}

.portfolio-row:hover {
  background: #c89b3c;
  border-color: #d1d5db;
}

/* ---------------------------------------
RETURN LINK
---------------------------------------- */

.return-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin-left: 20px;
  background: #f7f7f7;
  border: 1px solid #ddd;
  border-radius: 6px;
  color: #333;
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.return-link:hover {
  background: #eee;
  border-color: #c89b3c;
}

.return-link .arrow {
  font-size: 1.1rem;
  margin-right: 4px;
}

/* ---------------------------------------
MOBILE BREAKPOINTS (FINAL FIXES)
---------------------------------------- */

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .sector-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {

  .page {
    padding: 16px;
  }

  .title {
    font-size: 22px;
  }

  .subtitle {
    font-size: 13px;
  }

  .card-title {
    font-size: 16px;
  }

  .portfolio-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .portfolio-row .ticker-input,
  .portfolio-row .weight-input {
    max-width: 100%;
    flex: 1 1 100%;
  }

  .delete-row-btn {
    width: 100%;
    text-align: center;
  }

  .cluster-graph {
    height: 320px;
  }

  .return-link {
    padding: 6px 10px;
    font-size: 0.85rem;
    margin-left: 0;
  }

  .btn-primary,
  #add-row-btn,
  #export-btn,
  #import-btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .table th,
  .table td {
    padding: 4px 6px;
    font-size: 11px;
  }
}
.scroll-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  display: block;
}

.help-icon-wrapper {
    position: relative;
    display: inline-block;
    margin-left: 10px;
}

.help-icon {
    background: #c89b3c;
    color: #0b1b33;
    font-size: 14px;
    padding: 4px 7px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.help-tooltip {
    position: absolute;
    top: 28px;
    left: 0;
    width: 260px;
    background: rgba(15, 23, 42, 0.95);
    color: #e0e7ff;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(148,163,184,0.4);
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    z-index: 9999;
}

/* Hover for desktop */
.help-icon-wrapper:hover .help-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Tap-to-open for mobile */
.help-icon-wrapper .help-icon:active + .help-tooltip {
    opacity: 1;
    visibility: visible;
}
.cta-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    margin-left: 10px;
    background: #c89b3c;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #0b1b33;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.cta-link:hover {
    background: #d4a64a;
    border-color: #f0f0f0;
}
