/* ==========================================
   PANCHARM - Premium CSS Design System
   ========================================== */

/* Design Tokens & Custom Variables */
:root {
    --primary-color: #A9604B;
    --primary-dark: #8C4D3B;
    --primary-light: #C2826F;
    --secondary-color: #EEDFD6;
    --bg-color: #FBF7F4;
    --card-bg: #FFFFFF;
    --text-primary: #3D2620;
    --text-secondary: #836E69;
    --text-light: #A5928C;
    --border-color: #EADCD3;
    --border-light: #F3EAE3;
    
    /* Box Shadows */
    --shadow-sm: 0 2px 8px rgba(61, 38, 32, 0.04);
    --shadow-md: 0 8px 24px rgba(61, 38, 32, 0.06);
    --shadow-lg: 0 16px 40px rgba(61, 38, 32, 0.1);
    --shadow-primary: 0 8px 20px rgba(169, 96, 75, 0.2);
    
    /* Border Radii */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    /* Element Colors (Ngũ Hành) */
    --el-kim: #B57C1E; /* Gold/Metallic (contrast adjusted) */
    --el-kim-bg: rgba(240, 173, 78, 0.12);
    --el-kim-border: rgba(240, 173, 78, 0.25);
    
    --el-thuy: #2A6496; /* Water Blue (contrast adjusted) */
    --el-thuy-bg: rgba(51, 122, 183, 0.12);
    --el-thuy-border: rgba(51, 122, 183, 0.25);
    
    --el-moc: #508620; /* Wood Green (contrast adjusted) */
    --el-moc-bg: rgba(124, 179, 66, 0.12);
    --el-moc-border: rgba(124, 179, 66, 0.25);
    
    --el-hoa: #BD362F; /* Fire Red (contrast adjusted) */
    --el-hoa-bg: rgba(217, 83, 79, 0.12);
    --el-hoa-border: rgba(217, 83, 79, 0.25);
    
    --el-tho: #4A201B; /* Earth Brown */
    --el-tho-bg: rgba(74, 32, 27, 0.08);
    --el-tho-border: rgba(74, 32, 27, 0.2);
}

/* Base resets & typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.85rem;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    background-image: 
        radial-gradient(var(--border-color) 0.5px, transparent 0.5px), 
        radial-gradient(var(--border-color) 0.5px, var(--bg-color) 0.5px);
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
}

/* Layout */
.app-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}
.app-header.header-hidden {
    transform: translateY(-100%);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    width: 48px;
    height: 48px;
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.brand-text h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--primary-color);
}

.brand-text p {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 500;
}

.header-badge {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--card-bg);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    letter-spacing: 1.5px;
    box-shadow: var(--shadow-primary);
}

.app-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Premium Card Styles */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2.2rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding-bottom: 1.2rem;
    margin-bottom: 1.8rem;
}

.card-header h2 {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 1.4rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.card-header p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Forms styling */
.bazi-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-primary);
}

input, select, textarea {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(169, 96, 75, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    gap: 0.8rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #ffffff;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(169, 96, 75, 0.35);
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--card-bg);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-secondary:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
}

.btn-loader {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top: 2.5px solid #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.btn-secondary .btn-loader {
    border: 2.5px solid rgba(169, 96, 75, 0.3);
    border-top: 2.5px solid var(--primary-color);
}

