:root {
    --primary: #0f9b8e;
    --primary-dark: #0b7d73;
    --primary-light: #e6f7f5;
    --ink: #0f172a;
    --text: #334155;
    --muted: #64748b;
    --line: #e5eaf0;
    --bg: #f4f7fb;
    --card: #ffffff;
    --danger: #e54d42;
    --warning: #f59e0b;
    --sidebar-w: 222px;
    --header-h: 60px;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

a { color: var(--primary-dark); text-decoration: none; }

/* ---------- 布局 ---------- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0b1220 0%, #101c31 100%);
    color: #cbd5e1;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 17px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: #fff;
    /* background: linear-gradient(135deg, #14b8a6, #0b7d73); */
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: .5px;
    box-shadow: 0 4px 12px rgba(20, 184, 166, .35);
}

.brand-name { color: #fff; font-size: 17px; font-weight: 600; letter-spacing: .4px; }
.brand-sub { color: #7c8ca3; font-size: 11px; margin-top: 2px; }

.app-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-label { color: #5d6c82; font-size: 12px; padding: 10px 10px 6px; letter-spacing: .5px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: #b6c2d4;
    font-size: 14px;
    transition: all .18s;
    position: relative;
}

.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(20, 184, 166, .16); color: #5eead4; font-weight: 500; }
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #2dd4bf;
}
.nav-item .layui-icon { font-size: 17px; }

.sidebar-footer { padding: 14px 18px; font-size: 11px; color: #526078; border-top: 1px solid rgba(255, 255, 255, .06); }

.app-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 0 22px;
    gap: 12px;
    z-index: 999;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .03);
}

.page-title { font-size: 17px; font-weight: 600; color: var(--ink); flex: 1; }

.header-right { display: flex; align-items: center; gap: 14px; }
.role-tag {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 20px;
}

