:root {
    --app-bg: #f3f6fb; --app-surface: #fff; --app-surface-soft: #f8faff; --app-border: #e2e8f2;
    --app-text: #24334b; --app-muted: #748299; --app-primary: #3569e8; --app-primary-dark: #2454c8;
    --app-success: #15966e; --app-warning: #f3bc4d; --app-danger: #df5363; --app-info: #3187c9;
    --app-dark: #14243e; --app-dark-2: #102039; --sidebar-width: 232px; --rail-width: 76px;
    --header-height: 76px; --tab-height: 50px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--app-text); background: var(--app-bg); font: 14px/1.6 "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--app-primary); text-decoration: none; }
a:hover { color: var(--app-primary-dark); }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #92b4ff; outline-offset: 3px; }
button { font: inherit; }
.min-w-0 { min-width: 0; }
.mobile-nav-close { display: none; }
.wrapper { display: flex; min-height: 100vh; background: var(--app-bg); }
.main-content { width: calc(100% - var(--sidebar-width)); min-width: 0; margin-left: var(--sidebar-width); min-height: 100vh; padding: 24px; }
.sidebar { display: flex; flex-direction: column; color: #afbed4; background: var(--app-dark); }
.sidebar .nav-link { display: flex; align-items: center; gap: 11px; min-height: 44px; color: #afbed4; border: 0; border-radius: 9px; font-size: 14px; text-align: left; background: transparent; transition: background .16s, color .16s; }
.sidebar .nav-link:hover { color: #fff; background: #213654; }
.sidebar .nav-link.active { color: #fff; background: var(--app-primary); box-shadow: 0 4px 14px #08193225; }
.sidebar .nav-link i { flex: 0 0 20px; width: 20px; text-align: center; }
.sidebar .nav-link.add-area { color: #a5d8ff; }
.sidebar .nav-link.add-area:hover { color: #fff; }
.sidebar .logo { color: #fff; font-size: 17px; font-weight: 700; }
nav.standalone-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); height: 100vh; z-index: 30; background: var(--app-dark); }
nav.standalone-sidebar .logo { padding: 24px 20px; font-size: 17px; border-bottom: 1px solid #ffffff12; }
nav.standalone-sidebar .nav { flex: 1; overflow-y: auto; padding: 14px 12px; gap: 4px; }
nav.standalone-sidebar .nav-link { margin: 0; padding: 10px 12px; border-radius: 9px; }
nav.standalone-sidebar .user-block { padding: 18px; border-top: 1px solid #ffffff12; }
.user-block .btn { width: 100%; }
.page-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; }
.page-title, h1, h2, h3, h4, h5 { color: var(--app-text); font-weight: 650; letter-spacing: 0; }
.page-title { margin: 0; font-size: 24px; }
.app-card, .card, .modal-content, .block, .rule-card, .employee-card { border: 1px solid var(--app-border); border-radius: 14px; background: var(--app-surface); box-shadow: 0 3px 14px #14243e04; }
.card-header, .block-title { padding: 16px 20px; border-bottom: 1px solid var(--app-border); background: var(--app-surface); color: var(--app-text); font-size: 14px; font-weight: 600; }
.card-header:first-child { border-radius: 13px 13px 0 0; }
.card-body { padding: 20px; }
.table { color: var(--app-text); margin-bottom: 0; border-color: var(--app-border); }
.table thead th { color: #687891; background: #f7f9fd; font-size: 13px; font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--app-border); }
.table td, .table th { vertical-align: middle; }
.table > :not(caption) > * > * { padding: .85rem 1rem; border-bottom-color: #e9edf5; }
.table-hover { --bs-table-hover-bg: #f6f9ff; }
.table-hover tbody tr:hover { background: #f6f9ff; }
.table-responsive, .app-table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.app-table-scroll > .table { min-width: 560px; }
.btn { border-radius: 8px; font-weight: 500; letter-spacing: 0; padding: .5rem .9rem; box-shadow: none; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn-sm { padding: .3rem .65rem; border-radius: 6px; }
.btn-primary { border-color: var(--app-primary); background: var(--app-primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus { border-color: var(--app-primary-dark); background: var(--app-primary-dark); color: #fff; }
.btn-primary:disabled { background: var(--app-primary); border-color: var(--app-primary); }
.btn-success { border-color: var(--app-success); background: var(--app-success); color: #fff; }
.btn-success:hover { border-color: #087a56; background: #087a56; }
.btn-danger { border-color: var(--app-danger); background: var(--app-danger); color: #fff; }
.btn-danger:hover { border-color: #c4394b; background: #c4394b; }
.btn-warning { border-color: #f5d391; background: #fff1d2; color: #8a570b; }
.btn-warning:hover { border-color: #edc171; background: #ffe6b2; color: #724300; }
.btn-secondary, .btn-outline-secondary { color: #596980; border-color: #d4dce9; background: #fff; }
.btn-secondary:hover, .btn-outline-secondary:hover { color: var(--app-text); border-color: #b5c4db; background: #f2f6fc; }
.btn-outline-primary { color: var(--app-primary); border-color: #adc5fb; background: #fff; }
.btn-outline-primary:hover { color: #fff; background: var(--app-primary); border-color: var(--app-primary); }
.btn:focus-visible, .form-control:focus, .form-select:focus { box-shadow: 0 0 0 .2rem #3569e81c; }
.form-label { color: #506079; font-weight: 600; margin-bottom: .5rem; }
.form-control, .form-select { min-height: 40px; border: 1px solid #d5dfed; border-radius: 8px; color: var(--app-text); background-color: #fff; }
.form-control:focus, .form-select:focus { border-color: #83a5f6; }
.form-control::placeholder { color: #98a4b7; }
.input-group-text { border-color: #d5dfed; border-radius: 8px; background: #f6f8fc; color: #748299; }
.badge, .label { border-radius: 5px; padding: .42em .65em; font-weight: 500; letter-spacing: 0; }
.text-primary { color: var(--app-primary) !important; }
.bg-primary { background-color: var(--app-primary) !important; }
.alert { border-radius: 10px; box-shadow: none; }
.modal-header, .modal-footer { padding: 16px 20px; border-color: var(--app-border); }
.modal-body { padding: 20px; }
.access-denied { max-width: 520px; margin: 12vh auto; padding: 32px; border: 1px solid #f4ced4; border-radius: 14px; background: #fff7f8; color: #b3374b; text-align: center; font-size: 15px; }

/* Shared theme for older modules; deliberately avoids injected !important patches. */
body.app-page { color: var(--app-text); background: var(--app-bg); font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif; }
.app-page .main-content { width: calc(100% - var(--sidebar-width)); margin-left: var(--sidebar-width); padding: 24px; }
.app-page.app-embedded .main-content { width: 100%; margin-left: 0; min-height: 100vh; padding: 24px; }
.app-page.app-embedded > .wrapper > .sidebar { display: none; }
.app-page.app-embedded > .container-fluid { padding: 24px; }
.app-page .card, .app-page .modal-content, .app-page .rule-card, .app-page .employee-card, .app-page .app-card, .app-page .block,
.app-page .salary-hero, .app-page .salary-table-panel, .app-page .dashboard-toolbar, .app-page .stat-card, .app-page .metric-card { border: 1px solid var(--app-border); border-radius: 14px; background: #fff; box-shadow: 0 3px 14px #14243e04; }
.app-page .dashboard-toolbar, .app-page .salary-hero { margin-bottom: 22px; padding: 22px; }
.app-page .stat-grid, .app-page .salary-metrics { gap: 16px; margin-bottom: 22px; }
.app-page .stat-card, .app-page .metric-card { padding: 22px; min-height: 118px; }
.app-page .stat-value, .app-page .metric-value { color: var(--app-text); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.app-page .stat-icon, .app-page .dashboard-title i, .app-page .metric-label i { border-radius: 10px; background: #edf3ff; color: var(--app-primary); }
.app-page .salary-title i { border-radius: 10px; background: var(--app-primary); }
.app-page .salary-table-header { padding: 16px 20px; border-bottom: 1px solid var(--app-border); background: #fff; }
.app-page .status-badge { border-radius: 6px; }
.app-page .main-content > .d-flex.justify-content-between { gap: 14px; flex-wrap: wrap; }

/* Workspace shell */
body.workspace-body { overflow: hidden; }
.app-shell { display: flex; height: 100vh; height: 100dvh; min-width: 0; background: var(--app-bg); }
.app-shell > .sidebar { position: relative; flex: 0 0 auto; width: var(--rail-width); height: 100%; min-height: 0; z-index: 50; transition: width .2s ease; }
.app-shell.nav-expanded > .sidebar { width: var(--sidebar-width); }
.brand-row { height: var(--header-height); flex: 0 0 var(--header-height); display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid #ffffff0d; overflow: hidden; }
.brand-mark, .user-avatar, .page-icon { width: 40px; height: 40px; flex: 0 0 40px; display: inline-grid; place-items: center; border-radius: 11px; }
.brand-mark { background: #3569e8; color: #fff; font-size: 19px; }
.brand-text { color: #fff; font-size: 17px; font-weight: 650; white-space: nowrap; }
.brand-text small { display: block; color: #8496b2; font-size: 10px; font-weight: 500; letter-spacing: 1.7px; }
.sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 12px; gap: 5px; flex-wrap: nowrap; scrollbar-width: thin; scrollbar-color: #3f526e transparent; }
.app-shell .sidebar .nav-link { width: 100%; justify-content: center; padding: 11px 13px; }
.app-shell.nav-expanded .sidebar .nav-link { justify-content: flex-start; }
.nav-label { white-space: nowrap; overflow: hidden; }
.app-shell:not(.nav-expanded) .brand-text, .app-shell:not(.nav-expanded) .nav-label, .app-shell:not(.nav-expanded) .user-meta { display: none; }
.sidebar-divider { margin: 10px 8px; border-top: 1px solid #ffffff16; }
.user-info { display: flex; gap: 10px; align-items: center; flex: 0 0 auto; padding: 18px; border-top: 1px solid #ffffff12; overflow: hidden; }
.user-avatar { background: #2a3e5c; color: #d6e4ff; font-size: 15px; font-weight: 700; text-decoration: none; }
.user-avatar:hover { color: #fff; background: #3a5072; }
.user-meta { min-width: 0; flex: 1; color: #fff; }
.user-role { color: #90a4c1; font-size: 12px; }
.main-area { min-width: 0; min-height: 0; flex: 1; display: flex; flex-direction: column; }
.workspace-header { height: var(--header-height); flex: 0 0 var(--header-height); display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--app-border); }
.current-page { min-width: 0; display: flex; align-items: center; gap: 14px; }
.current-page-title { margin: 0; font-size: 18px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.current-page-subtitle { color: var(--app-muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.header-divider { height: 24px; margin: 0 6px; border-left: 1px solid var(--app-border); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border: 1px solid var(--app-border); border-radius: 9px; color: #71819a; background: #fff; }
.icon-btn:hover { background: #eff4ff; border-color: #c0d2fc; color: var(--app-primary); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.nav-toggle { border-color: transparent; color: #64758e; }
.logout-link { display: inline-flex; align-items: center; gap: 7px; color: #71819a; font-size: 13px; padding: 8px; }
.logout-link:hover { color: #d04b60; }
.tabs-bar { height: var(--tab-height); flex: 0 0 var(--tab-height); display: flex; align-items: center; gap: 6px; padding: 0 24px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--app-border); scrollbar-width: thin; }
.tab-item { display: inline-flex; align-items: center; flex: 0 0 auto; height: 34px; padding: 0 5px 0 12px; gap: 9px; border-radius: 7px; color: #77849a; background: transparent; font-size: 13px; white-space: nowrap; cursor: pointer; }
.tab-item:hover { background: #f3f6fb; }
.tab-item.active { color: var(--app-primary); background: #edf3ff; font-weight: 600; }
.close-tab { width: 26px; height: 26px; padding: 0; display: inline-grid; place-items: center; border: 0; border-radius: 6px; color: #9aa8bd; background: transparent; font-size: 18px; line-height: 1; }
.close-tab:hover { color: #b83049; background: #ffe2e7; }
.tab-content { flex: 1; min-height: 0; position: relative; background: var(--app-bg); }
.tab-content iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--app-bg); }
.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--app-muted); }
.empty-state i { font-size: 36px; color: #c1cee3; }
.empty-state p { margin: 0; }
.shell-notice { position: fixed; top: 90px; right: 24px; max-width: min(420px, calc(100vw - 32px)); z-index: 1090; box-shadow: 0 8px 30px #14243e1f; }
.nav-backdrop { display: none; }

@media (max-width: 900px) {
    .wrapper { display: block; }
    nav.standalone-sidebar { position: relative; width: 100%; height: auto; min-height: 0; }
    nav.standalone-sidebar .logo { padding: 16px 20px; }
    nav.standalone-sidebar .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
    nav.standalone-sidebar .user-block { display: flex; gap: 16px; align-items: center; }
    nav.standalone-sidebar .user-block .btn { width: auto; margin-left: auto; }
    .app-page .main-content, .main-content { width: 100%; margin-left: 0; padding: 18px; }
}
@media (max-width: 760px) {
    .mobile-nav-close { display: block; margin-left: auto; border: 0; border-radius: 8px; width: 32px; height: 32px; color: #fff; background: #ffffff16; font-size: 24px; line-height: 1; }
    :root { --header-height: 66px; --tab-height: 46px; }
    .app-shell > .sidebar, .app-shell.nav-expanded > .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; height: 100vh; height: 100dvh; transform: translateX(-100%); transition: transform .2s ease; }
    .app-shell.mobile-nav-open > .sidebar { transform: translateX(0); }
    .app-shell .sidebar .nav-link { justify-content: flex-start; }
    .app-shell:not(.nav-expanded) .brand-text, .app-shell:not(.nav-expanded) .nav-label, .app-shell:not(.nav-expanded) .user-meta { display: block; }
    .nav-backdrop { position: fixed; inset: 0; z-index: 40; background: #0a192f80; border: 0; }
    .app-shell.mobile-nav-open .nav-backdrop { display: block; }
    .workspace-header { padding: 0 12px; gap: 6px; }
    .current-page { gap: 8px; }
    .current-page-title { font-size: 16px; }
    .current-page-subtitle { font-size: 11px; }
    .header-actions { gap: 4px; }
    .header-divider, .logout-label, #closeActiveTabBtn { display: none; }
    .tabs-bar { padding: 0 12px; }
    .tab-item { height: 34px; }
    .app-page.app-embedded .main-content, .app-page.app-embedded > .container-fluid { padding: 14px; }
    .page-toolbar { align-items: stretch; margin-bottom: 16px; }
    .page-title { font-size: 21px; }
    .app-page .dashboard-toolbar, .app-page .salary-hero { padding: 18px; margin-bottom: 14px; flex-wrap: wrap; }
    .app-page .stat-grid, .app-page .salary-metrics { gap: 12px; margin-bottom: 14px; }
    .app-page .stat-card, .app-page .metric-card { padding: 18px; min-height: 102px; }
    .card-body { padding: 16px; }
    .table > :not(caption) > * > * { padding: .75rem; }
    .form-control, .form-select { font-size: 16px; }
    .shell-notice { top: 78px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

