/* 后台壳样式：所有可配置项走变量，业务页面直接消费同一套变量即可与壳保持一致 */
:root {
    --primary: #2563eb;
    --primary-weak: rgba(37, 99, 235, .12);
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #1e293b;
    --bg: #f1f5f9;
    --panel: #ffffff;
    --line: #e2e8f0;
    --line-2: #eef2f8;
    --text: #0f172a;
    --text-2: #475569;
    --muted: #64748b;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.boot {
    padding: 48px;
    color: var(--muted);
}

/* ---------- 登录 ---------- */
/* 这里只留空状态外框：booting 占位与登录页共用。登录卡片的样式随
   assets/pages/login.js 注入（#shell-login-style），覆盖登录页时无需改本文件 */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #dbeafe 0, transparent 45%),
        radial-gradient(circle at 80% 80%, #e0e7ff 0, transparent 40%), var(--bg);
    padding: 24px;
}

/* ---------- 布局 ---------- */
.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(148, 163, 184, .18);
}

.brand-mark {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-weak);
}

.nav {
    padding: 10px 10px 24px;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 12px;
    margin: 2px 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.menu-item:hover {
    background: rgba(148, 163, 184, .12);
    color: #fff;
}

.menu-item.group {
    color: #94a3b8;
    font-size: 12px;
    letter-spacing: .12em;
    cursor: pointer;
}

.menu-item.group i {
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform .15s;
}

.menu-group.open .menu-item.group i {
    transform: rotate(-135deg);
}

.menu-children {
    margin-left: 6px;
    padding-left: 8px;
    border-left: 1px solid rgba(148, 163, 184, .18);
}

.menu-item.leaf.active {
    background: var(--primary);
    color: #fff;
    font-weight: 500;
}

/* ---------- 主区 ---------- */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 18px;
    height: 54px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    min-width: 0;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
}

.tab.active {
    background: var(--primary-weak);
    border-color: var(--primary);
    color: var(--primary);
}

.tab-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: .7;
}

.tab-close:hover {
    opacity: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 13px;
}

.who em {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--primary-weak);
    color: var(--primary);
    font-size: 11px;
    font-style: normal;
}

.ghost {
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.content {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

/* ---------- 页面通用 ---------- */
.page {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    min-height: calc(100vh - 96px);
}

.page-head {
    margin-bottom: 16px;
}

.page-head h2 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 650;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: #f8fafc;
}

.card b {
    display: block;
    font-size: 20px;
    margin-top: 4px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th,
.table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--muted);
    font-weight: 500;
    background: #f8fafc;
}

.tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--primary-weak);
    color: var(--primary);
    font-size: 12px;
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 13px;
    margin-bottom: 12px;
}

/*
 * 勾选框 / 单选框统一尺寸：尺寸只在这里定一次，页面里不要再写 width/height。
 * 容器（表单、权限树、多选面板）各有自己的布局规则，不给这类控件设死尺寸时，
 * 容易被父级的整宽规则带着拉成一根宽条。
 */
input[type="checkbox"],
input[type="radio"] {
    flex: none;
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
    vertical-align: -2px;
}

.field {
    margin-bottom: 12px;
}

.field label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--muted);
}

/* 勾选框 / 单选框不套文本框的整宽、内边距与边框，否则会被拉成宽条、也压不平文字基线 */
.field input:not([type="checkbox"]):not([type="radio"]),
.field select {
    width: 100%;
    max-width: 320px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
}

.btn {
    padding: 8px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.btn.secondary {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
}

.btn.small {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
}

.btn.danger {
    background: #dc2626;
}

.btn.plain {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
}

.btn.danger.plain {
    border-color: #fecaca;
    color: #dc2626;
}

.btn[disabled] {
    opacity: .55;
    cursor: default;
}

/* ---------- 工具栏 / 分页 ---------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.toolbar .spacer {
    flex: 1;
}

.toolbar input,
.toolbar select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    outline: none;
}

.toolbar input {
    min-width: 220px;
}

.toolbar input:focus,
.toolbar select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-weak);
}

.pager {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
    color: var(--muted);
    font-size: 13px;
}

.pager button {
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

.pager button[disabled] {
    opacity: .5;
    cursor: default;
}

/* ---------- 弹窗 ---------- */
.modal-layer {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .42);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 56px 16px 24px;
    z-index: 900;
    overflow: auto;
}

.modal-card {
    width: 620px;
    max-width: 100%;
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal-card.wide {
    width: 820px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    font-weight: 650;
}

.modal-head button {
    border: 0;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}

.modal-body {
    padding: 18px 20px;
    max-height: calc(100vh - 230px);
    overflow: auto;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
}

/* ---------- 表单栅格 ---------- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.field input:not([type="checkbox"]):not([type="radio"]):focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-weak);
    outline: none;
}

.field input[readonly] {
    background: #f8fafc;
    color: var(--muted);
}

.field textarea {
    width: 100%;
    max-width: 100%;
    min-height: 62px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

/* ---------- 多选 / 树 / 分栏 ---------- */
.check-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 180px;
    overflow: auto;
}

.check-list label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.tree {
    font-size: 13px;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 2px 6px;
    border-radius: 6px;
}

.tree-row:hover {
    background: #f8fafc;
}

.tree-row .label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-row .ops {
    display: flex;
    gap: 6px;
    visibility: hidden;
}

.tree-row:hover .ops {
    visibility: visible;
}

.split {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 16px;
    align-items: start;
}

.side-list {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.side-list .item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    cursor: pointer;
}

.side-list .item:last-child {
    border-bottom: 0;
}

.side-list .item.active {
    background: var(--primary-weak);
    color: var(--primary);
    font-weight: 600;
}

