/* 幼儿园食材配送项目核算系统 —— 样式
   设计原则：浅色专业风格，金额数字右对齐等宽，手机端表格可横向滚动。
   不依赖任何外部 CDN，断网也能正常显示。 */

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #1d4ed8;
  --brand-soft: #eff4ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* 顶部导航 */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding-top: 10px;
  padding-bottom: 10px;
}
.brand { font-size: 15px; font-weight: 600; color: var(--brand); white-space: nowrap; }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  font-size: 14px;
}
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

/* 标题区 */
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
h1 { font-size: 19px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 13px; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card.tight { padding: 12px 16px; }

/* KPI 指标卡 */
.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}
.kpi.hero { background: var(--brand-soft); border-color: #c7d7fe; }
.kpi.hero .value { color: var(--brand); }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 提示条 */
.alert {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert.warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.alert.info { background: var(--brand-soft); border-color: #c7d7fe; color: #1e40af; }

/* 表格 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 500; font-size: 12px; background: #fafbfc; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
}
tfoot td { font-weight: 600; background: #fafbfc; border-top: 2px solid var(--line); }

.pos { color: var(--ok); }
.neg { color: var(--bad); }
.muted { color: var(--muted); }

/* 标签 */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 1.8;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.mute { background: var(--bg); color: var(--muted); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }

/* 表单 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
input, select, textarea {
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.check input { width: auto; }

button, .btn {
  font: inherit;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover { opacity: 0.9; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.danger { background: #fff; color: var(--bad); border-color: #fecaca; }
.btn.mini {
  padding: 4px 10px;
  font-size: 12px;
  background: #fff;
  color: var(--muted);
  border-color: var(--line);
}

/* 明细行 */
.items { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.item-row {
  display: grid;
  grid-template-columns: 2fr 0.9fr 0.9fr 0.9fr 1fr 40px;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.item-row:last-child { border-bottom: none; }
.item-row.head { font-size: 12px; color: var(--muted); background: #fafbfc; }
.item-row input, .item-row select { padding: 6px 8px; }
.item-row .del {
  border: none;
  background: none;
  color: var(--bad);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  width: 40px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.filter-bar input,
.filter-bar select {
  width: auto;
  min-width: 130px;
}
.filter-bar .check { width: auto; }
.actions { white-space: nowrap; }
.actions form { margin: 0 2px; }

.kpi-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* 明细展开 */
details > summary {
  cursor: pointer;
  padding: 8px 0;
  font-size: 13px;
  color: var(--brand);
}
.mini-table { font-size: 12px; margin: 6px 0 12px; }
.mini-table td, .mini-table th { padding: 5px 8px; }

.foot { color: var(--muted); font-size: 12px; padding: 24px 0 40px; }

.btn.outline { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn.outline:hover { background: var(--brand-soft); }

/* 结果提示条（导入成功/跳过） */
.banner {
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  background: var(--ok-soft);
  border: 1px solid #a7f3d0;
  color: var(--ok);
}
.banner.ok { background: var(--ok-soft); border-color: #a7f3d0; color: var(--ok); }
.banner.warn { background: var(--bad-soft); border-color: #fecaca; color: var(--bad); }

/* 登录/修改密码页 */
.login-wrap { min-height: 72vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; max-width: 92vw; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.logout { margin-left: auto; color: var(--bad) !important; font-size: 13px; }
.nav-link { color: var(--muted); text-decoration: none; }

/* 行布局与内联表单（批量导入区的按钮排列） */
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }

/* 首页图形 */
.chart-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-card h2 { margin-bottom: 14px; }
.chart-note { margin-top: 12px; }

.h-bars { display: flex; flex-direction: column; gap: 12px; }
.h-bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 120px;
  align-items: center;
  gap: 10px;
}
.h-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.h-bar-track {
  height: 12px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}
.h-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  min-width: 2px;
  transition: width 0.3s ease;
}
.h-bar-fill.neg { background: var(--bad); }
.h-bar-value {
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
}

.donut-wrap {
  position: relative;
  width: 156px;
  height: 156px;
  margin: 0 auto 16px;
}
.donut {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #e3e8ef;
}
.donut-center {
  position: absolute;
  inset: 24px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px var(--line);
}
.donut-center strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.donut-center span { font-size: 11px; color: var(--muted); }

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}
.legend li { display: flex; align-items: center; gap: 7px; }
.legend b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 9px;
}
.inline-legend {
  flex-direction: row;
  gap: 16px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.inline-legend span { display: inline-flex; align-items: center; gap: 5px; }

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.trend-col {
  flex: 1 0 14px;
  min-width: 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.trend-stack {
  height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #f8fafc;
  border-radius: 4px;
  overflow: hidden;
}
.trend-seg {
  width: 100%;
  min-height: 0;
  transition: height 0.3s ease;
}
.trend-seg.seg-purchase { background: #1d4ed8; }
.trend-seg.seg-delivery { background: #059669; }
.trend-seg.seg-expense { background: #b45309; }
.dot.seg-purchase { background: #1d4ed8; }
.dot.seg-delivery { background: #059669; }
.dot.seg-expense { background: #b45309; }
.trend-label {
  height: 16px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: visible;
}

/* 手机适配 */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  body { font-size: 15px; }
  .topbar .wrap { gap: 8px; }
  .brand { width: 100%; }
  .kpi .value { font-size: 19px; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row .head { display: none; }
  .item-row .del { width: auto; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .h-bar-row { grid-template-columns: 108px 1fr 92px; }
  .donut-wrap { width: 128px; height: 128px; }
  .donut-center { inset: 20px; }
  .kpi-3 { grid-template-columns: 1fr; }
}