.hidden {
    display: none !important;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Timeline Process */
.timeline-card h3 {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.timeline-steps {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    position: relative;
}

.timeline-steps::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background-color: var(--border-color);
    z-index: 1;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 1.2rem;
    position: relative;
    z-index: 2;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.step-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.step-desc h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.step-desc p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Step States */
.step.active {
    opacity: 1;
}

.step.active .step-icon {
    border-color: var(--primary-color);
    background-color: var(--secondary-color);
    color: var(--primary-color);
    box-shadow: 0 0 10px rgba(169, 96, 75, 0.2);
    animation: pulseGlow 1.8s infinite alternate;
}

.step.completed {
    opacity: 1;
}

.step.completed .step-icon {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
    color: #ffffff;
}

@keyframes pulseGlow {
    0% { transform: scale(1); box-shadow: 0 0 0 0px rgba(169, 96, 75, 0.4); }
    100% { transform: scale(1.05); box-shadow: 0 0 12px 4px rgba(169, 96, 75, 0.15); }
}

/* Bazi Grid & Table */
.bazi-chart-card {
    border-left: 5px solid var(--primary-color);
}

.badge {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.bazi-grid-container {
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--card-bg);
}

.bazi-grid-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
    text-align: center;
    table-layout: fixed;
}

.bazi-grid-table th, .bazi-grid-table td {
    padding: 1rem;
    border: 1px solid var(--border-color);
    font-size: 0.95rem;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.bazi-grid-table th {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.bazi-grid-table th:first-child,
.bazi-grid-table td:first-child {
    width: 160px;
}

.bazi-grid-table th:not(:first-child) {
    width: calc((100% - 160px) / 4);
}

.bazi-grid-table tbody tr td:first-child {
    background-color: var(--bg-color);
    font-weight: 600;
    text-align: left;
}

/* Specific Cell Highlights */
.highlight-nhat-chu {
    border: 2.5px solid var(--primary-color) !important;
    position: relative;
}

.highlight-nhat-chu::after {
    content: 'Nhật Chủ';
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: var(--primary-color);
    color: #ffffff;
    font-size: 0.85rem;
    padding: 1px 4px;
    font-weight: 700;
    border-bottom-left-radius: 4px;
}

.highlight-nguyet-lenh {
    border: 2px dashed var(--primary-color) !important;
}

/* Element color tags */
.el-tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
    margin: 0.1rem;
}

.el-tag.moc { color: var(--el-moc); background-color: var(--el-moc-bg); border: 1px solid var(--el-moc-border); }
.el-tag.hoa { color: var(--el-hoa); background-color: var(--el-hoa-bg); border: 1px solid var(--el-hoa-border); }
.el-tag.tho { color: var(--el-tho); background-color: var(--el-tho-bg); border: 1px solid var(--el-tho-border); }
.el-tag.kim { color: var(--el-kim); background-color: var(--el-kim-bg); border: 1px solid var(--el-kim-border); }
.el-tag.thuy { color: var(--el-thuy); background-color: var(--el-thuy-bg); border: 1px solid var(--el-thuy-border); }

/* Auxiliary Info Grid */
.aux-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
    margin-top: 1.5rem;
    background-color: var(--bg-color);
    padding: 1.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.aux-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.aux-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.aux-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Report Sections */
.report-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.report-card-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-bottom: 0.8rem;
    margin-bottom: 1.2rem;
}

.report-card-header h3 {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 1.4rem;
    color: var(--primary-color);
    margin: 0;
}

.report-card h3 {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
}

.highlight-box {
    border: 1.5px solid var(--primary-color);
    background-color: #FAF4F1;
}

.report-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.7;
}

/* Markdown Styling */
.markdown-body {
    font-size: 0.95rem;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    font-family: 'Be Vietnam Pro', sans-serif;
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    font-weight: 600;
}
.markdown-body h1 { font-size: 1.4rem; padding-bottom: 0.4rem; }
.markdown-body h2 { font-size: 1.4rem; }
.markdown-body h3 { font-size: 0.95rem; }
.markdown-body p { margin-bottom: 1rem; }
.markdown-body ul, .markdown-body ol { margin-left: 1.5rem; margin-bottom: 1rem; }
.markdown-body li { margin-bottom: 0.4rem; }
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}
.markdown-body th, .markdown-body td {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    text-align: left;
}
.markdown-body th { background-color: var(--bg-color); font-weight: 600; }
.markdown-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
    background-color: var(--bg-color);
}

/* Element layout */
.element-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-start;
}

.mermaid-container {
    flex: 1 1 350px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 2rem;
    background: transparent;
    padding: 0;
    border: none;
}

