:root {
  --bg: #E7F4F4;
  --surface: #FFFFFF;
  --surface-2: #F1F8F8;
  --border: #D3E6E6;
  --border-strong: #BCD8D8;
  --text: #17262A;
  --text-dim: #5E7476;
  --wine: #8B2942;
  --wine-dark: #6B1D38;
  --wine-grad: linear-gradient(180deg, #96305A 0%, #8B2942 100%);
  --green: #157F52;
  --green-bg: #E4F7EF;
  --orange: #B45309;
  --orange-bg: #FFF3DE;
  --red: #B91C1C;
  --red-bg: #FDECEC;
  --radius: 14px;
  --card-bg: linear-gradient(180deg, #FFFFFF 0%, #FAFDFD 100%);
  --shadow-card:
    0 1px 1px rgba(15, 55, 55, 0.05),
    0 6px 12px rgba(15, 55, 55, 0.08),
    0 20px 40px -8px rgba(15, 55, 55, 0.16);
  --shadow-card-hover:
    0 2px 3px rgba(15, 55, 55, 0.06),
    0 12px 20px rgba(15, 55, 55, 0.1),
    0 30px 52px -8px rgba(15, 55, 55, 0.2);
  --shadow-card-sm: 0 1px 1px rgba(15, 55, 55, 0.05), 0 3px 6px rgba(15, 55, 55, 0.08);
  --shadow-inset: inset 0 1px 3px rgba(15, 55, 55, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- Login / 首页 / 公司自助注册 / 试用锁定页：共用同一套全屏居中布局 ---------- */
#login-screen, #company-register-screen, #trial-locked-screen, #landing-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 38px 34px;
}

/* ---------- 首页：角色选择卡片 ---------- */
/* 语言下拉框固定在右上角，不占用居中卡片区域的布局空间——用 fixed 而不是 absolute，
   这样即使页面内容比视口高（小屏手机上两张卡片可能需要滚动）也始终留在视口右上角可见。 */
.landing-lang-select {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 5;
  width: auto;
  max-width: 130px;
  padding: 6px 10px;
  font-size: 13px;
}
.landing-wrap { width: 100%; max-width: 620px; }
.landing-header { text-align: center; margin-bottom: 34px; }
.landing-header h1 {
  font-size: 32px;
  margin: 0 0 10px;
  color: var(--wine);
  letter-spacing: 0.3px;
}
.landing-header p { margin: 0; color: var(--text-dim); font-size: 14.5px; }
/* 首月免费+价格徽标：故意做成显眼的胶囊形状放在首页最上方（而不是要点进注册表单才看到），
   这是潜在客户决定要不要点"注册"之前最想知道的信息，之前只在注册表单页才提到，等于
   让犹豫的老板多点一次才能看到"不用先付钱"这个最能打消顾虑的关键信息。 */
.landing-trial-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(139, 41, 66, 0.08);
  color: var(--wine);
  border: 1px solid rgba(139, 41, 66, 0.25);
  font-size: 13px;
  font-weight: 600;
}

.landing-cards { display: flex; flex-direction: column; gap: 16px; }
.landing-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 22px 26px;
  transition: box-shadow .2s ease, transform .2s ease;
}
.landing-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.landing-card-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: var(--shadow-card-sm);
}
.landing-card-icon.employee { background: linear-gradient(160deg, #E8A356 0%, #C97A3A 100%); }
.landing-card-icon.boss { background: var(--wine-grad); }
.landing-card-info { flex: 1; min-width: 0; }
.landing-card-info h3 { margin: 0 0 4px; font-size: 17px; color: var(--text); }
.landing-card-info p { margin: 0; font-size: 13px; color: var(--text-dim); }
.landing-card-actions { display: flex; gap: 10px; flex-shrink: 0; }
.btn-primary-sm {
  padding: 10px 20px;
  background: var(--wine-grad);
  color: #fff;
  border: 1px solid var(--wine-dark);
  border-radius: 10px;
  box-shadow: 0 1px 1px rgba(139, 41, 66, 0.2), 0 4px 10px rgba(139, 41, 66, 0.28);
}
.btn-primary-sm:hover { filter: brightness(1.06); }

.landing-footer {
  margin-top: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-dim);
}
.landing-footer a { color: var(--text-dim); font-weight: 500; }
.landing-footer a:hover { color: var(--wine); }

@media (max-width: 520px) {
  .landing-card { flex-direction: column; align-items: flex-start; text-align: left; }
  .landing-card-actions { width: 100%; }
  .landing-card-actions button { flex: 1; }
}
.brand {
  text-align: center;
  margin-bottom: 28px;
}
.brand h1 {
  font-size: 27px;
  margin: 0 0 4px;
  color: var(--wine);
  letter-spacing: 0.3px;
}
.brand p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13.5px;
  font-style: italic;
}
label {
  display: block;
  font-size: 13.5px;
  color: var(--text-dim);
  margin: 15px 0 6px;
  font-weight: 500;
}
input, select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  box-shadow: var(--shadow-inset);
}
input:focus, select:focus { outline: 1.5px solid var(--wine); border-color: var(--wine); }
input::placeholder { color: #9CA3AF; }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  transition: filter .15s ease, box-shadow .15s ease, transform .1s ease;
}
button:active { transform: translateY(1px); }
/* 全局禁用态：之前很多按钮点击后会 disabled=true 防止重复提交，但外观完全不变，
   用户分不清是"点了没反应"还是"正在处理中"。统一加一层视觉反馈。 */
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 22px;
  background: var(--wine-grad);
  color: #fff;
  border: 1px solid var(--wine-dark);
  box-shadow: 0 1px 1px rgba(139, 41, 66, 0.2), 0 4px 10px rgba(139, 41, 66, 0.28);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 2px 2px rgba(139, 41, 66, 0.22), 0 6px 16px rgba(139, 41, 66, 0.32); }
