/* ═══════════════════════════════════════════════════════════════════════════
   BeltCollins Wiki — Design System
   Office 365 Inspired Dual Theme + Apple-like Clean Layout
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root,
[data-theme="dark"] {
    --bg: #0f0f0f;
    --bg2: #141414;
    --surface: #1a1a1a;
    --surface2: #252525;
    --border: #303030;
    --border2: #3a3a3a;
    --text: #e0e0e0;
    --text-dim: #a0a0a0;
    --text-bright: #ffffff;
    --accent: #4f6df5;
    --accent-dim: rgba(79,109,245,0.12);
    --accent-hover: #3d5be0;
    --accent-text: #8ba1ff;
    --green: #34d399;
    --yellow: #fbbf24;
    --red: #f87171;
    --topbar-bg: rgba(15,15,15,0.92);
    --sidebar-bg: #121212;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.4);
    --card-shadow-hover: 0 6px 24px rgba(0,0,0,0.5);
    --overlay-bg: rgba(0,0,0,0.8);
    --sidebar-w: 230px;
    --topbar-h: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI',
             'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --transition: 0.25s cubic-bezier(.4,0,.2,1);
}

[data-theme="light"] {
    --bg: #f8f9fa;
    --bg2: #ffffff;
    --surface: #ffffff;
    --surface2: #f5f5f7;
    --border: #e0e0e0;
    --border2: #d0d0d0;
    --text: #202124;
    --text-dim: #5f6368;
    --text-bright: #000000;
    --accent: #1a73e8;
    --accent-dim: rgba(26,115,232,0.08);
    --accent-hover: #1557b0;
    --accent-text: #1a73e8;
    --green: #188038;
    --yellow: #d93025;
    --red: #ea4335;
    --topbar-bg: rgba(255,255,255,0.92);
    --sidebar-bg: #f1f3f4;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --card-shadow-hover: 0 6px 24px rgba(0,0,0,0.12);
    --overlay-bg: rgba(0,0,0,0.4);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-weight: 400;
    transition: background var(--transition), color var(--transition);
}
a { color: inherit; text-decoration: none; }

/* ── Top Bar ────────────────────────────────────────────────────────────── */
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 20px; gap: 16px; z-index: 100;
    transition: background var(--transition), border-color var(--transition);
}

