/* ========================================
   ERP系统 - 公共样式文件（白色简洁风格）
   ======================================== */

/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #1e293b;
    background: #f8fafc;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: #334155;
}

a:hover {
    color: #0f172a;
}

ul, ol {
    list-style: none;
}

/* ========================================
   整体布局
   ======================================== */
.layout {
    display: flex;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ========================================
   顶部导航栏
   ======================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.page-subtitle {
    font-size: 13px;
    color: #94a3b8;
}

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

.current-date {
    font-size: 13px;
    color: #64748b;
    background: #f1f5f9;
    padding: 6px 14px;
    border-radius: 8px;
}

/* ========================================
   主内容区域
   ======================================== */
.main-content {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
}

/* ========================================
   侧边栏样式（白色简洁风格）
   ======================================== */
.sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.3px;
}

/* 菜单导航 */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 3px;
}

.menu-list {
    padding: 0 8px;
}

/* 一级菜单项 */
.menu-item {
    margin-bottom: 2px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #475569;
    border-radius: 8px;
    transition: all 0.15s ease;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
}

.menu-link:hover {
    color: #0f172a;
    background: #f8fafc;
}

.menu-link.active {
    color: #334155;
    background: #f1f5f9;
    font-weight: 600;
}

/* 可折叠父菜单 */
.menu-link--parent {
    cursor: pointer;
}

.menu-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.menu-link:hover .menu-icon {
    color: #64748b;
}

.menu-link.active .menu-icon {
    color: #334155;
}

.menu-icon svg {
    width: 100%;
    height: 100%;
}

.menu-title {
    flex: 1;
    white-space: nowrap;
}

/* 折叠箭头 */
.menu-arrow {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    transition: transform 0.2s ease;
}

.menu-arrow svg {
    width: 100%;
    height: 100%;
}

.menu-item.is-open .menu-arrow {
    transform: rotate(180deg);
    color: #94a3b8;
}

/* 二级子菜单 */
.submenu {
    overflow: hidden;
    height: 0;
    transition: height 0.25s ease;
    padding: 0 0;
}

.menu-item.is-open .submenu {
    height: auto;
}

.submenu-item {
    margin: 0;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 8px 42px;
    color: #64748b;
    border-radius: 6px;
    transition: all 0.15s ease;
    font-size: 13px;
    font-weight: 400;
}

.submenu-link:hover {
    color: #0f172a;
    background: #f8fafc;
}

.submenu-link.active {
    color: #334155;
    background: #f1f5f9;
    font-weight: 600;
}

.submenu-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #cbd5e1;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.submenu-link:hover .submenu-dot {
    background: #94a3b8;
}

.submenu-link.active .submenu-dot {
    background: #334155;
}

.submenu-title {
    white-space: nowrap;
}

/* 底部用户区域 */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #334155;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-detail {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: #94a3b8;
}

.logout-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.logout-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   统计卡片
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    border: 1px solid #e2e8f0;
}

.stat-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.stat-card__icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card__icon svg {
    width: 22px;
    height: 22px;
}

.stat-card--blue .stat-card__icon { background: #eff6ff; color: #3b82f6; }
.stat-card--green .stat-card__icon { background: #f0fdf4; color: #22c55e; }
.stat-card--purple .stat-card__icon { background: #faf5ff; color: #8b5cf6; }
.stat-card--orange .stat-card__icon { background: #fff7ed; color: #f97316; }

.stat-card__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-card__value {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.stat-card__label {
    font-size: 13px;
    color: #94a3b8;
}

.stat-card__trend {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 6px;
    position: absolute;
    top: 14px;
    right: 14px;
}

.stat-card__trend svg {
    width: 13px;
    height: 13px;
}

.stat-card__trend--up {
    color: #16a34a;
    background: #f0fdf4;
}

.stat-card__trend--down {
    color: #dc2626;
    background: #fef2f2;
}

/* ========================================
   仪表盘下方网格
   ======================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
}

/* ========================================
   卡片样式
   ======================================== */
.card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}

.card-link {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.card-link:hover {
    color: #334155;
}

.card-body {
    padding: 0;
}

/* ========================================
   数据表格
   ======================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 20px;
    text-align: left;
}

.data-table th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.3px;
    border-bottom: 1px solid #e2e8f0;
}

.data-table td {
    font-size: 14px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

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

.data-table tbody tr:hover td {
    background: #fafbfc;
}

.text-mono {
    font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
    font-size: 13px;
    color: #475569;
    font-weight: 500;
}

/* ========================================
   徽章/标签
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.badge--success {
    color: #16a34a;
    background: #f0fdf4;
}

.badge--warning {
    color: #d97706;
    background: #fffbeb;
}

.badge--info {
    color: #2563eb;
    background: #eff6ff;
}

.badge--danger {
    color: #dc2626;
    background: #fef2f2;
}

/* ========================================
   快捷操作
   ======================================== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 16px;
}

.quick-action-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #f1f5f9;
    transition: all 0.15s ease;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
}

.quick-action-item:hover {
    border-color: #e2e8f0;
    background: #fafbfc;
    color: #0f172a;
}

.quick-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.quick-action-icon svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   通用按钮样式
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
    background: #fff;
    color: #334155;
}

.btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.btn-primary {
    background: #334155;
    color: #fff;
    border-color: #334155;
}

.btn-primary:hover {
    background: #1e293b;
    border-color: #1e293b;
    color: #fff;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

/* ========================================
   表单样式
   ======================================== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-size: 14px;
    font-weight: 500;
}

.form-group .form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.15s ease;
    background: #fff;
    color: #1e293b;
}

.form-group .form-control:focus {
    border-color: #94a3b8;
    outline: none;
    box-shadow: 0 0 0 2px rgba(51, 65, 85, 0.08);
}

/* 独立使用的 form-control（不在 .form-group 内） */
.form-control {
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.15s ease;
    background: #fff;
    color: #1e293b;
}

.form-control:focus {
    border-color: #94a3b8;
    outline: none;
    box-shadow: 0 0 0 2px rgba(51, 65, 85, 0.08);
}

/* ========================================
   标签页（Tab Bar）
   ======================================== */
.tab-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 32px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-bar::-webkit-scrollbar {
    height: 0;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    position: relative;
    margin-bottom: -1px;
    user-select: none;
}

.tab-item:hover {
    color: #334155;
    background: #f1f5f9;
}

.tab-item.active {
    color: #0f172a;
    background: #fff;
    border-color: #e2e8f0;
    font-weight: 600;
    z-index: 1;
}

.tab-item.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #fff;
}

.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    font-size: 14px;
    color: #94a3b8;
    transition: all 0.15s ease;
    line-height: 1;
}

.tab-close:hover {
    color: #ef4444;
    background: #fef2f2;
}

/* ========================================
   工具类
   ======================================== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .main-content {
        padding: 16px;
    }
    .topbar {
        padding: 12px 16px;
    }
}