
/* ===== LDA Knowledge Base ===== */
.kb-page {
    max-width: 1600px;
    margin: 0 auto;
}
.kb-page > .kb-hero,
.kb-page > .kb-cats,
.kb-page > section,
.article-layout,
.breadcrumbs {
    max-width: 1180px;
    margin-left: auto;
    margin-right: auto;
}
.kb-page .main-nav {
    width: 100%;
    align-items: center;
}
.kb-page .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    box-sizing: border-box;
    line-height: 1.15;
}
.kb-hero {
    background: linear-gradient(135deg, rgba(0,91,255,.12), rgba(139,92,246,.12));
    border: 1px solid var(--border-strong);
    border-radius: 28px;
    padding: 32px;
    box-shadow: var(--shadow-card);
    margin-bottom: 28px;
}
.kb-hero-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(0,91,255,.18);
    background: rgba(0,91,255,.08);
    color: var(--btn-primary);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 14px;
}
.kb-hero h1 {
    font-size: 38px;
    line-height: 1.08;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}
.kb-hero p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.65;
    max-width: 900px;
}
.kb-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}
.kb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 11px 16px;
    border-radius: 14px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    transition: .2s ease;
}
.kb-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.kb-btn.primary {
    color: #fff;
    background: linear-gradient(135deg, #005bff 0%, #448aff 52%, #8b5cf6 100%);
    border-color: transparent;
}
.kb-cats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.kb-cat {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}
.kb-section-title {
    font-size: 26px;
    color: var(--text-primary);
    margin: 26px 0 14px;
}
.kb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.kb-card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 22px;
    padding: 20px;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: .2s ease;
    display: block;
}
.kb-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); border-color: var(--btn-primary); }
.kb-card .tag {
    color: var(--btn-primary);
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: .04em;
    margin-bottom: 10px;
}
.kb-card h2, .kb-card h3 {
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.25;
    margin-bottom: 10px;
}
.kb-card p {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.55;
}
.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 24px;
    align-items: start;
}
.article-main {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 28px;
    padding: 34px;
    box-shadow: var(--shadow-card);
}
.article-main h1 {
    color: var(--text-primary);
    font-size: 36px;
    line-height: 1.1;
    margin-bottom: 12px;
    letter-spacing: -.4px;
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 22px;
}
.article-meta span {
    background: var(--bg-upload);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 10px;
}
.article-main p, .article-main li {
    color: var(--text-secondary);
    line-height: 1.72;
    font-size: 15px;
}
.article-main p { margin: 12px 0; }
.article-main h2 {
    margin-top: 28px;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 24px;
}
.article-main h3 {
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 18px;
}
.article-main ul, .article-main ol { padding-left: 22px; margin: 10px 0 16px; }
.article-note {
    background: linear-gradient(135deg, rgba(0,91,255,.09), rgba(16,185,129,.08));
    border: 1px solid rgba(0,91,255,.18);
    border-radius: 18px;
    padding: 16px 18px;
    margin: 18px 0;
}
.article-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.article-sidebar {
    position: sticky;
    top: 16px;
    display: grid;
    gap: 14px;
}
.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 22px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.sidebar-card h3 {
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 10px;
}
.sidebar-card a {
    display: block;
    color: var(--btn-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    margin: 9px 0;
}
.sidebar-card p {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}
.breadcrumbs {
    font-size: 13px;
    color: var(--text-muted);
    margin: 4px 0 16px;
}
.breadcrumbs a { color: var(--btn-primary); text-decoration: none; font-weight: 500; }
@media (max-width: 900px) {
    .article-layout { grid-template-columns: 1fr; }
    .article-sidebar { position: static; }
    .article-main { padding: 24px; }
    .article-main h1, .kb-hero h1 { font-size: 30px; }
}


/* v2: lighter article typography and stable menu width */
.kb-hero-label,
.kb-cat,
.kb-card .tag,
.article-meta span {
    font-weight: 500;
}
.sidebar-card h3 {
    font-weight: 600;
}
.sidebar-card a {
    font-weight: 500;
}
.article-main strong {
    font-weight: 600;
}
.kb-page .main-nav {
    max-width: none;
}

/* v3: cleaner knowledge base hero and article list with covers */
.kb-brand-header {
    max-width: 1180px;
    margin: 0 auto 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kb-brand-header h2 {
    margin: 0 0 6px;
    color: var(--text-primary);
    font-size: 28px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -.35px;
}
.kb-brand-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
}
.kb-brand-header-compact {
    margin-bottom: 16px;
}
.kb-brand-header-compact h2 { font-size: 24px; }
.kb-brand-header-compact p { font-size: 13px; }
.kb-hero-label { display: none !important; }
.kb-hero {
    padding: 34px 38px;
    text-align: center;
}
.kb-hero h1 {
    margin-left: auto;
    margin-right: auto;
}
.kb-hero p {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
    font-size: 17px;
    line-height: 1.72;
}
.kb-quick-actions {
    justify-content: center;
    display: grid;
    grid-template-columns: repeat(2, minmax(230px, 280px));
    gap: 12px;
}
.kb-btn {
    min-height: 48px;
    padding: 13px 18px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}
.kb-cats {
    justify-content: center;
    gap: 10px;
    margin-bottom: 26px;
}
.kb-cat {
    min-width: 118px;
    text-align: center;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 400;
}
.kb-section-title {
    text-align: center;
    margin: 30px 0 16px;
}
.kb-grid {
    grid-template-columns: 1fr;
    gap: 16px;
}
.kb-card {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 22px;
    align-items: center;
    padding: 18px;
    min-height: 180px;
}
.kb-card-image {
    width: 100%;
    height: 148px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--bg-upload);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.kb-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.kb-card-content {
    min-width: 0;
}
.kb-card .tag {
    display: inline-flex;
    margin-bottom: 10px;
    padding: 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
}
.kb-card h2, .kb-card h3 {
    font-size: 20px;
    line-height: 1.28;
    margin-bottom: 9px;
}
.kb-card p {
    font-size: 14.5px;
    line-height: 1.6;
}
.sidebar-card h3,
.sidebar-card a,
.article-meta span,
.kb-card .tag,
.kb-cat {
    font-weight: 400 !important;
}
.sidebar-card h3 {
    color: var(--text-primary);
}
.sidebar-card a {
    color: var(--btn-primary);
}
@media (max-width: 760px) {
    .kb-brand-header { margin-bottom: 16px; }
    .kb-brand-header h2 { font-size: 22px; }
    .kb-hero { padding: 24px 20px; text-align: left; }
    .kb-hero h1 { font-size: 30px; }
    .kb-hero p { font-size: 15px; }
    .kb-quick-actions { grid-template-columns: 1fr; }
    .kb-cats { justify-content: flex-start; }
    .kb-cat { min-width: auto; }
    .kb-card { grid-template-columns: 1fr; gap: 14px; min-height: 0; }
    .kb-card-image { height: 180px; }
    .kb-section-title { text-align: left; }
}


/* v4: full-width layout like other service sections + exact global header + category badges */
.kb-page {
    max-width: 1600px;
    margin: 0 auto;
}
.kb-page > .kb-hero,
.kb-page > .kb-cats,
.kb-page > section,
.article-layout,
.breadcrumbs,
.kb-page > .header-row {
    max-width: none !important;
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
}
.kb-brand-header,
.kb-brand-header-compact {
    display: none !important;
}
.kb-page .header-row {
    margin-bottom: 16px;
}
.kb-page .logo-area h1 {
    margin: 0;
}
.kb-page .brand-subtitle {
    margin: 4px 0 0;
}
.kb-hero {
    padding: 36px 42px;
    text-align: left;
}
.kb-hero h1 {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}
.kb-hero p {
    max-width: 1120px;
    margin-left: 0;
    margin-right: 0;
    font-size: 18px;
    line-height: 1.7;
}
.kb-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 330px));
    justify-content: flex-start;
    gap: 14px;
}
.kb-btn {
    min-height: 52px;
    padding: 14px 20px;
    border-radius: 17px;
    font-size: 14px;
    font-weight: 600;
}
.kb-cats {
    justify-content: flex-start;
    gap: 10px;
    margin-bottom: 24px;
}
.kb-cat {
    min-width: 124px;
    text-align: center;
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 400 !important;
}
.kb-article-list {
    margin-top: 0;
}
.kb-section-title {
    display: none !important;
}
.kb-grid {
    grid-template-columns: 1fr;
    gap: 18px;
}
.kb-card {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 24px;
    align-items: center;
    padding: 20px;
    min-height: 190px;
}
.kb-card-image {
    height: 156px;
    border-radius: 20px;
}
.article-badge,
.kb-card .tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 28px;
    padding: 6px 11px;
    border-radius: 999px;
    background: rgba(0, 91, 255, .08);
    border: 1px solid rgba(0, 91, 255, .16);
    color: var(--btn-primary);
    font-size: 12px;
    font-weight: 500 !important;
    letter-spacing: 0;
    text-transform: none;
    margin-bottom: 11px;
}
.kb-card h2,
.kb-card h3 {
    font-size: 21px;
    line-height: 1.28;
    margin-bottom: 9px;
}
.kb-card p {
    font-size: 14.5px;
    line-height: 1.62;
    max-width: 980px;
}
.kb-anchor {
    position: relative;
    top: -18px;
}
.article-status-row {
    margin-bottom: 14px;
}
.article-meta span {
    font-weight: 400 !important;
}
.sidebar-card h3,
.sidebar-card a {
    font-weight: 400 !important;
}
.article-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 26px;
}
@media (max-width: 900px) {
    .article-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .kb-hero { padding: 24px 20px; }
    .kb-hero h1 { font-size: 30px; }
    .kb-hero p { font-size: 15px; }
    .kb-quick-actions { grid-template-columns: 1fr; }
    .kb-cat { min-width: auto; }
    .kb-card { grid-template-columns: 1fr; gap: 14px; min-height: 0; }
    .kb-card-image { height: 180px; }
}

