/* 🌙 OS 어둡게(2026-11-29 대표 «다크모드 OS 전체») — html.os-dark(os-theme.js)일 때만.
   메신저 창은 자기 다크 규칙이 있다 — os-theme.js 가 메신저 창에서는 표식을 붙이지 않는다.
   1단계: 옛 화면들이 공통으로 쓰는 Tailwind 흰 바탕·회색 글자·테두리를 한꺼번에 바꾼다(그래서 !important).
   화면마다 JS 인라인으로 박힌 색은 일부만 잡힌다 — 남은 곳은 캡처로 찾아 화면별로 고친다(다음 단계). */
html.os-dark, html.msgr-v2[data-theme="dark"] {
    color-scheme: dark;
    --dk-bg: #0f1012; --dk-surface: #17181b; --dk-surface2: #1f2024; --dk-line: #2c2d33; --dk-line2: #3a3b42;
    --dk-text: #e6e6e9; --dk-text2: #c4c4cb; --dk-sub: #a1a1aa; --dk-faint: #71717a; --dk-accent: #60a5fa;
}
html.os-dark body { background: var(--dk-bg) !important; color: var(--dk-text); }

/* 새 틀 */
html.os-dark body.shell-v2 { --sv2-primary: #f4f4f5; --sv2-on-primary: #18181b; --sv2-ink: var(--dk-text); --sv2-sub: var(--dk-sub); --sv2-line: var(--dk-line); --sv2-side: var(--dk-surface); --sv2-soft: #1e293b; --sv2-accent: #60a5fa; }
html.os-dark body.shell-v2 .sv2-rail { background: var(--dk-surface); border-right-color: var(--dk-line); }
html.os-dark body.shell-v2 .sv2-it { color: var(--dk-text2); }
html.os-dark body.shell-v2 .sv2-it.on, html.os-dark body.shell-v2 .sv2-brand { color: #fff; }
html.os-dark body.shell-v2 .sv2-sub { color: var(--dk-sub); }
html.os-dark body.shell-v2 .sv2-sub.on { background: var(--dk-surface2); color: #fff; }
html.os-dark body.shell-v2 .sv2-it:hover, html.os-dark body.shell-v2 .sv2-sub:hover, html.os-dark body.shell-v2 .sv2-recent:hover { background: var(--dk-surface2); }
html.os-dark body.shell-v2 .sv2-top, html.os-dark body.shell-v2 .sv2-page:not([hidden]), html.os-dark body.shell-v2 .sv2-drawer, html.os-dark body.shell-v2 .sv2-df, html.os-dark body.shell-v2 .sv2-tabs { background: var(--dk-bg); border-color: var(--dk-line); }
html.os-dark body.shell-v2 .sv2-search, html.os-dark body.shell-v2 .sv2-cmt, html.os-dark body.shell-v2 .sv2-chip, html.os-dark body.shell-v2 .sv2-x, html.os-dark body.shell-v2 .sv2-btn.g { background: var(--dk-surface); color: var(--dk-text2); border-color: var(--dk-line2); }
html.os-dark body.shell-v2 .sv2-av { background: var(--dk-surface2); color: var(--dk-text2); }
html.os-dark body.shell-v2 .sv2-btn:not(.g), html.os-dark body.shell-v2 .sv2-chip.on, html.os-dark body.shell-v2 .sv2-new-btn { background: var(--sv2-primary); color: var(--sv2-on-primary); border-color: var(--sv2-primary); }
html.os-dark body.shell-v2 .sv2-new-menu { background: var(--dk-surface); border-color: var(--dk-line2); }
html.os-dark body.shell-v2 .sv2-new-it { color: var(--dk-text); }
html.os-dark body.shell-v2 .sv2-new-it:hover { background: var(--dk-surface2); }
html.os-dark body.shell-v2 .sv2-li.sel, html.os-dark body.shell-v2 .sv2-list .sv2-li.sel { background: var(--dk-surface2); box-shadow: inset 2px 0 0 #f4f4f5; }
html.os-dark body.shell-v2 .sv2-li:hover, html.os-dark body.shell-v2 .sv2-tr:hover { background: var(--dk-surface); }
html.os-dark body.shell-v2 .sv2-v.w { color: #f87171; }
html.os-dark body.shell-v2 .sv2-t-apv { background: #422006; color: #fcd34d; }
html.os-dark body.shell-v2 .sv2-t-ntf { background: var(--dk-surface2); color: var(--dk-text2); }
html.os-dark body.shell-v2 .sv2-mine { background: #1e293b; color: #93c5fd; }
html.os-dark .sv2-drawer .apvd-steps { background: var(--dk-surface); }
html.os-dark .sv2-drawer .apvd-step.done { background: var(--dk-surface2); color: var(--dk-text2); }
html.os-dark .sv2-drawer .apvd-step.now { background: #f4f4f5; color: #18181b; }
html.os-dark body.shell-v2 .content-area, html.os-dark body.shell-v2 #mainContent { background: var(--dk-bg); }

/* 옛 화면 공통 — 바탕 */
html.os-dark .bg-white, html.os-dark .settings-card, html.os-dark .modal-content,
html.os-dark [style*="background:#fff"], html.os-dark [style*="background: #fff"],
html.os-dark [style*="background:white"], html.os-dark [style*="background: white"],
html.os-dark [style*="background:#ffffff"], html.os-dark [style*="background-color: rgb(255, 255, 255)"] { background-color: var(--dk-surface) !important; }
html.os-dark .bg-slate-50, html.os-dark .bg-gray-50, html.os-dark .bg-slate-100, html.os-dark .bg-gray-100,
html.os-dark [style*="background:#f8fafc"], html.os-dark [style*="background: #f8fafc"], html.os-dark [style*="background:#f1f5f9"] { background-color: var(--dk-surface2) !important; }
html.os-dark .content-area, html.os-dark #mainContent, html.os-dark .app-body { background-color: var(--dk-bg) !important; }
html.os-dark .hover\:bg-slate-50:hover, html.os-dark .hover\:bg-slate-100:hover, html.os-dark .hover\:bg-gray-50:hover { background-color: var(--dk-surface2) !important; }

/* 글자 */
html.os-dark .text-slate-900, html.os-dark .text-slate-800, html.os-dark .text-gray-900, html.os-dark .text-gray-800, html.os-dark .text-black,
html.os-dark [style*="color:#1e293b"], html.os-dark [style*="color: #1e293b"], html.os-dark [style*="color:#0f172a"], html.os-dark [style*="color:#334155"] { color: var(--dk-text) !important; }
html.os-dark .text-slate-700, html.os-dark .text-slate-600, html.os-dark .text-gray-700, html.os-dark .text-gray-600,
html.os-dark [style*="color:#475569"], html.os-dark [style*="color: #475569"] { color: var(--dk-text2) !important; }
html.os-dark .text-slate-500, html.os-dark .text-slate-400, html.os-dark .text-gray-500, html.os-dark .text-gray-400,
html.os-dark [style*="color:#64748b"], html.os-dark [style*="color: #64748b"], html.os-dark [style*="color:#94a3b8"] { color: var(--dk-sub) !important; }

/* 테두리·구분선 */
html.os-dark .border-slate-100, html.os-dark .border-slate-200, html.os-dark .border-slate-300, html.os-dark .border-gray-100, html.os-dark .border-gray-200, html.os-dark .border-gray-300,
html.os-dark .divide-slate-100 > * + *, html.os-dark .divide-slate-200 > * + * { border-color: var(--dk-line) !important; }
html.os-dark table th, html.os-dark table td { border-color: var(--dk-line) !important; }
html.os-dark thead, html.os-dark .fin3-thead { background-color: var(--dk-surface2) !important; color: var(--dk-sub); }

/* 입력칸 */
html.os-dark input:not([type=checkbox]):not([type=radio]):not([type=range]), html.os-dark select, html.os-dark textarea { background-color: var(--dk-surface) !important; color: var(--dk-text) !important; border-color: var(--dk-line2) !important; }
html.os-dark input::placeholder, html.os-dark textarea::placeholder { color: var(--dk-faint) !important; }

/* 그림자는 어두운 바탕에서 지저분해 보여 줄인다 */
html.os-dark .shadow, html.os-dark .shadow-sm, html.os-dark .shadow-md, html.os-dark .shadow-lg, html.os-dark .shadow-xl { box-shadow: none !important; }

/* 문서·인쇄용 종이(견적서 미리보기)는 밝게 둔다 — 출력물과 같아야 한다. 위 공통 규칙이 덮은 것을 종이 안에서 되돌린다 */
html.os-dark .quote-paper { background-color: #fff !important; color: #0f172a !important; }
html.os-dark .quote-paper .bg-white, html.os-dark .quote-paper [style*="background"] { background-color: #fff !important; }
html.os-dark .quote-paper .bg-slate-50, html.os-dark .quote-paper .bg-slate-100 { background-color: #f8fafc !important; }
html.os-dark .quote-paper input:not([type=checkbox]):not([type=radio]), html.os-dark .quote-paper select, html.os-dark .quote-paper textarea { background-color: #fff !important; color: #0f172a !important; border-color: #e2e8f0 !important; }
html.os-dark .quote-paper [class*="text-slate"], html.os-dark .quote-paper [class*="text-gray"], html.os-dark .quote-paper [style*="color"] { color: #1e293b !important; }
html.os-dark .quote-paper table th, html.os-dark .quote-paper table td { border-color: #cbd5e1 !important; }
html.os-dark .quote-paper h1, html.os-dark .quote-paper h2, html.os-dark .quote-paper h3, html.os-dark .quote-paper .quote-title { color: #0f172a !important; }
html.os-dark .btn-outline { background: var(--dk-surface) !important; color: var(--dk-text2) !important; border-color: var(--dk-line2) !important; }
html.os-dark body.shell-v2 #mainContent .btn-primary, html.os-dark body.shell-v2 #mainContent button.bg-indigo-600, html.os-dark body.shell-v2 #mainContent button.bg-blue-600, html.os-dark body.shell-v2 #mainContent .apv-req-btn { background: var(--sv2-primary) !important; border-color: var(--sv2-primary) !important; color: var(--sv2-on-primary) !important; }
html.os-dark body.shell-v2 #mainContent button[aria-pressed="true"] { background: #f4f4f5 !important; border-color: #f4f4f5 !important; color: #18181b !important; }
html.os-dark .quote-workflow-heading strong, html.os-dark .workspace-tools summary { color: var(--dk-text) !important; }
html.os-dark .workspace-tools summary { background: var(--dk-surface) !important; border-color: var(--dk-line2) !important; }

/* JS 가 style.cssText 로 넣은 색은 브라우저가 rgb(…) 로 바꿔 적는다 — 그 모양으로 잡는다 */
html.os-dark [style*="background: rgb(255, 255, 255)"], html.os-dark [style*="background-color: rgb(255, 255, 255)"], html.os-dark [style*="background: white"] { background-color: var(--dk-surface) !important; }
html.os-dark [style*="background: rgb(248, 250, 252)"], html.os-dark [style*="background-color: rgb(248, 250, 252)"], html.os-dark [style*="background: rgb(241, 245, 249)"], html.os-dark [style*="background-color: rgb(241, 245, 249)"] { background-color: var(--dk-surface2) !important; }
html.os-dark [style*=" color: rgb(30, 41, 59)"], html.os-dark [style^="color: rgb(30, 41, 59)"], html.os-dark [style*=" color: rgb(15, 23, 42)"], html.os-dark [style^="color: rgb(15, 23, 42)"], html.os-dark [style*=" color: rgb(51, 65, 85)"], html.os-dark [style^="color: rgb(51, 65, 85)"] { color: var(--dk-text) !important; }
html.os-dark [style*=" color: rgb(71, 85, 105)"], html.os-dark [style^="color: rgb(71, 85, 105)"] { color: var(--dk-text2) !important; }
html.os-dark [style*=" color: rgb(100, 116, 139)"], html.os-dark [style^="color: rgb(100, 116, 139)"], html.os-dark [style*=" color: rgb(148, 163, 184)"], html.os-dark [style^="color: rgb(148, 163, 184)"] { color: var(--dk-sub) !important; }
html.os-dark [style*="rgb(226, 232, 240)"], html.os-dark [style*="rgb(241, 245, 249)"][style*="border"] { border-color: var(--dk-line) !important; }
html.os-dark .page-title, html.os-dark #topbarTitle { color: var(--dk-text) !important; }
html.os-dark #projectListContainer button:not([aria-pressed="true"]):not(.pl-create-btn), html.os-dark #projectListContainer summary { background: var(--dk-surface) !important; color: var(--dk-text2) !important; border-color: var(--dk-line2) !important; }

/* 표 머리줄 칸(옛 화면이 th 에 흰 바탕을 직접 준다) */
html.os-dark th { background-color: var(--dk-surface2) !important; color: var(--dk-sub) !important; }
/* 연한 색 바탕 칩·안내 상자 → 어두운 바탕에 맞는 옅은 색 */
html.os-dark .bg-emerald-50, html.os-dark .bg-emerald-100, html.os-dark .bg-green-50, html.os-dark .bg-green-100 { background-color: rgba(16, 185, 129, .16) !important; }
html.os-dark .bg-amber-50, html.os-dark .bg-amber-100, html.os-dark .bg-yellow-50, html.os-dark .bg-yellow-100, html.os-dark .bg-orange-50 { background-color: rgba(245, 158, 11, .16) !important; }
html.os-dark .bg-blue-50, html.os-dark .bg-blue-100, html.os-dark .bg-indigo-50, html.os-dark .bg-indigo-100, html.os-dark .bg-sky-50 { background-color: rgba(96, 165, 250, .16) !important; }
html.os-dark .bg-red-50, html.os-dark .bg-red-100, html.os-dark .bg-rose-50, html.os-dark .bg-rose-100 { background-color: rgba(248, 113, 113, .16) !important; }
html.os-dark .bg-violet-50, html.os-dark .bg-violet-100, html.os-dark .bg-purple-50 { background-color: rgba(167, 139, 250, .16) !important; }
html.os-dark .text-emerald-600, html.os-dark .text-emerald-700, html.os-dark .text-green-700 { color: #6ee7b7 !important; }
html.os-dark .text-amber-600, html.os-dark .text-amber-700, html.os-dark .text-amber-800, html.os-dark .text-yellow-700 { color: #fcd34d !important; }
html.os-dark .text-blue-600, html.os-dark .text-blue-700, html.os-dark .text-indigo-600, html.os-dark .text-indigo-700 { color: #93c5fd !important; }
html.os-dark .text-red-600, html.os-dark .text-red-700, html.os-dark .text-rose-700 { color: #fca5a5 !important; }
html.os-dark .border-amber-200, html.os-dark .border-amber-300, html.os-dark .border-yellow-200, html.os-dark .border-emerald-200, html.os-dark .border-blue-200, html.os-dark .border-indigo-200, html.os-dark .border-red-200 { border-color: var(--dk-line2) !important; }
html.os-dark body.shell-v2 #mainContent .pl-create-btn { background: #f4f4f5 !important; color: #18181b !important; }
html.os-dark .workspace-tools summary { border: 1px solid var(--dk-line2) !important; box-shadow: none !important; }
/* 결재 상세·지출 지급 목록(받은 일 서랍·재무 결재) */
html.os-dark .apvd-step.todo { background: var(--dk-surface) !important; color: var(--dk-faint) !important; border-color: var(--dk-line2) !important; }
html.os-dark .fin-expl-list, html.os-dark .exp-pay-more, html.os-dark .fin-action-menu-items { background-color: var(--dk-surface) !important; border-color: var(--dk-line) !important; color: var(--dk-text2); }
html.os-dark .fin-expl-list * { border-color: var(--dk-line) !important; }
/* 재무 대시보드 */
html.os-dark #finDashboardContainer .fin-overview-box { background: var(--dk-surface) !important; border-color: var(--dk-line) !important; }
html.os-dark #finDashboardContainer .fin-overview-bar { background: var(--dk-surface2) !important; }
html.os-dark .fin-review-chip { background: rgba(245, 158, 11, .16) !important; color: #fcd34d !important; border-color: var(--dk-line2) !important; }
/* 반투명 Tailwind 바탕(bg-slate-50/50 등)과 줄무늬 */
html.os-dark [class*="bg-slate-50/"], html.os-dark [class*="bg-slate-100/"], html.os-dark [class*="bg-gray-50/"], html.os-dark [class*="bg-white/"] { background-color: var(--dk-surface2) !important; }
html.os-dark .doc-table tbody tr:nth-child(even) { background: var(--dk-surface2) !important; }
/* JS 인라인 노랑·빨강 안내(rgb 표기) */
html.os-dark [style*="background: rgb(255, 251, 235)"], html.os-dark [style*="background-color: rgb(255, 251, 235)"], html.os-dark [style*="background: rgb(254, 243, 199)"], html.os-dark [style*="background-color: rgb(254, 243, 199)"] { background-color: rgba(245, 158, 11, .14) !important; }
html.os-dark [style*="background: rgb(254, 242, 242)"], html.os-dark [style*="background-color: rgb(254, 242, 242)"] { background-color: rgba(248, 113, 113, .14) !important; }
html.os-dark [style*=" color: rgb(146, 64, 14)"], html.os-dark [style^="color: rgb(146, 64, 14)"], html.os-dark [style*=" color: rgb(180, 83, 9)"], html.os-dark [style^="color: rgb(180, 83, 9)"], html.os-dark [style*=" color: rgb(120, 53, 15)"] { color: #fcd34d !important; }
html.os-dark [style*=" color: rgb(153, 27, 27)"], html.os-dark [style^="color: rgb(153, 27, 27)"], html.os-dark [style*=" color: rgb(185, 28, 28)"] { color: #fca5a5 !important; }
html.os-dark body.shell-v2 .guide-banner { background: transparent !important; border-color: var(--dk-line) !important; }
/* 재무 — 클래스로 색을 준 제목·줄·칩 */
html.os-dark #mainContent h1, html.os-dark #mainContent h2, html.os-dark #mainContent h3, html.os-dark #mainContent h4, html.os-dark .fin-overview-box-head, html.os-dark .trsd-t1 { color: var(--dk-text) !important; }
html.os-dark .fin-overview-box span:first-child, html.os-dark .fin-overview-box strong { color: var(--dk-text2) !important; }
html.os-dark .trsd-list, html.os-dark .trsd-row, html.os-dark .fin-trs-manage-tabs, html.os-dark #mainContent summary { background-color: var(--dk-surface) !important; color: var(--dk-text2) !important; border-color: var(--dk-line) !important; }
html.os-dark .trsd-row:hover { background-color: var(--dk-surface2) !important; }
html.os-dark .trsd-q-t, html.os-dark .trsd-q-n, html.os-dark .trsd-q-sub, html.os-dark .trsd-q-act, html.os-dark .trsd-sec-btn, html.os-dark .trsd-badge { color: var(--dk-text2) !important; }
html.os-dark #mainContent button.flex-1 { color: var(--dk-text2); }
html.os-dark body.shell-v2 .fin-overview-advice[data-sev] { color: var(--dk-text) !important; }
html.os-dark .trsd-q, html.os-dark .trsd-sec-btn { background-color: var(--dk-surface2) !important; border-color: var(--dk-line2) !important; color: var(--dk-text2) !important; }
html.os-dark .trsd-q.warn, html.os-dark .trsd-q.amber { border-color: rgba(245, 158, 11, .5) !important; }
html.os-dark .trsd-q.info { border-color: rgba(96, 165, 250, .5) !important; }
html.os-dark #mainContent button.bg-white { background-color: var(--dk-surface) !important; color: var(--dk-text2) !important; }
html.os-dark #financeTreasuryContainer button[aria-current="false"] { background: var(--dk-surface) !important; color: var(--dk-text2) !important; border-color: var(--dk-line2) !important; }
html.os-dark body.shell-v2 #financeTreasuryContainer button[aria-current="page"] { background: #f4f4f5 !important; color: #18181b !important; border-color: #f4f4f5 !important; }

/* 시험 셸의 옛 본문·슬라이드 패널. 출력용 종이에는 본문 팔레트를 적용하지 않는다. */
@scope (html.os-dark body.shell-v2 :is(#mainContent, .right-slide-panel)) to (.quote-paper) {
    :scope.right-slide-panel,
    :is(.bg-white, .fin-apv-controls, .fin-apv-list, .fin-apv-detail-pane,
        .fin-apv-type-groups button:not([aria-pressed="true"]), .approval-inbox-folders button[aria-current="page"],
        [style*="background:#fff;" i], [style*="background: #fff;" i],
        [style*="background: rgb(255, 255, 255)"], [style*="background-color: rgb(255, 255, 255)"]) {
        background-color: var(--sv2-side) !important;
        border-color: var(--sv2-line) !important;
    }
    :is(.right-slide-panel, .fin-apv-controls, .fin-apv-list, .fin-apv-detail-pane) { color: var(--sv2-ink); }
    :is(.bg-slate-50, .bg-gray-50, .bg-slate-100, .bg-gray-100, .apvd-steps, .approval-inbox-folders,
        .fin-apv-card:hover, .fin-apv-count, [style*="background:#f8fafc" i],
        [style*="background: rgb(248, 250, 252)"], [style*="background-color: rgb(248, 250, 252)"]) {
        background-color: var(--dk-surface2) !important;
    }
    :is(.fin-apv-card.is-selected, .fin-apv-card-avatar) { background-color: var(--sv2-soft) !important; }
    :is(.fin-apv-card, .fin-apv-filter-details, .apvd-steps, .border-slate-100, .border-slate-200,
        .border-slate-300, [style*="border:1px solid #e2e8f0" i]) { border-color: var(--sv2-line) !important; }
    :is(.text-slate-900, .text-slate-800, .text-slate-700, .fin-apv-card-project, .fin-apv-section,
        .fin-apv-card-amount, .fin-apv-card-avatar, .fin-apv-count,
        [style^="color:#1e293b" i], [style*=";color:#1e293b" i]) { color: var(--sv2-ink) !important; }
    :is(.text-slate-600, .text-slate-500, .text-slate-400, .fin-apv-card-type, .fin-apv-card-summary,
        .fin-apv-card-meta, .fin-apv-section-count, .fin-apv-pane-empty, .approval-inbox-help,
        .approval-inbox-folders button:not([aria-current="page"]), .fin-apv-type-groups button:not([aria-pressed="true"])) {
        color: var(--sv2-sub) !important;
    }
    .approval-inbox-folders button[aria-current="page"] { color: var(--sv2-accent) !important; }
}
/* 밝은 레거시 카드에 명시된 어두운 모드용 연한 글자. 반전 버튼 안에는 적용하지 않는다. */
@scope (html:not(.os-dark) body.shell-v2 :is(#mainContent, .right-slide-panel)) to (.quote-paper) {
    :where(.fin-apv-controls, .fin-apv-list, .fin-apv-detail-pane, .right-slide-panel,
        section.bg-white, div.bg-white, section.bg-slate-50, div.bg-slate-50, div.bg-amber-50) {
        color: var(--sv2-ink);
    }
    :is(.bg-white, .bg-slate-50, .bg-gray-50, .fin-apv-detail-pane) >
        :is(.text-slate-100, .text-slate-200, .text-gray-100, .text-gray-200,
            [style^="color:#e2e8f0" i], [style*=";color:#e2e8f0" i], [style^="color: rgb(226, 232, 240)"],
            [style*="; color: rgb(226, 232, 240)"]):not(button, [class*="bg-"], [style*="background"]) {
        color: var(--sv2-ink) !important;
    }
}

/* 프로젝트 정보 띠의 고정색은 저장 상태별 의미를 유지한다. */
html.os-dark body.shell-v2 #projectContextStrip .pcs-title,
html.os-dark body.shell-v2 #projectContextStrip .pcs-mobile-summary { color: var(--sv2-ink); }
html.os-dark body.shell-v2 #projectContextStrip .pcs-chip {
    background: var(--dk-surface); border-color: var(--sv2-line); color: var(--dk-text2);
}
html.os-dark body.shell-v2 #projectContextStrip .pcs-status { background: var(--sv2-soft); color: var(--sv2-accent); }
html.os-dark body.shell-v2 #projectContextStrip .pcs-save { background: transparent; color: var(--sv2-sub); }
html.os-dark body.shell-v2 #projectContextStrip .pcs-save-pending { color: var(--svf-amber); }
html.os-dark body.shell-v2 #projectContextStrip .pcs-save-bad { color: var(--svf-error); }
html.os-dark body.shell-v2 #view-dashboard .pb-entry {
    background: var(--dk-surface); color: var(--sv2-ink); border-color: var(--sv2-line); border-inline-start-color: var(--sv2-accent);
}
