/* ==========================================
   DESIGN SYSTEM & VARIABLES (LIGHT MODE)
   ========================================== */
:root {
    --bg-primary: #f8fafc;          /* Slate 50 */
    --bg-gradient-end: #f1f5f9;     /* Slate 100 */
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(248, 250, 252, 0.95);
    --border-color: rgba(15, 23, 42, 0.08); /* Slate 900 border with low opacity */
    --border-active: rgba(16, 185, 129, 0.8);
    
    /* Brand Colors */
    --color-primary: #2563eb;       /* Royal Blue */
    --color-primary-glow: rgba(37, 99, 235, 0.15);
    --color-success: #10b981;       /* Emerald Green */
    --color-success-glow: rgba(16, 185, 129, 0.15);
    --color-warning: #ea580c;       /* Orange-Red */
    --color-danger: #e11d48;        /* Rose-Red */
    
    /* Text Colors */
    --text-main: #0f172a;           /* Slate 900 */
    --text-muted: #475569;          /* Slate 600 */
    --text-light: #64748b;          /* Slate 500 */
    
    /* Layout */
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-heading: 'Outfit', 'Prompt', sans-serif;
    --font-body: 'Prompt', sans-serif;
}

/* ==========================================
   BASE STYLES & RESET
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: linear-gradient(185deg, var(--bg-primary) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Background glows for premium visual design */
/* position: fixed เพื่อไม่ให้วงแสงที่ยื่นออกนอกจอทำให้หน้าเว็บบนมือถือกว้างเกินจอ */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(160px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.3;
}

.bg-glow-1 {
    background: radial-gradient(circle, #bfdbfe 0%, transparent 70%); /* Light blue glow */
    top: -100px;
    right: -100px;
}

.bg-glow-2 {
    background: radial-gradient(circle, #a7f3d0 0%, transparent 70%); /* Light emerald glow */
    bottom: -100px;
    left: -100px;
}

/* ==========================================
   LAYOUT CONTAINERS
   ========================================== */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0 25px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 22px;
    color: var(--text-main);
}

.logo-text span {
    color: var(--color-success);
}

/* ==========================================
   WIDGETS & COMPONENT BASES
   ========================================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 30px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.04);
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: rgba(15, 23, 42, 0.15);
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.08);
}

.text-center {
    text-align: center;
}

/* ==========================================
   BUTTON SYSTEM
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    outline: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-success) 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.btn-secondary:hover:not(:disabled) {
    background: #f1f5f9;
    color: var(--text-main);
    border-color: rgba(15, 23, 42, 0.2);
}

.btn-accent {
    background: linear-gradient(135deg, var(--color-primary) 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-accent:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
}

.btn-icon-text {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--border-radius-md);
    padding: 8px 14px;
    font-family: var(--font-body);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-icon-text:hover {
    color: var(--text-main);
    border-color: rgba(15, 23, 42, 0.2);
    background: #f8fafc;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-large {
    padding: 16px 36px;
    font-size: 18px;
    border-radius: var(--border-radius-lg);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ==========================================
   PROGRESS BAR
   ========================================== */
.progress-container {
    display: flex;
    flex-direction: column;
    width: 45%;
    gap: 6px;
}

.progress-bar-wrapper {
    height: 6px;
    background: rgba(15, 23, 42, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-success) 100%);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.3);
    width: 0%;
    transition: width 0.4s ease-out;
}

.progress-status {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.progress-step-text {
    font-weight: 500;
}

/* ==========================================
   VIEW 1: WELCOME SCREEN
   ========================================== */
.welcome-card {
    max-width: 800px;
    margin: 40px auto;
    border: 1px solid rgba(15, 23, 42, 0.05);
}

.welcome-badge {
    background: rgba(16, 185, 129, 0.08);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.15);
    display: inline-block;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
}

.welcome-title {
    font-size: 42px;
    line-height: 1.25;
    margin-bottom: 20px;
    color: var(--text-main);
}

.welcome-desc {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 35px;
    max-width: 680px;
}

.welcome-features {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

@media(min-width: 768px) {
    .welcome-features {
        grid-template-columns: repeat(3, 1fr);
    }
}

.feature-item {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.04);
    padding: 20px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 10px rgba(0,0,0,0.01);
    transition: var(--transition-smooth);
}

.feature-item:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.04);
}