/* v5: category filters + stable article covers */
.kb-cat {
    cursor: pointer;
    font-family: inherit;
    line-height: 1.15;
    appearance: none;
    -webkit-appearance: none;
}
.kb-cat.active {
    background: linear-gradient(135deg, rgba(0,91,255,.12), rgba(139,92,246,.10));
    border-color: rgba(0,91,255,.32);
    color: var(--btn-primary);
    box-shadow: var(--shadow);
}
.kb-card[hidden] {
    display: none !important;
}
.kb-empty {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    padding: 18px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    box-shadow: var(--shadow);
}
.kb-card-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0,91,255,.06), rgba(139,92,246,.06));
}
.kb-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain !important;
    padding: 18px;
    box-sizing: border-box;
}
@media (max-width: 760px) {
    .kb-card-image img { padding: 16px; }
}

/* v6: larger article titles + category badge at card bottom/right + article badge in meta row */
.kb-card-content {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    min-height: 150px;
}
.kb-card-content h3 {
    order: 1;
}
.kb-card-content p {
    order: 2;
    margin-bottom: 14px;
}
.kb-card-content .article-badge {
    order: 3;
    align-self: flex-end;
    margin-top: auto;
    margin-bottom: 0;
}
.kb-card h2,
.kb-card h3 {
    font-size: 25px;
    line-height: 1.18;
    letter-spacing: -0.25px;
}
.article-status-row {
    display: none !important;
}
.article-meta {
    align-items: center;
}
.article-meta .article-badge,
.article-meta .article-meta-badge {
    margin: 0;
    min-height: 30px;
    padding: 7px 12px;
    font-size: 12px;
    color: var(--btn-primary);
    background: rgba(0, 91, 255, .08);
    border: 1px solid rgba(0, 91, 255, .16);
    font-weight: 500 !important;
}
@media (max-width: 760px) {
    .kb-card h2,
    .kb-card h3 {
        font-size: 21px;
        line-height: 1.24;
    }
    .kb-card-content {
        min-height: 0;
    }
    .kb-card-content .article-badge {
        align-self: flex-start;
    }
}

