/* ===== 宏观页面 - 全屏铺满 ===== */
.macro-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    font-family: -apple-system, "Microsoft YaHei", sans-serif;
    width: 100vw;
    height: 100vh;
}

/* ===== 顶部导航 ===== */
.macro-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    z-index: 10;
    min-height: 56px;
}

.macro-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.macro-brand .logo {
    font-size: 20px;
}
.macro-brand .title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
}
.macro-brand .status {
    font-size: 11px;
    color: #52c41a;
    padding: 2px 10px;
    background: rgba(82, 196, 26, 0.1);
    border-radius: 12px;
}

/* ===== 搜索区域 ===== */
.macro-search-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
    max-width: 650px;
}

.macro-search-box {
    display: flex;
    align-items: center;
    background: #f5f6fa;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 0 12px;
    transition: all 0.3s;
    flex: 1;
    max-width: 320px;
    height: 36px;
}

.macro-search-box:focus-within {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.macro-search-box .search-icon {
    color: #9ca3af;
    font-size: 14px;
    margin-right: 8px;
    flex-shrink: 0;
}

.macro-search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: #1f2937;
    font-size: 14px;
    padding: 8px 0;
    width: 100%;
}

.macro-search-box input::placeholder {
    color: #9ca3af;
}

.search-clear-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
}
.search-clear-btn:hover {
    color: #1f2937;
}

.macro-update-time {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

.macro-refresh-btn {
    padding: 4px 10px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #4b5563;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    height: 34px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.macro-refresh-btn:hover {
    background: #e5e7eb;
}

/* ===== 主体 - 三栏布局 ===== */
.macro-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    padding: 16px 20px 20px 20px;
    gap: 16px;
    background: #f0f2f5;
    min-height: 0;
}

/* ===== 最左侧：AI 分析面板 ===== */
.macro-ai-panel {
    width: 300px;
    min-width: 260px;
    max-width: 360px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px 20px;
    overflow-y: auto;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.macro-ai-panel::-webkit-scrollbar {
    width: 5px;
}
.macro-ai-panel::-webkit-scrollbar-track {
    background: transparent;
}
.macro-ai-panel::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* AI 空状态 */
.macro-ai-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6b7280;
    text-align: center;
}

.macro-ai-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.macro-ai-empty .empty-text {
    font-size: 16px;
    color: #4b5563;
}
.macro-ai-empty .empty-hint {
    font-size: 13px;
    color: #9ca3af;
    margin-top: 4px;
}

/* AI 内容 */
.macro-ai-content {
    display: none;
}
.macro-ai-content.active {
    display: block;
}

.macro-ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 14px;
}

.macro-ai-header .ai-icon {
    font-size: 22px;
}
.macro-ai-header .ai-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
}
.macro-ai-header .ai-badge {
    font-size: 10px;
    background: #3b82f6;
    color: #fff;
    padding: 1px 10px;
    border-radius: 12px;
    margin-left: auto;
}

/* AI 综合评分 */
.macro-ai-score {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f8faff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 14px;
}

.macro-ai-score .score-number {
    font-size: 36px;
    font-weight: 800;
    color: #3b82f6;
    line-height: 1;
}

.macro-ai-score .score-number.good {
    color: #52c41a;
}
.macro-ai-score .score-number.warning {
    color: #f59e0b;
}
.macro-ai-score .score-number.danger {
    color: #ef4444;
}

.macro-ai-score .score-label {
    font-size: 12px;
    color: #6b7280;
}
.macro-ai-score .score-label .sub {
    font-size: 11px;
    color: #9ca3af;
}

/* AI 内容块 */
.macro-ai-block {
    margin-bottom: 12px;
}

.macro-ai-block .block-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.macro-ai-block .block-text {
    font-size: 13px;
    line-height: 1.7;
    color: #374151;
}

.macro-ai-block .block-text .highlight {
    color: #3b82f6;
    font-weight: 600;
}
.macro-ai-block .block-text .positive {
    color: #52c41a;
    font-weight: 600;
}
.macro-ai-block .block-text .negative {
    color: #ef4444;
    font-weight: 600;
}

/* AI 风险标签 */
.macro-ai-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.macro-ai-tag {
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.macro-ai-tag.low {
    background: #dcfce7;
    color: #16a34a;
}
.macro-ai-tag.medium {
    background: #fef3c7;
    color: #d97706;
}
.macro-ai-tag.high {
    background: #fee2e2;
    color: #dc2626;
}

/* ===== 中间：详情面板（大框，自适应） ===== */
.macro-detail-panel {
    flex: 1;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px 24px;
    overflow-y: auto;
    min-width: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.macro-detail-panel::-webkit-scrollbar {
    width: 6px;
}
.macro-detail-panel::-webkit-scrollbar-track {
    background: transparent;
}
.macro-detail-panel::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* ===== 详情空状态 ===== */
.macro-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6b7280;
}

.macro-detail-empty .empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.5;
}
.macro-detail-empty .empty-text {
    font-size: 18px;
    color: #4b5563;
}
.macro-detail-empty .empty-hint {
    font-size: 14px;
    color: #6b7280;
    margin-top: 8px;
}

