
:root {
  --bg: #f8fafc; 
  --bg2: #ffffff; 
  --bg3: #f1f5f9; 
  --border: #e2e8f0; 
  --text: #0f172a; 
  --text2: #64748b; 
  --brand-blue: #0e4c9d;       /* Logo Navy Blue (PENG LENG JENG) */
  --brand-blue-hover: #093874; /* Logo Dark Blue Hover */
  --brand-red: #e71e25;        /* Logo Red (平靚正) */
  --brand-cyan: #36afb7;       /* Logo AI Teal */
  --brand-teal: #36afb7;
  --brand-green: #2baf7e;      /* Logo AI Emerald Green */
  --green: #2baf7e; 
  --red: #e71e25; 
  --gold: #f59e0b; 
  --blue: #0e4c9d; 
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, sans-serif; }
body::before {
  content: "";
  display: block;
  height: 3.5px;
  background: linear-gradient(90deg, #0e4c9d 0%, #0e4c9d 48%, #36afb7 72%, #2baf7e 86%, #e71e25 100%);
  width: 100%;
}
.header { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(14,76,157,0.04); }
.logo img { height: 45px; display: block; }
.container { display: flex; height: calc(100vh - 73px); }
.sidebar { width: 250px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
.nav-section { padding: 24px 20px 8px; font-size: 12px; font-weight: 800; color: var(--brand-blue); text-transform: uppercase; letter-spacing: 0.3px; }
.nav-item { padding: 12px 20px; font-size: 14px; font-weight: 600; color: var(--text2); cursor: pointer; transition: 0.2s; border-left: 4px solid transparent; }
.nav-item:hover { background: #f0f6ff; color: var(--brand-blue) !important; border-left: 4px solid var(--brand-cyan); }
.nav-item.active { background: #f0f6ff; color: var(--brand-blue) !important; border-left: 4px solid var(--brand-red); font-weight: 700; }
.main { flex: 1; padding: 24px; overflow-y: auto; }
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; color: var(--brand-blue); }
.table-container { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: #f8fafc; padding: 14px 16px; font-size: 13px; color: var(--brand-blue); font-weight: 700; border-bottom: 2px solid rgba(14,76,157,0.20); white-space: nowrap; user-select: none; vertical-align: top; }
th.sortable-th:hover { background: #e2e8f0; cursor: pointer; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tr:hover { background: rgba(14,76,157,0.045); cursor: pointer; }
.ticker { font-weight: 700; font-size: 15px; color: var(--brand-blue); }
.company { font-size: 12px; color: var(--text2); display: block; margin-top: 2px; }
.badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; display: inline-block; }
.b-green { background: rgba(43,175,126,0.12); color: #1b7a54; border: 1px solid rgba(43,175,126,0.35); }
.b-red { background: rgba(231,30,37,0.12); color: #d0141b; border: 1px solid rgba(231,30,37,0.35); }
.b-gold { background: rgba(245,158,11,0.15); color: var(--gold); border: 1px solid rgba(245,158,11,0.3); }
.b-blue { background: rgba(14,76,157,0.12); color: var(--brand-blue); border: 1px solid rgba(14,76,157,0.35); }
.bullet { font-size: 12px; color: var(--text2); display: block; margin-top: 4px; }
.btn { padding: 8px 18px; background: var(--brand-blue); color: white; border: none; border-radius: 6px; font-weight: 700; cursor: pointer; transition: 0.2s; box-shadow: 0 2px 4px rgba(14,76,157,0.18); }
.btn:hover { background: var(--brand-blue-hover); box-shadow: 0 4px 10px rgba(14,76,157,0.25); }
.sort-btn { display: inline-block; padding: 2px 6px; background: rgba(0,0,0,0.06); border-radius: 4px; cursor: pointer; margin: 0 2px; transition: 0.2s; color: var(--text); font-weight: 600; }
.sort-btn:hover { background: var(--brand-cyan); color: white; }
.sort-btn.active { background: var(--brand-blue); color: white; }

.filter-tab-btn {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}
.filter-tab-btn:hover {
  background: #f0f6ff;
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}
.filter-tab-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
  box-shadow: 0 2px 6px rgba(14,76,157,0.25);
}
.sidebar-details summary {
  list-style: none;
}
.sidebar-details summary::-webkit-details-marker {
  display: none;
}
.sidebar-details[open] .details-arrow {
  transform: rotate(180deg);
}

.nav-subgroup-summary {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: 0.2s;
  border-left: 4px solid transparent;
}
.nav-subgroup-summary:hover {
  background: #f0f6ff;
  color: var(--brand-blue);
  border-left: 4px solid var(--brand-cyan);
}
.sidebar-details.active > .nav-subgroup-summary,
.nav-subgroup-summary.active {
  background: #f0f6ff;
  color: var(--brand-blue);
  border-left: 4px solid var(--brand-red);
  font-weight: 700;
}

/* --- Climate Switcher (大市環境與動能 視角切換) --- */
.climate-switcher {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg2, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-left: 3.5px solid var(--brand-blue);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(14,76,157,0.05);
}
.climate-switcher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand-blue, #0e4c9d);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.climate-market-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}
.climate-pill {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 4px;
  text-decoration: none;
}
.climate-pill.active {
  background: #0e4c9d;
  color: #ffffff;
  font-weight: 600;
}
.climate-pill.link {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.climate-pill.link:hover {
  background: #e2e8f0;
  color: #0e4c9d;
}
.climate-switcher-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.climate-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text2, #64748b);
  background: var(--bg3, #f1f5f9);
  border: 1px solid transparent;
  transition: all 0.18s ease;
}
.climate-tab:hover {
  background: #e2e8f0;
  color: var(--brand-blue, #0e4c9d);
}
.climate-tab.active {
  background: #f0f6ff;
  color: var(--brand-blue, #0e4c9d);
  border-color: rgba(14, 76, 157, 0.30);
  box-shadow: 0 2px 6px rgba(14,76,157,0.08), inset 0 -2.5px 0 var(--brand-red);
  font-weight: 700;
}
.climate-tab-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(14,76,157,0.08);
  color: var(--brand-blue, #0e4c9d);
}
.climate-tab.active .climate-tab-badge {
  background: #0e4c9d;
  color: #ffffff;
}
@media (max-width: 600px) {
  .climate-switcher-tabs {
    flex-direction: column;
    gap: 6px;
  }
  .climate-tab {
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
  }
}


/* --- Unified PLJ Strategy Ranking Styles (Logo Blue #0e4c9d, Logo Red #e71e25, Logo Green #2baf7e) --- */
.plj-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.plj-filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.plj-chip {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.plj-chip:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  background: #f0f6ff;
}
.plj-chip.active {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
  box-shadow: 0 2px 6px rgba(14,76,157,0.25);
}
.qa-chip-btn {
  background: rgba(14, 76, 157, 0.05);
  border: 1px solid rgba(14, 76, 157, 0.18);
  color: var(--brand-blue);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.qa-chip-btn:hover {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
  box-shadow: 0 2px 6px rgba(14, 76, 157, 0.2);
  transform: translateY(-1px);
}
.qa-answer-content p {
  margin-bottom: 10px;
}
.qa-answer-content ul, .qa-answer-content ol {
  margin-left: 20px;
  margin-bottom: 10px;
}
.qa-answer-content li {
  margin-bottom: 4px;
}
.plj-view-switcher {
  display: inline-flex;
  background: #edf2f7;
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}
.plj-view-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text2);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.plj-view-btn.active {
  background: #ffffff;
  color: var(--brand-blue);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.plj-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.plj-stock-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.plj-stock-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(14,76,157,0.08);
  border-color: var(--brand-blue);
}
.plj-subscore-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: #e2e8f0;
  margin: 6px 0 10px;
}

.report-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15,23,42,0.6); z-index: 1000; justify-content: center; align-items: center; }
.report-modal.active { display: flex; }
.report-content { background: var(--bg2); width: 90%; max-width: 900px; height: 85vh; border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2); overflow: hidden; }
.report-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg3); }

.report-body { 
  padding: 32px; 
  overflow-y: auto; 
  flex: 1; 
  line-height: 1.8; 
  color: #1e293b; 
  font-size: 15px; 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f8fafc;
}

/* Headings with colorful hierarchy */
.report-body h1 { 
  font-size: 24px; 
  font-weight: 800; 
  color: var(--brand-blue); 
  margin: 0 0 20px; 
  padding-bottom: 12px; 
  border-bottom: 3px solid var(--brand-cyan); 
  display: flex; 
  align-items: center; 
  gap: 10px;
}

.report-body h2 { 
  font-size: 19px; 
  font-weight: 700; 
  color: var(--brand-blue); 
  margin: 28px 0 14px; 
  padding: 8px 14px; 
  background: linear-gradient(90deg, #f0f6ff 0%, #f8fafc 100%); 
  border-left: 5px solid var(--brand-red); 
  border-radius: 0 8px 8px 0;
}

.report-body h3 { 
  font-size: 16px; 
  font-weight: 700; 
  color: var(--brand-blue-hover); 
  margin: 20px 0 10px; 
  display: flex; 
  align-items: center; 
  gap: 6px;
}

.report-body h4 { 
  font-size: 15px; 
  font-weight: 700; 
  color: #334155; 
  margin: 16px 0 8px; 
}

/* Beautiful modern tables with highlights */
.report-body table { 
  width: 100%; 
  table-layout: fixed;
  border-collapse: separate; 
  border-spacing: 0; 
  margin: 18px 0 24px; 
  background: #ffffff; 
  border-radius: 8px; 
  overflow: hidden; 
  border: 1px solid #e2e8f0; 
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.report-body th { 
  background: #f1f5f9; 
  color: #1e293b; 
  font-weight: 700; 
  font-size: 13.5px; 
  padding: 12px 14px; 
  border-bottom: 2px solid #cbd5e1; 
  text-align: left; 
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.report-body td { 
  padding: 11px 14px; 
  font-size: 13.5px; 
  border-bottom: 1px solid #f1f5f9; 
  color: #334155; 
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.6;
}

.report-body tr:last-child td { 
  border-bottom: none; 
}

.report-body tr:hover td { 
  background: #f8fafc; 
}

/* Callout blockquotes */
.report-body blockquote { 
  background: #ffffff; 
  border-left: 5px solid var(--brand-cyan); 
  padding: 14px 20px; 
  margin: 18px 0; 
  border-radius: 0 8px 8px 0; 
  box-shadow: 0 1px 4px rgba(0,0,0,0.03); 
  color: #475569; 
  font-size: 14px;
}

/* Lists and bullet tags */
.report-body ul, .report-body ol { 
  padding-left: 24px; 
  margin: 12px 0 18px; 
}

.report-body li { 
  margin-bottom: 8px; 
  line-height: 1.7; 
}

/* Bold accenting */
.report-body strong { 
  color: #0f172a; 
  font-weight: 700; 
}

/* Horizontal Divider */
.report-body hr { 
  border: 0; 
  height: 1px; 
  background: linear-gradient(90deg, #cbd5e1, transparent); 
  margin: 28px 0; 
}

.loading-box { text-align: center; padding: 60px 20px; color: var(--text2); }
.spinner { display: inline-block; width: 36px; height: 36px; border: 3px solid rgba(0,0,0,0.1); border-radius: 50%; border-top-color: var(--brand-blue); animation: spin 0.8s linear infinite; margin-bottom: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }


@media print {
  body * { visibility: hidden; }
  .report-modal.active, .report-content, .report-content * { visibility: visible; }
  .report-modal { position: absolute; left: 0; top: 0; width: 100%; height: auto; background: #ffffff !important; }
  .report-content { width: 100%; max-width: 100%; height: auto; box-shadow: none !important; border: none !important; padding: 0 !important; }
  .report-header button, .btn-watchlist, .btn-print, .btn-close, #ai-stock-qa-box { display: none !important; }
  .report-body { padding: 0 !important; }
  .report-body table { page-break-inside: avoid; border: 1px solid #cbd5e1 !important; table-layout: auto !important; }
  .report-body th, .report-body td { border-color: #cbd5e1 !important; }
}

@media (max-width: 768px) {
  .report-content {
    width: 95% !important;
    max-width: 95vw !important;
    max-height: 92vh !important;
    overflow-x: hidden !important;
  }
  .report-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 14px !important;
  }
  .report-header > div:first-child {
    white-space: normal !important;
    word-break: break-word !important;
  }
  .report-header > div:last-child {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .report-header .btn {
    padding: 6px 10px !important;
    font-size: 12px !important;
    flex: 1 1 auto !important;
    text-align: center !important;
  }
  .report-body {
    padding: 16px 14px !important;
    overflow-x: hidden !important;
  }
  .report-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    table-layout: auto;
    margin: 14px 0 !important;
  }
  .report-body th, .report-body td {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
  }
}
.report-modal.minimized {
  display: block !important;
  position: fixed !important;
  top: auto !important;
  bottom: 24px !important;
  right: 24px !important;
  left: auto !important;
  width: auto !important;
  height: auto !important;
  background: transparent !important;
  z-index: 1000 !important;
}
.report-modal.minimized .report-content {
  width: auto !important;
  min-width: 520px !important;
  max-width: calc(100vw - 36px) !important;
  height: auto !important;
  border: 2px solid var(--brand-blue) !important;
  border-radius: 14px !important;
  box-shadow: 0 16px 36px rgba(14,76,157,0.22) !important;
  background: #ffffff !important;
  overflow: visible !important;
}
.report-modal.minimized .report-header {
  padding: 12px 20px !important;
  gap: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  background: #f8fafc !important;
  border-radius: 12px !important;
  border-bottom: none !important;
}
.report-modal.minimized .report-body {
  display: none !important;
}
.report-modal.minimized .btn {
  padding: 8px 16px !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}
.report-modal.minimized .btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.16) !important;
}
.btn-watchlist {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
}
.btn-watchlist:hover {
  background: var(--bg3);
  border-color: #cbd5e1;
}
.btn-watchlist.in-watch {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}


.search-container {
  display: flex;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 6px 3px 14px;
  width: 360px;
  transition: 0.2s;
}
.search-container:focus-within {
  border-color: var(--brand-blue);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(14,76,157,0.15);
}
.search-container input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 13px;
  color: var(--text);
}
.search-container button {
  background: var(--brand-blue);
  color: white;
  border: none;
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.2s;
}
.search-container button:hover {
  background: var(--brand-blue-hover);
}
.quick-chips-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.stock-chip {
  background: var(--bg3);
  color: var(--brand-blue);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stock-chip:hover {
  background: #f0f6ff;
  border-color: var(--brand-cyan);
  color: var(--brand-blue);
}
.beta-welcome-banner {
  background: linear-gradient(90deg, #f0f6ff 0%, #fff7f7 100%);
  border: 1px solid #cde0f7;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
/* ── Macro Economic Weather Bar ── */
.macro-weather-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: all 0.2s ease;
}
.macro-weather-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.macro-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #edf2f7;
  flex-wrap: wrap;
  gap: 8px;
}
.macro-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.macro-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.macro-badge-fresh {
  background: #ecfdf5;
  color: #047857;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #a7f3d0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.macro-badge-fresh::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
}
.macro-info-tip {
  font-size: 11px;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  cursor: help;
}
.macro-toggle-btn {
  background: #ffffff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}
.macro-toggle-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.macro-countries-wrap {
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.macro-country-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.macro-country-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  min-width: 68px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  letter-spacing: 0.3px;
  user-select: none;
}
.macro-country-tag.us {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #dbeafe;
}
.macro-country-tag.cn {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fee2e2;
}
.macro-pills-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.macro-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  user-select: none;
}
.macro-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}
.macro-pill-label {
  font-size: 11px;
  opacity: 0.85;
}
.macro-pill-val {
  font-weight: 700;
}
/* Contextual pill states */
.macro-pill.expansion {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}
.macro-pill.disinflation {
  background: #f0fdfa;
  color: #0f766e;
  border-color: #99f6e4;
}
.macro-pill.slowdown {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}
.macro-pill.tight {
  background: #faf5ff;
  color: #6b21a8;
  border-color: #e9d5ff;
}
.macro-pill.steady {
  background: #f8fafc;
  color: #334155;
  border-color: #cbd5e1;
}

.macro-summary-bar {
  padding: 8px 16px;
  background: #fcfcfd;
  border-top: 1px dashed #e2e8f0;
  font-size: 12px;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.45;
}

/* ── Expandable In-place Drawer ── */
.macro-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: #ffffff;
  border-top: 1px solid #edf2f7;
}
.macro-drawer.open {
  max-height: 2200px;
}
.macro-drawer-content {
  padding: 16px;
}
.macro-drawer-filter-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.macro-tab-btn {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.macro-tab-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}
.macro-tab-btn.active {
  background: #1e40af;
  color: #ffffff;
  border-color: #1e40af;
}
.macro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.macro-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: all 0.2s ease;
  position: relative;
}
.macro-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.macro-card.highlight {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
  background: #f8fafc;
}
.macro-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.macro-card-category {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.3px;
}
.macro-card-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}
.macro-card-values {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.macro-card-mainval {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
}
.macro-card-unit {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-left: 2px;
}
.macro-card-subval {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.macro-card-subval.pos {
  background: #ecfdf5;
  color: #059669;
}
.macro-card-subval.neg {
  background: #fef2f2;
  color: #dc2626;
}
.macro-card-subval.neu {
  background: #f1f5f9;
  color: #64748b;
}

/* Sparkline container */
.macro-sparkline-wrap {
  width: 100%;
  height: 34px;
  margin: 2px 0;
}
.macro-sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.macro-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: #64748b;
  border-top: 1px dashed #f1f5f9;
  padding-top: 6px;
}
.macro-card-source {
  color: #64748b;
}
.macro-card-period {
  font-weight: 600;
  color: #475569;
}

.macro-drawer-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  font-size: 11px;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 768px) {
  .macro-country-line {
    flex-direction: column;
    align-items: flex-start;
  }
  .macro-pills-row {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .macro-pill {
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
  }
  .macro-grid {
    grid-template-columns: 1fr;
  }
}
.mobile-feedback-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-cyan) 100%);
  color: white;
  padding: 13px 22px;
  border-radius: 32px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(14,76,157,0.45);
  cursor: pointer;
  z-index: 999;
  border: 1px solid rgba(255,255,255,0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}
.mobile-feedback-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 28px rgba(14,76,157,0.6);
}
@media (max-width: 768px) {
  .header { flex-direction: column; gap: 10px; align-items: stretch !important; padding: 12px 16px !important; }
  .search-container { width: 100% !important; }
  .container { flex-direction: column !important; height: auto !important; }
  .sidebar { width: 100% !important; border-right: none !important; border-bottom: 1px solid var(--border) !important; max-height: 200px !important; }
  .main { padding: 14px !important; }
  .mobile-feedback-fab { display: flex !important; align-items: center; gap: 8px; }
  .report-content { width: 95% !important; max-height: 90vh !important; }
  .report-modal.minimized { bottom: 16px !important; right: 16px !important; left: 16px !important; }
  .report-modal.minimized .report-content { min-width: 0 !important; width: 100% !important; max-width: 100% !important; }
  .report-modal.minimized .report-header { padding: 10px 14px !important; }
  .report-modal.minimized .btn { padding: 7px 12px !important; font-size: 13px !important; }
}


/* Report print acceptance: flowing pages, readable tables, no orphan headings. */
@media print {
  @page { size: A4; margin: 12mm; }
  .report-modal.active, .report-content, .report-body { max-height: none !important; overflow: visible !important; }
  .report-content { display: block !important; width: 100% !important; max-width: 100% !important; }
  .report-body { padding: 0 !important; }
  .report-body h1, .report-body h2, .report-body h3, .report-body h4, .report-body summary { break-after: avoid-page; page-break-after: avoid; }
  .report-body p, .report-body li { orphans: 3; widows: 3; }
  .report-body table { display: table !important; width: 100% !important; break-inside: auto; page-break-inside: auto; }
  .report-body tr { break-inside: avoid; }
  .report-body thead { display: table-header-group; }
  .report-header button, #ai-stock-qa-box { display: none !important; }
}

