/* ===== GLOBAL ===== */
:root {
  --kt-brand: #00a0df;
  --kt-brand-dark: #0078a8;
  --kt-challenge: #ff5a5f;
  --kt-opportunity: #00c49a;
  --kt-gold: #f5a623;
  --kt-bg: #1a1a2e;
  --kt-surface: #16213e;
  --kt-surface2: #0f3460;
  --kt-text: #e4e4e4;
  --kt-text-dim: #8a8fa0;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: var(--kt-bg);
  color: var(--kt-text);
}

/* ===== LOGIN ===== */
#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3e 50%, #0a2a4a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: loginFadeIn 0.5s ease;
}

@keyframes loginFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#login-card {
  background: var(--kt-surface);
  border: 1px solid rgba(0, 160, 223, 0.3);
  border-radius: 16px;
  padding: 48px 40px;
  width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 160, 223, 0.1);
}

#login-logo { margin-bottom: 16px; }

#login-card h2 {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--kt-text-dim);
  font-size: 14px;
  margin-bottom: 28px;
}

#login-form calcite-label {
  text-align: left;
  margin-bottom: 16px;
  display: block;
  font-size: 13px;
  color: var(--kt-text-dim);
}

#login-form calcite-button {
  margin-top: 8px;
}

#login-error {
  color: var(--kt-challenge);
  font-size: 13px;
  margin-top: 12px;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ===== SHELL LAYOUT ===== */
calcite-shell { height: 100%; }

calcite-navigation {
  --calcite-color-brand: var(--kt-brand);
}

calcite-shell-panel {
  --calcite-shell-panel-width: 360px;
}


/* ===== MAIN CONTENT ===== */
#main-content {
  height: 100%;
  position: relative;
  overflow: hidden;
}

.section {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.section.active {
  opacity: 1;
  pointer-events: all;
}

arcgis-map {
  width: 100%;
  height: 100%;
}

/* ===== MAP LEGEND ===== */
#map-legend {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: rgba(22, 33, 62, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 160, 223, 0.25);
  border-radius: 12px;
  padding: 16px 20px;
  z-index: 10;
}

.legend-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
  color: #fff;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--kt-text-dim);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.hq { background: var(--kt-brand); box-shadow: 0 0 8px var(--kt-brand); }
.legend-dot.competitor { background: var(--kt-challenge); box-shadow: 0 0 8px var(--kt-challenge); }
.legend-dot.growth { background: var(--kt-opportunity); box-shadow: 0 0 8px var(--kt-opportunity); }
.legend-dot.hotspot { background: var(--kt-gold); box-shadow: 0 0 8px var(--kt-gold); }
.legend-dot.distributor { background: #a29bfe; box-shadow: 0 0 8px #a29bfe; }
.legend-dot.commercial { background: #fd79a8; box-shadow: 0 0 8px #fd79a8; }

/* ===== STORY CONTAINERS ===== */
.story-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 32px 60px;
}

.section-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 28px;
  letter-spacing: -0.5px;
}

.challenge-color { color: var(--kt-challenge); }
.opportunity-color { color: var(--kt-opportunity); }

/* ===== STORY CARDS ===== */
.story-card {
  background: var(--kt-surface);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 20px;
  border-left: 4px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.story-card.challenge { border-left-color: var(--kt-challenge); }
.story-card.opportunity { border-left-color: var(--kt-opportunity); }

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.story-card.challenge .card-header calcite-icon { color: var(--kt-challenge); }
.story-card.opportunity .card-header calcite-icon { color: var(--kt-opportunity); }

.story-card p {
  color: var(--kt-text-dim);
  line-height: 1.7;
  font-size: 14px;
}

.story-card p strong { color: #fff; }

/* ===== IMPACT METER ===== */
.impact-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 12px;
}

.impact-label { color: var(--kt-text-dim); }

.impact-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.impact-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--kt-gold), var(--kt-challenge));
  border-radius: 3px;
  transition: width 1s ease;
}

.impact-value {
  font-weight: 700;
  color: var(--kt-challenge);
  font-size: 11px;
  text-transform: uppercase;
}

/* ===== OPPORTUNITY SCORE ===== */
.opportunity-score {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--kt-text-dim);
}