/* ===== 详情内容 ===== */
.macro-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.macro-detail-country {
    display: flex;
    align-items: center;
    gap: 10px;
}

.macro-detail-flag {
    font-size: 28px;
}

.macro-detail-name {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.macro-detail-code {
    font-size: 12px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 1px 10px;
    border-radius: 10px;
}

.macro-detail-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}
.macro-detail-close:hover {
    color: #1f2937;
}

/* ===== 详情指标网格 ===== */
.macro-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.macro-detail-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
}

.macro-detail-item .label {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.macro-detail-item .value {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.macro-detail-item .value.up {
    color: #52c41a;
}
.macro-detail-item .value.down {
    color: #ef4444;
}

/* ===== 地区标签 ===== */
.macro-detail-regions-title {
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    margin-top: 4px;
}

.macro-detail-regions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.macro-detail-region-tag {
    padding: 3px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 12px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.3s;
}
.macro-detail-region-tag:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #3b82f6;
}

/* ===== 右侧：国家列表（竖长条） ===== */
.macro-cards-area {
    width: 260px;
    min-width: 220px;
    max-width: 320px;
    overflow-y: auto;
    flex-shrink: 0;
    padding-right: 0;
}

.macro-cards-area::-webkit-scrollbar {
    width: 5px;
}
.macro-cards-area::-webkit-scrollbar-track {
    background: transparent;
}
.macro-cards-area::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* ===== 国家列表（竖排） ===== */
.macro-cards-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

/* ===== 单个国家项 ===== */
.macro-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.25s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 46px;
}

.macro-card:hover {
    border-color: #3b82f6;
    background: #f8faff;
    transform: translateX(2px);
}

.macro-card.active {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.12);
}

.macro-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.macro-card-country {
    display: flex;
    align-items: center;
    gap: 8px;
}

.macro-card-flag {
    font-size: 20px;
    line-height: 1;
}

.macro-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.macro-card-code {
    font-size: 10px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 1px 8px;
    border-radius: 10px;
    margin-left: 4px;
}

.macro-card-indicators {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.macro-card-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
}

.macro-card-indicator .label {
    font-size: 9px;
    color: #9ca3af;
    font-weight: 500;
    text-transform: uppercase;
}

.macro-card-indicator .value {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}

.macro-card-indicator .value.up {
    color: #52c41a;
}
.macro-card-indicator .value.down {
    color: #ef4444;
}
.macro-card-indicator .value.flat {
    color: #f59e0b;
}

/* ===== 加载状态 ===== */
.macro-loading-cards {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    color: #6b7280;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

/* ===== 空状态 ===== */
.macro-empty-cards {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    color: #6b7280;
}

.macro-empty-cards .empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}
.macro-empty-cards .empty-text {
    font-size: 14px;
    color: #4b5563;
}
.macro-empty-cards .empty-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

/* ===== 用户信息 ===== */
.macro-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.macro-user-display {
    font-size: 14px;
    color: #1f2937;
    font-weight: 500;
    white-space: nowrap;
}

.macro-logout-btn {
    padding: 6px 14px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    height: 34px;
}
.macro-logout-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ===== 详情 - 6个指标标签 ===== */
.macro-detail-tabs {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.macro-detail-tabs .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    min-height: 48px;
}

.macro-detail-tabs .tab:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.macro-detail-tabs .tab.active {
    background: #eff6ff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.macro-detail-tabs .tab .tab-label {
    font-size: 10px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.macro-detail-tabs .tab .tab-value {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    margin-top: 2px;
}

.macro-detail-tabs .tab.active .tab-label {
    color: #3b82f6;
}

.macro-detail-tabs .tab.active .tab-value {
    color: #1f2937;
}

/* ===== 图表容器 ===== */
.macro-detail-chart-wrapper {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px 8px 14px;
    margin-bottom: 12px;
}

.macro-detail-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 6px;
}

.macro-detail-chart {
    width: 100%;
    height: 200px;
}

/* ===== 关键数据点 ===== */
.macro-detail-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.macro-detail-stats .stat-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 10px;
    text-align: center;
}

.macro-detail-stats .stat-label {
    font-size: 10px;
    color: #6b7280;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.macro-detail-stats .stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    display: block;
    margin-top: 2px;
}