/* v7: dark theme polish + reading theme for knowledge base */
.header-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
}
.reading-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 40px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s;
}
.reading-toggle:hover {
    border-color: var(--btn-primary);
    transform: translateY(-1px);
}
body.dark .kb-hero,
body.dark .article-note {
    background: linear-gradient(135deg, rgba(59,130,246,.14), rgba(139,92,246,.12));
}
body.dark .kb-cat.active {
    background: linear-gradient(135deg, rgba(59,130,246,.20), rgba(139,92,246,.16));
    border-color: rgba(96,165,250,.42);
}
body.dark .article-badge,
body.dark .kb-card .tag,
body.dark .article-meta .article-badge,
body.dark .article-meta .article-meta-badge {
    background: rgba(59,130,246,.14);
    border-color: rgba(96,165,250,.28);
    color: #93c5fd;
}
body.dark .kb-card-image {
    background: linear-gradient(135deg, rgba(59,130,246,.10), rgba(139,92,246,.10));
}

body.reading-mode {
    --bg-page-start: #f6efe2;
    --bg-page-end: #fbf7ef;
    --bg-card: #fffaf0;
    --border: #eadfcb;
    --border-strong: #d9c8aa;
    --bg-upload: #f4ead8;
    --text-primary: #2f2518;
    --text-secondary: #4f4030;
    --text-muted: #7b6b58;
    --header-bg: #f4ead8;
    --btn-primary: #8a5a25;
    --btn-primary-hover: #6f4519;
    --shadow: 0 1px 3px rgba(84,59,28,.08);
    --shadow-card: 0 8px 22px rgba(84,59,28,.12);
}
body.dark.reading-mode {
    --bg-page-start: #17130e;
    --bg-page-end: #211a13;
    --bg-card: #2a2118;
    --border: #47382a;
    --border-strong: #5a4633;
    --bg-upload: #211a13;
    --text-primary: #f8ead7;
    --text-secondary: #e0cbb0;
    --text-muted: #b79f82;
    --header-bg: #33271c;
    --btn-primary: #f0b66a;
    --btn-primary-hover: #ffd08f;
    --shadow: 0 1px 3px rgba(0,0,0,.35);
    --shadow-card: 0 8px 24px rgba(0,0,0,.45);
}
body.reading-mode .kb-hero,
body.reading-mode .article-main,
body.reading-mode .sidebar-card,
body.reading-mode .kb-card,
body.reading-mode .main-nav,
body.reading-mode .theme-toggle,
body.reading-mode .reading-toggle {
    background: var(--bg-card);
}
body.reading-mode .kb-hero {
    border-color: var(--border-strong);
}
body.reading-mode .reading-toggle {
    border-color: var(--btn-primary);
    color: var(--btn-primary);
}
body.reading-mode .article-layout {
    grid-template-columns: minmax(0, 980px);
    justify-content: center;
}
body.reading-mode .article-sidebar {
    display: none;
}
body.reading-mode .article-main {
    padding: 46px 56px;
    max-width: 980px;
    margin: 0 auto;
}
body.reading-mode .article-main h1 {
    font-size: 42px;
    line-height: 1.16;
    letter-spacing: -.45px;
    margin-bottom: 18px;
}
body.reading-mode .article-main h2 {
    font-size: 28px;
    margin-top: 34px;
}
body.reading-mode .article-main h3 {
    font-size: 21px;
}
body.reading-mode .article-main p,
body.reading-mode .article-main li {
    font-size: 18px;
    line-height: 1.9;
}
body.reading-mode .article-main .lead {
    font-size: 20px;
    line-height: 1.85;
}
body.reading-mode .article-note {
    background: rgba(138,90,37,.09);
    border-color: rgba(138,90,37,.22);
}
body.reading-mode .article-cta {
    justify-content: center;
}
body.reading-mode .breadcrumbs {
    max-width: 980px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}