.chart-wrapper {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.chart-title {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.35rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mermaid-chart {
    width: 100%;
    max-width: 375px;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0.25rem auto !important;
}

.mermaid-chart svg path.slice {
    stroke: #ffffff !important;
    stroke-width: 1.5px !important;
}

.mermaid-chart svg {
    display: block;
    margin: 0 auto !important;
    width: 100% !important;
    height: 100% !important;
}

.mermaid-chart svg text {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    fill: #ffffff !important;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
    margin-top: 0.3rem;
    width: 100%;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.legend-color {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Hide default Mermaid pie chart legend and title to use custom layout */
.mermaid-chart svg .legend,
.mermaid svg .legend,
svg .legend,
g.legend {
    display: none !important;
}
.mermaid-chart svg text.title,
.mermaid svg text.title,
svg text.title {
    display: none !important;
}

.element-layout .report-content {
    flex: 2 1 500px;
}

/* Deep Analysis Card */
.deep-analysis-card {
    background: linear-gradient(135deg, var(--card-bg), #FAF7F5);
    border: 2px solid var(--primary-color);
    position: relative;
}

.deep-analysis-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--primary-color));
}

.deep-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin-top: 1.5rem;
}

.deep-btn {
    flex: 1 1 280px;
    font-size: 0.95rem;
    padding: 1.2rem 1.5rem;
    line-height: 1.4;
}

.deep-results-container {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.deep-result-card {
    border: 1.5px solid var(--primary-color);
    background-color: var(--card-bg);
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.deep-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.8rem;
    margin-bottom: 1.5rem;
}

.deep-result-header h3 {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 1.4rem;
    color: var(--primary-color);
    margin: 0;
}

.btn-close {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

/* Footer */
.app-footer {
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }
    .header-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .logo-area {
        flex-direction: column;
        gap: 0.5rem;
    }
    .card {
        padding: 1.5rem;
    }
    .btn {
        width: 100%;
    }
    .deep-btn {
        flex: 1 1 100%;
    }
    .timeline-steps::before {
        left: 15px;
    }
    .step-icon {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
    .aux-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .aux-grid {
        grid-template-columns: 1fr;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Custom Flatpickr Styling to match Premium Design system */
.flatpickr-calendar {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: var(--radius-sm) !important;
    font-family: inherit !important;
}
.flatpickr-day.selected, 
.flatpickr-day.selected:hover, 
.flatpickr-day.selected:focus {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}
.flatpickr-months .flatpickr-month {
    color: var(--text-primary) !important;
    fill: var(--text-primary) !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
    font-weight: 600 !important;
}
.flatpickr-day:hover {
    background: var(--secondary-color) !important;
    color: var(--primary-color) !important;
}
.flatpickr-weekday {
    color: var(--text-secondary) !important;
    font-weight: 600 !important;
}

/* ==========================================
   Dynamic Energy Analysis CSS styling
   ========================================== */
.dynamic-config-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.dynamic-select-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1 1 300px;
}

.dynamic-select-group select {
    width: 100%;
    background-color: var(--card-bg);
}

#btnRunDynamic {
    flex: 0 1 250px;
    height: 48px;
    white-space: nowrap;
}

.dynamic-layout {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    animation: fadeIn 0.5s ease forwards;
}

.dynamic-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 2.5rem;
}

.dynamic-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.line-chart-container {
    width: 100%;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.svg-chart-wrapper {
    width: 100%;
    max-width: 700px;
    height: 320px;
    margin: 1rem auto;
}

.pie-chart-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.elements-pie-section {
    align-items: center;
}

.elements-pie-section .report-content {
    width: 100%;
}

.chart-tooltip div {
    line-height: 1.4;
}

/* Line Chart Point Anim on Hover */
.chart-point {
    transition: r 0.2s ease, stroke-width 0.2s ease;
}

@media (max-width: 768px) {
    .dynamic-config-bar {
        flex-direction: column;
        align-items: stretch;
    }
    #btnRunDynamic {
        flex: 1 1 auto;
        width: 100%;
    }
    .svg-chart-wrapper {
        height: auto !important;
        aspect-ratio: 2/1 !important;
        max-width: 100% !important;
        margin: 0.15rem auto !important;
    }
    .mermaid-chart {
        height: auto !important;
        aspect-ratio: 1 !important;
        max-width: min(100%, 320px) !important;
        margin: 0.15rem auto !important;
    }
    .legend-item {
        font-size: 0.68rem !important;
    }
    .chart-legend {
        gap: 0.4rem !important;
        margin-top: 0.08rem !important;
    }
    .chart-inner-wrapper {
        justify-content: flex-start !important;
        padding: 0.25rem !important;
        gap: 0 !important;
    }
    .form-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Unified Grid Comparison Layout */
.comparison-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.three-chart-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.dynamic-only {
    display: none;
}

.dynamic-active .dynamic-only {
    display: block;
}

.comp-col {
    width: 100%;
}

@media (min-width: 992px) {
    .dynamic-active .comparison-row {
        grid-template-columns: 1fr 1fr;
        gap: 2.5rem;
    }
    
    .three-chart-row {
        grid-template-columns: 1fr 1fr; /* Ngũ hành tương quan & Ngũ hành dụng cục */
        gap: 2rem;
    }
    
    .dynamic-active .three-chart-row {
        grid-template-columns: 1fr 1fr 1fr; /* 3 columns for all 3 charts */
        gap: 2rem;
    }
}

/* Merged Chart Card Styles */
.merged-chart-card {
    margin-bottom: 2.5rem !important;
    padding: 2.2rem;
}

.merged-chart-card .comparison-row {
    margin-bottom: 0 !important;
}

.chart-titles-row {
    margin-bottom: 0.5rem !important;
}

.chart-titles-row .chart-title {
    margin-bottom: 0;
}

.chart-body-row .chart-inner-wrapper {
    padding-top: 0;
}

.chart-inner-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

@media (min-width: 992px) {
    .dynamic-active .merged-chart-card .chart-body-row {
        align-items: center;
    }
    .chart-body-row .chart-inner-wrapper {
        justify-content: flex-start;
    }
    .chart-body-row .chart-title {
        min-height: 2.6em;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .chart-body-row .chart-inner-wrapper .chart-legend {
        margin-top: auto;
    }
}

/* Custom Header Hierarchy Sync */
#card-brief-analysis .report-card-header h3 {
    font-size: 1.4rem !important;
    font-weight: 700 !important;
}

#card-dynamic-analysis .markdown-body h2,
#card-dynamic-analysis .markdown-body h3,
#card-dynamic-analysis .chart-title {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
}


/* ==========================================
   NAVIGATION TABS STYLING
   ========================================== */
.tabs-nav {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    margin-bottom: 2rem;
    padding: 0.8rem;
    background: rgba(61, 38, 32, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.tab-btn {
    padding: 0.8rem 2rem;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
}
.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(61, 38, 32, 0.03);
}
.tab-btn.active {
    color: #ffffff;
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}
.tab-content.hidden {
    display: none !important;
}
@media (max-width: 768px) {
    .tabs-nav {
        flex-wrap: wrap;
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }
    .tab-btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.78rem !important;
        flex: 1 1 calc(50% - 0.5rem);
        text-align: center;
        white-space: normal;
        line-height: 1.3;
    }
}

/* ==========================================
   COMPATIBILITY (HỢP HÔN) STYLING
   ========================================== */
.compat-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.compat-partner-card {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.compat-partner-card h3 {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.partner-form-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.partner-form-inputs .form-group:first-child,
.partner-form-inputs .form-group:nth-child(3) {
    grid-column: span 2;
}

.dual-bazi-grids {
    display: grid;
    grid-template-columns: 1fr; /* Stacks vertically to provide full width, eliminating squishing and horizontal scrollbars */
    gap: 2.5rem;
    margin-bottom: 2rem;
}

.compat-grid-card {
    border-left: 5px solid var(--primary-color);
}

.compat-table th, .compat-table td {
    padding: 0.8rem;
    font-size: 0.85rem;
}

.compat-table th:first-child,
.compat-table td:first-child {
    width: 140px;
}

.compat-table th:not(:first-child) {
    width: calc((100% - 140px) / 4);
}

.compat-aux-grid {
    grid-template-columns: repeat(2, 1fr);
    font-size: 0.95rem;
    padding: 0.8rem;
    gap: 0.8rem;
}

.triple-charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.compat-chart-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    box-shadow: var(--shadow-sm);
}

.compat-pie {
    height: 250px !important;
}

.compat-jewelry-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2rem;
    margin-top: 1rem;
    width: 100%;
}

.compat-jewelry-chart-col {
    flex: 1 1 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.compat-jewelry-text-col {
    flex: 1 1 100%;
    width: 100%;
}

.compat-jewelry-pie {
    height: 375px !important;
    max-width: 560px !important;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem auto !important;
}

@media (max-width: 992px) {
    .dual-bazi-grids {
        grid-template-columns: 1fr;
    }
    .triple-charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .compat-pie {
        height: auto !important;
        aspect-ratio: 1 !important;
        max-width: min(100%, 320px) !important;
        margin: 0.15rem auto !important;
    }
    .compat-jewelry-pie {
        height: auto !important;
        aspect-ratio: 1 !important;
        max-width: min(100%, 320px) !important;
        margin: 0.15rem auto !important;
    }
    .compat-form-grid {
        grid-template-columns: 1fr;
    }
    .partner-form-inputs {
        grid-template-columns: 1fr;
    }
    .partner-form-inputs .form-group:first-child,
    .partner-form-inputs .form-group:nth-child(3) {
        grid-column: span 1;
    }
    .compat-jewelry-layout {
        flex-direction: column;
        align-items: stretch;
    }
    .compat-jewelry-chart-col {
        flex: 1 1 auto;
    }
}

.compat-jewelry-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    width: 100%;
}

@media (max-width: 576px) {
    .compat-jewelry-charts-grid {
        grid-template-columns: 1fr;
    }
}

/* Barriers Grid for Child Tab */
.barriers-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
    max-width: 1000px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .barriers-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Premium Sales Highlights for High Conversion */
.sales-highlight {
    background: linear-gradient(135deg, rgba(169, 96, 75, 0.08) 0%, rgba(181, 124, 30, 0.08) 100%);
    border: 1.5px solid rgba(169, 96, 75, 0.25);
    color: var(--primary-color);
    font-weight: 700;
    font-style: italic;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(169, 96, 75, 0.06);
    display: inline-block;
    margin: 0.2rem 0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.sales-highlight:hover {
    background: linear-gradient(135deg, rgba(169, 96, 75, 0.15) 0%, rgba(181, 124, 30, 0.15) 100%);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(169, 96, 75, 0.15);
    transform: translateY(-1px);
}


/* ==========================================
   GEMINI AI CHAT WIDGET
   ========================================== */

/* ── Floating Action Button ── */
.ai-chat-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 22px;
    background: linear-gradient(135deg, #A9604B 0%, #C2826F 60%, #B57C1E 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 28px rgba(169, 96, 75, 0.45), 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
    animation: fabPulse 2.8s ease-in-out infinite;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
}
.ai-chat-fab.ai-chat-fab--visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.ai-chat-fab:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 10px 36px rgba(169, 96, 75, 0.55), 0 4px 12px rgba(0,0,0,0.18);
    animation: none;
}
.ai-chat-fab__icon {
    font-size: 1.1rem;
    line-height: 1;
}
@keyframes fabPulse {
    0%, 100% { box-shadow: 0 6px 28px rgba(169, 96, 75, 0.45), 0 2px 8px rgba(0,0,0,0.15); }
    50%       { box-shadow: 0 6px 36px rgba(169, 96, 75, 0.7),  0 2px 8px rgba(0,0,0,0.15); }
}

/* ── Overlay ── */
.ai-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(61, 38, 32, 0.35);
    backdrop-filter: blur(3px);
    z-index: 9001;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.ai-chat-overlay.ai-chat-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Chat Panel ── */
.ai-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(420px, 100vw);
    z-index: 9002;
    display: flex;
    flex-direction: column;
    background: #FBF7F4;
    border-left: 1px solid #EADCD3;
    box-shadow: -8px 0 40px rgba(61, 38, 32, 0.14);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-chat-panel.ai-chat-panel--open {
    transform: translateX(0);
}

/* ── Header ── */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, #A9604B 0%, #B57C1E 100%);
    flex-shrink: 0;
}
.ai-chat-header__left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ai-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.ai-chat-title {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.ai-chat-subtitle {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.75);
    margin-top: 1px;
}
.ai-chat-close {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 1;
}
.ai-chat-close:hover {
    background: rgba(255,255,255,0.28);
}

/* ── Messages ── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: #EADCD3; border-radius: 4px; }

/* ── Message Bubbles ── */
.ai-msg {
    display: flex;
    max-width: 100%;
}
.ai-msg--user {
    justify-content: flex-end;
}
.ai-msg--model {
    justify-content: flex-start;
}
.ai-msg__bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.875rem;
    line-height: 1.6;
    word-break: break-word;
}
.ai-msg--user .ai-msg__bubble {
    background: linear-gradient(135deg, #A9604B, #C2826F);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg--model .ai-msg__bubble {
    background: #fff;
    color: #3D2620;
    border: 1px solid #EADCD3;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(61,38,32,0.05);
}
.ai-msg--model .ai-msg__bubble p { margin: 0 0 6px; }
.ai-msg--model .ai-msg__bubble p:last-child { margin-bottom: 0; }
.ai-msg--model .ai-msg__bubble strong { color: #A9604B; }
.ai-msg--model .ai-msg__bubble ul, .ai-msg--model .ai-msg__bubble ol { padding-left: 18px; margin: 4px 0; }
.ai-msg--model .ai-msg__bubble h1,
.ai-msg--model .ai-msg__bubble h2,
.ai-msg--model .ai-msg__bubble h3 {
    font-size: 0.9rem;
    color: #A9604B;
    margin: 8px 0 4px;
}

/* ── Typing Indicator ── */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}
.ai-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #C2826F;
    animation: typingBounce 1.2s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Input Row ── */
.ai-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #EADCD3;
    background: #fff;
    flex-shrink: 0;
}
.ai-chat-input {
    flex: 1;
    border: 1.5px solid #EADCD3;
    border-radius: 12px;
    padding: 10px 14px;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.875rem;
    color: #3D2620;
    background: #FBF7F4;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 42px;
    line-height: 1.5;
    transition: border-color 0.2s;
}
.ai-chat-input:focus {
    border-color: #A9604B;
    background: #fff;
}
.ai-chat-input::placeholder { color: #A5928C; }
.ai-chat-send-btn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #A9604B, #C2826F);
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 12px rgba(169,96,75,0.3);
}
.ai-chat-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(169,96,75,0.4);
}
.ai-chat-send-btn:active { transform: scale(0.96); }
.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Responsive (mobile) ── */
@media (max-width: 480px) {
    .ai-chat-fab {
        bottom: 18px;
        right: 14px;
        padding: 11px 16px;
        font-size: 0.82rem;
    }
    .ai-chat-panel {
        width: 100vw;
        border-left: none;
    }
}