.btn-primary:active { box-shadow: 0 1px 1px rgba(139, 41, 66, 0.2); }

.btn-secondary {
  padding: 9px 14px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card-sm);
}
.btn-small {
  padding: 7px 12px;
  font-size: 13px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card-sm);
}
.btn-secondary:hover, .btn-small:hover { box-shadow: var(--shadow-card); }

.demo-hint {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}
.demo-hint b { color: var(--text); }

.error-box {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--red-bg);
  border: 1px solid #F3B4B4;
  color: var(--red);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
}

/* ---------- App shell ---------- */
#app-screen { min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(15, 55, 55, 0.07);
  position: relative;
  z-index: 5;
}
.topbar .brand-inline {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.topbar .brand-inline h2 { margin: 0; font-size: 19px; color: var(--wine); }
.topbar .brand-inline span { font-size: 13px; color: var(--text-dim); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill {
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 500;
}

/* ---------- App shell: 左侧边栏导航 + 右侧内容区 ---------- */
/* 一次只展示一个页面的内容，不再把所有区块堆在一条长长的单页滚动里——
   这是老板反馈"内容太拥挤、不知道现在在看哪一块"之后的重新设计。 */
.app-body {
  display: flex;
  align-items: flex-start;
  max-width: 1320px;
  margin: 0 auto;
}
.sidebar {
  width: 208px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 22px 12px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y: auto;
}
.nav-item {
  text-align: left;
  padding: 11px 14px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--wine-grad);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 41, 66, 0.25);
}

main { flex: 1; min-width: 0; padding: 24px 28px 60px; max-width: 980px; margin: 0; }

/* 概览卡片里可以点击跳转的几张（工资成本→员工档案、库存报警→智能库存等） */
.card.clickable { cursor: pointer; }
.card.clickable .hint { font-size: 11.5px; color: var(--text-dim); margin-top: 8px; }
.card.clickable:hover .hint { color: var(--wine); }

/* AI利润分析里可以点击跳转到相关详情页的因素行 */
.profit-driver-row.clickable { cursor: pointer; }
.profit-driver-row.clickable:hover { border-color: var(--wine); }

/* 员工档案表格：点"详情"展开的当天完整情况（考勤/评分/排班一次看全，不用再跳去别的表格拼） */
.emp-detail-row td { background: var(--surface-2); padding: 16px 20px; }
.emp-detail-grid { display: flex; flex-wrap: wrap; gap: 16px 34px; margin-bottom: 12px; }
.emp-detail-item { font-size: 12.5px; color: var(--text-dim); }
.emp-detail-item b { display: block; margin-top: 3px; color: var(--text); font-weight: 600; font-size: 14px; }
.emp-detail-list-title { font-weight: 600; color: var(--text); font-size: 13px; margin: 10px 0 6px; }
.emp-detail-list-empty { color: var(--text-dim); font-size: 13px; }
.emp-detail-list-row { font-size: 13px; color: var(--text); padding: 3px 0; }
.emp-detail-jump { margin-top: 10px; }