/* ===== AI 分析（原有，保留兼容） ===== */
.macro-detail-ai {
    background: #f0f7ff;
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.macro-detail-ai-header {
    font-size: 13px;
    font-weight: 600;
    color: #3b82f6;
    margin-bottom: 4px;
}

.macro-detail-ai-content {
    font-size: 13px;
    line-height: 1.7;
    color: #374151;
}

/* ===== 地区钻取 ===== */
.macro-detail-regions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.macro-detail-region-tag {
    padding: 3px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 12px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.3s;
}

.macro-detail-region-tag:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #3b82f6;
}

/* ============================================
   响应式
   ============================================ */

/* 大屏适配 */
@media (max-width: 1400px) {
    .macro-ai-panel {
        width: 260px;
        min-width: 220px;
    }
    .macro-cards-area {
        width: 230px;
        min-width: 190px;
    }
}

@media (max-width: 1200px) {
    .macro-ai-panel {
        width: 220px;
        min-width: 180px;
        padding: 14px 16px;
    }
    .macro-cards-area {
        width: 200px;
        min-width: 160px;
    }
    .macro-detail-grid {
        grid-template-columns: 1fr 1fr;
    }
    .macro-detail-tabs {
        grid-template-columns: repeat(3, 1fr);
    }
    .macro-detail-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .macro-ai-score .score-number {
        font-size: 28px;
    }
}

/* 平板及以下：三栏变两栏/一栏 */
@media (max-width: 992px) {
    .macro-body {
        flex-direction: column;
        padding: 12px 14px 14px 14px;
        gap: 12px;
    }

    /* AI 面板移到顶部（横条） */
    .macro-ai-panel {
        width: 100%;
        min-width: unset;
        max-width: 100%;
        height: auto;
        max-height: 180px;
        padding: 14px 18px;
        order: 1;
    }
    .macro-ai-empty {
        flex-direction: row;
        gap: 16px;
        height: auto;
        padding: 8px 0;
    }
    .macro-ai-empty .empty-icon {
        font-size: 32px;
        margin-bottom: 0;
    }
    .macro-ai-score {
        padding: 8px 14px;
    }
    .macro-ai-score .score-number {
        font-size: 28px;
    }

    /* 详情面板中间 */
    .macro-detail-panel {
        flex: none;
        width: 100%;
        height: 360px;
        order: 2;
        padding: 16px 18px;
    }

    /* 国家列表底部（横条） */
    .macro-cards-area {
        width: 100%;
        min-width: unset;
        max-width: 100%;
        max-height: 180px;
        flex-shrink: 0;
        order: 3;
        overflow-y: auto;
    }
    .macro-cards-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }
    .macro-card {
        flex: 1;
        min-width: 100px;
        max-width: 180px;
        min-height: 38px;
        padding: 6px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .macro-card-indicators {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    .macro-search-area {
        max-width: 400px;
    }
    .macro-search-box {
        max-width: 180px;
    }
}

@media (max-width: 768px) {
    .macro-top-bar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 14px;
        min-height: 48px;
    }
    .macro-search-area {
        flex: 1;
        max-width: 100%;
        justify-content: flex-start;
    }
    .macro-search-box {
        max-width: 150px;
        height: 32px;
    }
    .macro-brand .title {
        font-size: 14px;
    }

    .macro-ai-panel {
        max-height: 160px;
        padding: 12px 14px;
    }
    .macro-detail-panel {
        height: 300px;
        padding: 14px 16px;
    }
    .macro-detail-grid {
        grid-template-columns: 1fr 1fr;
    }
    .macro-cards-area {
        max-height: 150px;
    }
    .macro-card {
        min-width: 80px;
        max-width: 140px;
        padding: 4px 10px;
        min-height: 32px;
    }
    .macro-card-name {
        font-size: 12px;
    }
    .macro-card-flag {
        font-size: 16px;
    }
    .macro-card-indicator .value {
        font-size: 11px;
    }
    .macro-card-indicator .label {
        font-size: 8px;
    }
    .macro-detail-tabs {
        grid-template-columns: repeat(3, 1fr);
    }
    .macro-detail-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .macro-detail-chart {
        height: 150px;
    }
}

@media (max-width: 480px) {
    .macro-ai-panel {
        max-height: 140px;
        padding: 10px 12px;
    }
    .macro-ai-score .score-number {
        font-size: 22px;
    }
    .macro-ai-block .block-text {
        font-size: 12px;
    }
    .macro-detail-panel {
        height: 260px;
        padding: 12px 14px;
    }
    .macro-detail-tabs {
        grid-template-columns: repeat(2, 1fr);
    }
    .macro-detail-tabs .tab .tab-value {
        font-size: 14px;
    }
    .macro-detail-chart {
        height: 130px;
    }
    .macro-detail-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .macro-cards-area {
        max-height: 130px;
    }
    .macro-card {
        min-width: 70px;
        max-width: 110px;
        padding: 3px 8px;
        min-height: 28px;
    }
    .macro-card-name {
        font-size: 11px;
    }
    .macro-card-flag {
        font-size: 14px;
    }
}