/* 公司账务系统 —— 内部工具风格：清晰、紧凑、移动优先 */
:root {
  --bg: #f4f6f3;
  --sheet: #ffffff;
  --ink: #1c2a24;
  --muted: #6d7d74;
  --line: #dfe6df;
  --line-strong: #c3cec5;
  --green: #1f5c43;
  --green-soft: #e8f1ea;
  --red: #b3402f;
  --red-soft: #fbedeb;
  --amber: #8a6a1f;
  --amber-soft: #fbf3df;
  --blue: #2f5d8a;
  --blue-soft: #e9f0f7;
  --radius: 6px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); font-size: 13px; margin: 8px 0; }

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- 登录 ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 28px 20px; }
.auth-card { width: 100%; max-width: 360px; background: var(--sheet); border: 1px solid var(--line); border-radius: 10px; padding: 28px 24px; box-shadow: 0 10px 30px rgba(20, 40, 30, .06); }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; background: var(--red); color: #fff;
  font-size: 24px; border-radius: 6px; margin-bottom: 12px;
  font-family: "Songti SC", "SimSun", serif;
}
.brand-mark.small { width: 34px; height: 34px; font-size: 18px; margin: 0; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .muted { margin-bottom: 18px; }
.auth-card form { display: flex; flex-direction: column; }
.auth-card .btn { margin-top: 16px; }
.demo-accounts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.demo-accounts .btn { margin-top: 0; }

/* ---------- 顶栏 / 导航 ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--sheet); border-bottom: 1px solid var(--line);
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.topbar-main { flex: 1; min-width: 0; }
.topbar h1 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav {
  display: flex; gap: 4px; overflow-x: auto; background: var(--sheet);
  border-bottom: 1px solid var(--line); padding: 0 10px;
  position: sticky; top: 0; z-index: 10;
}
.nav button {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 10px 12px; font-size: 14px; color: var(--muted); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.nav .badge { font-size: 11px; padding: 0 6px; }
.nav button.is-active { color: var(--green); border-bottom-color: var(--green); font-weight: 600; }

.content { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 14px 14px 40px; }
.view { display: block; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.view-head h2 { font-size: 20px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-title { font-size: 15px; margin: 22px 0 8px; color: var(--ink); }

/* ---------- 表单 / 按钮 ---------- */
.input {
  width: 100%; background: var(--sheet); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 9px 10px; font-size: 15px; color: var(--ink);
}
.input.compact { width: auto; padding: 7px 8px; font-size: 13px; }
select.input { background: var(--sheet); }
.field-label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.btn {
  border: 1px solid var(--line-strong); background: var(--sheet); color: var(--ink);
  border-radius: var(--radius); padding: 9px 14px; font-size: 14px; line-height: 1.2;
}
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-quiet { background: transparent; }
.btn-block { width: 100%; display: block; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.inline-form { display: flex; gap: 8px; margin-bottom: 8px; }
.inline-form .input { flex: 1; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.grid-form .btn { grid-column: 1 / -1; justify-self: start; }
.payroll-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.payroll-controls .input { width: 100px; }

/* ---------- 卡片 / 列表 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.card-link { cursor: pointer; }
.card-link:hover { border-color: var(--green); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.link-text { color: var(--green); text-decoration: underline; }
.category-amount-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.category-amount-row { display: flex; align-items: center; gap: 8px; }
.category-amount-row > span { min-width: 34px; color: var(--muted); font-size: 14px; }
.category-amount-row .input { flex: 1; }
.card .label { font-size: 12px; color: var(--muted); }
.card .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.value.green { color: var(--green); }
.value.red { color: var(--red); }
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  background: var(--sheet); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
}
.row-main { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.order-row-main { display: block; }
.order-row-main > div { margin-bottom: 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-head .section-title { margin-bottom: 8px; }
.profit-highlight {
  display: inline-block; margin-top: 6px; padding: 4px 10px;
  border-radius: 8px; background: #fdecea; border: 1px solid #f3b6ae;
  color: #b3261e; font-size: 13px; font-weight: 600;
}
.profit-highlight b { font-size: 15px; margin: 0 2px; }
.row-title { font-weight: 600; }
.row-sub { font-size: 12px; color: var(--muted); }
.row-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.row-amount.green { color: var(--green); }
.row-amount.red { color: var(--red); }
.green-text { color: var(--green); font-weight: 600; }
.red-text { color: var(--red); font-weight: 600; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.goods-line-row .row-main { display: block; }
.goods-line-row .row-title { display: inline; }
.goods-line-row .badge, .goods-line-row select { vertical-align: middle; }
.goods-line-row .row-sub { margin-top: 3px; }
.goods-line-row .row-sub .input { width: 170px; display: inline-block; margin: 0 4px; }
.return-item { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.return-item .row-title { min-width: 96px; }
.return-item .input { width: 90px; margin: 0; }
.return-item .input.return-model { width: 190px; }
.return-item .input.return-qty { width: 70px; }
.chip-group { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.chip {
  display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px; font-size: 12px; cursor: pointer;
  background: var(--sheet); color: var(--muted); user-select: none;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) {
  background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 600;
}
.custom-category { width: 130px; display: inline-block; margin: 0 4px; }
.expenses-grid { display: flex; flex-direction: column; gap: 4px; margin: 4px 0; }
.expense-line { display: flex; align-items: center; gap: 8px; }
.expense-line .row-title { min-width: 64px; }
.expense-line .input { width: 120px; margin: 0; }
.expense-line .input:last-child { flex: 1; max-width: 260px; }
.badge {
  display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); white-space: nowrap;
}
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.approved { background: var(--blue-soft); color: var(--blue); }
.badge.paid, .badge.published, .badge.active, .badge.completed { background: var(--green-soft); color: var(--green); }
.badge.rejected { background: var(--red-soft); color: var(--red); }
.badge.withdrawn, .badge.draft, .badge.inactive { background: #eef0ee; color: var(--muted); }
.badge.work { background: var(--red-soft); color: var(--red); }
.badge.daily { background: var(--blue-soft); color: var(--blue); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }
.item-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.item-row .input { margin: 0; }
.item-row .input:first-child { flex: 1.3; }
.item-row .input:nth-child(2) { flex: 1; }
.order-line { margin-bottom: 10px; }
.line-main .input:first-child { flex: 1.8; }
.line-main .input:nth-child(2) { flex: 0.5; }
.line-extra {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: -2px 0 0 2px;
}
.line-extra select { max-width: 150px; }
.reimb-total { text-align: right; margin: 4px 0 10px; font-size: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
#inventory-cards { max-width: 360px; }
#parts-unsold-card { max-width: 360px; margin-bottom: 10px; }
.tab { background: none; border: none; padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; }
.tab.is-active { color: var(--green); border-color: var(--green); font-weight: 600; }
.check-label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.stock-panel { margin-top: 8px; }
.order-line select { flex: 1.6; }
.order-line input[data-line-qty] { flex: 0.6; }
.field-hint { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.photo-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.photo-row img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.photo-item { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.price-line .row-title { flex: 1; min-width: 220px; }
.price-line .input { width: 110px; }
.key-model-grid { align-items: start; }
.batch-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--green-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin: 8px 0; font-size: 13px;
}
.photo-upload { display: inline-block; margin-bottom: 10px; }
.modal-actions {
  position: sticky; bottom: -14px; z-index: 2;
  background: var(--sheet); padding: 10px 0 6px; margin-top: 8px;
  border-top: 1px solid var(--line);
}
.modal-panel { max-height: 90vh; overflow-y: auto; }
.todo-check {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  background: var(--sheet); color: var(--green); font-size: 14px; line-height: 1;
  vertical-align: middle; margin-right: 6px; cursor: pointer;
}
.todo-check:hover { border-color: var(--green); }
.todo-check.is-done { background: var(--green); border-color: var(--green); color: #fff; }
.confirm-layer {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(22, 34, 28, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.confirm-card {
  background: var(--sheet); border-radius: 10px; padding: 18px;
  width: min(420px, 100%); max-height: 82vh; overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
}
.confirm-title { font-size: 16px; margin-bottom: 10px; }
.confirm-card .list { margin-bottom: 10px; }
.confirm-card p { margin-bottom: 10px; font-size: 14px; }
.confirm-card .modal-actions { position: static; border-top: none; padding-top: 6px; }
.reward-row, .fees-row, .expenses-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.reward-row .input, .fees-row .input, .expenses-row .input { width: 90px; }
.fees-row label { display: inline-flex; align-items: center; gap: 3px; }
.expenses-row #order-expense-note { flex: 1; min-width: 120px; }
.notice {
  margin-top: 12px; padding: 9px 12px; border-radius: 8px;
  background: var(--amber-soft); color: var(--amber);
  font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* ---------- 库存 / 报表 ---------- */
.stock-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.stock-meta { font-size: 12px; color: var(--muted); }
.low { color: var(--red); }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding: 10px; background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar { width: 100%; background: var(--green); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar.red { background: var(--red); }
.bar-pair { display: flex; align-items: flex-end; gap: 2px; width: 100%; height: 100%; justify-content: center; }
.bar-pair .bar { flex: 1; }
.bar-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.bar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.bar-label { font-size: 11px; color: var(--muted); }
.export-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- 弹层 / 提示 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(12, 24, 18, .5); }
.modal-panel {
  position: relative; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: var(--sheet); border-radius: 12px 12px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0));
}
.modal-head {
  position: sticky; top: -16px; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  margin: -16px -16px 10px; padding: 16px 16px 10px;
  background: var(--sheet); border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 17px; }
.modal-form { display: flex; flex-direction: column; gap: 4px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 14px; z-index: 50; max-width: 86vw;
}
.files { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.files img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.audit-line { font-size: 12px; color: var(--muted); }

@media (min-width: 760px) {
  .row { flex-direction: row; align-items: center; justify-content: space-between; }
  .row-main { flex: 1; }
  .row-actions { flex: none; }
  .modal { align-items: center; }
  .modal-panel { border-radius: 12px; max-height: 84vh; }
}