@media (max-width: 900px) {
  .app-body { flex-direction: column; }
  .sidebar {
    position: static;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .nav-item { flex-shrink: 0; }
  main { max-width: 100%; }
}

.section-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  margin: 34px 0 14px;
  letter-spacing: 0.1px;
}
.section-title:first-of-type { margin-top: 8px; }
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 34px 0 14px;
}
.section-title-row .section-title { margin: 0; }
.section-title-row:first-child { margin-top: 8px; }

/* ---------- Dashboard cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  transition: box-shadow .2s ease, transform .2s ease;
}
.card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-3px); }
.card .label { font-size: 13.5px; color: var(--text-dim); margin-bottom: 10px; font-weight: 500; }
.card .value { font-size: 28px; font-weight: 700; color: var(--text); }
.card.accent-green .value { color: var(--green); }
.card.accent-red .value { color: var(--red); }
.card.accent-orange .value { color: var(--orange); }
.card.accent-wine .value { color: var(--wine); }

/* ---------- 营收趋势曲线（纯 SVG 手写，零依赖，不引入 Chart.js） ---------- */
.trend-toggle { display: flex; gap: 6px; }
.trend-period-btn.active, .ai-insight-tab-btn.active { background: var(--wine); color: #fff; border-color: var(--wine); }
.trend-chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 22px 14px;
}
.trend-svg { width: 100%; height: 200px; display: block; }
.trend-legend { display: flex; gap: 18px; margin-top: 8px; font-size: 12.5px; color: var(--text-dim); }
.trend-legend span { display: inline-flex; align-items: center; gap: 6px; }
.trend-legend i { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.trend-x-labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.trend-empty { color: var(--text-dim); font-size: 14px; padding: 30px 0; text-align: center; }

/* ---------- 全局加载进度条：覆盖全站的api()请求，见index.html里的说明 ---------- */
.global-loading-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 3000;
  background: var(--border);
  overflow: hidden;
}
.global-loading-bar::before {
  content: "";
  position: absolute; top: 0; left: 0; height: 100%; width: 40%;
  background: var(--wine-grad);
  animation: global-loading-sweep 1.1s ease-in-out infinite;
}
@keyframes global-loading-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---------- 骨架屏：驾驶舱首次加载时卡片区域用灰色占位块代替空白/"—"，
   让人知道"正在加载"而不是"这里本来就没数据"。数据回来后 renderCards() 会
   直接用真实卡片HTML覆盖掉这些骨架块。 ---------- */
.skeleton-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-sm);
  padding: 16px;
  height: 74px;
}
.skeleton-block {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 6px;
}
.skeleton-block.line-title { height: 12px; width: 55%; margin-bottom: 12px; }
.skeleton-block.line-value { height: 20px; width: 75%; }
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------- 通用确认/输入弹窗：替换原生 confirm()/prompt() ---------- */
.app-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15, 40, 40, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.app-modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-hover);
  padding: 22px 24px;
  max-width: 420px;
  width: 100%;
}
.app-modal-message { font-size: 14.5px; line-height: 1.6; color: var(--text); white-space: pre-line; }
.app-modal input#app-modal-input { margin-top: 12px; }
.app-modal-error { margin-top: 8px; font-size: 12.5px; color: var(--red); }
.app-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
/* 弹窗内的确定/取消按钮复用全站已有的 .btn-primary/.btn-secondary，
   但去掉它们原本给"表单提交按钮"设计的 width:100%/margin-top，改成并排的小按钮。 */
.app-modal-actions .btn-primary, .app-modal-actions .btn-secondary { width: auto; margin-top: 0; padding: 9px 18px; }
.app-modal-actions .btn-primary.btn-danger { background: var(--red); border-color: #8f1414; }

/* ---------- 试用期倒计时横幅：临近到期时从"提示色"升级为"警示色" ---------- */
.trial-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: var(--orange-bg);
  border-bottom: 1px solid var(--orange);
  font-size: 13.5px;
  color: var(--text);
}
.trial-banner.urgent { background: var(--red-bg); border-bottom-color: var(--red); }
.trial-banner span#trial-banner-text { flex: 1; font-weight: 600; }
.trial-banner.urgent span#trial-banner-text { color: var(--red); }
.trial-banner-dismiss {
  background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1;
  color: var(--text-dim); padding: 0 4px;
}
.trial-banner-dismiss:hover { color: var(--text); }