body.reading-mode .kb-card h2,
body.reading-mode .kb-card h3 {
    line-height: 1.22;
}
body.reading-mode .kb-card p {
    font-size: 15.5px;
    line-height: 1.75;
}
body.reading-mode .article-badge,
body.reading-mode .kb-card .tag,
body.reading-mode .article-meta .article-badge,
body.reading-mode .article-meta .article-meta-badge {
    background: rgba(138,90,37,.10);
    border-color: rgba(138,90,37,.22);
    color: var(--btn-primary);
}
body.dark.reading-mode .article-note {
    background: rgba(240,182,106,.10);
    border-color: rgba(240,182,106,.24);
}
body.dark.reading-mode .article-badge,
body.dark.reading-mode .kb-card .tag,
body.dark.reading-mode .article-meta .article-badge,
body.dark.reading-mode .article-meta .article-meta-badge {
    background: rgba(240,182,106,.12);
    border-color: rgba(240,182,106,.26);
    color: #ffd08f;
}
@media (max-width: 900px) {
    body.reading-mode .article-main {
        padding: 32px 26px;
    }
    body.reading-mode .article-main h1 {
        font-size: 32px;
    }
    body.reading-mode .article-main p,
    body.reading-mode .article-main li {
        font-size: 16.5px;
        line-height: 1.82;
    }
}
@media (max-width: 760px) {
    .header-controls {
        width: 100%;
        justify-content: flex-start;
    }
    .reading-toggle,
    .theme-toggle {
        min-height: 40px;
    }
}