/* ==========================================
   AUTH SYSTEM STYLES
   ========================================== */

/* ── Header right area ── */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ── Round auth pill button ── */
.auth-pill-wrap {
    position: relative;
}

.auth-pill-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #A9604B, #C2826F);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 3px 10px rgba(169,96,75,0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}
.auth-pill-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 16px rgba(169,96,75,0.45);
}
.auth-pill-btn.auth-pill-btn--loggedin {
    background: linear-gradient(135deg, #A9604B, #B57C1E);
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'Be Vietnam Pro', sans-serif;
    color: #fff;
    letter-spacing: 0;
}

/* ── Dropdown ── */
.auth-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 210px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(61,38,32,0.15), 0 2px 8px rgba(61,38,32,0.08);
    border: 1px solid var(--border-color);
    padding: 8px;
    z-index: 9100;
    transform-origin: top right;
    transform: scale(0.92) translateY(-4px);
    opacity: 0;
    transition: transform 0.18s cubic-bezier(0.4,0,0.2,1), opacity 0.18s;
    pointer-events: none;
}
.auth-dropdown.auth-dropdown--open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.auth-dd-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 4px 8px 6px;
}

.auth-dd-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 8px;
}
.auth-dd-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #A9604B, #C2826F);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    font-family: 'Be Vietnam Pro', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.auth-dd-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.auth-dd-role {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 1px;
}