/* ---------- 新公司注册后的空状态引导：快速上手清单 ---------- */
.onboarding-checklist {
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-sm);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.onboarding-checklist-header {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 14.5px; color: var(--wine); margin-bottom: 10px;
}
.onboarding-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.onboarding-item:last-child { border-bottom: none; }
.onboarding-item-check {
  width: 20px; height: 20px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border-strong); font-size: 12px; color: transparent;
}
.onboarding-item.done .onboarding-item-check { background: var(--green); border-color: var(--green); color: #fff; }
.onboarding-item.done .onboarding-item-label { color: var(--text-dim); text-decoration: line-through; }
.onboarding-item-label { flex: 1; }
.onboarding-item-action { color: var(--wine); font-weight: 600; cursor: pointer; font-size: 13px; }

/* ---------- 平台广告位：固定嵌入首页，不是弹窗，不能被公司管理员关闭 ---------- */
.ad-slot { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.ad-card {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 14px 18px;
}
.ad-card a.ad-card-link { text-decoration: none; color: inherit; display: flex; gap: 16px; align-items: center; flex: 1; min-width: 0; }
.ad-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.ad-media img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; flex-shrink: 0; box-shadow: var(--shadow-card-sm); }
.ad-media video { width: 220px; max-width: 40vw; border-radius: 10px; flex-shrink: 0; box-shadow: var(--shadow-card-sm); display: block; }
.ad-text { min-width: 0; }
.ad-title { font-size: 14.5px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.ad-body { font-size: 13px; color: var(--text-dim); line-height: 1.6; }

/* ---------- AI report ---------- */
/* "✨ AI" 徽章：贴在每个AI功能区块的标题旁边，纯视觉强调——这几个板块（AI日报/AI利润
   分析/AI老板助手/AI采购预测）是这个产品相对于普通排班打卡工具最大的差异化卖点，
   不应该长得和旁边的普通数据表格一模一样，容易被老板刷过去没注意到。不翻译"AI"这个词
   本身（9种语言里都是通用缩写，硬翻译成"人工智能"反而更长更不像徽章）。 */
.ai-powered-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--wine-grad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.2px;
  vertical-align: middle;
  box-shadow: 0 2px 5px rgba(139, 41, 66, 0.3);
}
.ai-report {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
}
.ai-report .headline {
  font-weight: 700;
  font-size: 15px;
  color: var(--wine);
  margin-bottom: 12px;
}
.ai-report ul { margin: 0; padding-left: 18px; }
.ai-report li { margin-bottom: 8px; line-height: 1.6; font-size: 14.5px; color: var(--text); }
.ai-report .empty { color: var(--text-dim); font-size: 14.5px; }
.profit-drivers { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.profit-driver-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: var(--shadow-card-sm);
  transition: box-shadow .18s ease, transform .18s ease;
}
.profit-driver-row:hover { box-shadow: var(--shadow-card); transform: translateY(-2px); }
.profit-driver-row .driver-label { color: var(--text); font-weight: 600; }
.profit-driver-row .driver-delta { color: var(--text-dim); font-size: 12.5px; margin-left: 8px; }
.profit-driver-row .driver-impact {
  font-weight: 700;
  font-size: 13px;
  padding: 4px 11px;
  border-radius: 999px;
  box-shadow: var(--shadow-inset);
}
.profit-driver-row .driver-impact.positive { color: var(--green); background: var(--green-bg); }
.profit-driver-row .driver-impact.negative { color: var(--red); background: var(--red-bg); }
.profit-headline-up { color: var(--green); }
.profit-headline-down { color: var(--red); }

/* ---------- 通知中心 ---------- */
.notif-wrap { position: relative; }
.notif-wrap .btn-small { position: relative; }
.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  box-shadow: 0 1px 3px rgba(185, 28, 28, 0.4);
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: 90vw;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-card-hover);
  z-index: 20;
  overflow: hidden;
}
.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
}
.notif-dropdown-actions { display: flex; gap: 6px; }
.notif-dropdown-actions .btn-small { padding: 5px 9px; font-size: 11.5px; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.55;
  cursor: pointer;
  transition: background .12s ease;
}
.notif-row:last-child { border-bottom: none; }
.notif-row:hover { background: var(--surface-2); }
.notif-row.unread { background: var(--surface-2); font-weight: 500; }
.notif-row .notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-row .notif-dot.critical { background: var(--red); }
.notif-row .notif-dot.warning { background: var(--orange); }
.notif-row .notif-dot.info { background: var(--green); }
.notif-row .notif-time { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.notif-row .notif-body { flex: 1; min-width: 0; }
.notif-delete-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.notif-delete-btn:hover { background: var(--red-bg); color: var(--red); }
.notif-empty { padding: 22px 14px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ---------- AI 老板助手（对话式问答） ---------- */
.assistant-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 18px 16px;
}
/* AI生成内容的卡片本身也加一点"这不是普通表格"的视觉区分：左侧一条酒红色的强调条。
   这条规则必须排在 .ai-report / .assistant-box 的 border 简写属性之后，
   不然会被那两条规则的 `border: 1px solid ...` 简写覆盖掉（简写会重置全部四条边）。 */
.ai-powered-card {
  border-left: 3px solid var(--wine);
}
.assistant-messages {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
  margin-bottom: 14px;
}
.assistant-empty { color: var(--text-dim); font-size: 14px; line-height: 1.7; padding: 4px 2px; }
.assistant-msg {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.assistant-msg.user {
  align-self: flex-end;
  background: var(--wine-grad);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(139, 41, 66, 0.22);
}
.assistant-msg.assistant {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.assistant-msg.assistant .source-tag {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  font-weight: 500;
}

/* AI 是否真的接了 Claude API、还是规则引擎兜底——诚实标注在每个AI区块标题旁边，
   不让老板误以为看到的都是"AI算的"，实际很可能是没配key时的规则引擎结果。 */
.ai-source-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}
.ai-source-badge.is-ai { background: var(--green-bg); color: var(--green); }
.ai-source-badge.is-rule { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.assistant-msg.pending { color: var(--text-dim); font-style: italic; }
.assistant-input-row { display: flex; gap: 10px; }
.assistant-input-row input { flex: 1; }
.assistant-input-row button { flex-shrink: 0; }

/* ---------- Tables ---------- */
/* 表格的立体感放在 .table-scroll 外层容器上（而不是 table 本身），这样横向滚动条
   不会把阴影和圆角切掉——桌面/移动端都保持和卡片一致的悬浮质感。 */
.table-scroll {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: box-shadow .2s ease, transform .2s ease;
}
.table-scroll:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  font-size: 14.5px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
th { color: var(--text-dim); font-weight: 600; background: var(--surface-2); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }

/* 表格行内编辑用的紧凑输入框（库存/排班/员工的"编辑"模式）：比表单里的大输入框更贴合表格行高 */
.edit-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 13.5px;
  border-radius: 7px;
}

/* 智能库存按分类/子类分组的组标题行——不是数据行，纯粹起分隔作用 */
.inv-group-row td {
  padding: 8px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.inv-group-category td { background: var(--surface-2); color: var(--text); font-size: 13.5px; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-dim { background: var(--surface-2); color: var(--text-dim); }

/* 温度记录超标行：整行浅红底，比单个状态徽章更容易被扫到——检查食安记录的人通常是快速
   扫一遍找有没有异常行，而不是逐行读状态列。 */
tr.temp-row-alert td { background: var(--red-bg); }

.form-inline {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
}
.form-inline .field { min-width: 130px; }
.form-inline label { margin: 0 0 6px; }

/* ---------- Employee clock view ---------- */
.clock-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.clock-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px;
  text-align: center;
}
.clock-buttons { display: flex; gap: 12px; margin-top: 22px; }
.clock-buttons button { flex: 1; padding: 16px; font-size: 15.5px; }
.btn-in {
  background: linear-gradient(180deg, #1B9350 0%, #15803D 100%);
  color: #fff;
  border: 1px solid #0F6631;
  box-shadow: 0 1px 1px rgba(21, 128, 61, 0.2), 0 4px 10px rgba(21, 128, 61, 0.28);
}
.btn-in:hover { filter: brightness(1.06); box-shadow: 0 2px 2px rgba(21, 128, 61, 0.22), 0 6px 16px rgba(21, 128, 61, 0.32); }
.btn-out {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card-sm);
}
.clock-status { margin-top: 18px; font-size: 14px; min-height: 20px; font-weight: 500; }
.clock-status.ok { color: var(--green); }
.clock-status.fail { color: var(--red); }

/* 打卡页的"今天已工作 X 小时 · 今天工资 €Y"——只读展示，不参与打卡操作本身，保持打卡按钮流程简单 */
.clock-hours-card {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: left;
}
.clock-hours-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  color: var(--text-dim);
  padding: 4px 0;
}
.clock-hours-row span:last-child { color: var(--text); font-weight: 600; font-size: 15px; }

/* 打卡页"智能仓库"：员工按子类+1(取用)/-1(归还)，极简，不放分类/单价等管理字段 */
.wh-card { margin-top: 18px; text-align: left; }
.wh-title { font-size: 13.5px; font-weight: 700; color: var(--text-dim); margin-bottom: 8px; letter-spacing: .3px; }
.wh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
}
.wh-row-info { font-size: 13.5px; color: var(--text); }
.wh-row-info .wh-qty { color: var(--text-dim); font-size: 12px; display: block; margin-top: 1px; }
.wh-stepper { display: flex; align-items: center; gap: 6px; }
/* 之前是纯符号（−/+）的圆形按钮，光看图标不容易一眼确认"这就是出库按钮"——
   改成带文字的胶囊按钮（符号+"出库"/"入库"字样），含义不用猜。 */
.wh-stepper button {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card-bg);
  color: var(--wine); font-size: 12.5px; font-weight: 700; line-height: 1; cursor: pointer;
}
.wh-stepper button:hover { box-shadow: var(--shadow-card-sm); }
.wh-stepper button.wh-minus { color: var(--red); }
.wh-stepper button .wh-stepper-sym { font-size: 15px; }
.wh-empty { font-size: 12.5px; color: var(--text-dim); padding: 6px 2px; }
.wh-search-wrap { position: relative; margin-bottom: 10px; }
.wh-search-wrap .wh-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-dim); pointer-events: none; }
.wh-search-wrap input { padding-left: 36px; }
.wh-search-wrap input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