.user-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ink);
    transition: background .18s;
}
.user-box:hover { background: #f5f8fc; }

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #14b8a6, #0b7d73);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-name { font-size: 13px; }
.user-box .layui-icon { font-size: 12px; color: var(--muted); }

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 142px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    padding: 5px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: all .18s;
    z-index: 10;
}
.user-box:hover .user-dropdown { opacity: 1; visibility: visible; transform: translateY(2px); }
.user-dropdown a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--text); font-size: 13px; }
.user-dropdown a:hover { background: #f3f7fb; color: var(--danger); }
.user-dropdown .layui-icon { margin-right: 5px; }

.sidebar-toggle {
    display: none;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.app-main { margin-left: var(--sidebar-w); padding-top: var(--header-h); min-height: 100vh; }
.app-content { padding: 20px 22px 32px; }

/* ---------- 通用卡片 ---------- */
.page-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--ink); flex: 1; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-body { padding: 18px; }

.btn-sm { height: 32px; line-height: 32px; padding: 0 13px; font-size: 13px; border-radius: 6px; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border-radius: 6px;
    padding: 0 15px;
    height: 36px;
    line-height: 36px;
    font-size: 14px;
    transition: background .18s;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-primary .layui-icon { font-size: 14px; }

.btn-plain {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 36px;
    line-height: 34px;
    padding: 0 14px;
    font-size: 13px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
}
.btn-plain:hover { border-color: #cbd5e1; color: var(--primary-dark); }

/* ---------- 工作台 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
}
.stat-icon.teal { background: #e6f7f5; color: #0f9b8e; }
.stat-icon.blue { background: #eaf1ff; color: #3b82f6; }
.stat-icon.orange { background: #fff3e6; color: #f59e0b; }
.stat-icon.purple { background: #f1ecfe; color: #8b5cf6; }
.stat-value { font-size: 25px; font-weight: 700; color: var(--ink); line-height: 1.15; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 3px; }
.stat-extra { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat-extra strong { color: var(--primary-dark); font-weight: 600; }

.charts-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-top: 16px; }
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chart-head { padding: 15px 18px 0; }
.chart-head .card-title { font-size: 15px; }
.chart-title-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chart-box { height: 300px; padding: 6px 10px 10px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.list-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.list-body { padding: 6px 8px 10px; }
.list-row { display: flex; gap: 10px; padding: 11px 10px; border-bottom: 1px dashed #eef2f7; align-items: flex-start; }
.list-row:last-child { border-bottom: 0; }
.list-avatar {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    background: #eef6f5; color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}
.list-main { flex: 1; min-width: 0; }
.list-title { color: var(--ink); font-size: 13px; font-weight: 500; line-height: 1.5; }
.list-sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-time { color: #94a3b8; font-size: 12px; white-space: nowrap; }
.empty-tip { text-align: center; color: #94a3b8; font-size: 13px; padding: 26px 0; }

/* ---------- 查询栏 ---------- */
.filter-bar {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.filter-bar .filter-input,
.filter-bar .filter-select {
    height: 36px;
    border: 1px solid #dfe6ef;
    border-radius: 6px;
    padding: 0 10px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    outline: none;
    min-width: 140px;
}
.filter-bar select.filter-select { padding-right: 26px; }
.filter-bar .filter-input:focus,
.filter-bar .filter-select:focus { border-color: var(--primary); }
.filter-bar .spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px 8px; }
.layui-table-view { border: 0; margin: 0; }
.layui-table-view .layui-table { border-color: #edf1f6; }
.layui-table th { background: #f8fafc !important; color: #475569; font-weight: 600; font-size: 13px; }
.layui-table td { color: var(--text); font-size: 13px; }
/* 统一行高：两行内容（公司+联系人）44px + 余量；固定高度保证右侧固定列与主表行严格对齐 */
.layui-table-cell { height: 46px; line-height: 22px; overflow: hidden; }
.layui-table-tool { border-bottom: 1px solid var(--line); background: #fff; padding: 10px 0; }
.layui-table-page { border-top: 1px solid var(--line); }

.table-company { color: var(--ink); font-weight: 600; }
.table-company a:hover { color: var(--primary-dark); }
.table-sub { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }

.badge {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 19px;
    white-space: nowrap;
}
.level-a { background: #fee2e2; color: #b91c1c; }
.level-b { background: #ffedd5; color: #c2410c; }
.level-c { background: #e0f2fe; color: #0369a1; }
.level-d { background: #f1f5f9; color: #64748b; }

.st-potential { background: #eef2f7; color: #475569; }
.st-following { background: #e6f7f5; color: #0b7d73; }
.st-deal { background: #dcfce7; color: #15803d; }
.st-pause { background: #fef3c7; color: #b45309; }
.st-lost { background: #f1f5f9; color: #94a3b8; }
.st-sample { background: #f3e8ff; color: #7e22ce; }
.st-negotiating { background: #ffedd5; color: #c2410c; }
.st-pending { background: #fef3c7; color: #b45309; }
.st-producing { background: #e0f2fe; color: #0369a1; }
.st-shipped { background: #ede9fe; color: #6d28d9; }
.st-done { background: #dcfce7; color: #15803d; }
.st-cancel { background: #f1f5f9; color: #94a3b8; }
.st-default { background: #f1f5f9; color: #64748b; }

.prio-1 { color: #dc2626; font-weight: 600; }
.prio-2 { color: #d97706; font-weight: 600; }
.prio-3 { color: #64748b; }

.text-danger { color: var(--danger); }
.text-muted { color: var(--muted); }
.text-success { color: #15803d; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- 详情页 ---------- */
.detail-head {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.detail-avatar {
    width: 52px; height: 52px; border-radius: 12px;
    background: linear-gradient(135deg, #14b8a6, #0b7d73);
    color: #fff; font-size: 20px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.detail-title { flex: 1; min-width: 240px; }
.detail-title h2 { margin: 0 0 6px; font-size: 20px; color: var(--ink); font-weight: 600; }
.detail-meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 16px; }
.detail-meta span i { font-size: 13px; margin-right: 3px; color: #94a3b8; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 28px; }
.info-item .info-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.info-item .info-value { color: var(--ink); font-size: 13px; word-break: break-all; }

.detail-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; padding: 0 4px; }
.detail-tab {
    padding: 11px 16px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.detail-tab.active { color: var(--primary-dark); border-color: var(--primary); font-weight: 500; }

.customer-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sum-box { background: #f8fafc; border-radius: 8px; padding: 12px 14px; }
.sum-value { font-size: 18px; font-weight: 600; color: var(--ink); }
.sum-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- 表单弹层 ---------- */
.form-wrap { background: #fff; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
.form-cell.full,
.form-grid > .layui-form-item.full { grid-column: 1 / -1; }
.form-wrap .layui-form-item { margin-bottom: 10px; }
.form-wrap .layui-form-label { width: 84px; padding: 9px 10px 9px 0; font-size: 13px; color: #475569; }
.form-wrap .layui-input-block { margin-left: 84px; }
.form-wrap .layui-input, .form-wrap .layui-select, .form-wrap .layui-textarea { border-radius: 6px; font-size: 13px; }
.form-wrap .layui-form-select .layui-input { padding-right: 30px; }
.form-wrap .layui-textarea { min-height: 76px; resize: vertical; }
.form-tip { color: var(--muted); font-size: 12px; padding: 0 0 12px 20px; }

.layui-layer-page .layui-layer-content { overflow: visible !important; }
.layui-layer-btn .layui-layer-btn0 { background: var(--primary) !important; border-color: var(--primary) !important; }

/* ---------- 登录页 ---------- */
.login-page {
    min-height: 100vh;
    background: #0a0f1a url('../img/login.jpg') center center / cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 45% 65% at 12% 88%, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 55%, rgba(10,15,26,.28) 100%),
        linear-gradient(180deg, rgba(10,15,26,.35) 0%, rgba(10,15,26,.10) 45%, rgba(10,15,26,.28) 100%);
    pointer-events: none;
}
.login-page::after { display: none; }
.login-card {
    position: relative;
    z-index: 2;
    width: 400px;
    max-width: 100%;
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(4px);
    border-radius: 18px;
    padding: 38px 36px 30px;
    box-shadow: 0 30px 70px rgba(2, 6, 23, .55), 0 4px 18px rgba(0,0,0,.18);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand .brand-logo { width: 44px; height: 44px; font-size: 19px; }
.login-brand h1 { margin: 0; font-size: 23px; color: var(--ink); letter-spacing: .3px; }
.login-brand p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.login-form .layui-form-item { margin-bottom: 16px; }
.login-form .layui-input { height: 44px; border-radius: 8px; padding-left: 40px; font-size: 14px; }
.login-field { position: relative; }
.login-field .field-icon { position: absolute; left: 13px; top: 12px; font-size: 18px; color: #94a3b8; z-index: 3; }
.login-submit { width: 100%; height: 44px; border-radius: 8px; background: var(--primary); border: 0; color: #fff; font-size: 15px; cursor: pointer; letter-spacing: 1px; }
.login-submit:hover { background: var(--primary-dark); }
.login-hint { margin-top: 18px; padding: 10px 12px; background: #f6f9fc; border: 1px dashed #dbe4ee; border-radius: 8px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.login-footer { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 18px; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }

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

@media (max-width: 860px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgba(2, 6, 23, .35); }
    .app-header { left: 0; }
    .sidebar-toggle { display: block; }
    .app-main { margin-left: 0; }
    .app-content { padding: 14px; }
    .two-col { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-cols { grid-template-columns: 1fr !important; }
    .detail-head { padding: 16px; }
    .detail-title h2 { font-size: 17px; }
    .customer-summary { grid-template-columns: 1fr; }
    .user-name, .role-tag { display: none; }
}
