:root {
    --primary-blue: #2563eb;
    --light-blue: #eff6ff;
    --dark-blue: #111827;
    --text-color: #111827;
    --text-secondary: #6b7280;
    --gray-bg: #f4f6f9;
    --success-color: #16a34a;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --sidebar-w: 240px;
    --topbar-h: 46px;
    --border-color: #e5e7eb;
    --border-subtle: #f3f4f6;
    --muted-text: #6b7280;
    --focus-color: #2563eb;
    --white: #ffffff;
    --card-shadow: 0 0 0 1px var(--border-color);
}

/* 접근성 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only-focusable:not(:focus):not(:focus-within) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 스킵링크 */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 9999;
    padding: 10px 16px;
    background: var(--primary-blue);
    color: var(--white);
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none;
    border-radius: 0 0 3px 0;
    transition: top 0.1s;
}
.skip-link:focus {
    top: 0;
}

/* 포커스 */
:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: 2px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    color: var(--text-color);
    background-color: var(--gray-bg);
    margin: 0;
    overflow-x: hidden;
    letter-spacing: -0.01em;
}

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* 사이드바 */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--white);
    color: var(--text-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.2s, transform 0.25s;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-brand a {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.brand-icon { display: none; width: 28px; height: 28px; }
.brand-full { height: 24px; }

.sidebar-nav {
    position: relative;
    flex: 1;
    padding: 6px 0;
}
.sidebar-section {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9CA3AF;
    padding: 14px 14px 4px;
    font-weight: 500;
    white-space: nowrap;
}
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 7px 10px;
    color: #374151;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
    gap: 8px;
    white-space: nowrap;
    border-radius: 6px;
    margin: 0 4px;
}
.sidebar-link span,
.sidebar-domain span,
.sidebar-subgroup span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar-link i { width: 17px; text-align: center; font-size: 0.82rem; flex-shrink: 0; }
.sidebar-link:hover { background: #f3f4f6; color: #111827; }
.sidebar-link.active { background: var(--light-blue); color: var(--primary-blue); font-weight: 500; }
.sidebar-badge {
    margin-left: auto;
    background: var(--danger-color);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    line-height: 1;
}
.sidebar-footer {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-hide-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 10px;
    min-height: 44px;
    border: none;
    background: transparent;
    color: #6B7280;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.sidebar-hide-btn:hover { background: var(--gray-bg); color: #111827; }
.sidebar-hide-btn i { font-size: 0.7rem; }
.sidebar-hide-btn.menu-pref-btn { width: auto; flex: none; justify-content: center; }
.menu-pref-btn i { font-size: 0.8rem; }

/* 사이드바 서브메뉴 */
.sidebar-submenu {
    display: none;
    padding-left: 0;
}
.sidebar-submenu.show {
    display: block;
}
.sidebar-submenu .sidebar-link {
    padding: 6px 10px 6px 30px;
    font-size: 0.8rem;
    color: #6B7280;
}
.sidebar-submenu .sidebar-link:hover {
    color: #111827;
    background: #f3f4f6;
}
.sidebar-submenu .sidebar-link.active {
    color: var(--primary-blue);
    background: var(--light-blue);
}
/* 메뉴 검색 */
.menu-find { position: relative; margin: 6px 8px; }
.menu-find .form-control { font-size: 13px; }
.menu-find-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 360px;
    overflow-y: auto;
    padding: 4px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.menu-find-item {
    display: block;
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    text-align: left;
    color: var(--text-color);
    background: none;
    border: 0;
    border-radius: 6px;
}
.menu-find-item small { display: block; font-size: 11px; color: var(--muted-text); }
.menu-find-item.on,
.menu-find-item:hover { background: var(--light-blue); }
.menu-find-none { padding: 10px; font-size: 12px; color: var(--muted-text); }

/* 모듈 전환 */
.mod-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin: 4px 8px 8px;
}
.mod-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--white);
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
}
.mod-btn i { font-size: 13px; }
.mod-btn:hover { color: var(--primary-blue); }
.mod-btn[aria-pressed="true"] { border-color: var(--primary-blue); background: var(--light-blue); color: var(--primary-blue); font-weight: 600; }
body:not(.sidebar-collapsed) .sidebar.mod-mode .sidebar-domain,
body:not(.sidebar-collapsed) .sidebar.mod-mode .sidebar-domain-body { display: none; }
body:not(.sidebar-collapsed) .sidebar.mod-mode .sidebar-domain-body.mod-on,
body:not(.sidebar-collapsed) .sidebar.mod-mode .mod-on .sidebar-subgroup-body { display: block; }
body:not(.sidebar-collapsed) .sidebar.mod-mode .mod-on .sidebar-subgroup { cursor: default; color: var(--text-secondary); font-size: 12px; }
body:not(.sidebar-collapsed) .sidebar.mod-mode .mod-on .sidebar-subgroup:hover { background: none; }
body:not(.sidebar-collapsed) .sidebar.mod-mode .mod-on .sidebar-arrow { display: none; }