/* 密码框"显示/隐藏"小眼睛：打字时容易看不清自己有没有打错，尤其是手机小键盘。
   两个 SVG（睁眼/闭眼）叠在同一个按钮里，JS 只切换哪个可见 + 切换 input 的 type。 */
.pw-field-wrap { position: relative; }
.pw-field-wrap input { padding-right: 40px; }
.pw-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  box-shadow: none;
  color: var(--text-dim);
  padding: 0;
}
.pw-toggle-btn:hover { color: var(--text); }
.pw-toggle-btn:active { transform: translateY(-50%); }
.pw-eye-icon { width: 19px; height: 19px; }
.wh-board { margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.wh-board-title { font-size: 12.5px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }
.wh-board-line { font-size: 13px; color: var(--text); padding: 3px 0; }
.wh-board-empty { font-size: 12.5px; color: var(--text-dim); }

/* 出入库流水行（员工端"我最近的操作"+老板端流水表共用的撤销按钮样式）：
   撤销是一个有实际后果的操作（会改动库存数量），用红色文字按钮而不是普通灰按钮，
   让它在视觉上和"删除/危险操作"归为一类，但又不像整块红底按钮那么抢眼——
   这类操作大多数时候不会被点，不需要占据视觉重心。 */
.tx-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; font-size: 12.5px; color: var(--text); border-bottom: 1px solid var(--border); }
.tx-row:last-child { border-bottom: none; }
.tx-row-info { flex: 1; min-width: 0; }
.tx-row-meta { color: var(--text-dim); font-size: 11.5px; margin-top: 1px; }
.btn-undo { flex-shrink: 0; padding: 4px 10px; font-size: 12px; background: var(--red-bg); color: var(--red); border: none; border-radius: 8px; cursor: pointer; }
.btn-undo:hover { opacity: 0.85; }