/* v2 finance article card polish */
.kb-card {
    align-items: stretch;
}
.kb-card-image {
    height: 172px;
    padding: 0;
}
.kb-card-image img {
    width: 100%;
    height: 100%;
    padding: 0 !important;
    object-fit: cover !important;
}
.kb-card-content {
    background: linear-gradient(135deg, rgba(0,91,255,.06), rgba(139,92,246,.05));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px 24px;
    min-height: 172px;
    box-sizing: border-box;
}
.kb-card h2,
.kb-card h3 {
    font-size: 31px;
    line-height: 1.12;
    letter-spacing: -0.35px;
    margin-bottom: 12px;
}
.kb-card p {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
    max-width: none;
}
.kb-card-content .article-badge {
    margin-top: auto;
    min-height: 32px;
    padding: 7px 13px;
    font-size: 12px;
}
body.dark .kb-card-content {
    background: linear-gradient(135deg, rgba(59,130,246,.12), rgba(139,92,246,.10));
    border-color: rgba(96,165,250,.18);
}
body.reading-mode .kb-card-content {
    background: rgba(138,90,37,.08);
    border-color: rgba(138,90,37,.18);
}
body.dark.reading-mode .kb-card-content {
    background: rgba(240,182,106,.08);
    border-color: rgba(240,182,106,.16);
}
@media (max-width: 900px) {
    .kb-card {
        grid-template-columns: 220px minmax(0, 1fr);
    }
    .kb-card h2,
    .kb-card h3 {
        font-size: 27px;
    }
}
@media (max-width: 760px) {
    .kb-card {
        grid-template-columns: 1fr;
    }
    .kb-card-image,
    .kb-card-content {
        min-height: 0;
        height: auto;
    }
    .kb-card-image {
        height: 190px;
    }
    .kb-card-content {
        padding: 18px;
    }
    .kb-card h2,
    .kb-card h3 {
        font-size: 23px;
        line-height: 1.2;
    }
    .kb-card p {
        font-size: 15px;
        line-height: 1.65;
    }
}