/* 즐겨찾기 */
.fav-star {
    margin-left: 6px;
    padding: 0 4px;
    border: 0;
    background: none;
    color: var(--muted-text);
    font-size: 15px;
    vertical-align: 2px;
}
.fav-star[aria-pressed="true"] { color: #f59e0b; }
.page-toolbar h1:has(+ .fav-star) { display: inline-block; }
.menu-star {
    position: absolute;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--muted-text);
    font-size: 12px;
}
.menu-star:hover { color: #f59e0b; }
.menu-star.on { color: #f59e0b; }
.sidebar-link.star-on { padding-right: 30px; }
.fav-link.dragging { opacity: 0.5; }

/* 메뉴 설정 */
.sidebar-domain.menu-off,
.sidebar-domain.menu-off + .sidebar-domain-body { display: none; }
.menu-pref-legend { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.menu-pref-help { margin: 12px 0 0; font-size: 12px; color: var(--muted-text); }

/* 도메인 (1단) */
.sidebar-domain {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    gap: 8px;
    white-space: nowrap;
    border-radius: 6px;
    margin: 2px 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.sidebar-domain:hover { background: #f3f4f6; }
.sidebar-domain i:first-child { width: 17px; text-align: center; font-size: 0.82rem; flex-shrink: 0; }
.sidebar-domain-body {
    display: none;
    padding-left: 0;
}
.sidebar-domain-body.show { display: block; }

/* 서브그룹 (2단) */
.sidebar-subgroup {
    display: flex;
    align-items: center;
    padding: 6px 10px 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    cursor: pointer;
    border-radius: 6px;
    margin: 0 4px;
    transition: background 0.15s;
}
.sidebar-subgroup:hover { background: #f3f4f6; }
.sidebar-subgroup-body {
    display: none;
    padding-left: 0;
}
.sidebar-subgroup-body.show { display: block; }
.sidebar-subgroup-body .sidebar-link {
    padding: 6px 10px 6px 28px;
    font-size: 13px;
    font-weight: 400;
    color: #6B7280;
}
.sidebar-subgroup-body .sidebar-link:hover { color: #111827; background: #f3f4f6; }
.sidebar-subgroup-body .sidebar-link.active { color: var(--primary-blue); background: var(--light-blue); }

/* 급여 모듈 book 전환 */
.sidebar-book-switch { padding: 2px 12px 8px 36px; }
.sidebar-book-switch select { font-size: 12px; }

.sidebar-sublabel {
    font-size: 0.65rem;
    color: #9CA3AF;
    padding: 6px 16px 2px 28px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-parent {
    cursor: pointer;
}
.sidebar-parent .sidebar-arrow {
    margin-left: auto;
    font-size: 0.6rem;
    transition: transform 0.2s;
}
.sidebar-parent.open .sidebar-arrow {
    transform: rotate(90deg);
}

/* 사이드바 리사이즈 */
.sidebar-resize {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    width: 4px;
    height: 100vh;
    cursor: col-resize;
    z-index: 1001;
    transition: left 0.2s, background 0.15s;
}
.sidebar-resize:hover,
.sidebar-resizing .sidebar-resize { background: rgba(0,86,179,0.3); }
.sidebar-resize:focus-visible { outline: 2px solid var(--focus-color); outline-offset: -1px; background: rgba(0,86,179,0.3); }
.sidebar-resizing { cursor: col-resize; user-select: none; }
.sidebar-resizing * { pointer-events: none; }
.sidebar-resizing .sidebar-resize { pointer-events: auto; }
.sidebar-resizing .sidebar,
.sidebar-resizing .sidebar-resize,
.sidebar-resizing .main-wrap { transition: none; }

.sidebar-hover-zone {
    position: fixed;
    top: 0;
    left: 0;
    width: 8px;
    height: 100vh;
    z-index: 999;
    display: none;
}
/* 사이드바 접기 */
.sidebar-collapsed .sidebar {
    width: 56px;
}
.sidebar-collapsed .sidebar-link span,
.sidebar-collapsed .sidebar-hide-btn span,
.sidebar-collapsed .sidebar-badge {
    display: none;
}
.sidebar-collapsed .sidebar-section {
    font-size: 0;
    padding: 0;
    margin: 6px 10px;
    height: 1px;
    background: var(--border-color);
}
.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 10px 0;
}
.sidebar-collapsed .sidebar-link.active {
    background: var(--light-blue);
}
.sidebar-collapsed .sidebar-link i {
    width: auto;
    font-size: 1rem;
}
.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
}
.sidebar-collapsed .brand-full { display: none; }
.sidebar-collapsed .brand-icon { display: block; }
.sidebar-collapsed .sidebar-hide-btn {
    justify-content: center;
}
.sidebar-collapsed .sidebar-hide-btn i {
    transform: rotate(180deg);
}
.sidebar-collapsed .sidebar-resize { left: 56px; }
.sidebar-collapsed .sidebar-footer { flex-direction: column; padding: 6px 4px; }
.sidebar-collapsed .main-wrap { margin-left: 56px; }
/* 접힌 사이드바 */
.sidebar-collapsed .sidebar-submenu { display: none; }
.sidebar-collapsed .sidebar-domain-body { display: none; }
.sidebar-collapsed .menu-find,
.sidebar-collapsed .mod-switch { display: none; }
.sidebar-collapsed .sidebar-subgroup-body { display: none; }
.sidebar-collapsed .sidebar-sublabel { display: none; }
.sidebar-collapsed .sidebar-parent .sidebar-arrow { display: none; }
.sidebar-collapsed .sidebar-domain span { display: none; }
.sidebar-collapsed .sidebar-domain {
    justify-content: center;
    padding: 10px 0;
}
.sidebar-collapsed .sidebar-domain i:first-child { width: auto; font-size: 1rem; }
.sidebar-collapsed .sidebar-subgroup { display: none; }
.sidebar-flyout {
    position: fixed;
    min-width: 120px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 0 6px 6px 0;
    box-shadow: 4px 2px 12px rgba(0,0,0,0.12);
    padding: 4px 0;
    z-index: 1100;
}
.sidebar-flyout .sidebar-link {
    display: flex;
    align-items: center;
    padding: 5px 12px;
    color: #4B5563;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.sidebar-flyout .sidebar-link span {
    display: inline;
}
.sidebar-flyout .sidebar-link:hover {
    color: #111827;
    background: var(--gray-bg);
}
.sidebar-flyout .sidebar-link.active {
    color: var(--primary-blue);
    background: var(--light-blue);
}
.sidebar-flyout .flyout-heading {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    padding: 6px 12px 2px;
    text-transform: uppercase;
}
.sidebar-flyout .flyout-heading:not(:first-child) {
    border-top: 1px solid var(--gray-bg);
    margin-top: 4px;
    padding-top: 8px;
}

.sidebar-hidden .sidebar-hover-zone { display: block; }

.sidebar-hidden .sidebar {
    transform: translateX(-100%);
}
.sidebar-hidden .sidebar-resize { display: none; }
.sidebar-hidden .main-wrap { margin-left: 0; }

.sidebar-peek .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
}
.sidebar-peek .main-wrap { margin-left: 0; }

.sidebar-reset-btn:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 6px 12px;
    margin: 4px 12px;
    overflow: visible;
    clip: auto;
    white-space: normal;
    border: 1px solid var(--border-color);
    background: var(--gray-bg);
    color: var(--text-color);
    border-radius: 3px;
    font-size: 0.8rem;
    cursor: pointer;
}

/* 메인 레이아웃 */
.main-wrap {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left 0.2s;
}

/* 탑바 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}
.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--muted-text);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 3px;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-toggle:hover { background: var(--gray-bg); color: var(--text-color); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--focus-color); outline-offset: 2px; }

.topbar-search {
    flex: 1;
    max-width: 360px;
    position: relative;
}
.topbar-search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 0.82rem;
}
.topbar-search input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 5px 10px 5px 30px;
    font-size: 0.85rem;
    background: var(--gray-bg);
    transition: border-color 0.2s, background 0.2s;
}
.topbar-search input:focus {
    border-color: var(--primary-blue);
    background: #fff;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}
.topbar-icon {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: var(--muted-text);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.topbar-actions > .dropdown {
    display: flex;
}
button.topbar-icon {
    background: none;
    border: none;
    padding: 0;
}
.topbar-icon:hover { background: var(--gray-bg); color: var(--text-color); }
.topbar-icon:focus-visible { outline: 2px solid var(--focus-color); outline-offset: 2px; }
.topbar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger-color);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.topbar-profile {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
    transition: background 0.15s;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    background: none;
    border: none;
    min-height: 36px;
}
.topbar-profile:hover { background: var(--gray-bg); }
.topbar-profile img { width: 26px; height: 26px; border-radius: 50%; }

/* 콘텐츠 영역 */
.content-area {
    padding: 20px 28px;
    min-height: calc(100vh - var(--topbar-h));
}
.content-area .container {
    max-width: none;
    padding: 0;
}

/* 페이지 헤더 */
.page-header {
    margin-bottom: 14px;
}
.page-header h1,
.page-toolbar h1 {
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--dark-blue);
    margin: 0;
    letter-spacing: -0.02em;
}

/* 리스트 섹션 */
.list-section {
    padding-top: 6px;
}

/* 페이지 툴바 */
.page-toolbar {
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 브레드크럼 */
.breadcrumb-nav {
    font-size: 0.75rem;
    color: var(--muted-text);
    margin-bottom: 0;
}
.breadcrumb-nav a {
    color: inherit;
    text-decoration: none;
}
.breadcrumb-nav a:hover {
    text-decoration: underline;
}

/* 유틸 */
.text-xs { font-size: 0.75rem; }
.text-078 { font-size: 0.78rem; }
.text-08 { font-size: 0.8rem; }
.text-088 { font-size: 0.88rem; }
.text-09 { font-size: 0.9rem; }
.text-093 { font-size: 0.93rem; }
.text-07 { font-size: 0.7rem; }
.text-xxs { font-size: 0.65rem; }
.text-095 { font-size: 0.95rem; }
.text-082 { font-size: 0.82rem; }
.pre-line { white-space: pre-line; }
.table-fixed { table-layout: fixed; }
.text-truncate-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.min-w-200 { min-width: 200px; }
.detail-wrap { max-width: 720px; }
.col-quarter { width: 25%; }

.bg-blue-light   { background-color: #dce8f5; color: var(--primary-blue); }
.bg-green-light  { background-color: #d8f0dd; color: #1e7e34; }
.bg-yellow-light { background-color: #fef3cd; color: #b07800; }
.bg-purple-light { background-color: #ece0f5; color: #6a1191; }
.bg-red-light    { background-color: #fadddd; color: #b02a37; }
.bg-teal-light   { background-color: #d4edea; color: #00574d; }
.bg-gray-light   { background-color: #ebebeb; color: #4a4a4a; }

.a11y-large body, .a11y-large { font-size: 1.15rem; }
.a11y-xlarge body, .a11y-xlarge { font-size: 1.3rem; }
.a11y-contrast { filter: contrast(1.2); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    .main-wrap,
    .sidebar-collapsed .main-wrap {
        margin-left: 0;
    }
    .sidebar-resize { display: none; }
    .content-area {
        padding: 14px 16px;
    }
    .topbar-search { display: none; }
}

/* 접근성 모드 */
.a11y-dropdown {
    min-width: 220px;
}
.a11y-option {
    padding: 8px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.a11y-option label {
    margin: 0;
    cursor: pointer;
    font-size: 0.88rem;
    white-space: nowrap;
}
.a11y-option select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 0.82rem;
}

html.font-lg {
    font-size: 150%;
}
html.font-xl {
    font-size: 200%;
}

/* 큰 조작 영역 */
body.large-target a,
body.large-target button,
body.large-target input,
body.large-target select,
body.large-target textarea,
body.large-target .sidebar-link {
    min-height: 52px;
    padding-top: 12px;
    padding-bottom: 12px;
}
body.large-target .sidebar-link {
    padding: 14px 20px;
    font-size: 1rem;
    gap: 12px;
}
body.large-target .topbar-icon {
    width: 52px;
    height: 52px;
}
body.large-target .table-custom td,
body.large-target .table-custom th {
    padding: 14px 16px;
}

.label-easy {
    display: none;
}
body.easy-mode .label-default {
    display: none;
}
body.easy-mode .label-easy {
    display: inline;
}
.icon-label {
    display: none;
}
body.easy-mode .icon-label {
    display: inline;
    margin-left: 0.25rem;
}