/* 厨房小票打印：平时 #kitchen-ticket-print 是空的、display:none，不占地方。只有触发打印
   （body 被加上 printing-ticket 类）时才会显示，并且把页面上其它所有内容藏起来——这样
   打印出来的纸上只有小票内容，不会把整个网页界面也打印进去。80mm 是常见热敏打印纸宽度，
   等宽字体（monospace）在窄纸上对齐数字/金额更整齐。 */
#kitchen-ticket-print { display: none; }
@media print {
  body.printing-ticket > *:not(#kitchen-ticket-print) { display: none !important; }
  #kitchen-ticket-print {
    display: block !important;
    width: 76mm;
    margin: 0 auto;
    font-family: "Courier New", monospace;
    font-size: 12px;
    color: #000;
    padding: 2mm 0;
  }
  #kitchen-ticket-print .kt-header { text-align: center; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
  #kitchen-ticket-print .kt-line { border-top: 1px dashed #000; margin: 6px 0; }
  #kitchen-ticket-print .kt-row { display: flex; justify-content: space-between; padding: 2px 0; }
  #kitchen-ticket-print .kt-total { font-weight: 700; font-size: 13px; }
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
  z-index: 50;
  animation: toast-in .25s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 90vw;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
/* toast 里可选的"撤销"按钮：出库/入库操作成功后立刻给一个原地撤销的入口，
   不用再跑去下面"我最近的操作"列表里找那一条——刚做完的操作，撤销应该伸手就能点到。 */
.toast-action-btn {
  flex-shrink: 0;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--red-bg);
  color: var(--red);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.toast-action-btn:hover { opacity: 0.85; }

/* ---------- 精修：整体细节打磨 ---------- */

/* 页面切换时轻微淡入，避免生硬闪现 */
#app-screen, #clock-screen:not(.hidden), #login-screen:not(.hidden) {
  animation: screen-in .28s ease;
}
@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 小标题前加一个圆点强调色块，呼应品牌色，增加视觉节奏感 */
.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
}
.section-title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wine);
  flex-shrink: 0;
}