.auth-dd-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

.auth-dd-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 8px;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}
.auth-dd-item:hover { background: var(--bg-color); }
.auth-dd-item--primary {
    background: linear-gradient(135deg, #A9604B, #C2826F);
    color: #fff;
    font-weight: 700;
    margin-bottom: 2px;
}
.auth-dd-item--primary:hover { opacity: 0.9; background: linear-gradient(135deg, #A9604B, #C2826F); }
.auth-dd-item--danger { color: var(--el-hoa); }
.auth-dd-item--danger:hover { background: var(--el-hoa-bg); }

/* ── Login Wall ── */
.auth-login-wall {
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: linear-gradient(135deg, rgba(251,247,244,0.97) 0%, rgba(238,223,214,0.97) 100%);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-wall-box {
    text-align: center;
    padding: 3rem 2.5rem;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-width: 380px;
    width: 90%;
}
.auth-wall-icon { font-size: 3rem; margin-bottom: 1rem; }
.auth-wall-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}
.auth-wall-sub {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}
.auth-wall-btn {
    padding: 12px 28px;
    background: linear-gradient(135deg, #A9604B, #C2826F);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(169,96,75,0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}
.auth-wall-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(169,96,75,0.45); }

/* ── Modal overlay ── */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(61,38,32,0.45);
    backdrop-filter: blur(4px);
    z-index: 8500;
}

/* ── Modal box ── */
.auth-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%) scale(0.96);
    z-index: 8600;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(61,38,32,0.18);
    padding: 2rem 2rem 1.5rem;
    width: min(420px, 94vw);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1), opacity 0.28s;
    opacity: 0;
    pointer-events: none;
}
.auth-modal.auth-modal--open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}
.admin-panel-modal { width: min(700px, 96vw); }

