/* ============================================================
   商邦进销存 · 业务系统 Demo —— 浅色专业后台设计系统
   品牌色：靛蓝 #6366f1 → 青 #06b6d4 渐变点缀
   所有 demo 页面共用此样式 + js/app.js
   ============================================================ */
:root {
    --brand: #6366f1;
    --brand-dark: #4f46e5;
    --cyan: #06b6d4;
    --gradient: linear-gradient(135deg, #6366f1, #06b6d4);
    --green: #16a34a;
    --green-bg: #dcfce7;
    --amber: #d97706;
    --amber-bg: #fef3c7;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --blue-bg: #e0e7ff;

    --bg: #f4f6fb;
    --card: #ffffff;
    --line: #e8ecf3;
    --line-strong: #d7deea;
    --text: #1e293b;
    --text-2: #64748b;
    --text-3: #94a3b8;

    --sidebar-w: 232px;
    --topbar-h: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow: 0 4px 16px rgba(15, 23, 42, .06);
    --shadow-lg: 0 16px 48px rgba(15, 23, 42, .16);
    --t: .2s cubic-bezier(.4, 0, .2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
svg { display: block; }
.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* ============ 应用骨架 ============ */
.app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: #fff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 30;
}
.sidebar-logo {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    flex: none;
}
.sidebar-logo .logo-mark { width: 30px; height: 30px; flex: none; border-radius: 8px; }
.sidebar-logo .logo-text { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 20px; }
.nav-group-label { font-size: .72rem; color: var(--text-3); font-weight: 600; padding: 16px 12px 6px; letter-spacing: .04em; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 500;
    transition: background var(--t), color var(--t);
    position: relative; margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; flex: none; color: var(--text-3); transition: color var(--t); }
.nav-item:hover { background: #f1f4f9; color: var(--text); }
.nav-item:hover svg { color: var(--text-2); }
.nav-item.active { background: var(--blue-bg); color: var(--brand-dark); font-weight: 600; }
.nav-item.active svg { color: var(--brand); }
.nav-item.active::before {
    content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; background: var(--gradient); border-radius: 0 3px 3px 0;
}
.nav-badge { margin-left: auto; font-size: .68rem; font-weight: 700; color: #fff; background: var(--red); border-radius: 999px; padding: 1px 7px; }

/* 主区 */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

/* 顶栏 */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { font-size: .9rem; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.topbar .crumb b { color: var(--text); font-weight: 600; }
.topbar .crumb .sep { color: var(--text-3); }
.topbar-spacer { flex: 1; }
.topbar .t-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
    padding: 7px 14px; color: var(--text-3); width: 220px;
}
.topbar .t-search svg { width: 16px; height: 16px; flex: none; }
.topbar .t-search input { border: none; background: none; outline: none; font-size: .86rem; width: 100%; color: var(--text); }
.topbar .t-icon svg { width: 18px; height: 18px; }
.topbar .menu-toggle svg { width: 18px; height: 18px; }
.topbar .t-icon {
    width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center; color: var(--text-2); background: #fff; position: relative;
}
.topbar .t-icon:hover { background: var(--bg); }
.topbar .t-icon .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; border: 2px solid #fff; }
.topbar .t-user { display: flex; align-items: center; gap: 9px; }
.topbar .t-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gradient); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .82rem; }
.topbar .t-user .nm { font-weight: 600; font-size: .86rem; }
.topbar .t-user .rl { font-size: .72rem; color: var(--text-3); }

/* 页面容器 */
.page { padding: 24px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.3rem; font-weight: 700; }
.page-head .sub { color: var(--text-2); font-size: .88rem; margin-top: 4px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============ 通用组件 ============ */
/* 按钮 */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
    background: #fff; color: var(--text); font-weight: 600; font-size: .86rem;
    transition: all var(--t); white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--gradient); border-color: transparent; color: #fff; }
.btn-primary:hover { color: #fff; filter: brightness(1.05); box-shadow: 0 6px 16px rgba(99, 102, 241, .3); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); color: var(--text); border-color: transparent; }
.btn-sm { padding: 6px 11px; font-size: .8rem; }
.btn-danger:hover { border-color: var(--red); color: var(--red); }
.btn-link { background: none; border: none; color: var(--brand); font-weight: 600; padding: 4px 6px; }
.btn-link:hover { text-decoration: underline; }

/* 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 1rem; font-weight: 700; }
.card-head .more { font-size: .82rem; color: var(--text-2); }
.card-body { padding: 20px; }
.card-pad { padding: 20px; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .k-label { color: var(--text-2); font-size: .84rem; }
.kpi .k-ico { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; }
.kpi .k-ico svg { width: 20px; height: 20px; }
.kpi .k-val { font-size: 1.7rem; font-weight: 800; margin-top: 10px; letter-spacing: -.02em; }
.kpi .k-trend { font-size: .8rem; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.k-trend.up { color: var(--green); }
.k-trend.down { color: var(--red); }

/* 数据表 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data thead th {
    text-align: left; font-weight: 600; color: var(--text-2); background: #fafbfd;
    padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: .82rem;
}
table.data tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background var(--t); }
table.data tbody tr:hover { background: #f7f9fc; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .muted { color: var(--text-3); }
table.data .strong { font-weight: 600; }

/* 徽章 */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { color: var(--green); background: var(--green-bg); }
.badge-amber { color: var(--amber); background: var(--amber-bg); }
.badge-red { color: var(--red); background: var(--red-bg); }
.badge-blue { color: var(--brand-dark); background: var(--blue-bg); }
.badge-gray { color: var(--text-2); background: #eef1f6; }
.badge.plain::before { display: none; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.col-2 { grid-column: span 2; }
.field label { font-size: .82rem; color: var(--text-2); font-weight: 600; }
.field label .req { color: var(--red); }
.input, .select, textarea.input {
    width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    font-size: .88rem; color: var(--text); background: #fff; outline: none; transition: border-color var(--t), box-shadow var(--t);
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.input-icon .input { padding-left: 34px; }

/* 工具条/筛选 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

/* 分段/标签 */
.tabs { display: flex; gap: 4px; background: #eef1f6; padding: 4px; border-radius: 10px; }
.tab { padding: 7px 14px; border-radius: 7px; font-size: .84rem; font-weight: 600; color: var(--text-2); transition: all var(--t); }
.tab.active { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow-sm); }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--line); color: var(--text-2); font-size: .84rem; flex-wrap: wrap; gap: 10px; }
.pager .pages { display: flex; gap: 4px; }
.pager .pg { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .82rem; color: var(--text-2); }
.pager .pg:hover { border-color: var(--brand); color: var(--brand); }
.pager .pg.active { background: var(--gradient); color: #fff; border-color: transparent; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .4); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-mask.open { display: flex; }
.modal {
    background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
    max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
    animation: modalIn .22s cubic-bezier(.4, 0, .2, 1);
}
.modal.lg { max-width: 820px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 1.05rem; font-weight: 700; }
.modal-head .x { width: 32px; height: 32px; border-radius: 8px; border: none; background: var(--bg); color: var(--text-2); display: flex; align-items: center; justify-content: center; }
.modal-head .x:hover { background: #e8ecf3; color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: #fafbfd; }

/* 抽屉（详情） */
.drawer-mask { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .4); display: none; }
.drawer-mask.open { display: block; }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw; background: #fff; z-index: 101;
    box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { font-size: 1.05rem; font-weight: 700; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }

/* 描述列表 */
.desc-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.desc-list .d-item.full { grid-column: span 2; }
.desc-list .d-k { font-size: .78rem; color: var(--text-3); margin-bottom: 3px; }
.desc-list .d-v { font-weight: 600; }

/* toast */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
    background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
    padding: 11px 18px 11px 14px; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .88rem;
    animation: toastIn .24s cubic-bezier(.4, 0, .2, 1);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.toast .t-dot { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.toast.ok .t-dot { background: var(--green); }
.toast.warn .t-dot { background: var(--amber); }
.toast.err .t-dot { background: var(--red); }

/* 简易图表辅助 */
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: .8rem; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding-top: 10px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars .bar-col .bar-stack { width: 100%; max-width: 38px; display: flex; flex-direction: column-reverse; gap: 3px; }
.bars .bar-col .bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 3px; }
.bars .bar-col .bar-x { font-size: .74rem; color: var(--text-3); }

/* 进度条 */
.progress { height: 7px; border-radius: 999px; background: #eef1f6; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--gradient); }

/* 空态 */
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty svg { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--line-strong); }

/* 工具类 */
.row { display: flex; gap: 16px; }
.col { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.text-green { color: var(--green); } .text-amber { color: var(--amber); } .text-red { color: var(--red); }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.fw-700 { font-weight: 700; } .tnum { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }

/* 移动端汉堡（默认隐藏） */
.menu-toggle { display: none; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; align-items: center; justify-content: center; color: var(--text-2); }

@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform var(--t); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .menu-toggle { display: flex; }
    .topbar .t-search { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .field.col-2 { grid-column: span 1; }
    .desc-list { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}
