/* 餐饮菜品成本卡系统 —— 样式 */
:root {
  --primary: #0f766e;
  --primary-600: #0d9488;
  --primary-700: #0f5f59;
  --primary-50: #f0fdfa;
  --accent: #f59e0b;
  --accent-50: #fffbeb;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --ok: #16a34a;
  --ok-50: #f0fdf4;
  --warn: #d97706;
  --warn-50: #fffbeb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --sidebar-w: 230px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #0b3b32 0%, #07231d 100%);
  color: #cfe9e3;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.brand { padding: 20px 18px 16px; display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #34d399, #0d9488);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; box-shadow: 0 4px 10px rgba(16, 185, 129, .35);
}
.brand-title { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.brand-sub { font-size: 10.5px; color: #7fb8ad; margin-top: 2px; letter-spacing: 1px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 20px; }
.nav-group { font-size: 10.5px; color: #5f8f85; letter-spacing: 1.5px; padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin: 2px 0;
  border-radius: 8px; cursor: pointer;
  color: #b9d9d2; font-size: 13.5px;
  border: none; background: none; width: 100%; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: rgba(52, 211, 153, .16); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #34d399; }
.nav-icon { width: 18px; text-align: center; opacity: .9; font-size: 15px; }
.sidebar-foot { padding: 12px 16px 16px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 11px; color: #6f9d93; line-height: 1.7; }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #34d399; margin-right: 5px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; flex-direction: column; justify-content: center; }
#page-title { font-size: 17px; font-weight: 700; margin: 0; }
#page-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.conn.on .conn-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .15); }
.conn.on { color: #15803d; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 20px; cursor: pointer; border: 1px solid var(--line); background: #fafafa; }
.user-chip:hover { border-color: var(--line-2); background: #f3f4f6; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #0d9488, #0f766e); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; }
.user-meta { line-height: 1.25; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10.5px; color: var(--muted); }
.user-menu { position: absolute; right: 26px; top: 56px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 160px; padding: 6px; z-index: 50; }
.user-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: none; background: none; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.user-menu button:hover { background: #f3f4f6; color: var(--text); }
.page { padding: 22px 26px 48px; flex: 1; }

/* ---------------- 通用组件 ---------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .hint { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Courier New", monospace; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; color: var(--text-2); cursor: pointer; font-size: 13px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary-600); color: var(--primary-700); background: var(--primary-50); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover { background: #d97706; border-color: #d97706; color: #fff; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: var(--danger-50); border-color: var(--danger); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f3f4f6; border-color: transparent; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 15px; padding: 4px 7px; border-radius: 6px; line-height: 1; }
.icon-btn:hover { background: #f3f4f6; color: var(--text); }
.link-btn { border: none; background: none; color: var(--primary); cursor: pointer; padding: 2px 4px; font-size: 12.5px; border-radius: 4px; }
.link-btn:hover { background: var(--primary-50); }
.link-btn.danger { color: var(--danger); }
.link-btn.danger:hover { background: var(--danger-50); }

input[type=text], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 7px;
  outline: none; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-600); box-shadow: 0 0 0 3px rgba(13, 148, 136, .12); }
input[readonly], input:disabled { background: #f9fafb; color: var(--muted); }
select { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.field .req { color: var(--danger); }
.field-help { font-size: 11px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { position: relative; width: 230px; }
.toolbar .search input { padding-left: 30px; }
.toolbar .search::before { content: "🔍"; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .6; }
.toolbar select { width: auto; min-width: 110px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data thead th {
  position: sticky; top: 0; z-index: 2; background: #f9fafb; color: var(--text-2);
  font-weight: 600; font-size: 12px; text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data tbody td { padding: 10px 12px; border-bottom: 1px solid #f1f3f4; vertical-align: middle; }
table.data tbody tr:hover { background: #fafcfb; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.ops { white-space: nowrap; text-align: right; }
table.data .name { font-weight: 600; color: var(--text); }
table.data .sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
table.data.compact th, table.data.compact td { padding: 7px 9px; font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 42px 10px !important; font-size: 13px; }
.empty .big { font-size: 30px; display: block; margin-bottom: 8px; opacity: .5; }

.badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--ok-50); color: #15803d; }
.badge-amber { background: var(--warn-50); color: #b45309; }
.badge-red { background: var(--danger-50); color: #b91c1c; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-teal { background: var(--primary-50); color: var(--primary-700); }
.dot-sep { color: #d1d5db; margin: 0 5px; }

/* ---------------- 统计卡 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -18px; top: -22px; width: 74px; height: 74px; border-radius: 50%; background: var(--primary-50); }
.stat .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 27px; font-weight: 700; margin-top: 7px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .foot { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.stat.teal .value { color: var(--primary-700); }
.stat.warn .value { color: var(--warn); }
.stat.red .value { color: var(--danger); }
.stat.amber .value { color: #b45309; }

/* ---------------- 进度条 / 条形 ---------------- */
.bar-row { display: grid; grid-template-columns: 120px 1fr 58px; align-items: center; gap: 10px; padding: 5px 0; font-size: 12.5px; }
.bar-row .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-track { height: 8px; background: #eef2f1; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #34d399, #0d9488); }
.bar-fill.warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar-fill.red { background: linear-gradient(90deg, #f87171, #dc2626); }
.bar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.stack-bar { display: flex; height: 18px; border-radius: 6px; overflow: hidden; background: #f3f4f6; }
.stack-bar span { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }

/* ---------------- 弹窗 ---------------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); width: 620px; max-width: 100%; animation: slide .18s ease; display: flex; flex-direction: column; max-height: calc(100vh - 80px); }
.modal.wide { width: 1080px; }
.modal.xwide { width: 1240px; }
@keyframes slide { from { transform: translateY(-10px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-head .sub { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: #fcfcfd; border-radius: 0 0 12px 12px; flex: 0 0 auto; }
.confirm-text { font-size: 14px; line-height: 1.7; margin: 4px 0 2px; }
.confirm-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------------- 提示 ---------------- */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg); animation: toastIn .2s ease; max-width: 520px; display: flex; align-items: center; gap: 8px; }
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.info { background: #1e3a5f; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.loading { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.loading::before { content: "⏳"; display: block; font-size: 24px; margin-bottom: 10px; opacity: .7; }
.error-block { padding: 30px; text-align: center; color: var(--danger); background: var(--danger-50); border: 1px solid #fecaca; border-radius: var(--radius); }

/* ---------------- 登录 ---------------- */
.login-view { min-height: 100vh; display: flex; }
.login-brand {
  flex: 1.1; background: linear-gradient(150deg, #0b3b32 0%, #0f766e 55%, #0d9488 100%);
  color: #e6f4f1; display: flex; flex-direction: column; justify-content: center; padding: 60px 64px; position: relative; overflow: hidden;
}
.login-brand::before { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(255, 255, 255, .05); top: -120px; right: -100px; }
.login-brand::after { content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%; background: rgba(255, 255, 255, .04); bottom: -120px; left: -80px; }
.login-brand .logo { font-size: 40px; margin-bottom: 20px; }
.login-brand h1 { font-size: 34px; line-height: 1.25; margin: 0 0 14px; color: #fff; letter-spacing: .5px; }
.login-brand p { font-size: 14.5px; line-height: 1.9; color: #b6ddd5; max-width: 440px; margin: 0; }
.login-brand ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 13px; }
.login-brand li { display: flex; gap: 10px; font-size: 13.5px; color: #d3ece7; align-items: flex-start; }
.login-brand li b { color: #fff; font-weight: 600; }
.login-brand .chk { width: 20px; height: 20px; border-radius: 50%; background: rgba(52, 211, 153, .25); color: #6ee7b7; display: flex; align-items: center; justify-content: center; font-size: 11px; flex: 0 0 auto; margin-top: 1px; }
.login-panel { width: 470px; flex: 0 0 470px; display: flex; align-items: center; justify-content: center; padding: 40px; background: #fff; }
.login-box { width: 100%; max-width: 340px; }
.login-box h2 { font-size: 22px; margin: 0 0 6px; }
.login-box .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 26px; }
.login-box .field { margin-bottom: 15px; }
.login-box .btn { width: 100%; padding: 11px; margin-top: 6px; font-size: 14px; }
.login-error { background: var(--danger-50); color: var(--danger); border: 1px solid #fecaca; border-radius: 7px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }
.login-tip { margin-top: 20px; padding: 12px 14px; background: #f9fafb; border: 1px dashed var(--line-2); border-radius: 8px; font-size: 11.5px; color: var(--muted); line-height: 1.8; }
.login-tip b { color: var(--text-2); }

/* ---------------- 成本卡 ---------------- */
.cost-card { font-size: 13px; }
.cost-card-head { text-align: center; padding-bottom: 14px; border-bottom: 2px solid var(--primary); margin-bottom: 14px; }
.cost-card-head h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: 2px; color: var(--primary-700); }
.cost-card-head .meta { font-size: 12px; color: var(--muted); }
.cost-card table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.cost-card th, .cost-card td { border: 1px solid var(--line-2); padding: 7px 9px; font-size: 12.5px; }
.cost-card th { background: #f0fdfa; color: var(--primary-700); font-weight: 600; }
.cost-card td.num, .cost-card th.num { text-align: right; }
.cost-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.summary-line { display: flex; justify-content: space-between; padding: 7px 10px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.summary-line b { font-variant-numeric: tabular-nums; }
.summary-line.total { background: var(--primary-50); border-radius: 6px; border-bottom: none; font-weight: 700; color: var(--primary-700); }
.sign-row { display: flex; gap: 40px; margin-top: 22px; font-size: 12px; color: var(--muted); }

/* ---------------- 导入 ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 9px 16px; cursor: pointer; border: none; background: none; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-700); border-bottom-color: var(--primary); font-weight: 600; }
.dropzone { border: 2px dashed var(--line-2); border-radius: 10px; padding: 30px; text-align: center; color: var(--muted); cursor: pointer; transition: all .15s; background: #fcfcfd; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary-600); background: var(--primary-50); color: var(--primary-700); }
.dropzone .big { font-size: 34px; display: block; margin-bottom: 8px; }
.dropzone b { color: var(--primary-700); }
.preview-ok { color: var(--ok); font-weight: 600; }
.preview-warn { background: var(--warn-50); border: 1px solid #fde68a; border-radius: 8px; padding: 12px 14px; font-size: 12.5px; color: #92400e; max-height: 180px; overflow-y: auto; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -240px; transition: left .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .main { width: 100%; }
  .page { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { flex: 1; width: 100%; }
  .cookie { }
}
.menu-toggle { display: none; }
@media (max-width: 900px) { .menu-toggle { display: inline-flex; } }

/* ---------------- 打印 ---------------- */
@media print {
  body { background: #fff; }
  #app, #login-view, #toast-root { display: none !important; }
  .sidebar, .topbar, .modal-head, .modal-foot, #toast-root, .no-print { display: none !important; }
  .modal-mask { position: static; background: none; padding: 0; overflow: visible; }
  .modal { box-shadow: none; width: 100%; max-height: none; }
  .modal-body { overflow: visible; padding: 0; }
  .print-area { display: block; }
  .page { padding: 0; }
}
