/* 阿里云百炼风格：紫色主色、浅灰底、白卡片、圆角 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #624aff;
  --primary-hover: #5238f0;
  --primary-light: #efecff;
  --primary-grad: linear-gradient(135deg, #7b64ff 0%, #624aff 55%, #4d7dff 100%);
  --border: #e6e8f0;
  --text: #1f2329;
  --muted: #8a8f99;
  --bg: #f5f6fa;
  --dev1: #ffc1c1;   /* >10% 粉 */
  --dev2: #ff5a5a;   /* >20% 红 */
  --dev3: #b22222;   /* >40% 深红 */
  --warn-bg: #fff8e6;
  --miss-bg: #fff3b0;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(31, 35, 41, .06);
}
html, body { height: 100%; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }

/* ===== 顶栏 ===== */
#topbar { display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 56px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
#topbar .brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
#topbar .brand .logo { width: 22px; height: 22px; border-radius: 6px; background: var(--primary-grad); display: inline-block; }
#topbar .ver { font-size: 12px; color: var(--muted); font-weight: 400; }
#topbar .client-switch { display: flex; align-items: center; gap: 8px; flex: 1; }
#topbar select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; min-width: 170px; background: #fff; }

#layout { display: flex; min-height: calc(100vh - 56px); }

/* ===== 侧栏（悬浮跟随页面滚动） ===== */
#sidenav { width: 168px; background: #fff; border-right: 1px solid var(--border); padding: 10px 8px; flex-shrink: 0; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; align-self: flex-start; }
/* 下拉框旁的「＋新增」按钮 */
.sel-with-add { display: flex; gap: 4px; align-items: center; }
.sel-with-add select { flex: 1; }
.sel-with-add .btn { flex-shrink: 0; padding: 4px 8px; }
#sidenav .nav-group { padding: 14px 12px 6px; font-size: 11px; color: var(--muted); letter-spacing: .5px; }
#sidenav a { display: block; padding: 9px 12px; margin: 2px 0; cursor: pointer; color: var(--text); border-radius: 8px; user-select: none; font-size: 13.5px; }
#sidenav a:hover { background: var(--bg); }
#sidenav a.on { background: var(--primary-light); color: var(--primary); font-weight: 600; }
#main { flex: 1; padding: 20px 24px; min-width: 0; } /* 不能加 overflow，否则 #dashboard 吸顶失效 */
.day-card.pricemode { outline: 2px solid #e8a13c; }
.day-card.pricemode .day-head { background: #fff7e0; }
.btn.warn { background: #e8a13c; border-color: #e8a13c; color: #fff; }
/* 食谱 Excel 式编辑器 */
.excel-edit td[contenteditable] { background: #fff; }
.excel-edit .xname { text-align: left; min-width: 160px; }
.excel-edit tr.xdate td { background: #efecff; text-align: left; }
.excel-edit .xop { background: #fafafa; }

/* ===== 通用 ===== */
h2.page-title { font-size: 18px; margin-bottom: 14px; font-weight: 600; }
h2.page-title .muted { font-weight: 400; }
h3.sec { font-size: 14.5px; margin: 18px 0 8px; font-weight: 600; }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.pad0 { padding: 0; overflow: hidden; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.red { color: #e34d4d; }
.green { color: #12a35c; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }

/* 百炼风渐变横幅卡片 */
.hero-card { background: var(--primary-grad); color: #fff; border-radius: 12px; padding: 24px 28px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 6px 18px rgba(98, 74, 255, .25); }
.hero-card .hero-title { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.hero-card .hero-sub { font-size: 13px; opacity: .85; }

.btn { display: inline-block; padding: 7px 16px; background: var(--primary); border: 1px solid var(--primary); color: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; user-select: none; transition: .15s; white-space: nowrap; }
#topbar label, #topbar .brand { white-space: nowrap; }
.btn:hover { background: var(--primary-hover); }
.btn.ghost { background: #fff; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-light); }
.btn.white { background: #fff; color: var(--primary); border-color: #fff; font-weight: 600; }
.btn.sm { padding: 4px 12px; font-size: 12px; border-radius: 7px; }
.btn.danger { background: #e34d4d; border-color: #e34d4d; }
.btn.gray { background: #f2f3f5; border-color: #e6e8f0; color: #555; }
.btn.gray:hover { background: #e8eaee; }
.btn.warn-btn { background: #f6a623; border-color: #f6a623; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

input[type=text], input[type=number], input[type=month], select, textarea {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; color: var(--text);
}
/* 隐藏 number input 的上下步进按钮（人数、金额等场景不需要） */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
input:focus, select:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
label.fld { display: inline-flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.fld > input, label.fld > select { width: 140px; }
label.fld.wide > input { width: 240px; }

/* ===== 表格 ===== */
table.grid { width: 100%; border-collapse: collapse; background: #fff; }
table.grid th, table.grid td { border: 1px solid #eef0f5; padding: 7px 10px; text-align: center; }
table.grid th { background: #f7f8fb; font-weight: 600; white-space: nowrap; color: #4a4f58; }
table.grid td[contenteditable] { background: #fbfaff; min-width: 50px; }
table.grid td[contenteditable]:focus { outline: 2px solid var(--primary); background: #fff; }
table.grid tr:hover td { background: #f8f9fe; }
table.grid td.num { text-align: right; }

/* 偏移分级着色 */
.dev1 { background: var(--dev1) !important; }
.dev2 { background: var(--dev2) !important; color: #fff; }
.dev3 { background: var(--dev3) !important; color: #fff; font-weight: 700; }
.badge { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 12px; background: #f2f3f5; }
.badge.dev1 { background: var(--dev1); color: #7a1f1f; }
.badge.dev2 { background: var(--dev2); color: #fff; }
.badge.dev3 { background: var(--dev3); color: #fff; }

.tag-missing { background: var(--miss-bg) !important; }
.tag-range { background: var(--dev1) !important; }

/* ===== 驾驶舱 ===== */
#dashboard { position: sticky; top: 56px; z-index: 40; background: #fff; border: 1.5px solid #c9c2f5; border-radius: var(--radius); padding: 12px 18px; margin-bottom: 14px; display: flex; gap: 26px; align-items: center; flex-wrap: wrap; box-shadow: 0 2px 10px rgba(31,35,41,.06); }
#dashboard .kpi { display: flex; flex-direction: column; }
#dashboard .kpi .v { font-size: 19px; font-weight: 700; }
#dashboard .kpi .k { font-size: 11px; color: var(--muted); }
#dashboard .kpi .v.neg { color: #e34d4d; }

/* ===== 送货单卡片 ===== */
.day-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow); overflow: hidden; }
.day-card .day-head { display: flex; gap: 16px; align-items: center; padding: 9px 16px; background: #f7f8fb; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.day-card .day-head .d { font-weight: 700; }
.day-card table.grid { border: none; }
.day-card .day-foot { padding: 9px 16px; display: flex; gap: 16px; align-items: center; }
.day-card .day-foot .sum { font-weight: 700; margin-left: auto; }
.leave-input { width: 56px; }

/* ===== 数据检查 ===== */
.check-list .item { padding: 7px 12px; border-left: 3px solid #ccc; margin-bottom: 6px; background: #fafafa; border-radius: 0 8px 8px 0; }
.check-list .item.ok { border-color: #12a35c; }
.check-list .item.warn { border-color: #f6a623; background: var(--warn-bg); }
.check-list .item.error { border-color: #e34d4d; background: #fff0f0; }

/* ===== 模态框 ===== */
#modal-mask { position: fixed; inset: 0; background: rgba(31,35,41,.4); z-index: 100; display: flex; align-items: center; justify-content: center; }
#modal-mask[hidden] { display: none; }
#toast[hidden] { display: none; }
#modal { background: #fff; border-radius: 12px; min-width: 440px; max-width: 760px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(31,35,41,.18); }
#modal-title { padding: 15px 20px; font-weight: 700; border-bottom: 1px solid var(--border); }
#modal-body { padding: 20px; overflow: auto; }
#modal-body .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#modal-actions { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

#toast { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); background: #2b2f36; color: #fff; padding: 10px 24px; border-radius: 10px; z-index: 200; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

/* ===== 上传区 ===== */
.uploader { border: 2px dashed #d6d9e6; border-radius: var(--radius); padding: 30px; text-align: center; color: var(--muted); cursor: pointer; background: #fff; margin-bottom: 14px; transition: .15s; }
.uploader:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.uploader-big { padding: 40px 30px; }
.uploader-big .up-title { font-size: 26px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.uploader-big .up-sub { font-size: 13px; color: var(--muted); }

/* ===== 页签（百炼精选/全部模型风格） ===== */
.pill-switch { display: inline-flex; background: #f2f3f5; border-radius: 9px; padding: 3px; }
.pill-switch span { padding: 5px 18px; cursor: pointer; border-radius: 7px; user-select: none; color: #5a5f68; font-size: 13px; }
.pill-switch span.on { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(31,35,41,.1); }

.todo { padding: 8px 12px; background: var(--warn-bg); border-radius: 8px; margin-bottom: 6px; }

/* ===== 搜索添加（固定下单表） ===== */
.search-results { margin-top: 4px; }
.search-item { display: flex; gap: 14px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; cursor: pointer; background: #fff; transition: .12s; }
.search-item:hover { border-color: var(--primary); background: var(--primary-light); }
.search-item.on { border-color: var(--primary); background: var(--primary-light); font-weight: 600; }
.search-item .btn { margin-left: auto; }
.search-item .badge { margin-left: auto; }

.period-bar label.fld > select { min-width: 120px; }

/* ===== 打印送货单 ===== */
@media print {
  #topbar, #sidenav, #dashboard, .no-print, #toast { display: none !important; }
  #main { padding: 0; }
  .day-card { page-break-after: always; border: 1px solid #000; box-shadow: none; }
  body { background: #fff; }
}

/* 菜谱布局（查看/编辑食谱弹窗）：每天一栏，菜名｜食物｜重量 */
.menu-days { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; max-height: 62vh; padding-bottom: 6px; }
.menu-day { min-width: 320px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.menu-day .mh { display: flex; gap: 8px; align-items: center; padding: 7px 10px; background: var(--primary-light); font-size: 13px; }
.menu-day .mh .btn { margin-left: auto; }
.menu-day table.grid { border: none; }
.menu-day table.grid td { padding: 4px 8px; }
td.mdish, th.mdish { width: 96px; color: #555; text-align: left; }
td.mqty, th.mqty { width: 56px; }
.menu-day .xop { width: 36px; }