.seg {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.seg button {
    padding: 6px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.seg button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.alert.ok {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

.tag.gray {
    background: #f1f5f9;
    color: var(--muted);
}

.empty {
    padding: 28px 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.fragment-host {
    min-height: 120px;
}

/* 片段里的 demo 表格等使用同一套变量，避免"壳与页面两张皮" */
.fragment-host h3 {
    margin: 0 0 8px;
    font-size: 15px;
}

.fragment-host .row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.fragment-host .result {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
    font-size: 13px;
}

/* ---------- 提示 ---------- */
.toast-layer {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999;
}

.toast {
    padding: 10px 14px;
    border-radius: 8px;
    background: #0f172a;
    color: #fff;
    font-size: 13px;
    box-shadow: var(--shadow);
}

/* ---------- 列表模式 ---------- */
/* 照搬 CRM 演示的列表观感：表头吸顶、行分隔线极淡、悬停泛蓝、首列双层文字、
   操作列用链接而不是方块按钮。只靠下面几段覆盖，不要求页面改结构 */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: #f8fbff;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.td-main {
    font-weight: 600;
    color: var(--text);
}

.td-sub {
    margin-top: 1px;
    font-size: 11.5px;
    color: var(--muted);
}

.num {
    font-variant-numeric: tabular-nums;
}

/* 列多时在表格内部横向滚动，不要把列挤成竖排单字 */
.table-wrap {
    overflow-x: auto;
}

.table .ellipsis {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/*
 * 操作列：宽度由按钮内容决定，不要写死像素。
 * 写死宽度时，多一个按钮（比如加了「查看」）就会折成两行；
 * 这里的 1% 表示“尽量窄”，配合 nowrap 后就是“刚好装下所有按钮”，
 * 列太多、窗口太窄时由 .table-wrap 横向滚动兜底，不会把按钮挤成竖排。
 */
.table .col-actions {
    width: 1%;
    white-space: nowrap;
}

/*
 * 行内操作按钮间距：没包 row-actions 的页面（早期写法、直接在 td 里排按钮）
 * 靠 HTML 空白只能挤出 4px，看着像粘在一起，这里统一成 10px。
 * .btn 与 .btn-link 两种写法都管，用直接子元素选择器是为了不与 row-actions 的 gap 叠加。
 */
.table tbody td > .btn + .btn,
.table tbody td > .btn-link + .btn-link {
    margin-left: 10px;
}

.toolbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

/* 工具栏下方的细线：与表格连成一块卡片，而不是悬在页面中间 */
.toolbar.line {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line-2);
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.btn-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary);
    font-size: 12.5px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-link.danger {
    color: #dc2626;
}

/* 标签：方角小标签 + 语义配色（状态 / 类型 / 岗位） */
.tag {
    padding: 1px 7px;
    border-radius: 5px;
    background: var(--line-2);
    color: var(--text-2);
    font-size: 11.5px;
    white-space: nowrap;
}

.tag + .tag {
    margin-left: 4px;
}

.tag.blue {
    background: #eaf2ff;
    color: #25538f;
}

.tag.green {
    background: #e9f8ef;
    color: #16794a;
}

.tag.amber {
    background: #fdf3e3;
    color: #9a6108;
}

.tag.red {
    background: #fdecec;
    color: #b42323;
}

.tag.purple {
    background: #f1ebfe;
    color: #5b21b6;
}

/* ---------- 部门：列表里的层级行 ---------- */
.tree-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* 竖向 + 横向两段细线，拼出“挂在上级下面”的折角 */
.tree-elbow {
    flex: none;
    width: 13px;
    height: 18px;
    margin: 0 1px 0 3px;
    border-left: 1px solid #c9d6ea;
    border-bottom: 1px solid #c9d6ea;
    border-radius: 0 0 0 5px;
}

.tree-grid tbody tr.root > td {
    background: #f3f7fd;
}

.tree-grid tbody tr.root:hover > td {
    background: #eef5ff;
}

.tree-grid tbody tr.depth > td:first-child {
    border-left: 2px solid transparent;
}

/* ---------- 岗位多选：分组勾选面板 ---------- */
.pp {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    container-type: inline-size;
}

.pp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line-2);
    flex-wrap: wrap;
}

.pp-title {
    font-size: 13px;
    font-weight: 600;
}

/* .field label 是整行的字段说明，面板里的勾选行要贴着复选框 */
.pp label {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    margin: 0;
    font-size: 12.5px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.pp-head .pp-all {
    gap: 5px;
    font-size: 12px;
    color: var(--text-2);
}

.pp-list {
    max-height: 260px;
    overflow: auto;
}

/* 部门标题在滚动时吸顶，长列表也不会丢掉“这一组属于哪个部门” */
.pp-group-title {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px 5px;
    background: #fbfcff;
    border-bottom: 1px solid var(--line-2);
    font-size: 11.5px;
    color: var(--text-2);
}

.pp-row {
    display: grid;
    grid-template-columns: minmax(150px, 1.4fr) minmax(120px, 1fr);
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px dashed var(--line-2);
    transition: .12s;
}

.pp-row:last-child {
    border-bottom: 0;
}

.pp-row.on {
    background: #f6faff;
}

.pp-name {
    overflow: hidden;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pp-meta {
    overflow: hidden;
    font-size: 11px;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pp-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: #fbfcff;
    border-top: 1px solid var(--line-2);
    font-size: 12px;
    flex-wrap: wrap;
}

.pp-foot b {
    font-weight: 700;
}

/* 弹窗宽度不可控，按面板自身宽度决定单列 / 隐藏备注，而不是看视口 */
@container (max-width: 460px) {
    .pp-row {
        grid-template-columns: 1fr;
        row-gap: 2px;
    }

    .pp-meta {
        display: none;
    }
}