.feature-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.feature-info h3 {
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--text-main);
}

.feature-info p {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.5;
}

.action-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 25px;
    width: 100%;
}

.action-bar .btn {
    width: 100%;
    max-width: 320px;
    justify-content: center;
}

.privacy-note {
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
    margin: 0;
    line-height: 1.4;
}

/* ==========================================
   VIEW 2: WIZARD & QUESTIONNAIRE
   ========================================== */
.quiz-container {
    max-width: 700px;
    margin: 20px auto;
}

.category-indicator {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.question-card {
    margin-bottom: 25px;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.question-text {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 25px;
    color: var(--text-main);
    line-height: 1.4;
}

/* Option Cards Layout */
.options-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: auto;
}

/* Interactive Option Card (Light Mode Style) */
.option-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 16px 20px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition-smooth);
    user-select: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.01);
}

.option-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(15, 23, 42, 0.2);
    transform: translateX(4px);
}

.option-card.selected {
    background: rgba(16, 185, 129, 0.05);
    border-color: var(--color-success);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.08);
}

.option-radio-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition-smooth);
    background: #ffffff;
}

.option-card.selected .option-radio-indicator {
    border-color: var(--color-success);
    background: var(--color-success);
}

.option-card.selected .option-radio-indicator::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ffffff;
}

.option-content {
    font-size: 15px;
    color: var(--text-main);
    font-weight: 500;
}

/* Multiple-choice option adjustments */
.option-card.checkbox-type.selected .option-radio-indicator {
    border-radius: 4px;
}
.option-card.checkbox-type .option-radio-indicator {
    border-radius: 4px;
}

/* Custom numeric inputs (Light Theme) */
.custom-input-group {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 24px;
    margin-top: 15px;
}

.custom-input-group label {
    display: block;
    font-size: 14px;
    color: var(--text-main);
    margin-bottom: 10px;
    font-weight: 700;
    border-left: 3px solid var(--color-primary);
    padding-left: 8px;
}

.numeric-input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.numeric-input-wrapper input,
select#healthSelect,
input#currentAgeInput,
input#retireAgeInput {
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px 44px 14px 20px;
    color: var(--text-main);
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    outline: none;
    transition: var(--transition-smooth);
}

select#healthSelect,
input#currentAgeInput,
input#retireAgeInput {
    padding-right: 20px;
    font-size: 15px;
    font-family: var(--font-body);
    font-weight: 500;
}

.numeric-input-wrapper input:focus,
select#healthSelect:focus,
input#currentAgeInput:focus,
input#retireAgeInput:focus {
    border-color: var(--color-primary);
    background: #ffffff;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.1);
}

/* ช่องกรอกเบี้ยประกันรายปี: เพิ่ม padding ขวาให้มากขึ้นรองรับ 'บาท / ปี' ที่ยาวกว่า 'บาท' */
.premium-input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.premium-input-wrapper input {
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px 90px 14px 20px;
    color: var(--text-main);
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    outline: none;
    transition: var(--transition-smooth);
}

.premium-input-wrapper input:focus {
    border-color: var(--color-primary);
    background: #ffffff;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.1);
}

.premium-input-wrapper .currency-symbol {
    position: absolute;
    right: 14px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.currency-symbol {
    position: absolute;
    right: 20px;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.quick-adds-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.btn-quick-add {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 14px;
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-quick-add:hover {
    background: #cbd5e1;
    color: var(--text-main);
}

/* Quiz Navigation */
.quiz-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.step-counter {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ==========================================
   VIEW 3: RESULTS DASHBOARD (LIGHT MODE)
   ========================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

@media(min-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 320px 1fr;
    }
}

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

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

.section-title-bar h2 {
    font-size: 26px;
    margin-bottom: 6px;
    color: var(--text-main);
}

.section-title-bar .subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

/* SVG Radar Chart Card styling */
.radar-chart-card {
    border: 1px solid var(--border-color);
    padding: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.03);
}

.radar-grid-line {
    stroke: #e2e8f0;
    stroke-width: 0.5px;
}

.radar-axis-line {
    stroke: #cbd5e1;
    stroke-width: 1px;
}

.radar-user-poly {
    fill: rgba(16, 185, 129, 0.18);
    stroke: #10b981;
    stroke-dasharray: none;
    stroke-width: 2.5px;
}

.radar-label {
    fill: #334155;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
}

/* Radial Score Card */
.score-radial-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 20px auto;
}

.score-radial {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.circle-bg {
    fill: none;
    stroke: #f1f5f9;
    stroke-width: 2.8;
}

.circle-fill {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    transition: stroke-dasharray 0.8s ease-in-out;
}

.score-fill-danger { stroke: var(--color-danger); }
.score-fill-warning { stroke: var(--color-warning); }
.score-fill-success { stroke: var(--color-success); }

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-family: var(--font-heading);
}

.score-val {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-main);
    display: block;
    line-height: 1;
}