.auth-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}
.auth-modal-close:hover { background: var(--border-light); color: var(--text-primary); }

.auth-modal-logo {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.2rem;
}

/* ── Tabs ── */
.auth-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.2rem;
}
.auth-tab {
    flex: 1;
    padding: 8px 0;
    background: none;
    border: none;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.auth-tab--active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* ── Form fields ── */
.auth-field {
    margin-bottom: 0.9rem;
}
.auth-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.auth-field input {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-color);
    outline: none;
    transition: border-color 0.2s;
}
.auth-field input:focus { border-color: var(--primary-color); background: #fff; }
.auth-req { color: var(--el-hoa); }

.auth-submit-btn {
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, #A9604B, #C2826F);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 0.4rem;
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 4px 14px rgba(169,96,75,0.3);
}
.auth-submit-btn:hover { opacity: 0.92; transform: translateY(-1px); }
.auth-submit-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.auth-note {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    margin-top: 0.75rem;
    line-height: 1.5;
}

/* ── Messages ── */
.auth-message {
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.8rem;
    line-height: 1.5;
}
.auth-message--error { background: var(--el-hoa-bg); color: var(--el-hoa); border: 1px solid var(--el-hoa-border); }
.auth-message--success { background: rgba(80,134,32,0.1); color: #508620; border: 1px solid rgba(80,134,32,0.25); }

/* ── Admin table ── */
.admin-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 1rem;
}
.admin-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.admin-table th {
    background: var(--bg-color);
    color: var(--text-secondary);
    font-weight: 700;
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.admin-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(169,96,75,0.03); }

.admin-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}
.admin-badge--pending  { background: rgba(181,124,30,0.12); color: #B57C1E; }
.admin-badge--approved { background: rgba(80,134,32,0.12); color: #508620; }
.admin-badge--rejected { background: var(--el-hoa-bg); color: var(--el-hoa); }

.admin-action-btn {
    padding: 3px 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    margin-right: 4px;
    transition: opacity 0.15s;
}
.admin-action-btn:hover { opacity: 0.8; }
.admin-action-btn--approve { background: rgba(80,134,32,0.12); color: #508620; }
.admin-action-btn--reject  { background: var(--el-hoa-bg); color: var(--el-hoa); }

.admin-refresh-btn {
    padding: 5px 14px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s;
}
.admin-refresh-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* ── Locked state ── */
.auth-locked { pointer-events: none; opacity: 0.3; user-select: none; }

/* ── Ngũ Hành Đối Ứng Help Button & Modal ── */
.info-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: transparent;
    color: rgba(169, 96, 75, 0.6);
    border: 1px solid rgba(169, 96, 75, 0.5);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    margin-left: 6px;
    margin-right: 0;
    vertical-align: middle;
    transition: transform 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
    opacity: 0.65;
    padding: 0;
    line-height: 1;
    box-shadow: none;
}
.info-help-btn:hover {
    transform: scale(1.15);
    color: var(--primary-color, #A9604B);
    border-color: var(--primary-color, #A9604B);
    opacity: 1;
}

.info-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(61, 38, 32, 0.45);
    backdrop-filter: blur(4px);
    z-index: 9500;
    opacity: 1;
    transition: opacity 0.3s ease;
}
.info-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.info-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(540px, 92vw);
    background-color: #FBF7F4;
    border: 1px solid #EADCD3;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(61, 38, 32, 0.2);
    z-index: 9501;
    padding: 2.2rem 2rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}
.info-modal.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -46%) scale(0.96);
}

