:root {
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-color: #0284c7;
    /* Darker blue for contrast on white */
    --accent-hover: #0ea5e9;
    --border-color: #e2e8f0;
    --glass-border: rgba(0, 0, 0, 0.05);
    --font-heading: 'Noto Sans KR', sans-serif;
    --font-body: 'Inter', 'Noto Sans KR', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
    /* App container handles scroll */
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.25rem;
}

.sidebar-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.search-container input {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.search-container input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.department-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    margin: 0 -0.5rem;
    /* Optical alignment */
    padding: 0 0.5rem;
}

.department-list::-webkit-scrollbar {
    width: 6px;
}

.department-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.dept-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.dept-item:hover {
    background-color: #f1f5f9;
    color: var(--text-primary);
}

.dept-item.active {
    background-color: #e0f2fe;
    /* Light blue bg */
    color: #0284c7;
    /* Brand blue text */
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    position: relative;
    overflow: hidden;
}

.top-bar {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.action-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background-color: #e0f2fe;
}

.top-bar h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: 8px;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    border-radius: 6px;
    font-family: var(--font-body);
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background-color: white;
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
}

.content-area {
    flex-grow: 1;
    padding: 2rem;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Markdown Styling */
.markdown-body {
    max-width: 900px;
    margin: 0 auto;
    color: #334155;
    line-height: 1.7;
    font-size: 1rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 700;
}

.markdown-body h1 {
    font-size: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.markdown-body h2 {
    font-size: 1.5rem;
}

.markdown-body h3 {
    font-size: 1.25rem;
}

.markdown-body p {
    margin-bottom: 1rem;
}

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body blockquote {
    border-left: 4px solid var(--accent-color);
    color: var(--text-secondary);
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    background: rgba(56, 189, 248, 0.1);
    padding: 1rem;
    border-radius: 0 8px 8px 0;
}

.markdown-body code {
    font-family: 'Fira Code', monospace;
    background-color: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e11d48;
    border: 1px solid #e2e8f0;
}

.markdown-body pre {
    background-color: #1e293b;
    /* Keep code blocks dark for contrast */
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.markdown-body pre code {
    background: none;
    color: #e2e8f0;
    padding: 0;
    border: none;
}

/* Tables */
/* Tables - Clean Grid Style */
/* Professional Data Table Style */
.markdown-body table {
    width: 100%;
    border-collapse: separate;
    /* Allows for border radius */
    border-spacing: 0;
    margin-bottom: 2rem;
    background-color: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    /* Rounded corners */
    overflow: hidden;
    font-size: 0.95rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.markdown-body th,
.markdown-body td {
    padding: 1rem 1.25rem;
    /* More comfortable padding */
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    /* Vertical dividers */
    color: #334155;
    line-height: 1.6;
    vertical-align: top;
    /* Align text to top for multi-line content */
}

/* Remove right border for the last column */
.markdown-body th:last-child,
.markdown-body td:last-child {
    border-right: none;
}

/* Remove bottom border for the last row */
.markdown-body tr:last-child td {
    border-bottom: none;
}

.markdown-body th {
    background-color: #f8fafc;
    /* Subtle header bg */
    color: #1e293b;
    /* Darker, distinct text */
    font-weight: 700;
    text-align: left;
    /* Clean left alignment */
    border-bottom: 2px solid #cbd5e1;
    /* Stronger separation */
    white-space: normal;
}

/* Alternate row coloring */
.markdown-body tr:nth-child(even) {
    background-color: #f8fafc;
}

.markdown-body tr:hover {
    background-color: #f1f5f9;
}

.markdown-body tr {
    page-break-inside: avoid;
}

.markdown-body table {
    page-break-inside: auto;
}



.placeholder-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.25rem;
    margin-top: 4rem;
    opacity: 0.7;
}

/* Print/PDF Styling - Now simpler as default is light */
@media print {
    .sidebar {
        display: none;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .top-bar {
        display: none;
    }

    .markdown-body {
        max-width: 100%;
    }
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.login-card h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.login-card input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.login-card button {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-card button:hover {
    background-color: var(--accent-hover);
}

.error-msg {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    min-height: 1.25rem;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    /* Off-canvas sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(100%);
        /* Hidden by default */
        transition: transform 0.3s ease-in-out;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        border-right: none;
        border-left: 1px solid var(--border-color);
        max-height: none;
    }

    .sidebar.active {
        transform: translateX(0);
        /* Visible */
    }

    .sidebar-close-btn {
        display: block;
        /* Visible on mobile */
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--text-secondary);
    }

    .main-content {
        height: 100%;
        overflow: hidden;
    }

    .top-bar {
        padding: 1rem;
        flex-direction: row;
        /* Keep row for header title and menu btn */
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .header-left {
        flex: 1;
    }

    .header-right {
        width: auto;
        justify-content: flex-end;
        display: flex;
        /* Ensure it's flex */
        align-items: center;
    }

    .mobile-menu-btn {
        display: block !important;
        /* Force visibility */
        margin-right: 0.5rem;
    }

    /* Tabs move to a new row if needed, or stack */
    .tabs {
        width: 100%;
        margin-top: 1rem;
        order: 3;
        /* Push to bottom of flex container */
        display: flex;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .content-area {
        padding: 1rem;
        overflow-y: auto;
        height: calc(100vh - 140px);
        /* Adjust based on header height */
    }

    .login-card {
        width: 90%;
        padding: 1.5rem;
    }
}

/* Base styles for new elements */
.mobile-menu-btn {
    display: none;
    /* Hidden on desktop */
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px;
    width: 32px;
    height: 32px;
    display: none;
    /* Desktop default: hidden */
}

.sidebar-close-btn {
    display: none;
    /* Hidden on desktop */
}