.score-max {
    font-size: 12px;
    color: var(--text-light);
}

.score-label {
    font-weight: 600;
    font-size: 16px;
    margin-top: 8px;
}

.score-card .score-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    line-height: 1.5;
}

/* Agent Information Card */
.agent-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.agent-avatar {
    width: 50px;
    height: 50px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    border: 1px solid var(--border-color);
}

.agent-info h4 {
    font-size: 15px;
    color: var(--text-main);
}

.agent-info .agent-title {
    font-size: 12px;
    color: var(--text-muted);
}

.agent-contact-details {
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.agent-contact-details a {
    color: var(--color-success);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 600;
}

.agent-contact-details a:hover {
    text-decoration: underline;
}

.print-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
}

/* Gap Details list */
.gap-cards-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.gap-card {
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.01);
}

/* ตารางสรุปเบี้ยประกันและสิทธิ์ลดภาษี */
.tax-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    margin-bottom: 16px;
    font-size: 13px;
}

.tax-breakdown-table thead tr {
    background: #f1f5f9;
    color: var(--text-main);
    font-weight: 600;
}

.tax-breakdown-table tbody tr {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.tax-breakdown-table tbody tr:last-child {
    border-bottom: none;
    background: #f8fafc;
    font-weight: 600;
}

.tax-breakdown-table th,
.tax-breakdown-table td {
    padding: 10px 14px;
    text-align: right;
    border-left: 1px solid var(--border-color);
}

.tax-breakdown-table th:first-child,
.tax-breakdown-table td:first-child {
    text-align: left;
    border-left: none;
}

.tax-highlight-green {
    color: #059669;
    font-weight: 600;
}

.tax-highlight-orange {
    color: var(--color-warning);
    font-weight: 600;
}

/* แถบแยกหัวข้อย่อยภายในการ์ด */
.section-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.custom-input-group + .custom-input-group {
    margin-top: 12px;
}

.gap-card-header {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 20px;
}

.gap-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

/* Icon backgrounds */
.gap-card-icon.red { background: #ffe4e6; }
.gap-card-icon.orange { background: #ffedd5; }
.gap-card-icon.purple { background: #f3e8ff; }
.gap-card-icon.blue { background: #dbeafe; }
.gap-card-icon.green { background: #d1fae5; }

.gap-card-title-group {
    flex-grow: 1;
}

.gap-card-title-group h3 {
    font-size: 16px;
    color: var(--text-main);
    margin-bottom: 2px;
}

.gap-status-text {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.gap-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.gap-badge-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.gap-badge-warning { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.gap-badge-danger { background: #ffe4e6; color: #9f1239; border: 1px solid #fecdd3; }

/* GAP COMPARISON CHARTS */
.gap-chart-area {
    background: #f8fafc;
    border-radius: var(--border-radius-md);
    padding: 16px 20px;
    border: 1px solid rgba(15, 23, 42, 0.03);
    margin-bottom: 16px;
}

.chart-labels {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.val-bold {
    font-weight: 600;
    color: var(--text-main);
    font-family: var(--font-heading);
}

.chart-bar-container {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-bar-fill.target {
    background: #94a3b8;
}

.chart-bar-fill.existing {
    background: linear-gradient(90deg, var(--color-success) 0%, #059669 100%);
}

.chart-bar-fill.gap-exist {
    background: linear-gradient(90deg, #ea580c 0%, var(--color-danger) 100%);
}

.spacer {
    margin-top: 14px;
}

/* Feedback message container */
.gap-feedback-box {
    background: #f8fafc;
    border-left: 4px solid var(--color-primary);
    padding: 14px 18px;
    border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    border-top: 1px solid rgba(0, 0, 0, 0.01);
    border-right: 1px solid rgba(0, 0, 0, 0.01);
    border-bottom: 1px solid rgba(0, 0, 0, 0.01);
}

.gap-feedback-box strong {
    color: var(--text-main);
}

.tax-saving-box {
    border-left-color: #8b5cf6; /* Violet border for tax */
    background: #fdfafb;
    margin-bottom: 10px;
}

/* Grid layout for health comparison table */
.gap-analysis-table {
    margin-bottom: 16px;
}

.grid-table {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.table-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
}

.table-row:last-child {
    border-bottom: none;
}

.header-row {
    background: #f1f5f9;
    font-weight: 600;
    color: var(--text-main);
}

/* ==========================================
   MODAL WINDOW STYLES
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5); /* Slate overlay background */
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-card {
    max-width: 500px;
    width: 100%;
    padding: 25px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: #ffffff;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    color: var(--text-main);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.5;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 10px 14px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: var(--transition-smooth);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    background: #ffffff;
    box-shadow: 0 0 6px rgba(37, 99, 235, 0.1);
}

.form-help {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    display: block;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}


/* ==========================================
   สไตล์สำหรับสวิตช์เลือกโหมดการกรอก (รายเดือน vs รายปี)
   ========================================== */
.btn-mode-active {
    background: #ffffff !important;
    color: var(--color-primary) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.btn-mode-inactive {
    background: transparent !important;
    color: var(--text-muted) !important;
}

.btn-mode-inactive:hover {
    color: var(--text-main) !important;
}

/* ==========================================
   แถบนำทางด้านบน & หน้าแบบสอบถาม (คลาสที่ใช้ใน index.html)
   ========================================== */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 10px 0 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-success);
}

.top-nav .progress-container {
    flex: 1 1 260px;
    max-width: 420px;
    width: auto;
}

.quiz-wrapper {
    max-width: 720px;
    width: 100%;
    margin: 10px auto;
}

.question-header {
    margin-bottom: 16px;
}

.category-badge {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(37, 99, 235, 0.08);
    border-radius: 50px;
    padding: 4px 14px;
    margin-bottom: 8px;
}

.category-title {
    font-size: 22px;
    color: var(--text-main);
    line-height: 1.35;
}

/* ==========================================
   ช่องขอความยินยอม PDPA
   ========================================== */
.consent-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px;
    margin-top: 4px;
}

.consent-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-main);
    cursor: pointer;
}

.consent-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
    accent-color: var(--color-success);
    cursor: pointer;
}

.consent-details {
    margin-top: 10px;
    padding-left: 30px;
    font-size: 12px;
    color: var(--text-muted);
}

.consent-details summary {
    cursor: pointer;
    color: var(--color-primary);
    font-weight: 500;
    padding: 4px 0;
}

.consent-details ul {
    margin: 8px 0 0 16px;
    line-height: 1.6;
}

.consent-details li + li {
    margin-top: 4px;
}

/* ==========================================
   หน้าต่างส่งข้อมูลสำเร็จ
   ========================================== */
.success-card {
    max-width: 450px;
    text-align: center;
    padding: 30px;
}

.success-emoji {
    font-size: 50px;
    margin-bottom: 12px;
}

.success-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 10px;
}

.success-desc {
    font-size: 15px;
    line-height: 1.65;
    margin-bottom: 22px;
}

.success-desc strong {
    color: var(--text-main);
}

.success-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 14px;
    line-height: 1.5;
}

.success-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
    margin-top: 10px;
    padding: 10px;
}

/* ==========================================
   ตารางรายชื่อลูกค้า (Leads)
   ========================================== */
.leads-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

.leads-table {
    width: 100%;
    min-width: 1400px;
    font-size: 13px;
}

.leads-table th,
.leads-table td {
    text-align: left;
    padding: 12px 10px;
    line-height: 1.45;
    vertical-align: top;
}

.leads-table th:first-child,
.leads-table td:first-child {
    text-align: left;
}

/* แถวสุดท้ายของตารางรายชื่อไม่ใช่แถวสรุปผลรวม */
.leads-table tbody tr:last-child {
    background: #ffffff;
    font-weight: normal;
}

.leads-table .lead-center {
    text-align: center;
}

.leads-table .lead-id {
    font-weight: 600;
    color: var(--text-muted);
}

.leads-table .lead-date {
    color: var(--text-muted);
    font-size: 12px;
}

.leads-table .lead-detail {
    font-size: 12px;
}

.lead-note {
    display: block;
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 500;
    margin-top: 2px;
}

.lead-phone {
    white-space: nowrap;
}

.lead-phone a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
}

.lead-consent {
    font-size: 12px;
    color: var(--text-light);
}

.lead-consent.ok {
    color: #059669;
    font-weight: 500;
}

.leads-table .gap-badge {
    display: inline-block;
    padding: 6px 10px;
    font-size: 12px;
    margin-top: 2px;
}

.btn-delete-lead {
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.15);
    width: 100%;
    border-radius: 6px;
}

.leads-message {
    text-align: center !important;
    padding: 24px !important;
    color: var(--text-muted);
}

.leads-message.error {
    color: var(--color-danger);
    font-weight: 500;
}

/* ==========================================
   ปรับการแสดงผลบนมือถือ (RESPONSIVE)
   ========================================== */
@media (max-width: 768px) {
    /* หน้าต่าง popup ยาวเกินจอให้เลื่อนได้ และไม่โดนคีย์บอร์ดบัง */
    .modal-overlay {
        align-items: flex-start;
        overflow-y: auto;
        padding: 12px;
    }

    .modal-card {
        padding: 20px 18px;
        margin: auto 0;
    }

    /* ตารางรายชื่อลูกค้าแสดงเป็นการ์ดทีละราย */
    .leads-table {
        min-width: 0;
    }

    .leads-table thead {
        display: none;
    }

    .leads-table,
    .leads-table tbody,
    .leads-table tr,
    .leads-table td {
        display: block;
        width: 100%;
    }

    .leads-table tbody tr,
    .leads-table tbody tr:last-child {
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-md);
        margin-bottom: 12px;
        padding: 6px 0;
    }

    .leads-table td,
    .leads-table td:first-child {
        border-left: none;
        padding: 6px 14px;
        text-align: left;
    }

    .leads-table td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 600;
        color: var(--text-light);
        margin-bottom: 1px;
    }

    .leads-table .lead-center {
        text-align: left;
    }

    .btn-delete-lead {
        min-height: 44px;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 15px;
    }

    .app-container {
        padding: 12px 16px;
    }

    .card {
        padding: 20px 18px;
    }

    /* แถบด้านบน: ปุ่มตัวแทนเหลือเฉพาะไอคอน */
    .top-nav {
        padding-bottom: 12px;
        margin-bottom: 16px;
    }

    .top-nav .btn-label {
        display: none;
    }

    .btn-icon-text {
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
        padding: 8px 10px;
    }

    .top-nav .progress-container {
        order: 3;
        flex-basis: 100%;
        max-width: none;
    }

    /* หน้าแรก */
    .welcome-card {
        margin: 10px auto;
    }

    .welcome-title {
        font-size: 28px;
        line-height: 1.3;
    }

    .welcome-desc {
        font-size: 15px;
        margin-bottom: 24px;
    }

    .feature-info p {
        font-size: 13px;
    }

    .privacy-note {
        font-size: 13px;
    }

    /* แบบสอบถาม */
    .category-title {
        font-size: 18px;
    }

    .question-card {
        min-height: 0;
    }

    .question-text {
        font-size: 18px;
        margin-bottom: 18px;
    }

    .option-card {
        padding: 14px 16px;
        min-height: 52px;
    }

    .option-card:hover {
        transform: none;
    }

    .custom-input-group {
        padding: 16px;
    }

    .btn-quick-add {
        font-size: 13px;
        padding: 8px 14px;
        min-height: 38px;
    }

    .quiz-navigation {
        position: sticky;
        bottom: 0;
        z-index: 10;
        gap: 10px;
        margin: 16px -16px 0;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        background: rgba(248, 250, 252, 0.92);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: 1px solid var(--border-color);
    }

    .quiz-navigation .btn {
        padding: 12px 18px;
        min-height: 48px;
    }

    /* แดชบอร์ด */
    .dashboard-grid {
        gap: 20px;
    }

    .section-title-bar h2 {
        font-size: 22px;
    }

    .gap-card-header {
        gap: 12px;
        flex-wrap: wrap;
    }

    .gap-card-title-group {
        flex: 1 1 0;
        min-width: 0;
    }

    .gap-card-title-group h3 {
        font-size: 15px;
    }

    .chart-labels {
        gap: 10px;
    }

    .chart-labels .val-bold {
        white-space: nowrap;
    }

    .gap-chart-area {
        padding: 14px;
    }

    .gap-feedback-box {
        font-size: 14px;
        padding: 12px 14px;
    }

    .table-row {
        gap: 10px;
        padding: 10px 12px;
    }

    .tax-breakdown-table th,
    .tax-breakdown-table td {
        padding: 8px 6px;
        font-size: 12px;
    }

    .gap-badge {
        font-size: 12px;
    }

    .radar-chart-card {
        padding: 16px 10px;
    }

    /* ฟอร์ม: ตัวอักษร 16px ป้องกัน iPhone ซูมหน้าจอเองเมื่อแตะช่องกรอก */
    .form-group input,
    .form-group select,
    .form-group textarea,
    select#healthSelect,
    input#currentAgeInput,
    input#retireAgeInput {
        font-size: 16px;
    }

    .form-group input,
    .form-group select {
        min-height: 46px;
    }

    .form-group label,
    .modal-desc {
        font-size: 14px;
    }

    .form-help {
        font-size: 12px;
    }

    .modal-header h3 {
        font-size: 17px;
        line-height: 1.4;
    }

    .modal-close {
        font-size: 28px;
        min-width: 44px;
        min-height: 44px;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
        min-height: 48px;
    }

    .consent-check {
        font-size: 14px;
    }

    .consent-check input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .consent-details {
        padding-left: 0;
        font-size: 13px;
    }

    .success-card {
        padding: 24px 18px;
    }

    .btn-large {
        padding: 15px 24px;
        font-size: 17px;
    }
}