.info-modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #A5928C;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s, transform 0.15s;
}
.info-modal-close:hover {
    color: var(--primary-color, #A9604B);
    transform: scale(1.1);
}

.info-modal-header h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary-dark, #3D2620);
    letter-spacing: 0.5px;
    margin: 0;
    text-align: center;
    border-bottom: 2px solid #EADCD3;
    padding-bottom: 12px;
}

.info-modal-body {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #3D2620;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.info-modal-body p {
    margin: 0;
}
.info-modal-body strong {
    color: var(--primary-color, #A9604B);
}

.info-case-box {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
}

.case-item {
    padding: 1rem 1.2rem;
    border-radius: 10px;
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(61, 38, 32, 0.03);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.case-item p {
    font-size: 0.82rem;
    line-height: 1.5;
    color: #5C4A44;
    margin: 0;
}

.border-vuong {
    border-left: 4px solid #508620;
    background-color: rgba(80, 134, 32, 0.02);
}
.border-nhuoc {
    border-left: 4px solid #A9604B;
    background-color: rgba(169, 96, 75, 0.02);
}

.case-badge {
    align-self: flex-start;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-vuong {
    background-color: rgba(80, 134, 32, 0.12);
    color: #508620;
}
.badge-nhuoc {
    background-color: rgba(169, 96, 75, 0.12);
    color: #A9604B;
}

.info-modal-footer {
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}

.info-modal-btn {
    padding: 10px 32px;
    background: linear-gradient(135deg, #A9604B, #C2826F);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(169, 96, 75, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}
.info-modal-btn:hover {
    transform: translateY(-1.5px);
    box-shadow: 0 6px 20px rgba(169, 96, 75, 0.45);
}
.info-modal-btn:active {
    transform: translateY(0);
}

/* ==========================================
   LỤC TỰ HOUR SELECTION MATRIX
   ========================================== */
.matrix-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.matrix-column {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(169, 96, 75, 0.15);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s ease;
}

.matrix-column:hover {
    border-color: rgba(169, 96, 75, 0.3);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.group-header {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(169, 96, 75, 0.3);
}

#matrix-group-1 .group-header {
    color: #4caf50;
    border-bottom-color: rgba(76, 175, 80, 0.3);
}

#matrix-group-2 .group-header {
    color: #ff9800;
    border-bottom-color: rgba(255, 152, 0, 0.3);
}

#matrix-group-3 .group-header {
    color: #f44336;
    border-bottom-color: rgba(244, 67, 54, 0.3);
}

.group-desc {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-secondary);
    min-height: 50px;
}

.group-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-matrix {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-matrix:hover {
    background: rgba(169, 96, 75, 0.15);
    border-color: rgba(169, 96, 75, 0.4);
    transform: translateY(-1.5px);
}

.btn-matrix.active {
    background: linear-gradient(135deg, #A9604B, #C2826F) !important;
    border-color: #A9604B !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(169, 96, 75, 0.3);
}

@media (max-width: 992px) {
    .matrix-grid {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }
}

/* Custom styling mappings for Lục Tự */
#luctu-btnRunDynamic {
    flex: 0 1 250px;
    height: 48px;
    white-space: nowrap;
}
@media (max-width: 768px) {
    #luctu-btnRunDynamic {
        flex: 1 1 auto;
        width: 100%;
    }
}

#luctu-card-brief-analysis .report-card-header h3 {
    font-size: 1.4rem !important;
    font-weight: 700 !important;
}

#luctu-card-dynamic-analysis .markdown-body h2,
#luctu-card-dynamic-analysis .markdown-body h3,
#luctu-card-dynamic-analysis .chart-title {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
}