.topbar-left { display: flex; align-items: center; flex-shrink: 0; }
.topbar-logo {
    display: flex; align-items: center; gap: 14px;
    color: var(--text-bright); text-decoration: none;
    font-weight: 700; font-size: 22px; letter-spacing: -0.02em; white-space: nowrap;
    font-family: 'SF Pro Display', 'Helvetica Neue', 'Arial', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: -0.01em;
}
.topbar-logo-img {
    width: 48px; height: 48px; border-radius: 8px; object-fit: contain; display: block; flex-shrink: 0;
    background: rgba(212, 175, 55, 0.08);
    padding: 2px;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.25), 
                0 0 6px rgba(212, 175, 55, 0.15) inset,
                0 0 2px rgba(212, 175, 55, 0.3);
}
.topbar-center { flex: 1; display: flex; justify-content: flex-end; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Search ─────────────────────────────────────────────────────────────── */
.search-form { position: relative; display: flex; align-items: center; width: 320px; max-width: 100%; }
.search-icon { position: absolute; left: 11px; color: var(--text-dim); }
.search-form input {
    width: 100%; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 44px 10px 34px; color: var(--text);
    font-family: var(--font); font-size: 14px; outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.search-form input::placeholder { color: var(--text-dim); }
.search-form kbd {
    position: absolute; right: 8px; background: var(--surface2); color: var(--text-dim);
    font-family: var(--mono); font-size: 10px; padding: 2px 6px; border-radius: 4px;
    pointer-events: none; border: 1px solid var(--border);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 14px; font-weight: 500;
    text-decoration: none; cursor: pointer; border: none;
    transition: all var(--transition); white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-sm:hover { transform: none; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

/* ── Theme Toggle ───────────────────────────────────────────────────────── */
.theme-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 50%;
    cursor: pointer; color: var(--text-dim); transition: all var(--transition);
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
[data-theme="light"] .theme-icon-sun { display: block; }
[data-theme="light"] .theme-icon-moon { display: none; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    height: calc(100vh - var(--topbar-h)); position: sticky; top: var(--topbar-h);
    overflow-y: auto; border-right: 1px solid var(--border);
    background: var(--sidebar-bg); padding: 40px 0 20px;
    transition: background var(--transition), border-color var(--transition);
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.sidebar-nav { padding: 0 8px; }
.sidebar-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    color: var(--text-dim); text-decoration: none;
    font-size: 14px; font-weight: 500;
    transition: background var(--transition), color var(--transition), transform var(--transition);
    line-height: 1.4; margin-bottom: 2px;
}
.sidebar-item:hover { background: var(--surface2); color: var(--text); transform: translateX(4px); }
.sidebar-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.sidebar-divider { height: 1px; background: var(--border); margin: 12px 16px; }
.sidebar-category-label {
    font-size: 12px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.08em; padding: 12px 16px 6px;
}

/* Bilingual nav */
.nav-en { font-size: 15px; font-weight: 500; color: inherit; display: block; line-height: 1.3; }
.nav-cn { font-size: 12px; color: var(--text-dim); font-weight: 400; display: block; line-height: 1.2; margin-top: 2px; opacity: 0.7; }
.page-title-cn { font-size: 14px; font-weight: 400; color: var(--text-dim); margin-left: 10px; }
.ai-card-cn { font-size: 11px; color: var(--text-dim); margin-left: 4px; }

/* ── Main Content ───────────────────────────────────────────────────────── */
.content {
    flex: 1; min-width: 0; padding: 60px 20px 120px;
    max-width: 1000px;
    margin: 0 auto;
    transition: background var(--transition);
}
.page-header { margin-bottom: 36px; }
.page-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text-dim); font-size: 12px; padding: 4px 10px; border-radius: 20px;
    font-weight: 500;
}
.page-title {
    font-size: 36px; font-weight: 700; color: var(--text-bright);
    line-height: 1.1; letter-spacing: -0.02em;
    margin-bottom: 24px;
    text-align: center;
}
.page-meta { margin-top: 12px; font-size: 14px; color: var(--text-dim); font-family: var(--mono); text-align: center; }
.badge {
    background: var(--red); color: white; font-size: 10px; font-weight: 600;
    padding: 2px 6px; border-radius: 10px; margin-left: auto; min-width: 18px; text-align: center;
}
.user-name { color: var(--text-dim); font-size: 12px; padding: 0 4px; }

/* ── Wiki Content ───────────────────────────────────────────────────────── */
.wiki-content { color: var(--text); line-height: 1.75; font-size: 15px; font-weight: 400; }
.wiki-content h1 { font-size: 30px; font-weight: 700; color: var(--text-bright); margin: 40px 0 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); letter-spacing: -0.01em; }
.wiki-content h2 { font-size: 26px; font-weight: 600; color: var(--text-bright); margin: 36px 0 16px; letter-spacing: -0.01em; }
.wiki-content h3 { font-size: 22px; font-weight: 600; color: var(--text); margin: 32px 0 12px; }
.wiki-content h4,.wiki-content h5,.wiki-content h6 { font-size: 18px; font-weight: 600; color: var(--text); margin: 24px 0 10px; }
.wiki-content p { margin: 0 0 16px; }
.wiki-content a { color: var(--accent-text); border-bottom: 1px solid transparent; transition: border-color var(--transition); font-weight: 500; }
.wiki-content a:hover { border-bottom-color: var(--accent-text); }
.wiki-content strong { color: var(--text-bright); font-weight: 600; }
.wiki-content em { color: var(--text-dim); font-style: italic; }
.wiki-content code { background: var(--surface2); border: 1px solid var(--border); color: var(--accent-text); font-family: var(--mono); font-size: 13px; padding: 2px 6px; border-radius: 4px; }
.wiki-content pre { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; overflow-x: auto; margin: 16px 0; box-shadow: var(--card-shadow); }
.wiki-content pre code { background: none; border: none; padding: 0; font-size: 14px; color: var(--text); }
.wiki-content blockquote { border-left: 3px solid var(--accent); background: var(--accent-dim); margin: 16px 0; padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-dim); font-style: italic; }
.wiki-content ul,.wiki-content ol { margin: 12px 0 16px 24px; }
.wiki-content li { margin: 4px 0; }
.wiki-content table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; box-shadow: var(--card-shadow); border-radius: var(--radius); overflow: hidden; }
.wiki-content th { background: var(--surface2); padding: 10px 14px; text-align: left; font-weight: 600; color: var(--text-bright); border: 1px solid var(--border); }
.wiki-content td { padding: 10px 14px; border: 1px solid var(--border); }
.wiki-content tr:nth-child(even) td { background: var(--surface); }
.wiki-content hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.wiki-content img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }

.wiki-content .excel-sheet { margin: 16px 0; overflow-x: auto; }
.wiki-content .excel-sheet h3 { font-size: 15px; font-weight: 600; color: var(--text-bright); margin: 0 0 8px 0; padding: 0; border: none; background: none; }
.wiki-content .excel-table { width: 100%; border-collapse: collapse; margin: 0; font-size: 12px; }
.wiki-content .excel-table th { background: var(--accent-bg); padding: 6px 10px; text-align: left; font-weight: 600; color: var(--accent-text); border: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.wiki-content .excel-table td { padding: 5px 10px; border: 1px solid var(--border); color: var(--text); max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-content .excel-table tr:hover td { background: var(--surface2); }
.wiki-content .excel-table tr:nth-child(even) td { background: var(--surface); }
.wiki-content .excel-table { display: block; overflow-x: auto; white-space: nowrap; }

.not-found { text-align: center; padding: 60px 0; }
.not-found h2 { color: var(--text-bright); margin-bottom: 8px; font-size: 48px; font-weight: 700; }
.not-found p { color: var(--text-dim); margin-bottom: 16px; }
.not-found a { color: var(--accent-text); }

/* ── Search Overlay ─────────────────────────────────────────────────────── */
.search-overlay { position: fixed; inset: 0; background: var(--overlay-bg); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: 100px; backdrop-filter: blur(6px); }
.search-results-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); width: 580px; max-width: 92vw; max-height: 65vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.4); }
.search-results-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-dim); }
.close-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; padding: 4px 8px; border-radius: 4px; }
.close-btn:hover { background: var(--surface2); color: var(--text); }
.search-result-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); text-decoration: none; transition: background var(--transition); }
.search-result-item:hover { background: var(--surface); }
.search-result-item:last-child { border-bottom: none; }
.search-result-title { font-size: 14px; font-weight: 600; color: var(--text-bright); margin-bottom: 2px; }
.search-result-meta { font-size: 11px; color: var(--accent-text); font-family: var(--mono); margin-bottom: 3px; }
.search-result-snippet { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.search-no-results { padding: 28px 16px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ── KB Dashboard ───────────────────────────────────────────────────────── */
.kb-hero {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px 28px; margin-bottom: 20px;
    box-shadow: var(--card-shadow); transition: background var(--transition), border-color var(--transition);
}
.kb-hero-text h1 { font-size: 20px; font-weight: 700; color: var(--text-bright); margin-bottom: 4px; letter-spacing: -0.02em; }
.kb-hero-text p { font-size: 12px; color: var(--text-dim); max-width: 460px; line-height: 1.6; }
.kb-hero-actions { display: flex; gap: 8px; flex-shrink: 0; }
.kb-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 20px; }
.kb-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--card-shadow); transition: all var(--transition); }
.kb-stat-card:hover { box-shadow: var(--card-shadow-hover); border-color: var(--border2); }
.kb-stat-icon { font-size: 20px; margin-bottom: 6px; }
.kb-stat-value { font-size: 22px; font-weight: 700; color: var(--text-bright); letter-spacing: -0.02em; }
.kb-stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.kb-stat-alert .kb-stat-value { color: var(--red); }
.kb-body { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.kb-main { min-width: 0; }
.kb-side { min-width: 0; }
.kb-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--card-shadow); transition: all var(--transition); }
.kb-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.kb-section-header h2 { font-size: 15px; font-weight: 600; color: var(--text-bright); letter-spacing: -0.01em; }
.section-link { font-size: 12px; color: var(--accent-text); font-weight: 500; }
.section-link:hover { text-decoration: underline; }
.ai-summary-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.ai-summary-content { font-size: 13px; color: var(--text); line-height: 1.7; }
.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.project-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-decoration: none; transition: all var(--transition); }
.project-card:hover { border-color: var(--accent); box-shadow: var(--card-shadow-hover); transform: translateY(-1px); }
.project-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.project-icon { font-size: 18px; }
.project-status { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.project-status-active { background: rgba(52,211,153,0.12); color: var(--green); }
.project-status-planning { background: var(--accent-dim); color: var(--accent); }
.project-status-completed { background: var(--surface2); color: var(--text-dim); }
.project-name { font-size: 14px; font-weight: 600; color: var(--text-bright); margin-bottom: 4px; }
.project-meta { font-size: 11px; color: var(--text-dim); display: flex; gap: 6px; flex-wrap: wrap; }
.project-latest { font-size: 10px; color: var(--text-dim); font-family: var(--mono); margin-top: 6px; }
.meeting-list { display: flex; flex-direction: column; }
.meeting-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); text-decoration: none; transition: color var(--transition); gap: 12px; }
.meeting-item:last-child { border-bottom: none; }
.meeting-item:hover .meeting-title { color: var(--accent-text); }
.meeting-item-left { flex: 1; min-width: 0; }
.meeting-title { font-size: 13px; font-weight: 500; color: var(--text-bright); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meeting-project { font-size: 11px; color: var(--text-dim); }
.meeting-item-right { text-align: right; flex-shrink: 0; }
.meeting-date { font-size: 11px; color: var(--text-dim); font-family: var(--mono); margin-bottom: 3px; }
.meeting-todos { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.todo-badge { background: var(--accent-dim); color: var(--accent); font-size: 10px; padding: 1px 7px; border-radius: 8px; font-weight: 500; }
.risk-badge { background: rgba(248,113,113,0.12); color: var(--red); font-size: 10px; padding: 1px 7px; border-radius: 8px; font-weight: 500; }
.case-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.case-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-decoration: none; transition: all var(--transition); }
.case-card:hover { border-color: var(--accent); box-shadow: var(--card-shadow-hover); }
.case-title { font-size: 13px; font-weight: 600; color: var(--text-bright); margin-bottom: 3px; }
.case-project { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.case-sentiment { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 8px; display: inline-block; margin-bottom: 5px; }
.sentiment-positive { background: rgba(52,211,153,0.12); color: var(--green); }
.sentiment-neutral { background: rgba(251,191,36,0.12); color: var(--yellow); }
.sentiment-negative { background: rgba(248,113,113,0.12); color: var(--red); }
.case-date { font-size: 10px; color: var(--text-dim); font-family: var(--mono); }
.side-alerts { display: flex; flex-direction: column; gap: 8px; }
.side-alert { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.side-alert-critical { border-left: 3px solid #dc2626; }
.side-alert-high { border-left: 3px solid var(--red); }
.side-alert-medium { border-left: 3px solid var(--yellow); }
.side-alert-low { border-left: 3px solid var(--green); }
.side-alert-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.side-alert-level { font-size: 11px; font-weight: 600; }
.side-alert-critical .side-alert-level { color: #dc2626; }
.side-alert-high .side-alert-level { color: var(--red); }
.side-alert-medium .side-alert-level { color: var(--yellow); }
.side-alert-low .side-alert-level { color: var(--green); }
.side-alert-time { font-size: 10px; color: var(--text-dim); font-family: var(--mono); }
.side-alert-message { font-size: 12px; color: var(--text); margin-bottom: 2px; }
.side-alert-source { font-size: 10px; color: var(--text-dim); font-family: var(--mono); }
.side-empty { text-align: center; padding: 14px; font-size: 12px; color: var(--text-dim); }
.quick-actions { display: flex; flex-direction: column; gap: 4px; }
.quick-action { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; font-size: 13px; color: var(--text); transition: all var(--transition); }
.quick-action:hover { border-color: var(--accent); color: var(--accent-text); }
.empty-state { text-align: center; padding: 20px; color: var(--text-dim); font-size: 13px; }
.empty-state a { color: var(--accent-text); }

/* ── Upload ─────────────────────────────────────────────────────────────── */
.upload-container { max-width: 640px; }
.dropzone { border: 2px dashed var(--border2); border-radius: var(--radius); padding: 40px 24px; text-align: center; transition: border-color var(--transition), background var(--transition); cursor: pointer; }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-dim); }
.dropzone svg { color: var(--text-dim); margin-bottom: 10px; }
.dropzone p { color: var(--text); font-size: 14px; margin-bottom: 6px; }
.dropzone span { color: var(--text-dim); font-size: 12px; display: block; margin: 6px 0 10px; }
.manual-entry { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.manual-entry summary { padding: 12px 16px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-dim); user-select: none; }
.manual-entry summary:hover { color: var(--text); }
.manual-entry[open] summary { border-bottom: 1px solid var(--border); color: var(--text); }
.manual-entry form { padding: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.form-label-cn { font-size: 10px; color: var(--text-dim); margin-left: 6px; text-transform: none; letter-spacing: 0; }
.form-group input,.form-group textarea,.form-group select { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; color: var(--text); font-family: var(--font); font-size: 13px; outline: none; transition: border-color var(--transition); }
.form-group input:focus,.form-group textarea:focus,.form-group select:focus { border-color: var(--accent); }
.form-group input::placeholder,.form-group textarea::placeholder { color: var(--text-dim); }
.form-group textarea { resize: vertical; min-height: 120px; font-family: var(--mono); font-size: 12px; }
.upload-pending,.upload-success,.upload-error { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 12px; }
.upload-pending { background: var(--surface2); color: var(--text-dim); }
.upload-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: var(--green); }
.upload-success a { color: var(--accent-text); }
.upload-error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--red); }

/* ── Projects Grid ──────────────────────────────────────────────────────── */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.pcl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-decoration: none; transition: all var(--transition); box-shadow: var(--card-shadow); }
.pcl-card:hover { border-color: var(--accent); box-shadow: var(--card-shadow-hover); transform: translateY(-1px); }
.pcl-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pcl-name { font-size: 15px; font-weight: 600; color: var(--text-bright); display: flex; align-items: center; gap: 8px; }
.pcl-stats { display: flex; gap: 14px; margin-bottom: 8px; }
.pcl-stat { text-align: center; }
.pcl-stat-value { font-size: 18px; font-weight: 700; color: var(--text-bright); }
.pcl-stat-label { font-size: 10px; color: var(--text-dim); }

