/* ===== 全局变量 ===== */
:root {
    --sidebar-width: 220px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --topbar-height: 56px;
    --content-bg: #f1f5f9;
    --card-bg: #ffffff;
    --primary: #3b82f6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
}

/* ===== Reset ===== */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--content-bg);
    color: var(--text-primary);
    font-size: 14px;
}

/* ===== 布局 ===== */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: width .2s ease;
}

.sidebar-brand {
    padding: 18px 20px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand i { font-size: 22px; color: var(--primary); }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all .15s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--sidebar-active);
}

.nav-item i { font-size: 18px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .2s ease;
}

body.sidebar-collapsed .sidebar { width: 60px; }
body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .sidebar-footer { display: none; }
body.sidebar-collapsed .main-area { margin-left: 60px; }

/* ===== 顶栏 ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}

.btn-toggle-sidebar:hover { background: var(--content-bg); }

.page-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ===== 内容区 ===== */
.content {
    flex: 1;
    padding: 24px;
}

/* ===== 卡片 ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* ===== 统计卡片 ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.bg-blue { background: #dbeafe; color: #2563eb; }
.stat-icon.bg-green { background: #dcfce7; color: #16a34a; }
.stat-icon.bg-orange { background: #fef3c7; color: #d97706; }
.stat-icon.bg-red { background: #fee2e2; color: #dc2626; }
.stat-icon.bg-cyan { background: #cffafe; color: #0891b2; }
.stat-icon.bg-purple { background: #ede9fe; color: #7c3aed; }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.stat-info p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 2px 0 0;
}

/* ===== 表格 ===== */
.table-container {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data-table thead th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

table.data-table tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table.data-table tbody tr:hover {
    background: #f8fafc;
}

table.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== 徽章/标签 ===== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-status.s-idle { background: #e2e8f0; color: #475569; }
.badge-status.s-using { background: #dbeafe; color: #2563eb; }
.badge-status.s-maintenance { background: #fef3c7; color: #d97706; }
.badge-status.s-scrapped { background: #fee2e2; color: #dc2626; }

.badge-mtc {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-mtc.level-0 { background: #dcfce7; color: #16a34a; }
.badge-mtc.level-1 { background: #fef3c7; color: #d97706; }
.badge-mtc.level-2 { background: #fee2e2; color: #dc2626; }

/* ===== 进度条 ===== */
.progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .3s ease;
    min-width: 2px;
}

.progress-bar-fill.low { background: var(--success); }
.progress-bar-fill.mid { background: var(--warning); }
.progress-bar-fill.high { background: var(--danger); }

/* ===== 筛选栏 ===== */
.filter-bar {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    box-shadow: var(--shadow-sm);
}

.filter-bar .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-bar label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-bar input,
.filter-bar select {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    min-width: 160px;
}

.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

/* ===== 按钮 ===== */
.btn-primary {
    background: var(--primary);
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    transition: background .15s;
}

.btn-primary:hover { background: #2563eb; }

.btn-outline-secondary {
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--content-bg);
    color: var(--text-primary);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

/* ===== 表单 ===== */
.form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.form-card .form-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.form-card .form-section:last-child { border-bottom: none; }

.form-card .section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    width: 100%;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.text-required { color: var(--danger); }

/* ===== 图表容器 ===== */
.chart-container {
    position: relative;
    height: 280px;
}

/* ===== 详情页 ===== */
.detail-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
    width: 140px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    flex-shrink: 0;
}

.detail-value {
    flex: 1;
    color: var(--text-primary);
    font-size: 13px;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ===== 工具类 ===== */
.text-blue { color: #2563eb; }
.text-green { color: #16a34a; }
.text-orange { color: #d97706; }
.text-red { color: #dc2626; }

.fw-600 { font-weight: 600; }

.cursor-pointer { cursor: pointer; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-brand span,
    .nav-item span,
    .sidebar-footer { display: none; }
    .main-area { margin-left: 60px; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 40px; height: 40px; font-size: 18px; }
    .stat-info h3 { font-size: 22px; }
    .content { padding: 16px; }
}
