:root {
    --primary: #3d7cf5;
    --primary-hover: #2f68d8;
    --primary-soft: #e8f0ff;
    --table-head: #4a90e2;
    --bg: #f5f7fa;
    --panel: #ffffff;
    --border: #e6e9ef;
    --border-strong: #dfe3ea;
    --text: #303743;
    --text-muted: #8b93a3;
    --sidebar-bg: #f7f8fb;
    --topbar-h: 56px;
    --sidebar-w: 200px;
    --radius: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}

/* ---------- 顶部导航 ---------- */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.brand-logo svg {
    width: 18px;
    height: 18px;
}

.brand-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    letter-spacing: .2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-user {
    font-size: 13px;
    color: #374151;
}

.topbar-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #eef1f6;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-avatar svg {
    width: 15px;
    height: 15px;
}

/* ---------- 布局 ---------- */
.container {
    display: flex;
    min-height: 100vh;
    padding-top: var(--topbar-h);
}

.sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.sidebar nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.nav-group {
    margin-bottom: 4px;
}

.nav-group-title {
    padding: 10px 18px 6px;
    font-size: 12px;
    color: #a3aab8;
    letter-spacing: .4px;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 18px;
    color: #4a5568;
    text-decoration: none;
    font-size: 13px;
    border-left: 2px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}

.nav-icon {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    opacity: .8;
}

.sidebar nav a:hover {
    background: #eef2f9;
    color: #1f2937;
}

.sidebar nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
}

.sidebar nav a.active .nav-icon {
    opacity: 1;
}

.logout-section {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
}

/* ---------- 主内容 ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page-tabs {
    background: #fff;
    border-bottom: 1px solid var(--border);
    height: 42px;
    padding: 0 16px;
    display: flex;
    align-items: flex-end;
}

.page-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 22px;
    font-size: 13px;
    color: var(--primary);
    background: #f4f7fd;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    margin-bottom: -1px;
}

.page-tab.active {
    background: #fff;
    font-weight: 500;
}

.page-tab.active::after {
    content: "";
    position: absolute;
    left: -1px;
    right: -1px;
    top: -1px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
}

.page-body {
    padding: 16px 20px 24px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 16px;
    border-radius: 5px;
    border: 1px solid transparent;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-soft {
    background: var(--primary-soft);
    border-color: var(--primary-soft);
    color: var(--primary);
}

.btn-soft:hover {
    background: #dae7ff;
    border-color: #dae7ff;
}

.btn-default {
    background: #fff;
    border-color: var(--border-strong);
    color: #4a5568;
}

.btn-default:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-block {
    width: 100%;
}

/* ---------- 筛选区 ---------- */
.filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 14px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.filter-item > label {
    flex: 0 0 auto;
    width: 60px;
    color: var(--text-muted);
    font-size: 12.5px;
    white-space: nowrap;
}

.filter-item input,
.filter-item select {
    flex: 1 1 auto;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: #fff;
    color: var(--text);
    font-size: 12.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.filter-item select:disabled,
.filter-item input:disabled {
    background: #f7f8fa;
    color: #9aa3b2;
}

.filter-item input:focus,
.filter-item select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(61, 124, 245, .12);
}

.filter-item input::placeholder {
    color: #b0b7c3;
}


.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- 聚合字段 ---------- */
.group-by-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    margin-bottom: 14px;
}

.group-by-box .group-label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-right: 2px;
}

.dim-pill {
    display: inline-flex;
    align-items: center;
}

.dim-pill input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.dim-pill span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: #fff;
    color: #4a5568;
    font-size: 12.5px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}

.dim-pill span::before {
    content: "";
    width: 12px;
    height: 12px;
    border: 1px solid #c7cdd8;
    border-radius: 2px;
    background: #fff;
    transition: all .15s;
}