/* ── Admin ──────────────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { background: var(--surface2); padding: 10px 14px; text-align: left; font-weight: 600; color: var(--text-bright); border-bottom: 2px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.admin-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.admin-table tr:hover td { background: var(--surface); }
.role-badge { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.04em; display: inline-block; }
.role-admin { background: rgba(248,113,113,0.12); color: var(--red); }
.role-editor { background: var(--accent-dim); color: var(--accent); }
.role-viewer { background: var(--surface2); color: var(--text-dim); }
.modal-overlay { position: fixed; inset: 0; background: var(--overlay-bg); z-index: 300; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); width: 480px; max-width: 92vw; box-shadow: 0 24px 64px rgba(0,0,0,0.5); overflow: hidden; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--text-bright); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Alerts Page ────────────────────────────────────────────────────────── */
.alerts-stats { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.alert-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 16px; text-align: center; min-width: 80px; }
.alert-stat-value { font-size: 20px; font-weight: 700; color: var(--text-bright); }
.alert-stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }
.alert-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 8px; transition: all var(--transition); }
.alert-card-critical { border-left: 3px solid #dc2626; }
.alert-card-high { border-left: 3px solid var(--red); }
.alert-card-medium { border-left: 3px solid var(--yellow); }
.alert-card-low { border-left: 3px solid var(--green); }

/* ── Search Page ────────────────────────────────────────────────────────── */
.search-bar-large { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 16px; }
.search-bar-large input { flex: 1; background: transparent; border: none; color: var(--text); font-size: 15px; outline: none; font-family: var(--font); }
.search-bar-large input::placeholder { color: var(--text-dim); }

/* ── Wiki Index ─────────────────────────────────────────────────────────── */
.cat-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.cat-tab { padding: 7px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--text-dim); cursor: pointer; transition: all var(--transition); }
.cat-tab:hover { color: var(--text); border-color: var(--border2); }
.cat-tab.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.page-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.page-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; text-decoration: none; transition: all var(--transition); display: block; }
.page-card:hover { border-color: var(--accent); box-shadow: var(--card-shadow-hover); }

