* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #0e7490;
    --primary-dark: #155e75;
    --primary-light: #e0f4f9;
    --accent: #0284c7;
    --bg: #f3f6fa;
    --card: #ffffff;
    --text: #1e2b3a;
    --muted: #6b7c93;
    --border: #e2eaf2;
    --danger: #dc2626;
    --ok: #059669;
}

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

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

.sidebar {
    width: 216px;
    position: fixed;
    inset: 0 auto 0 0;
    background: linear-gradient(180deg, #0a2738 0%, #0e3b52 100%);
    color: #bfd8e6;
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 22px; border-bottom: 1px solid rgba(255,255,255,.09); }
.brand-logo {
    width: 38px; height: 38px; border-radius: 10px; flex: none;
    background: linear-gradient(135deg, #22d3ee, #0e7490);
    color: #fff; font-size: 20px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(14,116,144,.45);
}
.brand-name { color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 9px; letter-spacing: 1.4px; color: #5d8aa3; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; padding-top: 18px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-radius: 9px;
    color: #a9c8d9; font-size: 14px;
    transition: background .15s, color .15s;
}
.nav a .dot { width: 5px; height: 5px; border-radius: 50%; background: #3a6e88; flex: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #e8f4fa; }
.nav a.active { background: linear-gradient(90deg, rgba(34,211,238,.16), rgba(34,211,238,.05)); color: #fff; }
.nav a.active .dot { background: #22d3ee; box-shadow: 0 0 8px #22d3ee; }
.nav a { position: relative; }
.nav-badge {
    position: absolute; top: 7px; right: 12px; min-width: 16px; height: 16px;
    padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff;
    font-size: 10.5px; line-height: 16px; text-align: center; font-weight: 600;
}

.sidebar-foot { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #73a0b8; line-height: 1.7; }
.sidebar-foot .tiny { font-size: 11px; color: #4f7a92; }

.main { flex: 1; margin-left: 216px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 20px 32px; background: #fff; border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 19px; font-weight: 700; }
.topbar .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.content { padding: 26px 32px 48px; width: 100%; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; box-shadow: 0 1px 3px rgba(16,42,67,.04); }
.card + .card { margin-top: 18px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ""; width: 3px; height: 15px; border-radius: 2px; background: var(--primary); }
.card-title .hint { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: auto; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-side { display: grid; grid-template-columns: 380px 1fr; gap: 18px; align-items: start; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
    background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px;
    position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%; background: var(--primary-light); opacity: .7; }
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: .3px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat.teal .value { color: var(--primary); }
.stat.blue .value { color: var(--accent); }
.stat.green .value { color: var(--ok); }
.stat.dark .value { color: #33475b; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted);
    padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th:first-child { border-radius: 8px 0 0 8px; }
.table th:last-child { border-radius: 0 8px 8px 0; }
.table td { padding: 13px 12px; border-bottom: 1px solid #eef3f8; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafcfe; }
.table .num { font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; }
.table .muted { color: var(--muted); }
.empty { text-align: center; padding: 46px 0; color: var(--muted); font-size: 13.5px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; background: var(--primary-light); color: var(--primary-dark); }
.tag.gray { background: #eef2f7; color: #5b6b7e; }
.tag.green { background: #e6f7f0; color: #047857; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 18px; border-radius: 9px; border: 1px solid transparent;
    background: #fff; color: var(--text); cursor: pointer; font-size: 13.5px;
    transition: .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(14,116,144,.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border-color: #cfdce8; color: #35506b; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #f7fcfd; }
.btn-danger { border-color: #f3c9c9; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-link { color: var(--primary); padding: 4px 6px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.col-span-2 { grid-column: span 2; }
.field.col-span-3 { grid-column: span 3; }
.field label { font-size: 12.5px; color: #4a6076; font-weight: 600; }
.field label .req { color: var(--danger); margin-left: 2px; }
.input, .field input, .field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #d5e1ec; border-radius: 9px;
    background: #fff; color: var(--text); outline: none; transition: .15s;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,116,144,.11);
}
.field input[readonly] { background: #f5f8fb; color: var(--muted); }
.field textarea { resize: vertical; min-height: 74px; }
.help { font-size: 11.5px; color: #93a3b5; }

.rx-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.rx-table th, .rx-table td { padding: 9px 8px; text-align: center; }
.rx-table th { font-size: 12.5px; color: #4a6076; font-weight: 600; background: #f4f9fc; border-bottom: 1px solid var(--border); }
.rx-table th:first-child { border-radius: 8px 0 0 8px; }
.rx-table th:last-child { border-radius: 0 8px 8px 0; }
.rx-table td input { text-align: center; padding: 9px 6px; }
.eye-badge { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.eye-r { background: #fef3c7; color: #b45309; }
.eye-l { background: #e0f2fe; color: #0369a1; }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border); }

/* ---------- 详情 ---------- */
.info-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.info-item { display: flex; gap: 10px; font-size: 13.5px; }
.info-item .k { color: var(--muted); min-width: 62px; }
.info-item .v { font-weight: 600; word-break: break-all; }

.rx-preview { border: 1.5px solid #1f3b52; border-radius: 6px; padding: 18px 20px; background: #fff; }
.rx-preview .rx-head { text-align: center; border-bottom: 1px solid #cbd7e1; padding-bottom: 10px; margin-bottom: 12px; }
.rx-preview .rx-head .shop { font-size: 17px; font-weight: 700; letter-spacing: 3px; }
.rx-preview .rx-head .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.rx-preview .rx-title { text-align: center; font-size: 15px; font-weight: 700; letter-spacing: 6px; margin: 8px 0 12px; }
.rx-preview .rx-meta { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 10px; color: #3c556b; }
.rx-preview table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rx-preview th, .rx-preview td { border: 1px solid #b9c9d6; padding: 7px 6px; text-align: center; font-size: 12.5px; }
.rx-preview th { background: #f2f7fa; font-weight: 600; }
.rx-preview .foot { display: flex; justify-content: space-between; margin-top: 14px; font-size: 12px; color: #3c556b; }

/* ---------- 搜索栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; max-width: 380px; }
.search-box input { width: 100%; padding: 10px 14px 10px 36px; border: 1px solid #d5e1ec; border-radius: 10px; background: #fff; outline: none; }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,116,144,.1); }
.search-box::before { content: "⌕"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #90a4b8; font-size: 17px; }

/* ---------- 库存与弹窗 ---------- */
.stock-low { color: var(--danger); font-weight: 700; }
.stock-warn-row td { background: #fff8f7; }
.stock-tip { font-size: 11.5px; color: #8fa3b6; margin-top: 4px; }
.stock-tip.low { color: var(--danger); font-weight: 600; }
.stock-tip.ok { color: var(--ok); }

/* 库存商品联想下拉（销售单录入） */
.suggest-list {
    position: fixed; z-index: 60; display: none;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 10px 26px rgba(10, 35, 55, .16);
    max-height: 240px; overflow-y: auto; padding: 4px;
}
.suggest-item {
    display: flex; flex-direction: column; gap: 3px;
    padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 12.5px;
}
.suggest-item:hover, .suggest-item.on { background: #eef6fb; }
.suggest-item .sug-top { display: flex; align-items: baseline; gap: 8px; }
.suggest-item .nm { font-weight: 600; color: #0e3b52; }
.suggest-item .sp { color: var(--muted); font-size: 12px; }
.suggest-item .sug-sub { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); }
.suggest-item .st { color: var(--ok); font-variant-numeric: tabular-nums; }
.suggest-item .pr { color: var(--primary); font-variant-numeric: tabular-nums; }

dialog {
    border: none; border-radius: 14px; padding: 0; width: 380px; max-width: calc(100vw - 32px);
    margin: auto;
    box-shadow: 0 24px 70px rgba(8, 30, 48, .32);
}
.dialog-lg { width: 640px; max-width: calc(100vw - 40px); max-height: 88vh; overflow: auto; }
dialog::backdrop { background: rgba(9, 28, 43, .46); }
.dialog-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 700;
}
.dialog-close { border: none; background: none; font-size: 21px; line-height: 1; color: #90a4b8; cursor: pointer; }
.dialog-close:hover { color: var(--danger); }
.dialog-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-body input { width: 100%; padding: 10px 12px; border: 1px solid #d5e1ec; border-radius: 9px; outline: none; }
.dialog-body input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,116,144,.11); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; }

.low-stock-panel { border-color: #f6d5cd; background: #fffaf8; }
.low-stock-panel .card-title::before { background: #dc2626; }
.low-list { display: flex; flex-direction: column; gap: 8px; }
.low-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px; border-radius: 9px; background: #fff; border: 1px solid #f3e2dc; font-size: 13px;
}
.low-item .n { font-weight: 600; }
.low-item .s { color: var(--muted); font-size: 12px; margin-left: 6px; }
.low-item .q { color: var(--danger); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 销售明细编辑 ---------- */
.items-table input { padding: 8px 10px; }
.items-table td { padding: 8px 6px; }
.items-table .col-name input { min-width: 150px; }
.items-table .col-num input { width: 88px; text-align: right; }
.items-table .amount-cell { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; padding-right: 12px; }

.summary-box { display: flex; justify-content: flex-end; }
.summary-inner { width: 340px; display: flex; flex-direction: column; gap: 10px; }
.summary-row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; }
.summary-row .k { color: var(--muted); }
.summary-row input { width: 130px; text-align: right; padding: 8px 10px; }
.summary-row.total { padding-top: 12px; border-top: 1px solid var(--border); font-size: 15px; }
.summary-row.total .v { font-size: 22px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

/* ---------- 提示 ---------- */
.notice { padding: 12px 16px; border-radius: 10px; background: #eff9fd; border: 1px solid #c9e9f5; color: #0e5e75; font-size: 13px; margin-bottom: 16px; }
.notice.warn { background: #fff8ec; border-color: #f5e0b8; color: #925c0a; }
.low-alert a { color: #925c0a; font-weight: 600; text-decoration: underline; margin-left: 4px; }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-side { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .field.col-span-3 { grid-column: span 2; }
}
@media (max-width: 760px) {
    .layout { display: block; }
    .sidebar {
        position: fixed; inset: auto 0 0 0; width: 100%; height: auto;
        flex-direction: row; align-items: stretch;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: linear-gradient(180deg, #0a2738 0%, #0e3b52 100%);
        border-top: 1px solid rgba(255,255,255,.12);
        z-index: 100;
    }
    .brand, .sidebar-foot { display: none; }
    .nav {
        flex-direction: row; padding: 0; gap: 2px; width: 100%;
        overflow-x: auto; -webkit-overflow-scrolling: touch;
    }
    .nav a {
        flex: 1 0 62px; flex-direction: column; gap: 3px;
        padding: 7px 2px; font-size: 11.5px; border-radius: 8px; text-align: center;
    }
    .nav a .dot { width: 4px; height: 4px; }
    .nav a .nav-badge { top: 2px; right: 4px; }
    .main { margin-left: 0; padding-bottom: 62px; }
    .topbar {
        position: sticky; top: 0; z-index: 50;
        padding: 12px 14px; gap: 10px; align-items: flex-start;
        box-shadow: 0 2px 10px rgba(16,42,67,.06);
    }
    .topbar h1 { font-size: 17px; }
    .topbar .sub { font-size: 11.5px; margin-top: 2px; }
    .top-actions { gap: 8px; }
    .content { padding: 14px 12px 24px; }
    .card { padding: 16px 14px; border-radius: 12px; }
    .card-title { font-size: 14.5px; margin-bottom: 12px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
    .stat { padding: 14px 14px; border-radius: 12px; }
    .stat .value { font-size: 21px; margin-top: 5px; }
    .stat .value small { font-size: 11.5px; }
    .form-grid { grid-template-columns: 1fr; gap: 13px; }
    .field.col-span-2, .field.col-span-3 { grid-column: span 1; }
    .info-list { grid-template-columns: 1fr; gap: 9px; }
    .info-item { font-size: 13px; }
    .toolbar { gap: 9px; }
    .search-box { max-width: none; flex-basis: 100%; }
    .form-actions { gap: 10px; }
    .form-actions .btn { flex: 1; }
    .summary-inner { width: 100%; }
    .summary-row input { width: 110px; }
    dialog { width: calc(100vw - 24px); }
    .dialog-lg { width: calc(100vw - 24px); max-height: 90vh; }
    .low-item { font-size: 12.5px; }
    .table th, .table td { padding: 9px 10px; font-size: 12.5px; }
    .rx-table td input { padding: 7px 3px; }
    .table-wrap .rx-table { min-width: 460px; }
    .rx-preview { padding: 12px 10px; overflow-x: auto; }
    .rx-preview .rx-head .shop { font-size: 14px; letter-spacing: 1.5px; }
    .rx-preview th, .rx-preview td { padding: 5px 3px; font-size: 11px; }
    .rx-preview .rx-meta, .rx-preview .foot { font-size: 11px; }
    .items-table { min-width: 560px; }
    .btn { min-height: 38px; }
    .btn-sm { min-height: 34px; padding: 7px 12px; }
    input, select, textarea { font-size: 16px; }
}

/* ---------- 登录 / 初始化 ---------- */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
    background: linear-gradient(160deg, #0a2738 0%, #0e7490 55%, #0b3d52 100%);
}
.auth-card {
    width: 100%; max-width: 380px; background: #fff; border-radius: 16px;
    padding: 30px 26px; box-shadow: 0 24px 60px rgba(4, 24, 38, .35);
}
.auth-logo {
    width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 14px;
    background: linear-gradient(135deg, #22d3ee, #0e7490);
    color: #fff; font-size: 26px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(14, 116, 144, .35);
}
.auth-title { text-align: center; font-size: 19px; font-weight: 700; }
.auth-sub { text-align: center; font-size: 12.5px; color: var(--muted); margin: 6px 0 22px; }
.auth-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.auth-field label { font-size: 12.5px; font-weight: 600; color: #4a6076; }
.auth-field input {
    width: 100%; padding: 11px 13px; border: 1px solid #d5e1ec; border-radius: 10px;
    outline: none; font-size: 16px;
}
.auth-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 116, 144, .11); }
.auth-error {
    padding: 10px 12px; border-radius: 9px; margin-bottom: 14px;
    background: #fef2f2; border: 1px solid #f5d3d3; color: var(--danger); font-size: 12.5px;
}
.auth-btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.auth-foot { text-align: center; font-size: 11.5px; color: #93a3b5; margin-top: 18px; }

.logout-btn {
    background: none; border: none; padding: 0; margin: 6px 0 10px;
    color: #8fb6cc; font-size: 12px; cursor: pointer; text-align: left;
}
.logout-btn:hover { color: #fff; }
.user-line { color: #d5e9f3; }

@media (max-width: 420px) {
    .auth-card { padding: 24px 18px; border-radius: 14px; }
}




/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pagination .page-info {
  font-size: 13px;
  color: #64748b;
}
.pagination .btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}