.dim-pill span:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.dim-pill input:checked + span {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.dim-pill input:checked + span::before {
    background: #fff;
    border-color: #fff;
    box-shadow: inset 0 0 0 3px var(--primary);
}

/* ---------- 表格 ---------- */
.table-container {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.table-container th,
.table-container td {
    padding: 9px 12px;
    text-align: center;
    white-space: nowrap;
    font-size: 12.5px;
    border-bottom: 1px solid #eef1f5;
}

.table-container th:first-child,
.table-container td:first-child {
    text-align: center;
}

.table-container thead th {
    background: var(--table-head);
    color: #fff;
    font-weight: 500;
    position: sticky;
    top: 0;
    text-align: center;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, .18);
}

.table-container thead th:last-child {
    border-right: none;
}

.table-container tbody tr:hover {
    background: #f4f8ff;
}

.table-container tbody tr:last-child td {
    border-bottom: none;
}

.table-container .idx-col {
    width: 46px;
    min-width: 46px;
    text-align: center !important;
    color: #9aa3b2;
    font-size: 12px;
}

.table-container tbody td.text-col {
    text-align: center;
}

/* ---------- 表头排序 ---------- */
.table-container thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.table-container thead th.sortable:hover {
    background: #3f83d6;
}

.th-sort-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.sort-arrows {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    line-height: 0;
}

.sort-arrows i {
    display: block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    transition: border-color .15s;
}

.sort-arrows i.up {
    border-bottom: 5px solid rgba(255, 255, 255, .5);
}

.sort-arrows i.down {
    border-top: 5px solid rgba(255, 255, 255, .5);
}

.table-container thead th.sort-asc .sort-arrows i.up {
    border-bottom-color: #fff;
}

.table-container thead th.sort-desc .sort-arrows i.down {
    border-top-color: #fff;
}

.table-container .summary-row {
    background: #f7f9fc !important;
    font-weight: 600;
    color: #1f2937;
}

.table-container .summary-row td {
    border-top: 1px solid var(--border);
    border-bottom: none;
}

.table-container .pkg-col,
.table-container .link-col {
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
}

.table-container .empty-tip {
    text-align: center !important;
    color: var(--text-muted);
    padding: 32px 0;
}

.app-chip {
    display: inline-block;
    background: var(--primary-soft);
    border: 1px solid #cfe0ff;
    color: #1d4ed8;
    border-radius: 4px;
    padding: 2px 8px;
    margin: 2px 4px 2px 0;
    font-size: 12px;
}

.app-chip em {
    font-style: normal;
    color: #64748b;
    margin-left: 4px;
    font-size: 11px;
}

/* ---------- 分页 ---------- */
.pagination {
    display: flex;
    gap: 6px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.pagination button {
    min-width: 32px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    background: #fff;
    color: #475569;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12.5px;
    transition: all .15s;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination button:disabled {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    cursor: default;
}

/* ---------- 账户信息 ---------- */
.account-forms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.account-forms form {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.account-forms h3 {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.account-forms .form-group {
    margin-bottom: 14px;
}

.account-forms .form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.account-forms .form-group span {
    color: var(--text);
}

.account-forms .form-group input {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font-size: 12.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.account-forms .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(61, 124, 245, .12);
}

/* ---------- 登录页 ---------- */
.login-container {
    max-width: 380px;
    margin: 12vh auto 0;
    background: #fff;
    border-radius: 10px;
    padding: 36px 32px;
    box-shadow: 0 6px 24px rgba(31, 41, 55, .08);
    border: 1px solid var(--border);
}

.login-container h2 {
    text-align: center;
    margin-bottom: 24px;
    color: #1f2937;
    font-size: 19px;
}

.login-container .form-group {
    margin-bottom: 16px;
}

.login-container .form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.login-container .form-group input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.login-container .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(61, 124, 245, .12);
}

.login-container button {
    width: 100%;
    height: 40px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 6px;
    transition: background .15s;
}

.login-container button:hover {
    background: var(--primary-hover);
}

.error-message {
    color: #ef4444;
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    min-height: 18px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 14px;
    }
    .brand-name {
        font-size: 15px;
    }
    .sidebar {
        width: 60px;
    }
    .nav-group-title,
    .sidebar nav a span {
        display: none;
    }
    .sidebar nav a {
        justify-content: center;
        padding: 12px 0;
        border-left: none;
    }
    .logout-section {
        padding: 10px 8px;
    }
    .logout-section .btn {
        padding: 0;
        font-size: 12px;
    }
    .main-content {
        margin-left: 60px;
    }
    .page-body {
        padding: 12px;
    }
    .filters {
        grid-template-columns: minmax(0, 1fr);
        padding: 14px;
    }
    .filter-item-wide {
        grid-column: span 1;
    }
    .filter-item > label {
        width: 68px;
    }
}

/* ---------- 可搜索下拉(输入快速匹配) ---------- */
.search-select {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

/* 原生 select 仅作为取值/级联的载体, 不显示 */
.search-select > select {
    display: none;
}

.search-select .ss-input {
    width: 100%;
    height: 32px;
    padding: 0 26px 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: #fff;
    color: var(--text);
    font-size: 12.5px;
    outline: none;
    cursor: pointer;
    text-overflow: ellipsis;
    transition: border-color .15s, box-shadow .15s;
}

.search-select .ss-input::placeholder {
    color: var(--text);
    opacity: 1;
}

.search-select.ss-open .ss-input,
.search-select .ss-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(61, 124, 245, .12);
    cursor: text;
}

.search-select .ss-arrow {
    position: absolute;
    right: 11px;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -4px;
    border-right: 1.5px solid #9aa3b2;
    border-bottom: 1.5px solid #9aa3b2;
    transform: rotate(45deg);
    transition: transform .15s, margin .15s;
    pointer-events: none;
}

.search-select.ss-open .ss-arrow {
    margin-top: -1px;
    transform: rotate(-135deg);
}

.search-select .ss-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    display: none;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 8px 22px rgba(23, 43, 77, .14);
    z-index: 60;
}

.search-select.ss-open .ss-panel {
    display: block;
}

/* 列表固定 300px 高度, 超出滚动 */
.search-select .ss-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
    overscroll-behavior: contain;
}

.search-select .ss-option {
    padding: 7px 9px;
    border-radius: 4px;
    font-size: 12.5px;
    line-height: 18px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-select .ss-option:hover,
.search-select .ss-option.active {
    background: var(--primary-soft);
}

.search-select .ss-option.selected {
    background: var(--primary);
    color: #fff;
}

.search-select .ss-empty {
    padding: 16px 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
}