/* 卡片顶部细色条，配合accent颜色做出更丰富的层次 */
.card { position: relative; overflow: hidden; }
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border-strong);
}
.card.accent-green::before { background: var(--green); }
.card.accent-red::before { background: var(--red); }
.card.accent-orange::before { background: var(--orange); }
.card.accent-wine::before { background: var(--wine); }

/* 表格行 hover 高亮，提升可读性和交互反馈 */
tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: var(--surface-2); }

/* 输入框聚焦时的柔和光晕，比单纯描边更有质感 */
input:focus, select:focus {
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(139, 41, 66, 0.12);
}

/* 自定义滚动条，匹配整体配色，避免默认灰色滚动条显得突兀 */
.assistant-messages::-webkit-scrollbar { width: 7px; }
.assistant-messages::-webkit-scrollbar-track { background: transparent; }
.assistant-messages::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
.assistant-messages::-webkit-scrollbar-thumb:hover { background: var(--wine); }

/* 表格在窄屏下允许横向滚动，避免挤压变形 */
.table-scroll { overflow-x: auto; border-radius: var(--radius); }

/* ---------- 响应式：平板/手机宽度适配 ---------- */
@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px 16px; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-start; }
  .topbar-right select { flex: 1; min-width: 120px; }
  main { padding: 18px 14px 48px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .form-inline { padding: 14px; }
  .form-inline .field { min-width: 100%; }
  table { font-size: 13.5px; }
  th, td { padding: 10px; }
  .assistant-msg { max-width: 92%; }
  .assistant-box { padding: 14px; }
  .profit-driver-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  #replacement-panel .card { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ---------- 更窄的手机屏幕（≤480px）：进一步收紧间距和字号 ---------- */
@media (max-width: 480px) {
  .login-card { padding: 28px 20px; }
  .clock-card { padding: 24px 18px; }
  .brand h1 { font-size: 23px; }
  .topbar .brand-inline h2 { font-size: 17px; }
  main { padding: 14px 10px 40px; }
  .section-title { font-size: 14.5px; margin: 26px 0 12px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { padding: 14px 15px; }
  .card .value { font-size: 22px; }
  .assistant-input-row { flex-direction: column; align-items: stretch; }
  .assistant-input-row button { width: 100%; padding: 11px; }
  .clock-buttons { flex-direction: column; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 9px; }
}
