/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1890ff;
    --primary-dark: #096dd9;
    --success: #52c41a;
    --warning: #faad14;
    --error: #f5222d;
    --text: #262626;
    --text-secondary: #595959;
    --text-muted: #8c8c8c;
    --bg: #f5f5f5;
    --bg-white: #ffffff;
    --border: #d9d9d9;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-card: 0 2px 12px rgba(0,0,0,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* 页面容器 */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* 角色选择页面 */
.role-select-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.role-select-container h1 {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--text);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 40px;
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.role-card {
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.role-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-card);
    transform: translateY(-4px);
}

.role-card:active {
    transform: translateY(0);
}

.role-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.role-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.role-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.version-info {
    color: var(--text-muted);
    font-size: 13px;
}

/* 主工作台布局（只有激活时才显示，否则会盖住首页的页头/侧栏） */
#dashboard-page.active {
    display: flex;
    flex-direction: column;
}

/* 顶部导航 */
.header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.role-badge {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 200px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar nav {
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: #f0f0f0;
    color: var(--text);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-icon {
    font-size: 18px;
}

.nav-text {
    font-size: 14px;
}

/* 主内容区 */
.main-content {
    margin-left: 200px;
    margin-top: 64px;
    padding: 24px;
    min-height: calc(100vh - 64px);
}

/* 工作台卡片 */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    padding: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.card-more {
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
}

/* 统计卡片 */
.stat-card {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue { background: #e6f7ff; }
.stat-icon.green { background: #f6ffed; }
.stat-icon.orange { background: #fff7e6; }
.stat-icon.red { background: #fff1f0; }

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    line-height: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 列表样式 */
.list-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.list-item:last-child {
    border-bottom: none;
}

.list-content {
    flex: 1;
}

.list-title {
    font-size: 14px;
    margin-bottom: 4px;
}

.list-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.list-action {
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
}

/* 标签 */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.tag-primary { background: #e6f7ff; color: #1890ff; }
.tag-success { background: #f6ffed; color: #52c41a; }
.tag-warning { background: #fff7e6; color: #faad14; }
.tag-error { background: #fff1f0; color: #f5222d; }
.tag-default { background: #f5f5f5; color: #595959; }

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

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

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

.btn-default {
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
}

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

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #f0f0f0;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
}

.btn-text:hover {
    text-decoration: underline;
}

/* 表格 */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
    background: #fafafa;
}

td {
    font-size: 14px;
}

tr:hover {
    background: #fafafa;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* ===== 首页：左侧人员栏 + 右侧数据看板 ===== */
#role-select-page {
    padding-top: 64px;
}

.header-logo {
    font-size: 22px;
}

.header-date {
    font-size: 13px;
    color: var(--text-muted);
}

.home-layout {
    display: flex;
    align-items: flex-start;
}

.people-sidebar {
    flex: 0 0 260px;
    width: 260px;
    position: sticky;
    top: 64px;
    align-self: flex-start;
    height: calc(100vh - 64px);
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    overflow-y: auto;
}

.people-sidebar .form-input {
    margin-bottom: 12px;
}

.people-group-title {
    font-size: 12px;
    color: var(--text-muted);
    padding: 10px 8px 4px;
    letter-spacing: .5px;
}

.person-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .2s;
}

.person-item:hover {
    background: #f0f7ff;
}

.person-avatar {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.person-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.person-name {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-role {
    font-size: 11px;
    color: var(--text-muted);
}

.person-enter {
    font-size: 12px;
    color: var(--primary);
    opacity: 0;
    transition: opacity .2s;
}

.person-item:hover .person-enter {
    opacity: 1;
}

.people-tip {
    margin-top: 4px;
    padding: 8px;
    border-top: 1px solid #f0f0f0;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
}

.home-main {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

.home-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 16px;
}

.home-title h2 {
    font-size: 20px;
}

.home-title .date {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== 首页看板紧凑化：让库存明细等板块一屏可见 ===== */
#home-dashboard .dashboard-grid {
    gap: 14px;
    margin-bottom: 14px;
}

#home-dashboard > .card {
    margin-bottom: 14px;
}

#home-dashboard > .card:last-child {
    margin-bottom: 0;
}

.dashboard-grid.stat-row,
.dashboard-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#home-dashboard .card {
    padding: 14px 16px;
}

#home-dashboard .card-header {
    margin-bottom: 10px;
}

#home-dashboard .stat-card {
    padding: 12px 16px;
    gap: 12px;
}

#home-dashboard .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
    flex: 0 0 38px;
}

#home-dashboard .stat-value {
    font-size: 22px;
}

#home-dashboard .stat-label {
    font-size: 12px;
    margin-top: 2px;
}

#home-dashboard .empty-state {
    padding: 14px 8px;
    font-size: 13px;
}

#home-dashboard .empty-icon {
    font-size: 26px;
    margin-bottom: 4px;
}

#home-dashboard .list-item {
    padding: 7px 0;
}

#home-dashboard .list-title {
    font-size: 13px;
    margin-bottom: 2px;
}

#home-dashboard .list-meta {
    font-size: 12px;
}

#home-dashboard table th,
#home-dashboard table td {
    padding: 5px 8px;
    font-size: 13px;
}

#home-dashboard .tag {
    padding: 1px 6px;
    font-size: 11px;
}

/* 库存明细两列排布，15 种物料不用滚动 */
.material-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.material-columns .table-container:empty {
    display: none;
}

/* 首页看板的 KPI 卡：数字 + 明细合并在一张卡里（原两排合并） */
.kpi-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.kpi-head .stat-info {
    flex: 1;
    min-width: 0;
}

/* 紧凑统计行（首页第二排小卡） */
.dashboard-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.dashboard-grid.compact .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

.dashboard-grid.compact .stat-value {
    font-size: 22px;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .role-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .home-layout {
        flex-direction: column;
    }

    .people-sidebar {
        position: static;
        width: 100%;
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .home-main {
        padding: 16px;
    }

    #home-dashboard .dashboard-grid.stat-row,
    #home-dashboard .dashboard-grid.three {
        grid-template-columns: 1fr;
    }

    .material-columns {
        grid-template-columns: 1fr;
    }
}