/* ── Detail Pages ───────────────────────────────────────────────────────── */
.meeting-page,.case-page { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--card-shadow); }
.meeting-ai-panel,.case-ai-panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-top: 16px; }
.ai-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; }
.ai-card:last-child { margin-bottom: 0; }
.ai-card-title { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; margin-bottom: 6px; }
.ai-card-content { font-size: 13px; color: var(--text); line-height: 1.6; }
.project-hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; box-shadow: var(--card-shadow); }
.project-hero-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.project-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .kb-body { grid-template-columns: 1fr; } .kb-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { padding: 20px 16px 60px; }
    .form-row { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
    .topbar-left { flex: 0 0 auto; }
    .topbar-center { flex: 1 1 100%; order: 3; max-width: 100%; }
    .topbar-center .search-form { width: 100%; }
    .topbar-right { flex: 0 0 auto; gap: 6px; }
    .topbar-center form kbd { display: none; }
    .user-name { display: none; }
    .kb-stats { grid-template-columns: repeat(3, 1fr); }
    .projects-grid { grid-template-columns: 1fr; }
    .project-hero { flex-direction: column; }
    .project-body { grid-template-columns: 1fr; }
    .admin-table { display: block; overflow-x: auto; }
}
@media (max-width: 480px) {
    .topbar { padding: 8px 12px; gap: 6px; }
    .topbar-logo { font-size: 14px; }
    .topbar-logo-img { width: 28px; height: 28px; }
    .btn { padding: 6px 10px; font-size: 12px; }
    .content { padding: 14px 12px 60px; }
    .kb-stats { grid-template-columns: repeat(2, 1fr); }
    .project-cards,.case-cards { grid-template-columns: 1fr; }
}
@media print {
    .topbar,.sidebar,.search-overlay,.btn { display: none !important; }
    .layout { padding-top: 0; }
    .content { padding: 20px; max-width: 100%; }
}

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-body {
    font-family: var(--font);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.login-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid var(--border);
    width: 380px;
    max-width: 90vw;
}

.login-card h1 {
    text-align: center;
    color: var(--text-bright);
    margin-bottom: 6px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-subtitle {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 28px;
}

.login-fg {
    margin-bottom: 18px;
}

.login-fg label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-dim);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-fg input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
}

.login-fg input:focus {
    border-color: var(--accent);
}

.login-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    transition: background var(--transition);
}

.login-btn:hover {
    background: var(--accent-hover);
}

.login-error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--red);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 18px;
    text-align: center;
    font-size: 13px;
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.login-link {
    text-align: center;
    margin-top: 18px;
    color: var(--text-dim);
    font-size: 13px;
}

.login-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.login-link a:hover {
    text-decoration: underline;
}

.login-theme-sw {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.login-logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 8px;
}

/* ── Topic Suggestions ───────────────────────────────────────────────────── */
.topic-input-container {
    position: relative;
    width: 100%;
}

.topic-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--card-shadow);
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    margin-top: 2px;
}

.topic-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.topic-suggestion:last-child {
    border-bottom: none;
}

.topic-suggestion:hover {
    background-color: var(--surface2);
}

.topic-count {
    font-size: 12px;
    color: var(--text-dim);
    font-family: var(--mono);
}