/* Mobile responsive full-width Bazi table fit (No horizontal scrolling) */
@media (max-width: 768px) {
    .bazi-grid-container {
        overflow-x: visible !important;
        border: none !important;
        margin: 1rem 0 !important;
    }
    
    .bazi-grid-table, .compat-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed !important;
        font-size: 0.6rem !important;
    }

    .bazi-grid-table th, .bazi-grid-table td,
    .compat-table th, .compat-table td {
        padding: 0.35rem 0.12rem !important;
        font-size: 0.58rem !important;
        line-height: 1.25 !important;
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
    }
    
    .bazi-grid-table th:first-child,
    .bazi-grid-table td:first-child,
    .compat-table th:first-child,
    .compat-table td:first-child {
        width: 72px !important; /* Fixed width for label column */
    }
    
    .bazi-grid-table th:not(:first-child),
    .bazi-grid-table td:not(:first-child),
    .compat-table th:not(:first-child),
    .compat-table td:not(:first-child) {
        width: calc((100% - 72px) / 4) !important; /* Equal widths for remaining 4 columns */
    }
    
    .bazi-grid-table .el-tag,
    .compat-table .el-tag {
        font-size: 0.58rem !important;
        padding: 1px 3px !important;
        margin: 1px !important;
        line-height: 1.2 !important;
    }

    .bazi-grid-table .badge,
    .compat-table .badge {
        font-size: 0.58rem !important;
        padding: 0.1rem 0.35rem !important;
        line-height: 1.2 !important;
    }
    
    .highlight-nhat-chu::after {
        font-size: 0.5rem !important;
        padding: 0px 2px !important;
        content: 'NC' !important; /* Shorten 'Nhật Chủ' to 'NC' to fit on mobile */
        top: -1px !important;
        right: -1px !important;
    }
}

/* Label abbreviation: show full on desktop, short on mobile */
.label-short { display: none; }
.stars-short  { display: none; }

@media (max-width: 768px) {
    .label-full  { display: none; }
    .label-short { display: inline; }
    .stars-full  { display: none; }
    .stars-short { display: inline; }

    .chart-title {
        font-size: 0.57rem !important;
        margin-bottom: 0.2rem !important;
    }
}