/* ==========================================
   PRINT LAYOUT STYLES (PDF EXPORT)
   ========================================== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 11px;
    }

    .bg-glow,
    .app-header .header-actions,
    .top-nav .header-actions,
    .print-actions,
    .modal-overlay,
    .app-header .progress-container,
    .top-nav .progress-container,
    .radar-chart-card p {
        display: none !important;
    }
    
    .app-container {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .logo-text {
        color: #000000 !important;
    }
    .logo-text span {
        color: #059669 !important;
    }

    .card {
        background: none !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        color: #000000 !important;
        page-break-inside: avoid;
        margin-bottom: 12px !important;
        padding: 12px !important;
    }

    .dashboard-grid {
        display: block !important;
    }

    .db-sidebar {
        margin-bottom: 20px;
    }

    .db-main {
        width: 100% !important;
    }
    
    h1, h2, h3, h4, h5, h6, .val-bold {
        color: #000000 !important;
    }

    .chart-bar-container {
        background: #f1f5f9 !important;
        border: 1px solid #cbd5e1 !important;
    }

    .chart-bar-fill.target {
        background: #64748b !important;
    }

    .chart-bar-fill.existing {
        background: #059669 !important;
    }

    .chart-bar-fill.gap-exist {
        background: #dc2626 !important;
    }

    .gap-badge {
        border: 1px solid #777 !important;
        color: #000000 !important;
        background: #f1f5f9 !important;
    }

    .gap-feedback-box {
        border-left: 3px solid #64748b !important;
        background: #fafafa !important;
        color: #111111 !important;
    }

    .agent-card {
        border: 2px solid #059669 !important;
    }

    .agent-card button {
        display: none !important;
    }
    
    .radar-chart-card {
        border: 1px solid #ccc !important;
        margin-bottom: 20px !important;
    }
    
    .radar-user-poly {
        fill: rgba(0, 0, 0, 0.05) !important;
        stroke: #000000 !important;
    }
}

/* ==========================================
   GLASSMORPHISM THEME (v1.4)
   ========================================== */