.opp-stars {
  display: flex;
  gap: 2px;
}

.opp-stars calcite-icon { color: var(--kt-gold); }

/* ===== LEFT PANEL ===== */
.info-content { padding: 4px 0; }

.info-content p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--kt-text-dim);
}

.info-content p strong { color: #fff; }

.stat-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.brand-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ===== METRIC GRID ===== */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-card {
  background: rgba(0, 160, 223, 0.08);
  border: 1px solid rgba(0, 160, 223, 0.15);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.metric-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--kt-brand);
}

.metric-label {
  font-size: 11px;
  color: var(--kt-text-dim);
  margin-top: 4px;
  line-height: 1.3;
}

/* ===== BAR CHART ===== */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }

.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 40px;
  align-items: center;
  gap: 8px;
}

.bar-label {
  font-size: 12px;
  color: var(--kt-text-dim);
  text-align: right;
}

.bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1.2s ease;
}

.bar-fill.sunbelt { background: linear-gradient(90deg, #ff6b35, #ff9a5c); }
.bar-fill.west { background: linear-gradient(90deg, var(--kt-brand), #56ccf2); }
.bar-fill.southeast { background: linear-gradient(90deg, var(--kt-opportunity), #55efc4); }
.bar-fill.midwest { background: linear-gradient(90deg, #6c5ce7, #a29bfe); }

.bar-value {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.chart-note {
  margin-top: 10px;
  font-size: 11px;
  padding: 8px;
  background: rgba(255, 107, 53, 0.08);
  border-radius: 6px;
  border-left: 3px solid #ff6b35;
}

/* ===== COMPETITOR LIST ===== */
.competitor-list { display: flex; flex-direction: column; gap: 10px; }

.competitor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}

.comp-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  min-width: 120px;
}

.comp-loc {
  font-size: 11px;
  color: var(--kt-text-dim);
  margin-left: auto;
}

/* ===== SWOT FULL TAB ===== */
.swot-color { color: var(--kt-brand); }

.swot-full { max-width: 1000px; }

.swot-grid-full {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.swot-card {
  border-radius: 12px;
  padding: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.swot-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.swot-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.swot-card-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.swot-card ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.swot-card li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--kt-text-dim);
  padding-left: 16px;
  position: relative;
}

.swot-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.swot-card li strong { color: #fff; }

.swot-card.strength {
  background: rgba(0, 160, 223, 0.08);
  border: 1px solid rgba(0, 160, 223, 0.2);
  border-top: 3px solid var(--kt-brand);
}
.swot-card.strength .swot-card-header calcite-icon { color: var(--kt-brand); }
.swot-card.strength li::before { background: var(--kt-brand); }

.swot-card.weakness {
  background: rgba(255, 90, 95, 0.08);
  border: 1px solid rgba(255, 90, 95, 0.2);
  border-top: 3px solid var(--kt-challenge);
}
.swot-card.weakness .swot-card-header calcite-icon { color: var(--kt-challenge); }
.swot-card.weakness li::before { background: var(--kt-challenge); }

.swot-card.opp {
  background: rgba(0, 196, 154, 0.08);
  border: 1px solid rgba(0, 196, 154, 0.2);
  border-top: 3px solid var(--kt-opportunity);
}
.swot-card.opp .swot-card-header calcite-icon { color: var(--kt-opportunity); }
.swot-card.opp li::before { background: var(--kt-opportunity); }

.swot-card.threat {
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.2);
  border-top: 3px solid var(--kt-gold);
}
.swot-card.threat .swot-card-header calcite-icon { color: var(--kt-gold); }
.swot-card.threat li::before { background: var(--kt-gold); }

.verdict-card {
  margin-top: 8px;
}

@media (max-width: 700px) {
  .swot-grid-full { grid-template-columns: 1fr; }
}

/* ===== SOURCE LIST ===== */
.source-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-list a {
  color: var(--kt-brand);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.2s;
}

.source-list a:hover {
  color: #56ccf2;
  text-decoration: underline;
}

/* ===== SCROLLBAR ===== */
.section::-webkit-scrollbar { width: 6px; }
.section::-webkit-scrollbar-track { background: transparent; }
.section::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
.section::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  #left-panel { display: none; }
  .story-container { padding: 24px 16px; }
}