:root {
    --glass-bg: rgba(255, 255, 255, 0.58);
    --glass-bg-strong: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(255, 255, 255, 0.75);
    --glass-shadow: 0 8px 32px rgba(30, 41, 59, 0.08);
    --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --glass-blur: blur(18px) saturate(160%);
    --border-radius-lg: 20px;
    --border-radius-md: 12px;
}

body {
    background:
        radial-gradient(1200px 600px at 0% 0%, #dbeafe 0%, transparent 60%),
        radial-gradient(900px 600px at 100% 10%, #d1fae5 0%, transparent 55%),
        radial-gradient(900px 700px at 50% 110%, #ede9fe 0%, transparent 60%),
        #f4f7fb;
    background-attachment: fixed;
}

.bg-glow { opacity: 0.55; filter: blur(120px); }
.bg-glow-1 { background: radial-gradient(circle, #93c5fd 0%, transparent 70%); }
.bg-glow-2 { background: radial-gradient(circle, #6ee7b7 0%, transparent 70%); }

/* การ์ดกระจก */
.card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow), var(--glass-highlight);
}

.card:hover {
    border-color: var(--glass-border);
    box-shadow: 0 12px 40px rgba(30, 41, 59, 0.11), var(--glass-highlight);
}

/* เบราว์เซอร์ที่เบลอไม่ได้: ใช้พื้นทึบให้อ่านง่าย */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .card, .top-nav, .modal-card { background: rgba(255, 255, 255, 0.96); }
}

/* แถบด้านบนแบบกระจกติดขอบบน */
.top-nav {
    position: sticky;
    top: 10px;
    z-index: 50;
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 10px 14px;
}

.btn-icon-text {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
}

/* ปุ่มหลัก */
.btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #0ea5a4 100%);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--glass-border);
}

/* ตัวเลือกคำตอบ / ช่องกรอก */
.option-card,
.custom-input-group,
.gap-chart-area,
.gap-feedback-box,
.grid-table,
.table-row {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(255, 255, 255, 0.8);
}

.option-card.selected {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--color-success);
}

.form-group input,
.form-group select,
.form-group textarea,
.numeric-input-wrapper input,
.premium-input-wrapper input {
    background: rgba(255, 255, 255, 0.7);
}

.modal-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

/* ==========================================
   หน้าแรกแบบใหม่
   ========================================== */
.welcome-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    max-width: 1040px;
    margin: 8px auto 24px;
    width: 100%;
}

@media (min-width: 900px) {
    .welcome-layout {
        grid-template-columns: 1.35fr 1fr;
        gap: 20px;
    }
}

.hero {
    padding: 36px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    font-size: 13px;
    font-weight: 500;
    color: #047857;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 6px 14px;
    border-radius: 50px;
    margin-bottom: 18px;
}

.hero-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.hero-title {
    font-size: 44px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
}

.text-gradient {
    background: linear-gradient(120deg, #2563eb 0%, #10b981 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-desc {
    font-size: 17px;
    color: var(--text-muted);
    line-height: 1.65;
    margin-bottom: 26px;
    max-width: 520px;
}

.btn-hero {
    align-self: flex-start;
    padding: 17px 34px;
    font-size: 18px;
    font-weight: 600;
}

.hero-trust {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 18px;
    font-size: 13px;
    color: var(--text-muted);
}

/* การ์ดที่ปรึกษา */
.advisor { padding: 24px; }

.advisor-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.advisor-avatar {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #fff;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35);
    overflow: hidden;
}

.advisor-kicker {
    font-size: 12px;
    color: var(--color-success);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.advisor-name {
    font-size: 19px;
    line-height: 1.3;
    color: var(--text-main);
}

.advisor-role {
    font-size: 13px;
    color: var(--text-muted);
}

.advisor-license {
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 14px;
}

.advisor-license strong {
    color: var(--text-main);
    font-family: var(--font-heading);
    letter-spacing: 0.03em;
}

.advisor-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.advisor-stats div {
    text-align: center;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 10px 4px;
}

.advisor-stats strong {
    display: block;
    font-family: var(--font-heading);
    font-size: 20px;
    color: var(--text-main);
    line-height: 1.2;
}

.advisor-stats span {
    font-size: 12px;
    color: var(--text-muted);
}

.advisor-quote {
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.6;
    border-left: 3px solid var(--color-success);
    padding-left: 12px;
}

/* ขั้นตอน & 6 ด้าน */
.steps, .dimensions { padding: 22px 24px; }

.section-kicker {
    font-size: 15px;
    color: var(--text-main);
    margin-bottom: 14px;
}

.steps-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.steps-list li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.step-num {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #10b981);
}

.steps-list strong {
    font-size: 15px;
    color: var(--text-main);
}

.steps-list p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.dimension-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.dim {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    font-size: 13px;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 12px 6px;
}

.dim span { font-size: 22px; }

@media (min-width: 900px) {
    .steps, .dimensions { grid-column: span 1; }
    .welcome-layout > .steps { grid-column: 1; }
    .welcome-layout > .dimensions { grid-column: 2; }
}

/* ปุ่มเริ่มติดล่างจอ (มือถือเท่านั้น) */
.mobile-cta { display: none; }

@media (max-width: 640px) {
    .top-nav { top: 8px; padding: 8px 10px; }

    .hero { padding: 26px 20px; }
    .hero-title { font-size: 30px; }
    .hero-desc { font-size: 15.5px; margin-bottom: 20px; }
    .btn-hero { align-self: stretch; justify-content: center; }
    .hero-trust { flex-direction: column; gap: 4px; }

    .advisor, .steps, .dimensions { padding: 20px 18px; }

    .mobile-cta {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.75);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        border-top: 1px solid var(--glass-border);
    }
    .mobile-cta .btn { min-height: 50px; font-size: 16px; font-weight: 600; }
    #viewWelcome { padding-bottom: 80px; }
}

/* PDF: กลับเป็นพื้นขาวล้วน ไม่มีเอฟเฟกต์กระจก */
@media print {
    body { background: #ffffff !important; }
    .card, .top-nav, .modal-card {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    .top-nav { position: static !important; border: none !important; box-shadow: none !important; background: none !important; }
    .gap-chart-area, .gap-feedback-box, .grid-table, .table-row { background: #fafafa !important; }
    .mobile-cta { display: none !important; }
}


.hero-title .nw { white-space: nowrap; }
.advisor-license { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.advisor-license svg { color: var(--color-success); flex-shrink: 0; }

/* ปุ่มติดล่างจอ: แสดงเมื่อเลื่อนผ่านปุ่มหลักไปแล้วเท่านั้น */
@media (max-width: 640px) {
    .mobile-cta { transform: translateY(110%); transition: transform 0.25s ease; }
    .mobile-cta.visible { transform: translateY(0); }
}
/* ==========================================
   แบบสอบถามชุดใหม่ (v1.5)
   ========================================== */
.question-hint {
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.55;
    margin: -14px 0 20px;
    padding: 10px 12px;
    background: rgba(37, 99, 235, 0.06);
    border-radius: 10px;
}

.option-sub {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

.option-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.option-stack.compact .option-content { font-size: 13.5px; }

.field-label {
    margin-top: 18px;
}

.field-error {
    color: var(--color-danger);
    font-size: 13px;
    min-height: 0;
    margin-top: 4px;
}

.field-error:empty { display: none; }

.chip-group { margin-top: 4px; }

.btn-quick-add.chip {
    padding: 8px 16px;
    font-size: 14px;
    font-family: var(--font-body);
}

.btn-quick-add.chip.active {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #ffffff;
    font-weight: 600;
}

.number-field + .number-field { margin-top: 18px; }

.toggle-wrap { margin-top: 12px; }

.toggle-card { border-style: dashed; }

.income-group .custom-input-group + .custom-input-group { margin-top: 14px; }

.mode-toggle {
    display: flex;
    gap: 6px;
    max-width: 320px;
    margin: 0 auto 16px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
}

.mode-toggle button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.calc-help {
    margin-top: 8px;
    font-size: 13px;
    color: var(--color-primary);
    font-weight: 500;
}

input#currentAgeInput { max-width: 200px; }

.assessment-note {
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-light);
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
}

@media (max-width: 640px) {
    .question-hint { font-size: 13px; margin-top: -8px; }
    .btn-quick-add.chip { min-height: 42px; }
    input#currentAgeInput { max-width: none; }
}

@media print {
    .assessment-note { background: none !important; border: 1px solid #ccc !important; color: #333 !important; }
}

/* หน้าลิงก์ไม่ถูกต้อง / ปิดใช้งานชั่วคราว */
.unavailable-card { max-width: 480px; margin: 60px auto; text-align: center; }

/* แอตทริบิวต์ hidden ต้องซ่อนเสมอ แม้คลาสจะกำหนด display ไว้ */
[hidden] { display: none !important; }

/* ป๊อปอัปที่สูงกว่าจอ (เช่น หน้าตั้งค่าบนแล็ปท็อป) ต้องเลื่อนดูได้ครบทุกขนาดจอ */
.modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 24px 16px;
}
.modal-overlay .modal-card { margin: auto 0; }
